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
@@ -4,19 +4,88 @@ module SolidusAdmin
|
|
4
4
|
class ShippingCategoriesController < SolidusAdmin::BaseController
|
5
5
|
include SolidusAdmin::ControllerHelpers::Search
|
6
6
|
|
7
|
-
|
8
|
-
shipping_categories = apply_search_to(
|
9
|
-
Spree::ShippingCategory.order(id: :desc),
|
10
|
-
param: :q,
|
11
|
-
)
|
7
|
+
before_action :set_shipping_category, only: %i[edit update]
|
12
8
|
|
13
|
-
|
9
|
+
def new
|
10
|
+
@shipping_category = Spree::ShippingCategory.new
|
11
|
+
|
12
|
+
set_index_page
|
13
|
+
|
14
|
+
respond_to do |format|
|
15
|
+
format.html { render component('shipping_categories/new').new(page: @page, shipping_category: @shipping_category) }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def create
|
20
|
+
@shipping_category = Spree::ShippingCategory.new(shipping_category_params)
|
21
|
+
|
22
|
+
if @shipping_category.save
|
23
|
+
respond_to do |format|
|
24
|
+
flash[:notice] = t('.success')
|
25
|
+
|
26
|
+
format.html do
|
27
|
+
redirect_to solidus_admin.shipping_categories_path, status: :see_other
|
28
|
+
end
|
29
|
+
|
30
|
+
format.turbo_stream do
|
31
|
+
# we need to explicitly write the refresh tag for now.
|
32
|
+
# See https://github.com/hotwired/turbo-rails/issues/579
|
33
|
+
render turbo_stream: '<turbo-stream action="refresh" />'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
else
|
37
|
+
set_index_page
|
38
|
+
|
39
|
+
respond_to do |format|
|
40
|
+
format.html do
|
41
|
+
page_component = component('shipping_categories/new').new(page: @page, shipping_category: @shipping_category)
|
42
|
+
render page_component, status: :unprocessable_entity
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def index
|
49
|
+
set_index_page
|
14
50
|
|
15
51
|
respond_to do |format|
|
16
52
|
format.html { render component('shipping_categories/index').new(page: @page) }
|
17
53
|
end
|
18
54
|
end
|
19
55
|
|
56
|
+
def edit
|
57
|
+
set_index_page
|
58
|
+
|
59
|
+
respond_to do |format|
|
60
|
+
format.html { render component('shipping_categories/edit').new(page: @page, shipping_category: @shipping_category) }
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def update
|
65
|
+
if @shipping_category.update(shipping_category_params)
|
66
|
+
respond_to do |format|
|
67
|
+
flash[:notice] = t('.success')
|
68
|
+
|
69
|
+
format.html do
|
70
|
+
redirect_to solidus_admin.shipping_categories_path, status: :see_other
|
71
|
+
end
|
72
|
+
|
73
|
+
format.turbo_stream do
|
74
|
+
render turbo_stream: '<turbo-stream action="refresh" />'
|
75
|
+
end
|
76
|
+
end
|
77
|
+
else
|
78
|
+
set_index_page
|
79
|
+
|
80
|
+
respond_to do |format|
|
81
|
+
format.html do
|
82
|
+
page_component = component('shipping_categories/edit').new(page: @page, shipping_category: @shipping_category)
|
83
|
+
render page_component, status: :unprocessable_entity
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
20
89
|
def destroy
|
21
90
|
@shipping_category = Spree::ShippingCategory.find_by!(id: params[:id])
|
22
91
|
|
@@ -28,13 +97,21 @@ module SolidusAdmin
|
|
28
97
|
|
29
98
|
private
|
30
99
|
|
31
|
-
def
|
32
|
-
@shipping_category = Spree::ShippingCategory.
|
33
|
-
authorize! action_name, @shipping_category
|
100
|
+
def set_shipping_category
|
101
|
+
@shipping_category = Spree::ShippingCategory.find(params[:id])
|
34
102
|
end
|
35
103
|
|
36
104
|
def shipping_category_params
|
37
|
-
params.require(:shipping_category).permit(:
|
105
|
+
params.require(:shipping_category).permit(:name)
|
106
|
+
end
|
107
|
+
|
108
|
+
def set_index_page
|
109
|
+
shipping_categories = apply_search_to(
|
110
|
+
Spree::ShippingCategory.order(id: :desc),
|
111
|
+
param: :q,
|
112
|
+
)
|
113
|
+
|
114
|
+
set_page_and_extract_portion_from(shipping_categories)
|
38
115
|
end
|
39
116
|
end
|
40
117
|
end
|
@@ -28,11 +28,6 @@ module SolidusAdmin
|
|
28
28
|
|
29
29
|
private
|
30
30
|
|
31
|
-
def load_shipping_method
|
32
|
-
@shipping_method = Spree::ShippingMethod.find_by!(number: params[:id])
|
33
|
-
authorize! action_name, @shipping_method
|
34
|
-
end
|
35
|
-
|
36
31
|
def shipping_method_params
|
37
32
|
params.require(:shipping_method).permit(:shipping_method_id, permitted_shipping_method_attributes)
|
38
33
|
end
|
@@ -26,14 +26,14 @@ module SolidusAdmin
|
|
26
26
|
|
27
27
|
def update
|
28
28
|
quantity_adjustment = params[:quantity_adjustment].to_i
|
29
|
-
@stock_item.assign_attributes(stock_item_params
|
29
|
+
@stock_item.assign_attributes(stock_item_params)
|
30
30
|
@stock_item.stock_movements.build(quantity: quantity_adjustment, originator: current_solidus_admin_user)
|
31
31
|
|
32
32
|
if @stock_item.save
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
respond_to do |format|
|
34
|
+
format.html { redirect_to solidus_admin.stock_items_path, status: :see_other }
|
35
|
+
format.turbo_stream { render turbo_stream: '<turbo-stream action="refresh" />' }
|
36
|
+
end
|
37
37
|
else
|
38
38
|
respond_to do |format|
|
39
39
|
format.html { render component('stock_items/edit').new(stock_item: @stock_item, page: @page), status: :unprocessable_entity }
|
@@ -61,7 +61,7 @@ module SolidusAdmin
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def stock_item_params
|
64
|
-
params.require(:stock_item).permit(:backorderable
|
64
|
+
params.require(:stock_item).permit(:backorderable)
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
@@ -28,11 +28,6 @@ module SolidusAdmin
|
|
28
28
|
|
29
29
|
private
|
30
30
|
|
31
|
-
def load_stock_location
|
32
|
-
@stock_location = Spree::StockLocation.find_by!(number: params[:id])
|
33
|
-
authorize! action_name, @stock_location
|
34
|
-
end
|
35
|
-
|
36
31
|
def stock_location_params
|
37
32
|
params.require(:stock_location).permit(:stock_location_id, permitted_stock_location_attributes)
|
38
33
|
end
|
@@ -4,19 +4,86 @@ module SolidusAdmin
|
|
4
4
|
class StoreCreditReasonsController < SolidusAdmin::BaseController
|
5
5
|
include SolidusAdmin::ControllerHelpers::Search
|
6
6
|
|
7
|
-
|
8
|
-
store_credit_reasons = apply_search_to(
|
9
|
-
Spree::StoreCreditReason.unscoped.order(id: :desc),
|
10
|
-
param: :q,
|
11
|
-
)
|
7
|
+
before_action :set_store_credit_reason, only: %i[edit update]
|
12
8
|
|
13
|
-
|
9
|
+
def index
|
10
|
+
set_index_page
|
14
11
|
|
15
12
|
respond_to do |format|
|
16
13
|
format.html { render component('store_credit_reasons/index').new(page: @page) }
|
17
14
|
end
|
18
15
|
end
|
19
16
|
|
17
|
+
def new
|
18
|
+
@store_credit_reason = Spree::StoreCreditReason.new
|
19
|
+
|
20
|
+
set_index_page
|
21
|
+
|
22
|
+
respond_to do |format|
|
23
|
+
format.html { render component('store_credit_reasons/new').new(page: @page, store_credit_reason: @store_credit_reason) }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def create
|
28
|
+
@store_credit_reason = Spree::StoreCreditReason.new(store_credit_reason_params)
|
29
|
+
|
30
|
+
if @store_credit_reason.save
|
31
|
+
respond_to do |format|
|
32
|
+
flash[:notice] = t('.success')
|
33
|
+
|
34
|
+
format.html do
|
35
|
+
redirect_to solidus_admin.store_credit_reasons_path, status: :see_other
|
36
|
+
end
|
37
|
+
|
38
|
+
format.turbo_stream do
|
39
|
+
render turbo_stream: '<turbo-stream action="refresh" />'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
else
|
43
|
+
set_index_page
|
44
|
+
|
45
|
+
respond_to do |format|
|
46
|
+
format.html do
|
47
|
+
page_component = component('store_credit_reasons/new').new(page: @page, store_credit_reason: @store_credit_reason)
|
48
|
+
render page_component, status: :unprocessable_entity
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def edit
|
55
|
+
set_index_page
|
56
|
+
|
57
|
+
respond_to do |format|
|
58
|
+
format.html { render component('store_credit_reasons/edit').new(page: @page, store_credit_reason: @store_credit_reason) }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def update
|
63
|
+
if @store_credit_reason.update(store_credit_reason_params)
|
64
|
+
respond_to do |format|
|
65
|
+
flash[:notice] = t('.success')
|
66
|
+
|
67
|
+
format.html do
|
68
|
+
redirect_to solidus_admin.store_credit_reasons_path, status: :see_other
|
69
|
+
end
|
70
|
+
|
71
|
+
format.turbo_stream do
|
72
|
+
render turbo_stream: '<turbo-stream action="refresh" />'
|
73
|
+
end
|
74
|
+
end
|
75
|
+
else
|
76
|
+
set_index_page
|
77
|
+
|
78
|
+
respond_to do |format|
|
79
|
+
format.html do
|
80
|
+
page_component = component('store_credit_reasons/edit').new(page: @page, store_credit_reason: @store_credit_reason)
|
81
|
+
render page_component, status: :unprocessable_entity
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
20
87
|
def destroy
|
21
88
|
@store_credit_reason = Spree::StoreCreditReason.find_by!(id: params[:id])
|
22
89
|
|
@@ -28,13 +95,21 @@ module SolidusAdmin
|
|
28
95
|
|
29
96
|
private
|
30
97
|
|
31
|
-
def
|
32
|
-
@store_credit_reason = Spree::StoreCreditReason.
|
33
|
-
authorize! action_name, @store_credit_reason
|
98
|
+
def set_store_credit_reason
|
99
|
+
@store_credit_reason = Spree::StoreCreditReason.find(params[:id])
|
34
100
|
end
|
35
101
|
|
36
102
|
def store_credit_reason_params
|
37
|
-
params.require(:store_credit_reason).permit(:
|
103
|
+
params.require(:store_credit_reason).permit(:name, :active)
|
104
|
+
end
|
105
|
+
|
106
|
+
def set_index_page
|
107
|
+
store_credit_reasons = apply_search_to(
|
108
|
+
Spree::StoreCreditReason.unscoped.order(id: :desc),
|
109
|
+
param: :q,
|
110
|
+
)
|
111
|
+
|
112
|
+
set_page_and_extract_portion_from(store_credit_reasons)
|
38
113
|
end
|
39
114
|
end
|
40
115
|
end
|
@@ -4,13 +4,84 @@ module SolidusAdmin
|
|
4
4
|
class TaxCategoriesController < SolidusAdmin::BaseController
|
5
5
|
include SolidusAdmin::ControllerHelpers::Search
|
6
6
|
|
7
|
-
|
8
|
-
tax_categories = apply_search_to(
|
9
|
-
Spree::TaxCategory.order(created_at: :desc, id: :desc),
|
10
|
-
param: :q,
|
11
|
-
)
|
7
|
+
before_action :set_tax_category, only: %i[edit update]
|
12
8
|
|
13
|
-
|
9
|
+
def new
|
10
|
+
@tax_category = Spree::TaxCategory.new
|
11
|
+
|
12
|
+
set_index_page
|
13
|
+
|
14
|
+
respond_to do |format|
|
15
|
+
format.html { render component('tax_categories/new').new(page: @page, tax_category: @tax_category) }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def edit
|
20
|
+
@tax_category = Spree::TaxCategory.find(params[:id])
|
21
|
+
|
22
|
+
set_index_page
|
23
|
+
|
24
|
+
respond_to do |format|
|
25
|
+
format.html { render component('tax_categories/edit').new(page: @page, tax_category: @tax_category) }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def create
|
30
|
+
@tax_category = Spree::TaxCategory.new(tax_category_params)
|
31
|
+
|
32
|
+
if @tax_category.save
|
33
|
+
respond_to do |format|
|
34
|
+
flash[:notice] = t('.success')
|
35
|
+
|
36
|
+
format.html do
|
37
|
+
redirect_to solidus_admin.tax_categories_path, status: :see_other
|
38
|
+
end
|
39
|
+
|
40
|
+
format.turbo_stream do
|
41
|
+
# we need to explicitly write the refresh tag for now.
|
42
|
+
# See https://github.com/hotwired/turbo-rails/issues/579
|
43
|
+
render turbo_stream: '<turbo-stream action="refresh" />'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
else
|
47
|
+
set_index_page
|
48
|
+
|
49
|
+
respond_to do |format|
|
50
|
+
format.html do
|
51
|
+
page_component = component('tax_categories/new').new(page: @page, tax_category: @tax_category)
|
52
|
+
render page_component, status: :unprocessable_entity
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def update
|
59
|
+
if @tax_category.update(tax_category_params)
|
60
|
+
respond_to do |format|
|
61
|
+
flash[:notice] = t('.success')
|
62
|
+
|
63
|
+
format.html do
|
64
|
+
redirect_to solidus_admin.tax_categories_path, status: :see_other
|
65
|
+
end
|
66
|
+
|
67
|
+
format.turbo_stream do
|
68
|
+
render turbo_stream: '<turbo-stream action="refresh" />'
|
69
|
+
end
|
70
|
+
end
|
71
|
+
else
|
72
|
+
set_index_page
|
73
|
+
|
74
|
+
respond_to do |format|
|
75
|
+
format.html do
|
76
|
+
page_component = component('tax_categories/edit').new(page: @page, tax_category: @tax_category)
|
77
|
+
render page_component, status: :unprocessable_entity
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def index
|
84
|
+
set_index_page
|
14
85
|
|
15
86
|
respond_to do |format|
|
16
87
|
format.html { render component('tax_categories/index').new(page: @page) }
|
@@ -28,13 +99,21 @@ module SolidusAdmin
|
|
28
99
|
|
29
100
|
private
|
30
101
|
|
31
|
-
def
|
32
|
-
@tax_category = Spree::TaxCategory.
|
33
|
-
authorize! action_name, @tax_category
|
102
|
+
def set_tax_category
|
103
|
+
@tax_category = Spree::TaxCategory.find(params[:id])
|
34
104
|
end
|
35
105
|
|
36
106
|
def tax_category_params
|
37
|
-
params.require(:tax_category).permit(:
|
107
|
+
params.require(:tax_category).permit(:name, :description, :is_default, :tax_code)
|
108
|
+
end
|
109
|
+
|
110
|
+
def set_index_page
|
111
|
+
tax_categories = apply_search_to(
|
112
|
+
Spree::TaxCategory.order(created_at: :desc, id: :desc),
|
113
|
+
param: :q,
|
114
|
+
)
|
115
|
+
|
116
|
+
set_page_and_extract_portion_from(tax_categories)
|
38
117
|
end
|
39
118
|
end
|
40
119
|
end
|
@@ -28,11 +28,6 @@ module SolidusAdmin
|
|
28
28
|
|
29
29
|
private
|
30
30
|
|
31
|
-
def load_tax_rate
|
32
|
-
@tax_rate = Spree::TaxRate.find_by!(number: params[:id])
|
33
|
-
authorize! action_name, @tax_rate
|
34
|
-
end
|
35
|
-
|
36
31
|
def tax_rate_params
|
37
32
|
params.require(:tax_rate).permit(:tax_rate_id, permitted_tax_rate_attributes)
|
38
33
|
end
|
@@ -3,12 +3,15 @@
|
|
3
3
|
module SolidusAdmin
|
4
4
|
class UsersController < SolidusAdmin::BaseController
|
5
5
|
include SolidusAdmin::ControllerHelpers::Search
|
6
|
+
include Spree::Core::ControllerHelpers::StrongParameters
|
6
7
|
|
7
|
-
|
8
|
+
before_action :set_user, only: [:edit, :addresses, :update_addresses, :orders, :items]
|
9
|
+
|
10
|
+
search_scope(:all, default: true)
|
11
|
+
search_scope(:customers) { _1.left_outer_joins(:role_users).where(role_users: { id: nil }) }
|
8
12
|
search_scope(:admin) { _1.joins(:role_users).distinct }
|
9
13
|
search_scope(:with_orders) { _1.joins(:orders).distinct }
|
10
14
|
search_scope(:without_orders) { _1.left_outer_joins(:orders).where(orders: { id: nil }) }
|
11
|
-
search_scope(:all)
|
12
15
|
|
13
16
|
def index
|
14
17
|
users = apply_search_to(
|
@@ -23,6 +26,52 @@ module SolidusAdmin
|
|
23
26
|
end
|
24
27
|
end
|
25
28
|
|
29
|
+
def addresses
|
30
|
+
respond_to do |format|
|
31
|
+
format.turbo_stream { render turbo_stream: '<turbo-stream action="refresh" />' }
|
32
|
+
format.html { render component('users/addresses').new(user: @user) }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def update_addresses
|
37
|
+
set_address_from_params
|
38
|
+
|
39
|
+
if @address.valid? && @user.update(user_params)
|
40
|
+
flash[:success] = t(".#{@type}.success")
|
41
|
+
|
42
|
+
respond_to do |format|
|
43
|
+
format.turbo_stream { render turbo_stream: '<turbo-stream action="refresh" />' }
|
44
|
+
format.html { render component('users/addresses').new(user: @user) }
|
45
|
+
end
|
46
|
+
else
|
47
|
+
respond_to do |format|
|
48
|
+
format.html { render component('users/addresses').new(user: @user, address: @address, type: @type), status: :unprocessable_entity }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def orders
|
54
|
+
set_orders
|
55
|
+
|
56
|
+
respond_to do |format|
|
57
|
+
format.html { render component('users/orders').new(user: @user, orders: @orders) }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def items
|
62
|
+
set_items
|
63
|
+
|
64
|
+
respond_to do |format|
|
65
|
+
format.html { render component('users/items').new(user: @user, items: @items) }
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def edit
|
70
|
+
respond_to do |format|
|
71
|
+
format.html { render component('users/edit').new(user: @user) }
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
26
75
|
def destroy
|
27
76
|
@users = Spree.user_class.where(id: params[:id])
|
28
77
|
|
@@ -34,13 +83,43 @@ module SolidusAdmin
|
|
34
83
|
|
35
84
|
private
|
36
85
|
|
37
|
-
def
|
38
|
-
@user = Spree.user_class.
|
39
|
-
authorize! action_name, @user
|
86
|
+
def set_user
|
87
|
+
@user = Spree.user_class.find(params[:id])
|
40
88
|
end
|
41
89
|
|
42
90
|
def user_params
|
43
|
-
params.require(:user).permit(
|
91
|
+
params.require(:user).permit(
|
92
|
+
:user_id,
|
93
|
+
permitted_user_attributes,
|
94
|
+
bill_address_attributes: permitted_address_attributes,
|
95
|
+
ship_address_attributes: permitted_address_attributes
|
96
|
+
)
|
97
|
+
end
|
98
|
+
|
99
|
+
# @note This method is used to generate validation errors on the address.
|
100
|
+
# Since the update is being performed via the @user, and not directly on
|
101
|
+
# the @address, we sadly don't seem to get these errors automatically.
|
102
|
+
def set_address_from_params
|
103
|
+
if user_params.key?(:bill_address_attributes)
|
104
|
+
@address = Spree::Address.new(user_params[:bill_address_attributes])
|
105
|
+
@type = "bill"
|
106
|
+
elsif user_params.key?(:ship_address_attributes)
|
107
|
+
@address = Spree::Address.new(user_params[:ship_address_attributes])
|
108
|
+
@type = "ship"
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def set_orders
|
113
|
+
params[:q] ||= {}
|
114
|
+
@search = Spree::Order.reverse_chronological.ransack(params[:q].merge(user_id_eq: @user.id))
|
115
|
+
@orders = @search.result.page(params[:page]).per(Spree::Config[:admin_products_per_page])
|
116
|
+
end
|
117
|
+
|
118
|
+
def set_items
|
119
|
+
params[:q] ||= {}
|
120
|
+
@search = Spree::Order.reverse_chronological.includes(line_items: { variant: [:product, { option_values: :option_type }] }).ransack(params[:q].merge(user_id_eq: @user.id))
|
121
|
+
@orders = @search.result.page(params[:page]).per(Spree::Config[:admin_products_per_page])
|
122
|
+
@items = @orders&.map(&:line_items)&.flatten
|
44
123
|
end
|
45
124
|
|
46
125
|
def authorization_subject
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusAdmin
|
4
|
+
module LastLoginHelper
|
5
|
+
def last_login(user)
|
6
|
+
return t('solidus_admin.users.last_login.never') if user.try(:last_sign_in_at).blank?
|
7
|
+
|
8
|
+
t(
|
9
|
+
'solidus_admin.users.last_login.login_time_ago',
|
10
|
+
# @note The second `.try` is here for the specs and for setups that use a
|
11
|
+
# custom User class which may not have this attribute.
|
12
|
+
last_login_time: time_ago_in_words(user.try(:last_sign_in_at))
|
13
|
+
).capitalize
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusAdmin
|
4
|
+
module PermissionSetsHelper
|
5
|
+
# @param permission_sets [Array<Spree::PermissionSet>] an array of
|
6
|
+
# PermissionSet objects to be organized into categories based on their
|
7
|
+
# names.
|
8
|
+
# @param view_label [String] A string of your choice associated with "View"
|
9
|
+
# or "Display" level permissions. Used when rendering the checkbox.
|
10
|
+
# @param edit_label [String] A string of your choice associated with "Edit"
|
11
|
+
# or "Management" level permissions. Used when rendering the checkbox.
|
12
|
+
def organize_permissions(permission_sets:, view_label:, edit_label:)
|
13
|
+
return {} if permission_sets.blank?
|
14
|
+
|
15
|
+
permission_sets.each_with_object({}) do |permission, grouped_permissions|
|
16
|
+
group_key = permission.category.to_sym
|
17
|
+
|
18
|
+
case permission.privilege
|
19
|
+
when "display"
|
20
|
+
grouped_permissions[group_key] ||= []
|
21
|
+
grouped_permissions[group_key] << { label: view_label, id: permission.id }
|
22
|
+
when "management"
|
23
|
+
grouped_permissions[group_key] ||= []
|
24
|
+
grouped_permissions[group_key] << { label: edit_label, id: permission.id }
|
25
|
+
else
|
26
|
+
grouped_permissions[:other] ||= []
|
27
|
+
grouped_permissions[:other] << { label: permission.name, id: permission.id }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -11,6 +11,7 @@
|
|
11
11
|
<%= stylesheet_link_tag SolidusAdmin::Config.theme_path(session[:admin_light_theme]), media: '(prefers-color-scheme: light)', "data-turbo-track": "reload" %>
|
12
12
|
<%= stylesheet_link_tag SolidusAdmin::Config.theme_path(session[:admin_dark_theme]), media: '(prefers-color-scheme: dark)', "data-turbo-track": "reload" %>
|
13
13
|
<%= javascript_importmap_tags "solidus_admin/application", shim: false, importmap: SolidusAdmin.importmap %>
|
14
|
+
<meta name="turbo-refresh-scroll", content="preserve">
|
14
15
|
</head>
|
15
16
|
|
16
17
|
<body class="bg-gray-15 font-sans">
|
@@ -29,7 +30,7 @@
|
|
29
30
|
|
30
31
|
<div class="fixed inset-x-0 bottom-3 flex items-center justify-center flex-col gap-3 pointer-events-none" role="alert">
|
31
32
|
<% flash.each do |key, message| %>
|
32
|
-
<%= render component("ui/toast").new(text: message, scheme: key == :error ? :error : :default) %>
|
33
|
+
<%= render component("ui/toast").new(text: message, scheme: key.to_sym == :error ? :error : :default) %>
|
33
34
|
<% end %>
|
34
35
|
</div>
|
35
36
|
</body>
|
@@ -1,6 +1,8 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
2
|
<html>
|
3
3
|
<head>
|
4
|
+
<%= stylesheet_link_tag SolidusAdmin::Config.theme_path(session[:admin_light_theme]), media: '(prefers-color-scheme: light)', "data-turbo-track": "reload" %>
|
5
|
+
<%= stylesheet_link_tag SolidusAdmin::Config.theme_path(session[:admin_dark_theme]), media: '(prefers-color-scheme: dark)', "data-turbo-track": "reload" %>
|
4
6
|
<%= javascript_importmap_tags "solidus_admin/application", shim: false, importmap: SolidusAdmin.importmap %>
|
5
7
|
</head>
|
6
8
|
<body class="p-3">
|
@@ -10,7 +10,7 @@ if Rails.env.development? || Rails.env.test?
|
|
10
10
|
clear = "\e[0m"
|
11
11
|
|
12
12
|
ActiveSupport::Notifications.subscribe("render.view_component") do |*args|
|
13
|
-
next unless args.last[:name]
|
13
|
+
next unless args.last[:name]&.starts_with?("SolidusAdmin::")
|
14
14
|
|
15
15
|
event = ActiveSupport::Notifications::Event.new(*args)
|
16
16
|
SolidusAdmin::BaseComponent.logger.debug \
|
@@ -3,4 +3,8 @@ en:
|
|
3
3
|
adjustment_reasons:
|
4
4
|
title: "Adjustment Reasons"
|
5
5
|
destroy:
|
6
|
-
success: "Adjustment
|
6
|
+
success: "Adjustment reasons were successfully removed."
|
7
|
+
create:
|
8
|
+
success: "Adjustment reason was successfully created."
|
9
|
+
update:
|
10
|
+
success: "Adjustment reason was successfully updated."
|