Skip to content

Commit

Permalink
Merge pull request #3026 from AlchemyCMS/move-resource-table-partial
Browse files Browse the repository at this point in the history
Move alchemy resources table into resource_table partial
  • Loading branch information
tvdeyen authored Sep 5, 2024
2 parents 1aba04f + c35d0fe commit bc022cc
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
3 changes: 3 additions & 0 deletions app/views/alchemy/admin/resources/_resource_table.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<%= render Alchemy::Admin::Resource::Table.new(resources_instance_variable, query: @query, search_filter_params: search_filter_params, icon: local_assigns[:icon]) %>

<%= paginate resources_instance_variable, scope: resource_url_proxy, theme: 'alchemy' %>
28 changes: 27 additions & 1 deletion app/views/alchemy/admin/resources/_table.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
<%= render Alchemy::Admin::Resource::Table.new(resources_instance_variable, query: @query, search_filter_params: search_filter_params, icon: local_assigns[:icon]) %>
<% Alchemy::Deprecation.warn "The `alchemy/admin/resources/_table` partial is deprecated. Please `render 'alchemy/admin/resources/_resource_table'` instead and update it to your needs." %>

<% if resources_instance_variable.any? %>
<table class="list" id="<%= resource_handler.resources_name %>_list">
<thead>
<tr>
<% if local_assigns[:icon] %>
<th class="icon"></th>
<% end %>
<% resource_handler.sorted_attributes.each do |attribute| %>
<th class="<%= attribute[:type] %> <%= attribute[:name] %>">
<%= sort_link [:resource_url_proxy, @query],
sortable_resource_header_column(attribute),
resource_handler.model.human_attribute_name(attribute[:name]),
default_order: attribute[:type].to_s =~ /date|time/ ? 'desc' : 'asc' %>
</th>
<% end %>
<th class="tools"></th>
</tr>
</thead>
<tbody>
<%= render_resources(icon: local_assigns[:icon]) %>
</tbody>
</table>
<% elsif search_filter_params[:q].present? %>
<p><%= Alchemy.t('Nothing found') %></p>
<% end %>

<%= paginate resources_instance_variable, scope: resource_url_proxy, theme: 'alchemy' %>
2 changes: 1 addition & 1 deletion app/views/alchemy/admin/resources/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

<div id="archive_all" class="resources-table-wrapper<%= ' with_tag_filter' if resource_has_tags || resource_has_filters %>">
<%= render 'alchemy/admin/resources/table_header' %>
<%= render 'table' %>
<%= render 'resource_table' %>

<% if resource_has_tags || resource_has_filters %>
<div id="library_sidebar">
Expand Down
2 changes: 1 addition & 1 deletion app/views/alchemy/admin/sites/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<div id="archive_all" class="resources-table-wrapper">
<% if @sites.any? %>
<%= render 'alchemy/admin/resources/table_header' %>
<%= render 'table', icon: "global" %>
<%= render 'alchemy/admin/resources/resource_table', icon: "global" %>
<% elsif search_filter_params[:q].present? %>
<%= render_message { Alchemy.t('Nothing found') } %>
<% else %>
Expand Down

0 comments on commit bc022cc

Please sign in to comment.