diff --git a/app/views/administrate/application/_resource_group.html.erb b/app/views/administrate/application/_resource_group.html.erb new file mode 100644 index 0000000000..70c36ad2f7 --- /dev/null +++ b/app/views/administrate/application/_resource_group.html.erb @@ -0,0 +1,9 @@ +<% attributes = resource_group.second %> + +<%= render( + partial: 'resource_item', + layout: 'resource_item_layout', + collection: attributes, + as: :attribute, + locals: local_assigns +) %> diff --git a/app/views/administrate/application/_resource_group_layout.html.erb b/app/views/administrate/application/_resource_group_layout.html.erb new file mode 100644 index 0000000000..68fa82189e --- /dev/null +++ b/app/views/administrate/application/_resource_group_layout.html.erb @@ -0,0 +1,16 @@ +<% group_title = resource_group.first %> + +<% if group_title.present? %> + <%# grouped attributes: { title => attributes } %> +
+ <%= t "helpers.label.#{page.resource_name}.#{group_title}", default: group_title %> +
+ <%= yield %> +
+
+<% else %> + <%# non-grouped attributes: { "" => attributes } %> +
+ <%= yield %> +
+<% end %> diff --git a/app/views/administrate/application/_resource_item.html.erb b/app/views/administrate/application/_resource_item.html.erb new file mode 100644 index 0000000000..8d8451733a --- /dev/null +++ b/app/views/administrate/application/_resource_item.html.erb @@ -0,0 +1 @@ +<%= render_field attribute, page: page %> diff --git a/app/views/administrate/application/_resource_item_layout.html.erb b/app/views/administrate/application/_resource_item_layout.html.erb new file mode 100644 index 0000000000..42897fd417 --- /dev/null +++ b/app/views/administrate/application/_resource_item_layout.html.erb @@ -0,0 +1,10 @@ +
+ <%= t( + "helpers.label.#{resource_name}.#{attribute.name}", + default: page.resource.class.human_attribute_name(attribute.name), + ) %> +
+ +
+ <%= yield %> +
diff --git a/app/views/administrate/application/show.html.erb b/app/views/administrate/application/show.html.erb index e12fe87f7b..4d1ae66163 100644 --- a/app/views/administrate/application/show.html.erb +++ b/app/views/administrate/application/show.html.erb @@ -50,27 +50,13 @@ as well as a link to its edit page. <%= content_for(:main) %> <% else %>
-
- <% page.attributes.each do |title, attributes| %> -
"> - <% if title.present? %> - <%= t "helpers.label.#{page.resource_name}.#{title}", default: title %> - <% end %> - - <% attributes.each do |attribute| %> -
- <%= t( - "helpers.label.#{resource_name}.#{attribute.name}", - default: page.resource.class.human_attribute_name(attribute.name), - ) %> -
- -
<%= render_field attribute, page: page %>
- <% end %> -
- <% end %> -
+ <%= render( + partial: 'resource_group', + layout: 'resource_group_layout', + collection: page.attributes.to_a, + as: :resource_group, + locals: local_assigns + ) %>
<% end %>