Skip to content

armgit / spree

Public Imported from GitHub
0

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.

Admin: standarize empty list view (#12619)

Damian Legawiecb1cc8d5995a6
diff --git a/admin/app/views/spree/admin/coupon_codes/index.html.erb b/admin/app/views/spree/admin/coupon_codes/index.html.erb
index 8da1dced09..5ac29e6ece 100644
--- a/admin/app/views/spree/admin/coupon_codes/index.html.erb
+++ b/admin/app/views/spree/admin/coupon_codes/index.html.erb
@@ -54,13 +54,11 @@
</tbody>
</table>
<% else %>
- <div class="text-muted p-5 d-flex align-items-center w-100 justify-content-center">
- <%= Spree.t(:no_resource_found, resource: plural_resource_name(Spree::CouponCode)) %>
- </div>
+ <%= render 'spree/admin/shared/no_resource_found', new_object_url: nil %>
<% end %>
</div>
- <%= render 'spree/admin/shared/index_table_options', collection: @coupon_codes, simple: true if @coupon_codes.any? %>
+ <%= render 'spree/admin/shared/index_table_options', collection: @coupon_codes if @coupon_codes.any? %>
</div>
</div>
diff --git a/admin/app/views/spree/admin/customer_returns/index.html.erb b/admin/app/views/spree/admin/customer_returns/index.html.erb
index 58f8884d25..bc1b7f29d3 100644
--- a/admin/app/views/spree/admin/customer_returns/index.html.erb
+++ b/admin/app/views/spree/admin/customer_returns/index.html.erb
@@ -5,8 +5,8 @@
<% content_for :page_title do %>
<%= Spree.t(:customer_returns) %>
<% end %>
-<div class="card-lg">
+<div class="card-lg">
<%= search_form_for [:admin, @search], url: spree.admin_customer_returns_path, class: "filter-wrap", data: {controller: "filters reveal", reveal_hidden_class: "d-none"} do |f| %>
<%= render "spree/admin/shared/filters_search_bar",
param: :number_cont,
@@ -37,21 +37,8 @@
</tbody>
</table>
</div>
+ <%= render 'spree/admin/shared/index_table_options', collection: @collection %>
<% else %>
- <div
- class="
- text-muted p-5 d-flex align-items-center w-100 justify-content-center
- "
- >
- <%= Spree.t(
- :no_resource_found,
- resource: plural_resource_name(Spree::CustomerReturn),
- ) %>
- </div>
+ <%= render 'spree/admin/shared/no_resource_found', new_object_url: nil %>
<% end %>
-
- <%= render partial: "spree/admin/shared/index_table_options",
- locals: {
- collection: @collection,
- } %>
</div>
diff --git a/admin/app/views/spree/admin/orders/_list.html.erb b/admin/app/views/spree/admin/orders/_list.html.erb
index 3483f390b3..51f165fae0 100644
--- a/admin/app/views/spree/admin/orders/_list.html.erb
+++ b/admin/app/views/spree/admin/orders/_list.html.erb
@@ -23,8 +23,6 @@
</table>
</div>
<% else %>
- <div class="text-muted p-5 d-flex align-items-center w-100 justify-content-center">
- <%= Spree.t(:no_resource_found, resource: plural_resource_name(Spree::Order)) %>
- </div>
+ <%= render 'spree/admin/shared/no_resource_found', new_object_url: nil %>
<% end %>
-<%= render 'spree/admin/shared/index_table_options', collection: @orders, simple: true if @orders.any? %>
+<%= render 'spree/admin/shared/index_table_options', collection: @orders if @orders.any? %>
diff --git a/admin/app/views/spree/admin/post_categories/index.html.erb b/admin/app/views/spree/admin/post_categories/index.html.erb
index b269410b0b..3c28a98c1f 100644
--- a/admin/app/views/spree/admin/post_categories/index.html.erb
+++ b/admin/app/views/spree/admin/post_categories/index.html.erb
@@ -4,7 +4,7 @@
<%= render 'spree/admin/shared/posts_tabs' %>
-<% if @post_categories.any? %>
+<% if @collection.any? %>
<div class="card-lg">
<div class="table-responsive rounded-lg">
<table class="table">
@@ -15,13 +15,11 @@
</tr>
</thead>
<tbody>
- <%= render partial: 'spree/admin/post_categories/post_category', collection: @post_categories, cached: spree_base_cache_scope %>
+ <%= render collection: @collection, partial: 'spree/admin/post_categories/post_category', cached: spree_base_cache_scope %>
</tbody>
</table>
</div>
</div>
<% else %>
- <div class="text-muted p-5 d-flex align-items-center w-100 justify-content-center">
- <%= Spree.t(:no_resource_found, resource: Spree.t(:post_categories)) %>
- </div>
+ <%= render 'spree/admin/shared/no_resource_found' %>
<% end %>
diff --git a/admin/app/views/spree/admin/posts/index.html.erb b/admin/app/views/spree/admin/posts/index.html.erb
index 1a3d007e5f..41438ec35d 100644
--- a/admin/app/views/spree/admin/posts/index.html.erb
+++ b/admin/app/views/spree/admin/posts/index.html.erb
@@ -8,8 +8,7 @@
<div class="card-lg">
<%= render "spree/admin/posts/filters" %>
-
- <% if @posts.any? %>
+ <% if @collection.any? %>
<div class="table-responsive rounded-lg">
<table class="table">
<thead class="text-muted">
@@ -22,15 +21,12 @@
</tr>
</thead>
<tbody>
- <%= render partial: "spree/admin/posts/post", collection: @posts, cached: spree_base_cache_scope %>
+ <%= render collection: @collection, partial: "spree/admin/posts/post", cached: spree_base_cache_scope %>
</tbody>
</table>
</div>
-
- <%= render partial: "spree/admin/shared/index_table_options", locals: { collection: @posts } %>
+ <%= render "spree/admin/shared/index_table_options", collection: @collection %>
<% else %>
- <div class="text-muted p-5 d-flex align-items-center w-100 justify-content-center">
- <%= Spree.t(:no_resource_found, resource: Spree.t(:posts)) %>
- </div>
+ <%= render 'spree/admin/shared/no_resource_found' %>
<% end %>
</div>
diff --git a/admin/app/views/spree/admin/return_authorizations/_list.html.erb b/admin/app/views/spree/admin/return_authorizations/_list.html.erb
index b73c64dcfd..b0c27354fd 100644
--- a/admin/app/views/spree/admin/return_authorizations/_list.html.erb
+++ b/admin/app/views/spree/admin/return_authorizations/_list.html.erb
@@ -17,14 +17,5 @@
</table>
</div>
<% else %>
- <div
- class="
- text-muted p-5 d-flex align-items-center w-100 justify-content-center
- "
- >
- <%= Spree.t(
- :no_resource_found,
- resource: plural_resource_name(Spree::ReturnAuthorization),
- ) %>.
- </div>
+ <%= render 'spree/admin/shared/no_resource_found', new_object_url: nil %>
<% end %>
diff --git a/admin/app/views/spree/admin/shared/_no_resource_found.html.erb b/admin/app/views/spree/admin/shared/_no_resource_found.html.erb
index a6e26efaac..595d36de6c 100644
--- a/admin/app/views/spree/admin/shared/_no_resource_found.html.erb
+++ b/admin/app/views/spree/admin/shared/_no_resource_found.html.erb
@@ -2,5 +2,5 @@
<div class="text-muted p-5 d-flex align-items-center w-100 justify-content-center">
<%= Spree.t(:no_resource_found, resource: resource_name) %>
- <%= link_to_with_icon 'plus', Spree.t(:add_one), new_object_url, class: 'btn btn-light ml-3' if can?(:create, model_class) && defined?(new_object_url) && new_object_url.present? %>
+ <%= link_to_with_icon 'plus', Spree.t(:add_one), new_object_url, class: 'btn btn-light ml-3', data: { 'turbo-frame': '_top' } if can?(:create, model_class) && defined?(new_object_url) && new_object_url.present? %>
</div>
\ No newline at end of file
diff --git a/admin/app/views/spree/admin/stock_items/index.html.erb b/admin/app/views/spree/admin/stock_items/index.html.erb
index f747294aee..a287a1b6ca 100644
--- a/admin/app/views/spree/admin/stock_items/index.html.erb
+++ b/admin/app/views/spree/admin/stock_items/index.html.erb
@@ -9,7 +9,7 @@
<div class="card-lg">
<%= render "filters" %>
- <% if @stock_items.any? %>
+ <% if @collection.any? %>
<div class="table-responsive">
<table class="table" id="listing_products">
<thead class="text-muted">
@@ -24,15 +24,12 @@
</tr>
</thead>
<tbody>
- <%= render partial: "stock_item", collection: @stock_items %>
+ <%= render collection: @collection, partial: "stock_item" %>
</tbody>
</table>
</div>
+ <%= render "spree/admin/shared/index_table_options", collection: @collection %>
<% else %>
- <div class="text-muted p-5 d-flex align-items-center w-100 justify-content-center">
- <%= Spree.t(:no_resource_found, resource: Spree.t(:stock)) %>
- </div>
+ <%= render 'spree/admin/shared/no_resource_found', new_object_url: nil %>
<% end %>
-
- <%= render "spree/admin/shared/index_table_options", collection: @stock_items, simple: true if @stock_items.any? %>
</div>
diff --git a/admin/app/views/spree/admin/stock_transfers/index.html.erb b/admin/app/views/spree/admin/stock_transfers/index.html.erb
index 16847f024c..c26ddb28e0 100644
--- a/admin/app/views/spree/admin/stock_transfers/index.html.erb
+++ b/admin/app/views/spree/admin/stock_transfers/index.html.erb
@@ -12,7 +12,7 @@
<div class="card-lg">
<%= render "filters" %>
- <% if @stock_transfers.any? %>
+ <% if @collection.any? %>
<div class="table-responsive">
<table class="table" id="listing_products">
<thead class="text-muted">
@@ -27,12 +27,12 @@
</tr>
</thead>
<tbody>
- <%= render partial: 'stock_transfer', collection: @stock_transfers %>
+ <%= render collection: @collection, partial: 'stock_transfer' %>
</tbody>
</table>
</div>
+ <%= render 'spree/admin/shared/index_table_options', collection: @collection %>
<% else %>
<%= render 'spree/admin/shared/no_resource_found' %>
<% end %>
- <%= render 'spree/admin/shared/index_table_options', collection: @stock_transfers, simple: true if @stock_transfers.any? %>
</div>
diff --git a/admin/app/views/spree/admin/users/index.html.erb b/admin/app/views/spree/admin/users/index.html.erb
index 43072e3851..b28fabd768 100644
--- a/admin/app/views/spree/admin/users/index.html.erb
+++ b/admin/app/views/spree/admin/users/index.html.erb
@@ -13,14 +13,10 @@
<%= link_to_with_icon 'plus', Spree.t(:create_customer), spree.new_admin_user_path, class: "btn btn-primary" %>
<% end if can? :create, Spree::user_class %>
-<% content_for :table_filter_title do %>
- <%= Spree.t(:search) %>
-<% end %>
-
<div class="card-lg">
<%= render "spree/admin/users/filters" %>
- <% if @users.any? %>
+ <% if @collection.any? %>
<div data-controller="bulk-operation" 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' %>
@@ -90,15 +86,14 @@
</tr>
</thead>
<tbody>
- <%= render collection: @users, partial: "spree/admin/users/user", cached: spree_base_cache_scope %>
+ <%= 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 if @collection.any? %>
<% else %>
<%= render "spree/admin/shared/no_resource_found" %>
<% end %>
-
- <%= render "spree/admin/shared/index_table_options", collection: @users, simple: true if @users.any? %>
</div>