Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/views/administrate/application/_resource_group.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<% attributes = resource_group.second %>

<%= render(
partial: 'resource_item',
layout: 'resource_item_layout',
collection: attributes,
as: :attribute,
locals: local_assigns
) %>
16 changes: 16 additions & 0 deletions app/views/administrate/application/_resource_group_layout.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<% group_title = resource_group.first %>

<% if group_title.present? %>
<%# grouped attributes: { title => attributes } %>
<fieldset class="field-unit--nested">
<legend><%= t "helpers.label.#{page.resource_name}.#{group_title}", default: group_title %></legend>
<dl>
<%= yield %>
</dl>
</fieldset>
<% else %>
<%# non-grouped attributes: { "" => attributes } %>
<dl>
<%= yield %>
</dl>
<% end %>
1 change: 1 addition & 0 deletions app/views/administrate/application/_resource_item.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= render_field attribute, page: page %>
10 changes: 10 additions & 0 deletions app/views/administrate/application/_resource_item_layout.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<dt class="attribute-label" id="<%= attribute.name %>">
<%= t(
"helpers.label.#{resource_name}.#{attribute.name}",
default: page.resource.class.human_attribute_name(attribute.name),
) %>
</dt>

<dd class="attribute-data attribute-data--<%=attribute.html_class%>">
<%= yield %>
</dd>
28 changes: 7 additions & 21 deletions app/views/administrate/application/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -50,27 +50,13 @@ as well as a link to its edit page.
<%= content_for(:main) %>
<% else %>
<section class="main-content__body">
<dl>
<% page.attributes.each do |title, attributes| %>
<fieldset class="<%= "field-unit--nested" if title.present? %>">
<% if title.present? %>
<legend><%= t "helpers.label.#{page.resource_name}.#{title}", default: title %></legend>
<% end %>

<% attributes.each do |attribute| %>
<dt class="attribute-label" id="<%= attribute.name %>">
<%= t(
"helpers.label.#{resource_name}.#{attribute.name}",
default: page.resource.class.human_attribute_name(attribute.name),
) %>
</dt>

<dd class="attribute-data attribute-data--<%=attribute.html_class%>"
><%= render_field attribute, page: page %></dd>
<% end %>
</fieldset>
<% end %>
</dl>
<%= render(
partial: 'resource_group',
layout: 'resource_group_layout',
collection: page.attributes.to_a,
as: :resource_group,
locals: local_assigns
) %>
</section>
<% end %>

Expand Down
Loading