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
Admin: Dashboard screen - always show top products to show all availa… (#12588)
Damian Legawiec45e03b69b022
diff --git a/admin/app/controllers/spree/admin/dashboard_controller.rb b/admin/app/controllers/spree/admin/dashboard_controller.rbindex 39a0334e83..0ad61c7db5 100644--- a/admin/app/controllers/spree/admin/dashboard_controller.rb+++ b/admin/app/controllers/spree/admin/dashboard_controller.rb@@ -83,7 +83,10 @@ module Spreeproduct_ids = line_items_grouped.map(&:variant_product_id).uniq.compact- return if product_ids.empty?+ if product_ids.empty?+ @top_products = []+ return+ endproducts = current_store.products.with_deleted.includes(:master, :variants).where(id: product_ids)diff --git a/admin/app/views/spree/admin/dashboard/_top_products.html.erb b/admin/app/views/spree/admin/dashboard/_top_products.html.erbindex 90a7178337..788c54db44 100644--- a/admin/app/views/spree/admin/dashboard/_top_products.html.erb+++ b/admin/app/views/spree/admin/dashboard/_top_products.html.erb@@ -32,40 +32,50 @@</tr></thead><tbody>- <% @top_products.each do |list_item| %>- <% product = list_item[:product] %>- <tr>- <% cache_unless @vendor, spree_base_cache_scope.call(product) do %>- <td>- <%= link_to spree.edit_admin_product_path(product), class: 'd-flex align-items-center font-weight-bold', data: { 'turbo-frame': '_top' } do %>- <div class="mr-3">- <%= render 'spree/admin/shared/product_image', object: product %>- </div>- <%= product.name %>+ <% if @top_products.any? %>+ <% @top_products.each do |list_item| %>+ <% product = list_item[:product] %>+ <tr>+ <% cache_unless @vendor, spree_base_cache_scope.call(product) do %>+ <td>+ <%= link_to spree.edit_admin_product_path(product), class: 'd-flex align-items-center font-weight-bold', data: { 'turbo-frame': '_top' } do %>+ <div class="mr-3">+ <%= render 'spree/admin/shared/product_image', object: product %>+ </div>+ <%= product.name %>+ <% end %>+ </td>+ <% if enterprise_edition? && defined?(vendor_logo_link) && !@vendor %>+ <td>+ <%= vendor_logo_link(product.vendor) if product.vendor.present? %>+ </td><% end %>- </td>- <% if enterprise_edition? && defined?(vendor_logo_link) && !@vendor %><td>- <%= vendor_logo_link(product.vendor) if product.vendor.present? %>+ <%= display_admin_price(product) %></td><% end %>- <td>- <%= display_admin_price(product) %>+ <td class="text-center">+ <%= list_item[:quantity] %></td>- <% end %>- <td class="text-center">- <%= list_item[:quantity] %>- </td>- <td class="text-right">- <%= list_item[:amount] %>+ <td class="text-right">+ <%= list_item[:amount] %>+ </td>+ </tr>+ <% end %>+ <% else %>+ <tr>+ <td colspan="5" class="text-center text-muted py-5">+ <%= Spree.t(:no_resource_found, resource: Spree::Product.name.demodulize.underscore.humanize) %></td></tr><% end %></tbody></table></div>- <p class="text-center mt-0 border-top py-2 mb-0">- <%= link_to Spree.t('admin.dashboard.view_report'), report_link, class: 'm-2 w-50 btn btn-light mt-2', data: { turbo_frame: '_top' } %>- </p>+ <% if @top_products.any? %>+ <p class="text-center mt-0 border-top py-2 mb-0">+ <%= link_to Spree.t('admin.dashboard.view_report'), report_link, class: 'm-2 w-50 btn btn-light mt-2', data: { turbo_frame: '_top' } %>+ </p>+ <% end %></div></div>diff --git a/admin/app/views/spree/admin/dashboard/analytics.html.erb b/admin/app/views/spree/admin/dashboard/analytics.html.erbindex aae959b6ff..f799d9d626 100644--- a/admin/app/views/spree/admin/dashboard/analytics.html.erb+++ b/admin/app/views/spree/admin/dashboard/analytics.html.erb@@ -113,6 +113,6 @@</div></div>- <%= render 'top_products' if @top_products.present? %>+ <%= render 'top_products' if @top_products %><%= render 'visits' if @visits %><% end %>