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.

Improve Admin Customers view

Damian Legawiecffcb8bbd55dc
diff --git a/admin/app/views/spree/admin/shared/_user.html.erb b/admin/app/views/spree/admin/shared/_user.html.erb
index 8562b1e59b..4c5c3b837f 100644
--- a/admin/app/views/spree/admin/shared/_user.html.erb
+++ b/admin/app/views/spree/admin/shared/_user.html.erb
@@ -1,4 +1,4 @@
-<%= link_to spree.admin_user_path(user), class: 'rounded hover-light p-2 d-flex justify-content-start align-items-center', data: {turbo_frame: :_top} do %>
+<%= link_to spree.admin_user_path(user), class: 'rounded hover-light p-2 d-flex justify-content-start align-items-center', data: {turbo_frame: :_top, row_link_target: :link} do %>
<% if user.name.present? %>
<%= render_avatar(user, width: 48, height: 48, class: 'mr-3 avatar') %>
<% else %>
diff --git a/admin/app/views/spree/admin/users/_user.html.erb b/admin/app/views/spree/admin/users/_user.html.erb
index e4e2584cb3..ec9ff8d108 100644
--- a/admin/app/views/spree/admin/users/_user.html.erb
+++ b/admin/app/views/spree/admin/users/_user.html.erb
@@ -1,17 +1,18 @@
-<tr id="<%= spree_dom_id user %>">
+<tr id="<%= spree_dom_id user %>" data-controller="row-link">
<td class="pr-0 w-5">
<%= bulk_operations_checkbox(user) %>
</td>
- <td class='user_name w-50 no-wrap py-0 pl-1 pr-0'>
+ <td class='w-50 no-wrap py-0 pl-1 pr-0'>
<%= render 'spree/admin/shared/user', user: user %>
</td>
- <td class="no-wrap">
+ <td class="cursor-pointer" data-action="click->row-link#openLink">
<%= active_badge(user.accepts_email_marketing?) %>
</td>
- <td class="w-25 no-wrap">
+ <td class="w-25 cursor-pointer" data-action="click->row-link#openLink">
<%= customer_location_flag(user) %>
<%= customer_location(user) %>
</td>
- <td class='user_num_orders w-10 no-wrap'><%= user.completed_orders_for_store(current_store).count %></td>
- <td class='user_amount_spent w-10 no-wrap'><%= user.display_amount_spent_in(current_currency) %></td>
+ <td class='w-10 no-wrap cursor-pointer' data-action="click->row-link#openLink"><%= user.completed_orders_for_store(current_store).count %></td>
+ <td class='w-10 no-wrap cursor-pointer' data-action="click->row-link#openLink"><%= user.display_amount_spent_in(current_currency) %></td>
+ <td class='w-10 no-wrap cursor-pointer' data-action="click->row-link#openLink"><%= local_time(user.created_at) %></td>
</tr>
diff --git a/admin/app/views/spree/admin/users/index.html.erb b/admin/app/views/spree/admin/users/index.html.erb
index 4a0915d174..be398263b3 100644
--- a/admin/app/views/spree/admin/users/index.html.erb
+++ b/admin/app/views/spree/admin/users/index.html.erb
@@ -3,8 +3,8 @@
<% end %>
<% content_for :page_actions do %>
- <%= link_to spree.admin_users_path(q: params[:q].to_unsafe_hash, page: params[:page], per_page: params[:per_page], format: :csv), class: 'btn btn-light bg-transparent with-tip mr-2 d-none d-lg-inline-flex', title: 'Export Customers to a CSV file. To filter specific Customers use "Filters" or Customers/Subscribers tabs before clicking this button' do %>
- <%= icon 'table-export', class: 'mr-2' %>
+ <%= link_to spree.admin_users_path(q: params[:q].to_unsafe_hash, page: params[:page], per_page: params[:per_page], format: :csv), class: 'btn btn-light bg-transparent with-tip d-none d-lg-inline-flex', title: 'Export Customers to a CSV file. To filter specific Customers use "Filters" or Customers/Subscribers tabs before clicking this button' do %>
+ <%= icon 'table-export' %>
<%= Spree.t(:export) %>
<% end if can?(:export, Spree::Export) %>
@@ -53,6 +53,7 @@
<th><%= Spree.t(:location) %></th>
<th><%= Spree.t('admin.num_orders') %></th>
<th><%= Spree.t('admin.amount_spent') %></th>
+ <th><%= sort_link @search, :created_at, Spree.t(:created_at) %></th>
</tr>
</thead>
<tbody>