solidus_admin 0.1.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +61 -7
- data/Rakefile +1 -0
- data/app/assets/builds/solidus_admin/tailwind.css +197 -162
- data/app/assets/stylesheets/solidus_admin/dark.css +1 -0
- data/app/assets/stylesheets/solidus_admin/dimmed.css +1 -0
- data/app/components/solidus_admin/adjustment_reasons/edit/component.html.erb +27 -0
- data/app/components/solidus_admin/adjustment_reasons/edit/component.rb +12 -0
- data/app/components/solidus_admin/adjustment_reasons/edit/component.yml +8 -0
- data/app/components/solidus_admin/adjustment_reasons/index/component.rb +26 -19
- data/app/components/solidus_admin/adjustment_reasons/new/component.html.erb +28 -0
- data/app/components/solidus_admin/adjustment_reasons/new/component.rb +12 -0
- data/app/components/solidus_admin/adjustment_reasons/new/component.yml +8 -0
- data/app/components/solidus_admin/base_component.rb +4 -1
- data/app/components/solidus_admin/option_types/index/component.rb +21 -7
- data/app/components/solidus_admin/orders/index/component.rb +28 -23
- data/app/components/solidus_admin/orders/index/component.yml +1 -1
- data/app/components/solidus_admin/orders/show/address/component.html.erb +56 -54
- data/app/components/solidus_admin/orders/show/adjustments/index/adjustable/component.rb +27 -0
- data/app/components/solidus_admin/orders/show/adjustments/index/adjustable/spree_line_item/component.rb +14 -0
- data/app/components/solidus_admin/orders/show/adjustments/index/adjustable/spree_order/component.rb +11 -0
- data/app/components/solidus_admin/orders/show/adjustments/index/adjustable/spree_shipment/component.rb +15 -0
- data/app/components/solidus_admin/orders/show/adjustments/index/component.rb +147 -0
- data/app/components/solidus_admin/orders/show/adjustments/index/component.yml +21 -0
- data/app/components/solidus_admin/orders/show/adjustments/index/source/component.rb +26 -0
- data/app/components/solidus_admin/orders/show/adjustments/index/source/spree_tax_rate/component.rb +17 -0
- data/app/components/solidus_admin/orders/show/adjustments/index/source/spree_unit_cancel/component.rb +7 -0
- data/app/components/solidus_admin/orders/show/component.html.erb +7 -3
- data/app/components/solidus_admin/orders/show/component.rb +8 -0
- data/app/components/solidus_admin/orders/show/email/component.html.erb +18 -13
- data/app/components/solidus_admin/orders/show/email/component.rb +0 -4
- data/app/components/solidus_admin/orders/show/summary/component.html.erb +1 -1
- data/app/components/solidus_admin/payment_methods/index/component.rb +29 -19
- data/app/components/solidus_admin/payment_methods/index/component.yml +0 -5
- data/app/components/solidus_admin/products/index/component.rb +25 -15
- data/app/components/solidus_admin/products/index/component.yml +0 -2
- data/app/components/solidus_admin/products/show/component.html.erb +14 -3
- data/app/components/solidus_admin/products/status/component.rb +4 -1
- data/app/components/solidus_admin/products/status/component.yml +1 -0
- data/app/components/solidus_admin/properties/index/component.rb +18 -19
- data/app/components/solidus_admin/refund_reasons/edit/component.html.erb +27 -0
- data/app/components/solidus_admin/refund_reasons/edit/component.rb +12 -0
- data/app/components/solidus_admin/refund_reasons/edit/component.yml +8 -0
- data/app/components/solidus_admin/refund_reasons/index/component.rb +26 -19
- data/app/components/solidus_admin/refund_reasons/new/component.html.erb +27 -0
- data/app/components/solidus_admin/refund_reasons/new/component.rb +12 -0
- data/app/components/solidus_admin/refund_reasons/new/component.yml +6 -0
- data/app/components/solidus_admin/refunds_and_returns/component.rb +33 -13
- data/app/components/solidus_admin/reimbursement_types/index/component.rb +7 -25
- data/app/components/solidus_admin/return_reasons/edit/component.html.erb +26 -0
- data/app/components/solidus_admin/return_reasons/edit/component.rb +12 -0
- data/app/components/solidus_admin/return_reasons/edit/component.yml +8 -0
- data/app/components/solidus_admin/return_reasons/index/component.rb +27 -19
- data/app/components/solidus_admin/return_reasons/new/component.html.erb +27 -0
- data/app/components/solidus_admin/return_reasons/new/component.rb +12 -0
- data/app/components/solidus_admin/return_reasons/new/component.yml +8 -0
- data/app/components/solidus_admin/roles/edit/component.html.erb +33 -0
- data/app/components/solidus_admin/roles/edit/component.rb +20 -0
- data/app/components/solidus_admin/roles/edit/component.yml +19 -0
- data/app/components/solidus_admin/roles/index/component.rb +70 -0
- data/app/components/solidus_admin/roles/index/component.yml +6 -0
- data/app/components/solidus_admin/roles/new/component.html.erb +33 -0
- data/app/components/solidus_admin/roles/new/component.rb +20 -0
- data/app/components/solidus_admin/roles/new/component.yml +19 -0
- data/app/components/solidus_admin/shipping/component.rb +23 -11
- data/app/components/solidus_admin/shipping_categories/edit/component.html.erb +16 -0
- data/app/components/solidus_admin/shipping_categories/edit/component.rb +12 -0
- data/app/components/solidus_admin/shipping_categories/edit/component.yml +6 -0
- data/app/components/solidus_admin/shipping_categories/index/component.rb +37 -20
- data/app/components/solidus_admin/shipping_categories/new/component.html.erb +17 -0
- data/app/components/solidus_admin/shipping_categories/new/component.rb +12 -0
- data/app/components/solidus_admin/shipping_categories/new/component.yml +6 -0
- data/app/components/solidus_admin/shipping_methods/index/component.rb +19 -19
- data/app/components/solidus_admin/stock_items/edit/component.html.erb +66 -72
- data/app/components/solidus_admin/stock_items/edit/component.rb +0 -5
- data/app/components/solidus_admin/stock_items/index/component.rb +13 -20
- data/app/components/solidus_admin/stock_locations/index/component.rb +19 -11
- data/app/components/solidus_admin/stock_locations/index/component.yml +0 -3
- data/app/components/solidus_admin/store_credit_reasons/edit/component.html.erb +26 -0
- data/app/components/solidus_admin/store_credit_reasons/edit/component.rb +12 -0
- data/app/components/solidus_admin/store_credit_reasons/edit/component.yml +8 -0
- data/app/components/solidus_admin/store_credit_reasons/index/component.rb +26 -19
- data/app/components/solidus_admin/store_credit_reasons/new/component.html.erb +27 -0
- data/app/components/solidus_admin/store_credit_reasons/new/component.rb +12 -0
- data/app/components/solidus_admin/store_credit_reasons/new/component.yml +8 -0
- data/app/components/solidus_admin/stores/index/component.rb +18 -19
- data/app/components/solidus_admin/tax_categories/edit/component.html.erb +28 -0
- data/app/components/solidus_admin/tax_categories/edit/component.rb +12 -0
- data/app/components/solidus_admin/tax_categories/edit/component.yml +8 -0
- data/app/components/solidus_admin/tax_categories/index/component.rb +28 -21
- data/app/components/solidus_admin/tax_categories/new/component.html.erb +28 -0
- data/app/components/solidus_admin/tax_categories/new/component.rb +12 -0
- data/app/components/solidus_admin/tax_categories/new/component.yml +8 -0
- data/app/components/solidus_admin/tax_rates/index/component.rb +21 -17
- data/app/components/solidus_admin/taxes/component.rb +8 -8
- data/app/components/solidus_admin/taxonomies/index/component.rb +18 -12
- data/app/components/solidus_admin/ui/button/component.rb +1 -1
- data/app/components/solidus_admin/ui/checkbox_row/component.html.erb +29 -0
- data/app/components/solidus_admin/ui/checkbox_row/component.rb +11 -0
- data/app/components/solidus_admin/ui/forms/address/component.html.erb +27 -9
- data/app/components/solidus_admin/ui/forms/address/component.js +38 -13
- data/app/components/solidus_admin/ui/forms/search/component.html.erb +2 -3
- data/app/components/solidus_admin/ui/forms/search/component.js +3 -3
- data/app/components/solidus_admin/ui/modal/component.html.erb +7 -7
- data/app/components/solidus_admin/ui/modal/component.js +7 -0
- data/app/components/solidus_admin/ui/modal/component.rb +1 -1
- data/app/components/solidus_admin/ui/pages/index/component.html.erb +44 -0
- data/app/components/solidus_admin/ui/pages/index/component.rb +105 -0
- data/app/components/solidus_admin/ui/panel/component.html.erb +5 -16
- data/app/components/solidus_admin/ui/panel/component.rb +11 -7
- data/app/components/solidus_admin/ui/table/component.html.erb +2 -1
- data/app/components/solidus_admin/ui/table/component.js +31 -2
- data/app/components/solidus_admin/ui/table/component.rb +24 -8
- data/app/components/solidus_admin/ui/table/component.yml +1 -0
- data/app/components/solidus_admin/ui/thumbnail/component.rb +1 -1
- data/app/components/solidus_admin/ui/thumbnail_with_caption/component.html.erb +17 -0
- data/app/components/solidus_admin/ui/thumbnail_with_caption/component.rb +15 -0
- data/app/components/solidus_admin/users/addresses/component.html.erb +46 -0
- data/app/components/solidus_admin/users/addresses/component.rb +61 -0
- data/app/components/solidus_admin/users/addresses/component.yml +14 -0
- data/app/components/solidus_admin/users/edit/api_access/component.html.erb +49 -0
- data/app/components/solidus_admin/users/edit/api_access/component.js +9 -0
- data/app/components/solidus_admin/users/edit/api_access/component.rb +7 -0
- data/app/components/solidus_admin/users/edit/api_access/component.yml +10 -0
- data/app/components/solidus_admin/users/edit/component.html.erb +52 -0
- data/app/components/solidus_admin/users/edit/component.rb +51 -0
- data/app/components/solidus_admin/users/edit/component.yml +12 -0
- data/app/components/solidus_admin/users/index/component.rb +25 -16
- data/app/components/solidus_admin/users/index/component.yml +0 -3
- data/app/components/solidus_admin/users/items/component.html.erb +41 -0
- data/app/components/solidus_admin/users/items/component.rb +170 -0
- data/app/components/solidus_admin/users/items/component.yml +16 -0
- data/app/components/solidus_admin/users/orders/component.html.erb +42 -0
- data/app/components/solidus_admin/users/orders/component.rb +131 -0
- data/app/components/solidus_admin/users/orders/component.yml +12 -0
- data/app/components/solidus_admin/users/stats/component.html.erb +11 -0
- data/app/components/solidus_admin/users/stats/component.rb +9 -0
- data/app/components/solidus_admin/users/stats/component.yml +2 -0
- data/app/components/solidus_admin/users_and_roles/component.rb +24 -0
- data/app/components/solidus_admin/users_and_roles/component.yml +2 -0
- data/app/components/solidus_admin/zones/index/component.rb +19 -11
- data/app/controllers/solidus_admin/addresses_controller.rb +6 -1
- data/app/controllers/solidus_admin/adjustment_reasons_controller.rb +85 -10
- data/app/controllers/solidus_admin/adjustments_controller.rb +57 -0
- data/app/controllers/solidus_admin/customers_controller.rb +5 -1
- data/app/controllers/solidus_admin/orders_controller.rb +5 -1
- data/app/controllers/solidus_admin/products_controller.rb +11 -0
- data/app/controllers/solidus_admin/properties_controller.rb +1 -1
- data/app/controllers/solidus_admin/refund_reasons_controller.rb +85 -10
- data/app/controllers/solidus_admin/reimbursement_types_controller.rb +0 -5
- data/app/controllers/solidus_admin/return_reasons_controller.rb +85 -10
- data/app/controllers/solidus_admin/roles_controller.rb +118 -0
- data/app/controllers/solidus_admin/shipping_categories_controller.rb +87 -10
- data/app/controllers/solidus_admin/shipping_methods_controller.rb +0 -5
- data/app/controllers/solidus_admin/stock_items_controller.rb +6 -6
- data/app/controllers/solidus_admin/stock_locations_controller.rb +0 -5
- data/app/controllers/solidus_admin/store_credit_reasons_controller.rb +85 -10
- data/app/controllers/solidus_admin/stores_controller.rb +0 -5
- data/app/controllers/solidus_admin/tax_categories_controller.rb +89 -10
- data/app/controllers/solidus_admin/tax_rates_controller.rb +0 -5
- data/app/controllers/solidus_admin/users_controller.rb +85 -6
- data/app/controllers/solidus_admin/zones_controller.rb +0 -5
- data/app/helpers/solidus_admin/last_login_helper.rb +16 -0
- data/app/helpers/solidus_admin/permission_sets_helper.rb +32 -0
- data/app/views/layouts/solidus_admin/application.html.erb +2 -1
- data/app/views/layouts/solidus_admin/preview.html.erb +2 -0
- data/config/initializers/view_component.rb +1 -1
- data/config/locales/adjustment_reasons.en.yml +5 -1
- data/config/locales/adjustments.en.yml +10 -0
- data/config/locales/refund_reasons.en.yml +10 -0
- data/config/locales/return_reasons.en.yml +5 -1
- data/config/locales/roles.en.yml +10 -0
- data/config/locales/shipping_categories.en.yml +4 -0
- data/config/locales/store_credit_reasons.en.yml +5 -1
- data/config/locales/tax_categories.en.yml +4 -0
- data/config/locales/users.en.yml +10 -0
- data/config/routes.rb +24 -7
- data/docs/components.md +109 -0
- data/docs/{customizing_view_components.md → customizing_components.md} +2 -7
- data/docs/index_pages.md +146 -0
- data/docs/{customizing_menu_items.md → menu_items.md} +1 -1
- data/docs/stimulusjs.md +85 -0
- data/docs/{customizing_tailwindcss.md → tailwindcss.md} +27 -8
- data/lib/solidus_admin/component_registry.rb +40 -0
- data/lib/solidus_admin/configuration.rb +5 -27
- data/lib/solidus_admin/install_tailwindcss.rb +3 -1
- data/lib/solidus_admin/testing_support/admin_assets.rb +10 -0
- data/lib/solidus_admin/testing_support/component_helpers.rb +27 -0
- data/lib/solidus_admin/testing_support/dummy_app/rake_tasks.rb +60 -0
- data/lib/solidus_admin/testing_support/feature_helpers.rb +34 -0
- data/lib/solidus_admin/version.rb +1 -1
- data/solidus_admin.gemspec +7 -3
- metadata +111 -59
- data/app/components/solidus_admin/adjustment_reasons/index/component.html.erb +0 -32
- data/app/components/solidus_admin/adjustment_reasons/index/component.yml +0 -4
- data/app/components/solidus_admin/option_types/index/component.html.erb +0 -30
- data/app/components/solidus_admin/orders/index/component.html.erb +0 -35
- data/app/components/solidus_admin/payment_methods/index/component.html.erb +0 -38
- data/app/components/solidus_admin/products/index/component.html.erb +0 -34
- data/app/components/solidus_admin/promotion_categories/index/component.html.erb +0 -26
- data/app/components/solidus_admin/promotion_categories/index/component.rb +0 -57
- data/app/components/solidus_admin/promotion_categories/index/component.yml +0 -4
- data/app/components/solidus_admin/promotions/index/component.html.erb +0 -34
- data/app/components/solidus_admin/promotions/index/component.rb +0 -97
- data/app/components/solidus_admin/promotions/index/component.yml +0 -14
- data/app/components/solidus_admin/properties/index/component.html.erb +0 -34
- data/app/components/solidus_admin/properties/index/component.yml +0 -4
- data/app/components/solidus_admin/refund_reasons/index/component.html.erb +0 -31
- data/app/components/solidus_admin/refund_reasons/index/component.yml +0 -4
- data/app/components/solidus_admin/refunds_and_returns/component.html.erb +0 -26
- data/app/components/solidus_admin/reimbursement_types/index/component.html.erb +0 -22
- data/app/components/solidus_admin/reimbursement_types/index/component.yml +0 -4
- data/app/components/solidus_admin/return_reasons/index/component.html.erb +0 -31
- data/app/components/solidus_admin/return_reasons/index/component.yml +0 -4
- data/app/components/solidus_admin/shipping/component.html.erb +0 -30
- data/app/components/solidus_admin/shipping_categories/index/component.html.erb +0 -32
- data/app/components/solidus_admin/shipping_categories/index/component.yml +0 -4
- data/app/components/solidus_admin/shipping_methods/index/component.html.erb +0 -32
- data/app/components/solidus_admin/shipping_methods/index/component.yml +0 -4
- data/app/components/solidus_admin/stock_items/index/component.html.erb +0 -26
- data/app/components/solidus_admin/stock_locations/index/component.html.erb +0 -32
- data/app/components/solidus_admin/store_credit_reasons/index/component.html.erb +0 -31
- data/app/components/solidus_admin/store_credit_reasons/index/component.yml +0 -4
- data/app/components/solidus_admin/stores/index/component.html.erb +0 -34
- data/app/components/solidus_admin/stores/index/component.yml +0 -4
- data/app/components/solidus_admin/tax_categories/index/component.html.erb +0 -32
- data/app/components/solidus_admin/tax_categories/index/component.yml +0 -6
- data/app/components/solidus_admin/tax_rates/index/component.html.erb +0 -32
- data/app/components/solidus_admin/tax_rates/index/component.yml +0 -4
- data/app/components/solidus_admin/taxes/component.html.erb +0 -24
- data/app/components/solidus_admin/taxonomies/index/component.html.erb +0 -28
- data/app/components/solidus_admin/taxonomies/index/component.yml +0 -4
- data/app/components/solidus_admin/users/index/component.html.erb +0 -34
- data/app/components/solidus_admin/zones/index/component.html.erb +0 -35
- data/app/components/solidus_admin/zones/index/component.yml +0 -4
- data/app/controllers/solidus_admin/promotion_categories_controller.rb +0 -38
- data/app/controllers/solidus_admin/promotions_controller.rb +0 -46
- data/config/locales/promotion_categories.en.yml +0 -6
- data/config/locales/promotions.en.yml +0 -6
- data/config/locales/refund_reasons_.en.yml +0 -6
- /data/app/components/solidus_admin/{option_types → ui/pages}/index/component.yml +0 -0
@@ -0,0 +1,12 @@
|
|
1
|
+
en:
|
2
|
+
title: "Users / %{email}"
|
3
|
+
account: Account
|
4
|
+
addresses: Addresses
|
5
|
+
order_history: Order History
|
6
|
+
items: Items
|
7
|
+
store_credit: Store Credit
|
8
|
+
last_active: Last Active
|
9
|
+
create_order_for_user: Create order for this user
|
10
|
+
update: Update
|
11
|
+
cancel: Cancel
|
12
|
+
back: Back
|
@@ -1,28 +1,37 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
class SolidusAdmin::Users::Index::Component < SolidusAdmin::
|
4
|
-
include SolidusAdmin::
|
3
|
+
class SolidusAdmin::Users::Index::Component < SolidusAdmin::UsersAndRoles::Component
|
4
|
+
include SolidusAdmin::LastLoginHelper
|
5
5
|
|
6
|
-
def
|
7
|
-
|
6
|
+
def model_class
|
7
|
+
Spree.user_class
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
11
|
-
|
10
|
+
def search_key
|
11
|
+
:email_cont
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
15
|
-
solidus_admin.
|
14
|
+
def search_url
|
15
|
+
solidus_admin.users_path
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
19
|
-
solidus_admin.
|
18
|
+
def row_url(user)
|
19
|
+
solidus_admin.edit_user_path(user)
|
20
|
+
end
|
21
|
+
|
22
|
+
def page_actions
|
23
|
+
render component("ui/button").new(
|
24
|
+
tag: :a,
|
25
|
+
text: t('.add'),
|
26
|
+
href: spree.new_admin_user_path,
|
27
|
+
icon: "add-line",
|
28
|
+
)
|
20
29
|
end
|
21
30
|
|
22
31
|
def batch_actions
|
23
32
|
[
|
24
33
|
{
|
25
|
-
|
34
|
+
label: t('.batch_actions.delete'),
|
26
35
|
action: solidus_admin.users_path,
|
27
36
|
method: :delete,
|
28
37
|
icon: 'delete-bin-7-line',
|
@@ -32,18 +41,18 @@ class SolidusAdmin::Users::Index::Component < SolidusAdmin::BaseComponent
|
|
32
41
|
|
33
42
|
def scopes
|
34
43
|
[
|
35
|
-
{ name: :
|
44
|
+
{ name: :all, label: t('.scopes.all'), default: true },
|
45
|
+
{ name: :customers, label: t('.scopes.customers') },
|
36
46
|
{ name: :admin, label: t('.scopes.admin') },
|
37
47
|
{ name: :with_orders, label: t('.scopes.with_orders') },
|
38
48
|
{ name: :without_orders, label: t('.scopes.without_orders') },
|
39
|
-
{ name: :all, label: t('.scopes.all') },
|
40
49
|
]
|
41
50
|
end
|
42
51
|
|
43
52
|
def filters
|
44
53
|
[
|
45
54
|
{
|
46
|
-
|
55
|
+
label: Spree::Role.model_name.human.pluralize,
|
47
56
|
attribute: "spree_roles_id",
|
48
57
|
predicate: "in",
|
49
58
|
options: Spree::Role.pluck(:name, :id)
|
@@ -81,8 +90,8 @@ class SolidusAdmin::Users::Index::Component < SolidusAdmin::BaseComponent
|
|
81
90
|
data: -> { _1.display_lifetime_value.to_html },
|
82
91
|
},
|
83
92
|
{
|
84
|
-
header: :
|
85
|
-
data: ->(user) {
|
93
|
+
header: :last_active,
|
94
|
+
data: ->(user) { last_login(user) },
|
86
95
|
},
|
87
96
|
]
|
88
97
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
<%= page do %>
|
2
|
+
<%= page_header do %>
|
3
|
+
<%= page_header_back(solidus_admin.users_path) %>
|
4
|
+
<%= page_header_title(t(".title", email: @user.email)) %>
|
5
|
+
|
6
|
+
<%= page_header_actions do %>
|
7
|
+
<%= render component("ui/button").new(tag: :a, text: t(".create_order_for_user"), href: spree.new_admin_order_path(user_id: @user.id)) %>
|
8
|
+
<% end %>
|
9
|
+
<% end %>
|
10
|
+
|
11
|
+
<%= page_header do %>
|
12
|
+
<% tabs.each do |tab| %>
|
13
|
+
<%= render(component("ui/button").new(tag: :a, scheme: :ghost, text: tab[:text], 'aria-current': tab[:current], href: tab[:href])) %>
|
14
|
+
<% end %>
|
15
|
+
<% end %>
|
16
|
+
|
17
|
+
<%= page_with_sidebar do %>
|
18
|
+
<%= page_with_sidebar_main do %>
|
19
|
+
<%= render component('ui/panel').new(title: t(".items_purchased")) do %>
|
20
|
+
<% if @items.present? %>
|
21
|
+
<%= render component('ui/table').new(
|
22
|
+
id: stimulus_id,
|
23
|
+
data: {
|
24
|
+
class: model_class,
|
25
|
+
rows: rows,
|
26
|
+
columns: columns,
|
27
|
+
url: -> { row_url(_1.order) },
|
28
|
+
},
|
29
|
+
)%>
|
30
|
+
<% else %>
|
31
|
+
<%= t(".no_orders_found") %>
|
32
|
+
<%= render component("ui/button").new(tag: :a, text: t(".create_one"), href: spree.new_admin_order_path(user_id: @user.id)) %>
|
33
|
+
<% end %>
|
34
|
+
<% end %>
|
35
|
+
<% end %>
|
36
|
+
|
37
|
+
<%= page_with_sidebar_aside do %>
|
38
|
+
<%= render component("users/stats").new(user: @user) %>
|
39
|
+
<% end %>
|
40
|
+
<% end %>
|
41
|
+
<% end %>
|
@@ -0,0 +1,170 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class SolidusAdmin::Users::Items::Component < SolidusAdmin::BaseComponent
|
4
|
+
include SolidusAdmin::Layout::PageHelpers
|
5
|
+
|
6
|
+
def initialize(user:, items:)
|
7
|
+
@user = user
|
8
|
+
@items = items
|
9
|
+
end
|
10
|
+
|
11
|
+
def tabs
|
12
|
+
[
|
13
|
+
{
|
14
|
+
text: t('.account'),
|
15
|
+
href: solidus_admin.user_path(@user),
|
16
|
+
current: false,
|
17
|
+
},
|
18
|
+
{
|
19
|
+
text: t('.addresses'),
|
20
|
+
href: solidus_admin.addresses_user_path(@user),
|
21
|
+
current: false,
|
22
|
+
},
|
23
|
+
{
|
24
|
+
text: t('.order_history'),
|
25
|
+
href: solidus_admin.orders_user_path(@user),
|
26
|
+
current: false,
|
27
|
+
},
|
28
|
+
{
|
29
|
+
text: t('.items'),
|
30
|
+
href: solidus_admin.items_user_path(@user),
|
31
|
+
current: true,
|
32
|
+
},
|
33
|
+
{
|
34
|
+
text: t('.store_credit'),
|
35
|
+
href: spree.admin_user_store_credits_path(@user),
|
36
|
+
current: false,
|
37
|
+
},
|
38
|
+
]
|
39
|
+
end
|
40
|
+
|
41
|
+
def model_class
|
42
|
+
Spree::LineItem
|
43
|
+
end
|
44
|
+
|
45
|
+
def row_url(order)
|
46
|
+
spree.edit_admin_order_path(order)
|
47
|
+
end
|
48
|
+
|
49
|
+
def rows
|
50
|
+
@items
|
51
|
+
end
|
52
|
+
|
53
|
+
def columns
|
54
|
+
[
|
55
|
+
date_column,
|
56
|
+
image_column,
|
57
|
+
description_column,
|
58
|
+
price_column,
|
59
|
+
quantity_column,
|
60
|
+
total_column,
|
61
|
+
state_column,
|
62
|
+
number_column,
|
63
|
+
]
|
64
|
+
end
|
65
|
+
|
66
|
+
def date_column
|
67
|
+
{
|
68
|
+
col: { class: "w-[8%]" },
|
69
|
+
header: :date,
|
70
|
+
data: ->(item) do
|
71
|
+
content_tag :div, l(item.order.created_at, format: :short), class: "text-sm"
|
72
|
+
end
|
73
|
+
}
|
74
|
+
end
|
75
|
+
|
76
|
+
def image_column
|
77
|
+
{
|
78
|
+
col: { class: "w-[8%]" },
|
79
|
+
header: tag.span('aria-label': Spree::Image.model_name.human, role: 'text'),
|
80
|
+
data: ->(item) do
|
81
|
+
image = item.variant.gallery.images.first || item.variant.product.gallery.images.first or return
|
82
|
+
|
83
|
+
render(
|
84
|
+
component('ui/thumbnail').new(
|
85
|
+
src: image.url(:small),
|
86
|
+
alt: item.product.name
|
87
|
+
)
|
88
|
+
)
|
89
|
+
end
|
90
|
+
}
|
91
|
+
end
|
92
|
+
|
93
|
+
def description_column
|
94
|
+
{
|
95
|
+
col: { class: "w-[24%]" },
|
96
|
+
header: t(".description_column_header"),
|
97
|
+
data: ->(item) { item_name_with_variant_and_sku(item) }
|
98
|
+
}
|
99
|
+
end
|
100
|
+
|
101
|
+
def price_column
|
102
|
+
{
|
103
|
+
col: { class: "w-[10%]" },
|
104
|
+
header: :price,
|
105
|
+
data: ->(item) do
|
106
|
+
content_tag :div, item.single_money.to_html
|
107
|
+
end
|
108
|
+
}
|
109
|
+
end
|
110
|
+
|
111
|
+
def quantity_column
|
112
|
+
{
|
113
|
+
col: { class: "w-[7%]" },
|
114
|
+
header: :qty,
|
115
|
+
data: ->(item) do
|
116
|
+
content_tag :div, item.quantity
|
117
|
+
end
|
118
|
+
}
|
119
|
+
end
|
120
|
+
|
121
|
+
def total_column
|
122
|
+
{
|
123
|
+
col: { class: "w-[10%]" },
|
124
|
+
header: t(".total_column_header"),
|
125
|
+
data: ->(item) do
|
126
|
+
content_tag :div, item.money.to_html
|
127
|
+
end
|
128
|
+
}
|
129
|
+
end
|
130
|
+
|
131
|
+
def state_column
|
132
|
+
{
|
133
|
+
col: { class: "w-[15%]" },
|
134
|
+
header: :state,
|
135
|
+
data: ->(item) do
|
136
|
+
color = {
|
137
|
+
'complete' => :green,
|
138
|
+
'returned' => :red,
|
139
|
+
'canceled' => :blue,
|
140
|
+
'cart' => :graphite_light,
|
141
|
+
}[item.order.state] || :yellow
|
142
|
+
component('ui/badge').new(name: item.order.state.humanize, color: color)
|
143
|
+
end
|
144
|
+
}
|
145
|
+
end
|
146
|
+
|
147
|
+
def number_column
|
148
|
+
{
|
149
|
+
col: { class: "w-[18%]" },
|
150
|
+
header: t(".number_column_header"),
|
151
|
+
data: ->(item) do
|
152
|
+
content_tag :div, item.order.number, class: "font-semibold text-sm"
|
153
|
+
end
|
154
|
+
}
|
155
|
+
end
|
156
|
+
|
157
|
+
private
|
158
|
+
|
159
|
+
def item_name_with_variant_and_sku(item)
|
160
|
+
content = []
|
161
|
+
content << item.product.name
|
162
|
+
content << "(#{item.variant.options_text})" if item.variant.option_values.any?
|
163
|
+
content << "<strong>#{t('spree.sku')}:</strong> #{item.variant.sku}" if item.variant.sku.present?
|
164
|
+
|
165
|
+
# The `.html_safe` is required for the description to display as desired.
|
166
|
+
# rubocop:disable Rails/OutputSafety
|
167
|
+
safe_join([content_tag(:div, content.join("<br>").html_safe, class: "text-sm")])
|
168
|
+
# rubocop:enable Rails/OutputSafety
|
169
|
+
end
|
170
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
en:
|
2
|
+
title: "Users / %{email} / Items Purchased"
|
3
|
+
account: Account
|
4
|
+
addresses: Addresses
|
5
|
+
order_history: Order History
|
6
|
+
items: Items
|
7
|
+
store_credit: Store Credit
|
8
|
+
last_active: Last Active
|
9
|
+
create_order_for_user: Create order for this user
|
10
|
+
items_purchased: Items Purchased
|
11
|
+
no_orders_found: No Orders found.
|
12
|
+
create_one: Create One
|
13
|
+
back: Back
|
14
|
+
number_column_header: "Order #"
|
15
|
+
description_column_header: "Description"
|
16
|
+
total_column_header: "Total"
|
@@ -0,0 +1,42 @@
|
|
1
|
+
<%= page do %>
|
2
|
+
<%= page_header do %>
|
3
|
+
<%= page_header_back(solidus_admin.users_path) %>
|
4
|
+
<%= page_header_title(t(".title", email: @user.email)) %>
|
5
|
+
|
6
|
+
<%= page_header_actions do %>
|
7
|
+
<%= render component("ui/button").new(tag: :a, text: t(".create_order_for_user"), href: spree.new_admin_order_path(user_id: @user.id)) %>
|
8
|
+
<% end %>
|
9
|
+
<% end %>
|
10
|
+
|
11
|
+
<%= page_header do %>
|
12
|
+
<% tabs.each do |tab| %>
|
13
|
+
<%= render(component("ui/button").new(tag: :a, scheme: :ghost, text: tab[:text], 'aria-current': tab[:current], href: tab[:href])) %>
|
14
|
+
<% end %>
|
15
|
+
<% end %>
|
16
|
+
|
17
|
+
<%= page_with_sidebar do %>
|
18
|
+
<%= page_with_sidebar_main do %>
|
19
|
+
<%= render component('ui/panel').new(title: t(".order_history")) do %>
|
20
|
+
<% if @orders.present? %>
|
21
|
+
<%= render component('ui/table').new(
|
22
|
+
id: stimulus_id,
|
23
|
+
data: {
|
24
|
+
class: model_class,
|
25
|
+
rows: rows,
|
26
|
+
fade: -> { row_fade(_1) },
|
27
|
+
columns: columns,
|
28
|
+
url: -> { row_url(_1) },
|
29
|
+
},
|
30
|
+
)%>
|
31
|
+
<% else %>
|
32
|
+
<%= t(".no_orders_found") %>
|
33
|
+
<%= render component("ui/button").new(tag: :a, text: t(".create_one"), href: spree.new_admin_order_path(user_id: @user.id)) %>
|
34
|
+
<% end %>
|
35
|
+
<% end %>
|
36
|
+
<% end %>
|
37
|
+
|
38
|
+
<%= page_with_sidebar_aside do %>
|
39
|
+
<%= render component("users/stats").new(user: @user) %>
|
40
|
+
<% end %>
|
41
|
+
<% end %>
|
42
|
+
<% end %>
|
@@ -0,0 +1,131 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class SolidusAdmin::Users::Orders::Component < SolidusAdmin::BaseComponent
|
4
|
+
include SolidusAdmin::Layout::PageHelpers
|
5
|
+
|
6
|
+
def initialize(user:, orders:)
|
7
|
+
@user = user
|
8
|
+
@orders = orders
|
9
|
+
end
|
10
|
+
|
11
|
+
def tabs
|
12
|
+
[
|
13
|
+
{
|
14
|
+
text: t('.account'),
|
15
|
+
href: solidus_admin.user_path(@user),
|
16
|
+
current: false,
|
17
|
+
},
|
18
|
+
{
|
19
|
+
text: t('.addresses'),
|
20
|
+
href: solidus_admin.addresses_user_path(@user),
|
21
|
+
current: false,
|
22
|
+
},
|
23
|
+
{
|
24
|
+
text: t('.order_history'),
|
25
|
+
href: solidus_admin.orders_user_path(@user),
|
26
|
+
current: true,
|
27
|
+
},
|
28
|
+
{
|
29
|
+
text: t('.items'),
|
30
|
+
href: spree.items_admin_user_path(@user),
|
31
|
+
current: false,
|
32
|
+
},
|
33
|
+
{
|
34
|
+
text: t('.store_credit'),
|
35
|
+
href: spree.admin_user_store_credits_path(@user),
|
36
|
+
current: false,
|
37
|
+
},
|
38
|
+
]
|
39
|
+
end
|
40
|
+
|
41
|
+
def model_class
|
42
|
+
Spree::Order
|
43
|
+
end
|
44
|
+
|
45
|
+
def row_url(order)
|
46
|
+
spree.edit_admin_order_path(order)
|
47
|
+
end
|
48
|
+
|
49
|
+
def rows
|
50
|
+
@orders
|
51
|
+
end
|
52
|
+
|
53
|
+
def row_fade(_order)
|
54
|
+
false
|
55
|
+
end
|
56
|
+
|
57
|
+
def columns
|
58
|
+
[
|
59
|
+
number_column,
|
60
|
+
state_column,
|
61
|
+
date_column,
|
62
|
+
payment_column,
|
63
|
+
shipment_column,
|
64
|
+
total_column,
|
65
|
+
]
|
66
|
+
end
|
67
|
+
|
68
|
+
def number_column
|
69
|
+
{
|
70
|
+
header: :order,
|
71
|
+
data: ->(order) do
|
72
|
+
if !row_fade(order)
|
73
|
+
content_tag :div, order.number, class: 'font-semibold'
|
74
|
+
else
|
75
|
+
content_tag :div, order.number
|
76
|
+
end
|
77
|
+
end
|
78
|
+
}
|
79
|
+
end
|
80
|
+
|
81
|
+
def state_column
|
82
|
+
{
|
83
|
+
header: :state,
|
84
|
+
data: ->(order) do
|
85
|
+
color = {
|
86
|
+
'complete' => :green,
|
87
|
+
'returned' => :red,
|
88
|
+
'canceled' => :blue,
|
89
|
+
'cart' => :graphite_light,
|
90
|
+
}[order.state] || :yellow
|
91
|
+
component('ui/badge').new(name: order.state.humanize, color: color)
|
92
|
+
end
|
93
|
+
}
|
94
|
+
end
|
95
|
+
|
96
|
+
def date_column
|
97
|
+
{
|
98
|
+
header: :date,
|
99
|
+
data: ->(order) do
|
100
|
+
content_tag :div, l(order.created_at, format: :short)
|
101
|
+
end
|
102
|
+
}
|
103
|
+
end
|
104
|
+
|
105
|
+
def total_column
|
106
|
+
{
|
107
|
+
header: :total,
|
108
|
+
data: ->(order) do
|
109
|
+
content_tag :div, number_to_currency(order.total)
|
110
|
+
end
|
111
|
+
}
|
112
|
+
end
|
113
|
+
|
114
|
+
def payment_column
|
115
|
+
{
|
116
|
+
header: :payment,
|
117
|
+
data: ->(order) do
|
118
|
+
component('ui/badge').new(name: order.payment_state.humanize, color: order.paid? ? :green : :yellow) if order.payment_state?
|
119
|
+
end
|
120
|
+
}
|
121
|
+
end
|
122
|
+
|
123
|
+
def shipment_column
|
124
|
+
{
|
125
|
+
header: :shipment,
|
126
|
+
data: ->(order) do
|
127
|
+
component('ui/badge').new(name: order.shipment_state.humanize, color: order.shipped? ? :green : :yellow) if order.shipment_state?
|
128
|
+
end
|
129
|
+
}
|
130
|
+
end
|
131
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
en:
|
2
|
+
title: "Users / %{email} / Order History"
|
3
|
+
account: Account
|
4
|
+
addresses: Addresses
|
5
|
+
order_history: Order History
|
6
|
+
items: Items
|
7
|
+
store_credit: Store Credit
|
8
|
+
last_active: Last Active
|
9
|
+
create_order_for_user: Create order for this user
|
10
|
+
no_orders_found: No Orders found.
|
11
|
+
create_one: Create One
|
12
|
+
back: Back
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<%= render component("ui/panel").new(title: t("spree.lifetime_stats")) do %>
|
2
|
+
<%= render component("ui/details_list").new(
|
3
|
+
items: [
|
4
|
+
{ label: t("spree.total_sales"), value: @user.display_lifetime_value.to_html },
|
5
|
+
{ label: t("spree.order_count"), value: @user.order_count.to_i },
|
6
|
+
{ label: t("spree.average_order_value"), value: @user.display_average_order_value.to_html },
|
7
|
+
{ label: t("spree.member_since"), value: @user.created_at.to_date },
|
8
|
+
{ label: t(".last_active"), value: last_login(@user) },
|
9
|
+
]
|
10
|
+
) %>
|
11
|
+
<% end %>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class SolidusAdmin::UsersAndRoles::Component < SolidusAdmin::UI::Pages::Index::Component
|
4
|
+
def title
|
5
|
+
page_header_title safe_join([
|
6
|
+
tag.div(t(".title")),
|
7
|
+
])
|
8
|
+
end
|
9
|
+
|
10
|
+
def tabs
|
11
|
+
[
|
12
|
+
{
|
13
|
+
text: Spree.user_class.model_name.human(count: 2),
|
14
|
+
href: solidus_admin.users_path,
|
15
|
+
current: model_class == Spree.user_class,
|
16
|
+
},
|
17
|
+
{
|
18
|
+
text: Spree::Role.model_name.human(count: 2),
|
19
|
+
href: solidus_admin.roles_path,
|
20
|
+
current: model_class == Spree::Role,
|
21
|
+
},
|
22
|
+
]
|
23
|
+
end
|
24
|
+
end
|
@@ -1,28 +1,36 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
class SolidusAdmin::Zones::Index::Component < SolidusAdmin::
|
4
|
-
|
3
|
+
class SolidusAdmin::Zones::Index::Component < SolidusAdmin::UI::Pages::Index::Component
|
4
|
+
def model_class
|
5
|
+
Spree::Zone
|
6
|
+
end
|
5
7
|
|
6
|
-
def
|
7
|
-
|
8
|
+
def search_key
|
9
|
+
:name_or_description_cont
|
8
10
|
end
|
9
11
|
|
10
|
-
def
|
11
|
-
|
12
|
+
def search_url
|
13
|
+
solidus_admin.zones_path
|
12
14
|
end
|
13
15
|
|
14
|
-
def
|
15
|
-
|
16
|
+
def row_url(zone)
|
17
|
+
spree.edit_admin_zone_path(zone)
|
16
18
|
end
|
17
19
|
|
18
|
-
def
|
19
|
-
|
20
|
+
def page_actions
|
21
|
+
render component("ui/button").new(
|
22
|
+
tag: :a,
|
23
|
+
text: t('.add'),
|
24
|
+
href: spree.new_admin_zone_path,
|
25
|
+
icon: "add-line",
|
26
|
+
class: "align-self-end w-full",
|
27
|
+
)
|
20
28
|
end
|
21
29
|
|
22
30
|
def batch_actions
|
23
31
|
[
|
24
32
|
{
|
25
|
-
|
33
|
+
label: t('.batch_actions.delete'),
|
26
34
|
action: solidus_admin.zones_path,
|
27
35
|
method: :delete,
|
28
36
|
icon: 'delete-bin-7-line',
|
@@ -26,7 +26,12 @@ module SolidusAdmin
|
|
26
26
|
|
27
27
|
def update
|
28
28
|
if @order.contents.update_cart(order_params)
|
29
|
-
|
29
|
+
respond_to do |format|
|
30
|
+
flash[:notice] = t('.success')
|
31
|
+
|
32
|
+
format.html { redirect_to order_path(@order), status: :see_other }
|
33
|
+
format.turbo_stream { render turbo_stream: '<turbo-stream action="refresh" />' }
|
34
|
+
end
|
30
35
|
else
|
31
36
|
flash.now[:error] = @order.errors[:base].join(", ") if @order.errors[:base].any?
|
32
37
|
|