From c35d0feb6e7dea614ad339dc6b90de2daa5871b2 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Thu, 5 Sep 2024 15:58:37 +0200 Subject: [PATCH] Move alchemy resources table into resource_table partial To make upgrades easier for sites that might have the `table` partial overwritten, we introduce a new partial for the new resource table and leverage that for our own views. --- .../admin/resources/_resource_table.html.erb | 3 ++ .../alchemy/admin/resources/_table.html.erb | 28 ++++++++++++++++++- .../alchemy/admin/resources/index.html.erb | 2 +- app/views/alchemy/admin/sites/index.html.erb | 2 +- 4 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 app/views/alchemy/admin/resources/_resource_table.html.erb diff --git a/app/views/alchemy/admin/resources/_resource_table.html.erb b/app/views/alchemy/admin/resources/_resource_table.html.erb new file mode 100644 index 0000000000..b19560223a --- /dev/null +++ b/app/views/alchemy/admin/resources/_resource_table.html.erb @@ -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' %> diff --git a/app/views/alchemy/admin/resources/_table.html.erb b/app/views/alchemy/admin/resources/_table.html.erb index b19560223a..846627d902 100644 --- a/app/views/alchemy/admin/resources/_table.html.erb +++ b/app/views/alchemy/admin/resources/_table.html.erb @@ -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? %> + + + + <% if local_assigns[:icon] %> + + <% end %> + <% resource_handler.sorted_attributes.each do |attribute| %> + + <% end %> + + + + + <%= render_resources(icon: local_assigns[:icon]) %> + +
+ <%= 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' %> +
+<% elsif search_filter_params[:q].present? %> +

<%= Alchemy.t('Nothing found') %>

+<% end %> <%= paginate resources_instance_variable, scope: resource_url_proxy, theme: 'alchemy' %> diff --git a/app/views/alchemy/admin/resources/index.html.erb b/app/views/alchemy/admin/resources/index.html.erb index 68b78da297..ce808418da 100644 --- a/app/views/alchemy/admin/resources/index.html.erb +++ b/app/views/alchemy/admin/resources/index.html.erb @@ -29,7 +29,7 @@
<%= render 'alchemy/admin/resources/table_header' %> - <%= render 'table' %> + <%= render 'resource_table' %> <% if resource_has_tags || resource_has_filters %>
diff --git a/app/views/alchemy/admin/sites/index.html.erb b/app/views/alchemy/admin/sites/index.html.erb index 12ad3e9cc0..b084ddd532 100644 --- a/app/views/alchemy/admin/sites/index.html.erb +++ b/app/views/alchemy/admin/sites/index.html.erb @@ -22,7 +22,7 @@
<% 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 %>