Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Implement it for more screens
Damian Legawiec17c248566ca0
diff --git a/admin/app/controllers/spree/admin/resource_controller.rb b/admin/app/controllers/spree/admin/resource_controller.rbindex 2b17103250..4f5c181360 100644--- a/admin/app/controllers/spree/admin/resource_controller.rb+++ b/admin/app/controllers/spree/admin/resource_controller.rb@@ -242,6 +242,9 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController# @return [Ransack::Search]def search_collection@search ||= begin+ # Process query_state from table query builder if present+ process_table_query_state if table_registered?+params[:q] ||= {}params[:q][:s] ||= collection_default_sort if collection_default_sort.present?scope.ransack(params[:q])@@ -251,7 +254,14 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController# Returns the filtered and paginated ransack results# @return [ActiveRecord::Relation]def collection- @collection ||= search_collection.result(distinct: true).page(params[:page]).per(params[:per_page])+ @collection ||= begin+ result = search_collection.result(distinct: true)++ # Apply custom sort scope if configured (e.g., for price sorting)+ result = apply_table_sort(result) if table_registered? && custom_sort_active?++ result.page(params[:page]).per(params[:per_page])+ endenddef collection_includesdiff --git a/admin/app/views/spree/admin/customer_returns/index.html.erb b/admin/app/views/spree/admin/customer_returns/index.html.erbindex db2b1cbccd..6cf858cacf 100644--- a/admin/app/views/spree/admin/customer_returns/index.html.erb+++ b/admin/app/views/spree/admin/customer_returns/index.html.erb@@ -12,4 +12,4 @@<%= render_admin_partials(:customer_returns_header_partials) %>-<%= render 'spree/admin/shared/index_table', new_object_url: nil %>+<%= render_table @collection, :customer_returns %>diff --git a/admin/app/views/spree/admin/gift_cards/index.html.erb b/admin/app/views/spree/admin/gift_cards/index.html.erbindex 1669cad4d8..6ebe131db0 100644--- a/admin/app/views/spree/admin/gift_cards/index.html.erb+++ b/admin/app/views/spree/admin/gift_cards/index.html.erb@@ -1,29 +1,27 @@-<% unless turbo_frame_request? %>- <% content_for :page_title do %>- <%= Spree.t(:gift_cards) %>- <% end %>+<% content_for :page_title do %>+ <%= Spree.t(:gift_cards) %>+<% end %>- <% content_for :page_actions do %>- <%= render_admin_partials(:gift_cards_actions_partials) %>- <%= link_to_export_modal %>+<% content_for :page_actions do %>+ <%= render_admin_partials(:gift_cards_actions_partials) %>+ <%= link_to_export_modal %>- <%= dropdown id: 'page_actions_dropdown' do %>- <%= dropdown_toggle class: 'whitespace-nowrap btn-primary self-center', id: 'more-actions-link' do %>- <%= icon 'plus' %>- <%= Spree.t(:new_gift_card) %>+ <%= dropdown id: 'page_actions_dropdown' do %>+ <%= dropdown_toggle class: 'whitespace-nowrap btn-primary self-center', id: 'more-actions-link' do %>+ <%= icon 'plus' %>+ <%= Spree.t(:new_gift_card) %>+ <% end %>+ <%= dropdown_menu do %>+ <%= link_to spree.new_admin_gift_card_path,+ class: 'text-left dropdown-item' do %>+ <%= icon 'add' %>+ <%= Spree.t(:gift_card) %><% end %>- <%= dropdown_menu do %>- <%= link_to spree.new_admin_gift_card_path,- class: 'text-left dropdown-item' do %>- <%= icon 'add' %>- <%= Spree.t(:gift_card) %>- <% end %>- <%= link_to spree.new_admin_gift_card_batch_path,- class: 'text-left dropdown-item' do %>- <%= icon 'add' %>- <%= Spree.t(:gift_card_batch) %>- <% end %>+ <%= link_to spree.new_admin_gift_card_batch_path,+ class: 'text-left dropdown-item' do %>+ <%= icon 'add' %>+ <%= Spree.t(:gift_card_batch) %><% end %><% end %><% end %>@@ -31,17 +29,4 @@<%= render_admin_partials(:gift_cards_header_partials) %>-<div class="card-lg p-0">- <% if params[:frame_name].present? %>- <%= turbo_frame_tag params[:frame_name], autoscroll: true, data: { autoscroll_block: :nearest, autoscroll_behavior: :smooth } do %>- <%= render 'filters', frame_name: params[:frame_name] %>- <%= render 'list' %>- <% end %>- <% else %>- <%= turbo_frame_tag "gift_cards", autoscroll: true, data: { autoscroll_behavior: :smooth, turbo_action: 'advance' } do %>- <%= render 'spree/admin/shared/export_modal', export_type: Spree::Exports::GiftCards %>- <%= render 'filters' %>- <%= render 'list' %>- <% end %>- <% end %>-</div>+<%= render_table @collection, :gift_cards, export_type: Spree::Exports::GiftCards %>diff --git a/admin/app/views/spree/admin/metafield_definitions/index.html.erb b/admin/app/views/spree/admin/metafield_definitions/index.html.erbindex 688142c1c9..752a8cbd87 100644--- a/admin/app/views/spree/admin/metafield_definitions/index.html.erb+++ b/admin/app/views/spree/admin/metafield_definitions/index.html.erb@@ -6,4 +6,4 @@<%= link_to_with_icon 'plus', Spree.t(:new_metafield_definition), new_object_url, class: 'btn btn-primary' %><% end %>-<%= render 'spree/admin/shared/index_table' %>\ No newline at end of file+<%= render_table @collection, :metafield_definitions %>\ No newline at end of filediff --git a/admin/app/views/spree/admin/newsletter_subscribers/index.html.erb b/admin/app/views/spree/admin/newsletter_subscribers/index.html.erbindex c170aefcad..fad40f39c1 100644--- a/admin/app/views/spree/admin/newsletter_subscribers/index.html.erb+++ b/admin/app/views/spree/admin/newsletter_subscribers/index.html.erb@@ -6,4 +6,4 @@<%= link_to_export_modal %><% end %>-<%= render 'spree/admin/shared/index_table', new_object_url: nil, export_type: Spree::Exports::NewsletterSubscribers %>\ No newline at end of file+<%= render_table @collection, :newsletter_subscribers, export_type: Spree::Exports::NewsletterSubscribers %>\ No newline at end of filediff --git a/admin/app/views/spree/admin/option_types/index.html.erb b/admin/app/views/spree/admin/option_types/index.html.erbindex 5ede4d80b6..757e8fba97 100644--- a/admin/app/views/spree/admin/option_types/index.html.erb+++ b/admin/app/views/spree/admin/option_types/index.html.erb@@ -16,7 +16,7 @@<%= render_admin_partials(:option_types_header_partials) %>-<%= render 'spree/admin/shared/index_table', sortable: true %>+<%= render_table @collection, :option_types, sortable: true %><p class="documentation-link-container"><%= external_link_to "Learn more about options", "https://spreecommerce.org/docs/user/manage-products/product-options" %>diff --git a/admin/app/views/spree/admin/policies/index.html.erb b/admin/app/views/spree/admin/policies/index.html.erbindex 9a98457195..1fbd2050e0 100644--- a/admin/app/views/spree/admin/policies/index.html.erb+++ b/admin/app/views/spree/admin/policies/index.html.erb@@ -6,4 +6,4 @@<%= link_to_with_icon 'plus', Spree.t(:new_policy), new_object_url, class: 'btn btn-primary' if can?(:create, Spree::Policy) %><% end %>-<%= render 'spree/admin/shared/index_table' %>\ No newline at end of file+<%= render_table @collection, :policies %>\ No newline at end of filediff --git a/admin/app/views/spree/admin/promotions/index.html.erb b/admin/app/views/spree/admin/promotions/index.html.erbindex ec48c449c6..5a87f60c36 100644--- a/admin/app/views/spree/admin/promotions/index.html.erb+++ b/admin/app/views/spree/admin/promotions/index.html.erb@@ -9,4 +9,4 @@<%= render_admin_partials(:promotions_header_partials) %>-<%= render 'spree/admin/shared/index_table' %>+<%= render_table @collection, :promotions %>diff --git a/admin/app/views/spree/admin/stock_transfers/index.html.erb b/admin/app/views/spree/admin/stock_transfers/index.html.erbindex a9a78d8def..dd3380ff4e 100644--- a/admin/app/views/spree/admin/stock_transfers/index.html.erb+++ b/admin/app/views/spree/admin/stock_transfers/index.html.erb@@ -13,4 +13,4 @@<%= render_admin_partials(:stock_transfers_header_partials) %>-<%= render 'spree/admin/shared/index_table' %>+<%= render_table @collection, :stock_transfers %>diff --git a/admin/app/views/spree/admin/tables/columns/_gift_card_status.html.erb b/admin/app/views/spree/admin/tables/columns/_gift_card_status.html.erbnew file mode 100644index 0000000000..fb71845e88--- /dev/null+++ b/admin/app/views/spree/admin/tables/columns/_gift_card_status.html.erb@@ -0,0 +1,2 @@+<%# locals: (record:, column:, value:) %>+<%= active_badge(record.active?, label: record.display_state) %>diff --git a/admin/app/views/spree/admin/tables/columns/_metafield_definition_display_on.html.erb b/admin/app/views/spree/admin/tables/columns/_metafield_definition_display_on.html.erbnew file mode 100644index 0000000000..0b12994165--- /dev/null+++ b/admin/app/views/spree/admin/tables/columns/_metafield_definition_display_on.html.erb@@ -0,0 +1,4 @@+<%# locals: (record:, column:, value:) %>+<%= form_with model: record, url: spree.admin_metafield_definition_path(record), method: :patch, data: { controller: 'auto-submit' } do |f| %>+ <%= f.select :display_on, display_on_options(Spree::MetafieldDefinition), {}, { class: 'form-select form-select-sm', data: { action: 'auto-submit#submit' } } %>+<% end %>diff --git a/admin/app/views/spree/admin/tables/columns/_promotion_code.html.erb b/admin/app/views/spree/admin/tables/columns/_promotion_code.html.erbnew file mode 100644index 0000000000..cf8308e964--- /dev/null+++ b/admin/app/views/spree/admin/tables/columns/_promotion_code.html.erb@@ -0,0 +1,8 @@+<%# locals: (record:, column:, value:) %>+<% if record.coupon_code? && record.code.present? %>+ <code><%= record.code.upcase %></code>+<% elsif record.multi_codes? && record.code_prefix.present? %>+ <code><%= record.code_prefix %>-<%= '*' * 6 %></code>+<% else %>+ <span class="text-gray-600 small"><%= Spree.t(:not_available) %></span>+<% end %>diff --git a/admin/app/views/spree/admin/tables/columns/_promotion_kind.html.erb b/admin/app/views/spree/admin/tables/columns/_promotion_kind.html.erbnew file mode 100644index 0000000000..a607f3f42f--- /dev/null+++ b/admin/app/views/spree/admin/tables/columns/_promotion_kind.html.erb@@ -0,0 +1,9 @@+<%# locals: (record:, column:, value:) %>+<span class="badge badge-<% if record.automatic? %>info<% else %>light<% end %>">+ <% if record.automatic? %>+ <%= icon('automation', class: 'mr-2') %>+ <% else %>+ <%= icon('ticket', class: 'mr-2') %>+ <% end %>+ <%= record.kind.humanize %>+</span>diff --git a/admin/app/views/spree/admin/tables/columns/_user_location.html.erb b/admin/app/views/spree/admin/tables/columns/_user_location.html.erbnew file mode 100644index 0000000000..b827b5ccac--- /dev/null+++ b/admin/app/views/spree/admin/tables/columns/_user_location.html.erb@@ -0,0 +1,2 @@+<%= customer_location_flag(record) %>+<%= customer_location(record) %>diff --git a/admin/app/views/spree/admin/users/index.html.erb b/admin/app/views/spree/admin/users/index.html.erbindex c3257b9700..ed75dffea6 100644--- a/admin/app/views/spree/admin/users/index.html.erb+++ b/admin/app/views/spree/admin/users/index.html.erb@@ -10,62 +10,4 @@<%= render_admin_partials(:users_header_partials) %>-<div class="card-lg">- <%= turbo_frame_tag "customers", autoscroll: true, data: { autoscroll_behavior: :smooth, turbo_action: 'advance' } do %>- <%= render 'spree/admin/shared/export_modal', export_type: Spree::Exports::Customers %>- <%= render "spree/admin/users/filters" %>-- <% if @collection.any? %>- <div data-controller="bulk-operation bulk-dialog" data-action="keydown.esc->bulk-operation#cancel" tabindex="0">- <%= form_tag spree.admin_users_path, data: { 'bulk-operation-target': 'form' } do %>- <%= render 'spree/admin/shared/bulk_modal' %>- <div id="bulk-panel" class="hidden" data-bulk-operation-target="panel">- <div class="bulk-panel-container">- <%= bulk_operations_counter %>-- <% if can?(:manage_tags, Spree.user_class) %>- <%= bulk_action_link(- Spree.t("admin.bulk_ops.users.title.add_tags"),- spree.bulk_modal_admin_users_path(kind: :add_tags),- icon: "tag-plus",- url: spree.bulk_add_tags_admin_users_path- ) %>- <%= bulk_action_link(- Spree.t("admin.bulk_ops.users.title.remove_tags"),- spree.bulk_modal_admin_users_path(kind: :remove_tags),- icon: "tag-minus",- url: spree.bulk_remove_tags_admin_users_path- ) %>- <% end %>- <%= bulk_operations_close_button %>- </div>- </div>-- <div class="table-responsive">- <table class="table" id="listing_users">- <thead>- <tr data-hook="admin_users_index_headers">- <th scope="col" class="pr-0 w-5">- <%= bulk_operations_select_all_checkbox %>- </th>- <th scope="col"><%= Spree.t(:name) %></th>- <th scope="col"><%= Spree.t(:email_marketing) %></th>- <th scope="col"><%= Spree.t(:location) %></th>- <th scope="col"><%= Spree.t('admin.num_orders') %></th>- <th scope="col"><%= Spree.t('admin.amount_spent') %></th>- <th scope="col"><%= sort_link @search, :created_at, Spree.t(:created_at) %></th>- </tr>- </thead>- <tbody>- <%= render collection: @collection, partial: "spree/admin/users/user", cached: spree_base_cache_scope %>- </tbody>- </table>- </div>- <% end %>- </div>- <%= render "spree/admin/shared/index_table_options", collection: @collection %>- <% else %>- <%= render "spree/admin/shared/no_resource_found" %>- <% end %>- <% end %>-</div>+<%= render_table @collection, :users, bulk_operations: true, export_type: Spree::Exports::Customers %>