@@ -17,44 +17,22 @@ to display a collection of resources in an HTML table.
1717
1818[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Collection
1919%>
20+ <%# locals: (collection_presenter:, collection_field_name:, page:, resources:, table_title:, resource_class: nil) %>
2021
2122< table aria-labelledby ="<%= table_title %> " data-controller ="table " data-action ="click->table#visitDataUrl keydown->table#visitDataUrl ">
2223 < thead >
2324 < tr >
24- <% collection_presenter . attribute_types . each do |attr_name , attr_type | %>
25- < th class ="cell-label
26- cell-label--<%= attr_type . html_class %>
27- cell-label--<%= collection_presenter . ordered_html_class ( attr_name ) %>
28- cell-label-- <%= "#{ collection_presenter . resource_name } _#{ attr_name } " %> "
29- scope ="col "
30- <% if attr_type . sortable? %>
31- aria-sort ="<%= sort_order ( collection_presenter . ordered_html_class ( attr_name ) ) %> "
32- <% end %>
33- >
34- <% if attr_type . sortable? %>
35- <%= link_to ( params : sanitized_order_params ( page , collection_field_name ) . merge (
36- collection_presenter . order_params_for ( attr_name , key : collection_field_name )
37- ) ) do %>
38- <%= t (
39- "helpers.label.#{ collection_presenter . resource_name } .#{ attr_name } " ,
40- default : resource_class . human_attribute_name ( attr_name ) . titleize ,
41- ) %>
42- <% if collection_presenter . ordered_by? ( attr_name ) %>
43- < span class ="cell-label__sort-indicator cell-label__sort-indicator-- <%= collection_presenter . ordered_html_class ( attr_name ) %> ">
44- < svg aria-hidden ="true ">
45- < use xlink:href ="#icon-up-caret " />
46- </ svg >
47- </ span >
48- <% end %>
49- <% end %>
50- <% else %>
51- <%= t (
52- "helpers.label.#{ collection_presenter . resource_name } .#{ attr_name } " ,
53- default : resource_class . human_attribute_name ( attr_name ) . titleize ,
54- ) %>
55- <% end %>
56- </ th >
57- <% end %>
25+ <%= render (
26+ partial : 'collection_header_item' ,
27+ layout : 'collection_header_item_layout' ,
28+ collection : collection_presenter . attribute_types . to_a ,
29+ as : :attribute_type ,
30+ locals : {
31+ collection_presenter : collection_presenter ,
32+ collection_field_name : collection_field_name ,
33+ page : page
34+ }
35+ ) %>
5836 <%= render (
5937 "collection_header_actions" ,
6038 collection_presenter : collection_presenter ,
@@ -66,37 +44,16 @@ to display a collection of resources in an HTML table.
6644 </ thead >
6745
6846 < tbody >
69- <% resources . each do |resource | %>
70- < tr class ="js-table-row "
71- <% if accessible_action? ( resource , :show ) %>
72- <%= %(tabindex=0 data-url=#{ polymorphic_path ( [ namespace , resource ] ) } ) %>
73- <% end %>
74- >
75- <% collection_presenter . attributes_for ( resource ) . each do |attribute | %>
76- < td class ="cell-data cell-data-- <%= attribute . html_class %> ">
77- <% if accessible_action? ( resource , :show ) -%>
78- < a href ="<%= polymorphic_path ( [ namespace , resource ] ) -%> "
79- tabindex ="-1 "
80- class ="action-show "
81- >
82- <%= render_field attribute %>
83- </ a >
84- <% else %>
85- <%= render_field attribute %>
86- <% end -%>
87- </ td >
88- <% end %>
89-
90- <%= render (
91- "collection_item_actions" ,
92- collection_presenter : collection_presenter ,
93- collection_field_name : collection_field_name ,
94- page : page ,
95- namespace : namespace ,
96- resource : resource ,
97- table_title : "page-title"
98- ) %>
99- </ tr >
100- <% end %>
47+ <%= render (
48+ partial : "collection_item" ,
49+ layout : "collection_item_layout" ,
50+ collection : resources ,
51+ as : :resource ,
52+ locals : {
53+ collection_presenter : collection_presenter ,
54+ collection_field_name : collection_field_name ,
55+ page : page
56+ }
57+ ) %>
10158 </ tbody >
10259</ table >
0 commit comments