Skip to content
Snippets Groups Projects
Commit cb64f57e authored by Arnaud Levy's avatar Arnaud Levy
Browse files

introspective helpers

parent bd45b33f
No related branches found
No related tags found
No related merge requests found
module Admin::BlocksHelper
def block_component_edit(property, **options)
component = block_component property
partial = "admin/communication/blocks/components/#{component.kind}/edit"
render partial, property: property, **options
end
def block_component_preview(property, **options)
component = block_component property
partial = "admin/communication/blocks/components/#{component.kind}/preview"
render partial, property: property, **options
end
def block_component_static(property, **options)
component = block_component property
partial = "admin/communication/blocks/components/#{component.kind}/static"
render partial, property: property, **options
end
protected
def block_component(property)
@block.template.public_send "#{property}_component"
end
end
...@@ -13,4 +13,8 @@ class Communication::Block::Component::Base ...@@ -13,4 +13,8 @@ class Communication::Block::Component::Base
def data=(value) def data=(value)
@data = value @data = value
end end
def kind
self.class.name.demodulize.underscore
end
end end
<div class="row mb-4"> <div class="row mb-4">
<div class="col-md-6"> <div class="col-md-6">
<%= render 'admin/communication/blocks/components/rich_text/edit', property: :text %> <%= block_component_edit :text %>
<%= render 'admin/communication/blocks/components/rich_text/edit', property: :notes %> <%= block_component_edit :notes %>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<%= render 'admin/communication/blocks/components/image/edit', property: :image %> <%= block_component_edit :image %>
</div> </div>
</div> </div>
<%= render 'admin/communication/blocks/components/image/preview', property: :image %> <%= block_component_preview :image %>
<%= render 'admin/communication/blocks/components/rich_text/preview', property: :text %> <%= block_component_preview :notes %>
<%= render 'admin/communication/blocks/components/rich_text/preview', property: :notes %> <%= block_component_preview :text %>
<%= render 'admin/communication/blocks/components/rich_text/static', property: :text %> <%= block_component_static :text %>
<%= render 'admin/communication/blocks/components/rich_text/static', property: :notes %> <%= block_component_static :notes %>
<%= render 'admin/communication/blocks/components/image/static', property: :image %> <%= block_component_static :image %>
<div class="row mb-4"> <div class="row mb-4">
<div class="col-md-6"> <div class="col-md-6">
<%= render 'admin/communication/blocks/components/string/edit', property: :url %> <%= block_component_edit :url %>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<%= render 'admin/communication/blocks/components/text/edit', property: :transcription, rows: 10 %> <%= block_component_edit :transcription, rows: 10 %>
</div> </div>
</div> </div>
<%# TODO iframe video %> <%# TODO iframe video %>
<%= render 'admin/communication/blocks/components/string/preview', property: :url %> <%= block_component_preview :url %>
<%= render 'admin/communication/blocks/components/text/preview', property: :transcription %> <%= block_component_preview :transcription %>
<%= render 'admin/communication/blocks/components/string/static', property: :url %> <%= block_component_static :url %>
<%= render 'admin/communication/blocks/components/text/static', property: :transcription %> <%= block_component_static :transcription %>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment