Skip to content

Commit 6c79ced

Browse files
committed
split show template
1 parent b8d4885 commit 6c79ced

5 files changed

Lines changed: 43 additions & 21 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<% attributes = resource_group.second %>
2+
3+
<%= render(
4+
partial: 'resource_item',
5+
layout: 'resource_item_layout',
6+
collection: attributes,
7+
as: :attribute,
8+
locals: local_assigns
9+
) %>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<% group_title = resource_group.first %>
2+
3+
<% if group_title.present? %>
4+
<%# grouped attributes: { title => attributes } %>
5+
<fieldset class="field-unit--nested">
6+
<legend><%= t "helpers.label.#{page.resource_name}.#{group_title}", default: group_title %></legend>
7+
<dl>
8+
<%= yield %>
9+
</dl>
10+
</fieldset>
11+
<% else %>
12+
<%# non-grouped attributes: { "" => attributes } %>
13+
<dl>
14+
<%= yield %>
15+
</dl>
16+
<% end %>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<%= render_field attribute, page: page %>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<dt class="attribute-label" id="<%= attribute.name %>">
2+
<%= t(
3+
"helpers.label.#{resource_name}.#{attribute.name}",
4+
default: page.resource.class.human_attribute_name(attribute.name),
5+
) %>
6+
</dt>
7+
8+
<dd class="attribute-data attribute-data--<%=attribute.html_class%>">
9+
<%= yield %>
10+
</dd>

app/views/administrate/application/show.html.erb

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -50,27 +50,13 @@ as well as a link to its edit page.
5050
<%= content_for(:main) %>
5151
<% else %>
5252
<section class="main-content__body">
53-
<dl>
54-
<% page.attributes.each do |title, attributes| %>
55-
<fieldset class="<%= "field-unit--nested" if title.present? %>">
56-
<% if title.present? %>
57-
<legend><%= t "helpers.label.#{page.resource_name}.#{title}", default: title %></legend>
58-
<% end %>
59-
60-
<% attributes.each do |attribute| %>
61-
<dt class="attribute-label" id="<%= attribute.name %>">
62-
<%= t(
63-
"helpers.label.#{resource_name}.#{attribute.name}",
64-
default: page.resource.class.human_attribute_name(attribute.name),
65-
) %>
66-
</dt>
67-
68-
<dd class="attribute-data attribute-data--<%=attribute.html_class%>"
69-
><%= render_field attribute, page: page %></dd>
70-
<% end %>
71-
</fieldset>
72-
<% end %>
73-
</dl>
53+
<%= render(
54+
partial: 'resource_group',
55+
layout: 'resource_group_layout',
56+
collection: page.attributes.to_a,
57+
as: :resource_group,
58+
locals: local_assigns
59+
) %>
7460
</section>
7561
<% end %>
7662

0 commit comments

Comments
 (0)