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,86 @@ module SolidusAdmin
|
|
4
4
|
class AdjustmentReasonsController < SolidusAdmin::BaseController
|
5
5
|
include SolidusAdmin::ControllerHelpers::Search
|
6
6
|
|
7
|
-
|
8
|
-
adjustment_reasons = apply_search_to(
|
9
|
-
Spree::AdjustmentReason.order(id: :desc),
|
10
|
-
param: :q,
|
11
|
-
)
|
7
|
+
before_action :set_adjustment_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('adjustment_reasons/index').new(page: @page) }
|
17
14
|
end
|
18
15
|
end
|
19
16
|
|
17
|
+
def new
|
18
|
+
@adjustment_reason = Spree::AdjustmentReason.new
|
19
|
+
|
20
|
+
set_index_page
|
21
|
+
|
22
|
+
respond_to do |format|
|
23
|
+
format.html { render component('adjustment_reasons/new').new(page: @page, adjustment_reason: @adjustment_reason) }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def create
|
28
|
+
@adjustment_reason = Spree::AdjustmentReason.new(adjustment_reason_params)
|
29
|
+
|
30
|
+
if @adjustment_reason.save
|
31
|
+
respond_to do |format|
|
32
|
+
flash[:notice] = t('.success')
|
33
|
+
|
34
|
+
format.html do
|
35
|
+
redirect_to solidus_admin.adjustment_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('adjustment_reasons/new').new(page: @page, adjustment_reason: @adjustment_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('adjustment_reasons/edit').new(page: @page, adjustment_reason: @adjustment_reason) }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def update
|
63
|
+
if @adjustment_reason.update(adjustment_reason_params)
|
64
|
+
respond_to do |format|
|
65
|
+
flash[:notice] = t('.success')
|
66
|
+
|
67
|
+
format.html do
|
68
|
+
redirect_to solidus_admin.adjustment_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('adjustment_reasons/edit').new(page: @page, adjustment_reason: @adjustment_reason)
|
81
|
+
render page_component, status: :unprocessable_entity
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
20
87
|
def destroy
|
21
88
|
@adjustment_reason = Spree::AdjustmentReason.find_by!(id: params[:id])
|
22
89
|
|
@@ -28,13 +95,21 @@ module SolidusAdmin
|
|
28
95
|
|
29
96
|
private
|
30
97
|
|
31
|
-
def
|
32
|
-
@adjustment_reason = Spree::AdjustmentReason.
|
33
|
-
authorize! action_name, @adjustment_reason
|
98
|
+
def set_adjustment_reason
|
99
|
+
@adjustment_reason = Spree::AdjustmentReason.find(params[:id])
|
34
100
|
end
|
35
101
|
|
36
102
|
def adjustment_reason_params
|
37
|
-
params.require(:adjustment_reason).permit(:
|
103
|
+
params.require(:adjustment_reason).permit(:name, :code, :active)
|
104
|
+
end
|
105
|
+
|
106
|
+
def set_index_page
|
107
|
+
adjustment_reasons = apply_search_to(
|
108
|
+
Spree::AdjustmentReason.order(id: :desc),
|
109
|
+
param: :q,
|
110
|
+
)
|
111
|
+
|
112
|
+
set_page_and_extract_portion_from(adjustment_reasons)
|
38
113
|
end
|
39
114
|
end
|
40
115
|
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class SolidusAdmin::AdjustmentsController < SolidusAdmin::BaseController
|
4
|
+
before_action :load_order
|
5
|
+
|
6
|
+
def index
|
7
|
+
load_adjustments
|
8
|
+
set_page_and_extract_portion_from(@adjustments)
|
9
|
+
|
10
|
+
respond_to do |format|
|
11
|
+
format.html do
|
12
|
+
render component('orders/show/adjustments/index').new(
|
13
|
+
order: @order,
|
14
|
+
adjustments: @adjustments,
|
15
|
+
)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def lock
|
21
|
+
@adjustments = @order.all_adjustments.not_finalized.where(id: params[:id])
|
22
|
+
@adjustments.each(&:finalize!)
|
23
|
+
flash[:success] = t('.success')
|
24
|
+
|
25
|
+
redirect_to order_adjustments_path(@order), status: :see_other
|
26
|
+
end
|
27
|
+
|
28
|
+
def unlock
|
29
|
+
@adjustments = @order.all_adjustments.finalized.where(id: params[:id])
|
30
|
+
@adjustments.each(&:unfinalize!)
|
31
|
+
flash[:success] = t('.success')
|
32
|
+
|
33
|
+
redirect_to order_adjustments_path(@order), status: :see_other
|
34
|
+
end
|
35
|
+
|
36
|
+
def destroy
|
37
|
+
@adjustments = @order.all_adjustments.where(id: params[:id])
|
38
|
+
@adjustments.destroy_all
|
39
|
+
flash[:success] = t('.success')
|
40
|
+
|
41
|
+
redirect_to order_adjustments_path(@order), status: :see_other
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def load_adjustments
|
47
|
+
@adjustments = @order
|
48
|
+
.all_adjustments
|
49
|
+
.order("adjustable_type ASC, created_at ASC")
|
50
|
+
.ransack(params[:q])
|
51
|
+
.result
|
52
|
+
end
|
53
|
+
|
54
|
+
def load_order
|
55
|
+
@order = Spree::Order.find_by!(number: params[:order_id])
|
56
|
+
end
|
57
|
+
end
|
@@ -4,7 +4,11 @@ class SolidusAdmin::CustomersController < SolidusAdmin::BaseController
|
|
4
4
|
before_action :load_order, only: [:show, :destroy]
|
5
5
|
|
6
6
|
def show
|
7
|
-
|
7
|
+
respond_to do |format|
|
8
|
+
format.html do
|
9
|
+
render component('orders/show/email').new(order: @order)
|
10
|
+
end
|
11
|
+
end
|
8
12
|
end
|
9
13
|
|
10
14
|
def destroy
|
@@ -54,7 +54,11 @@ module SolidusAdmin
|
|
54
54
|
flash[:error] = t('.error')
|
55
55
|
end
|
56
56
|
|
57
|
-
|
57
|
+
respond_to do |format|
|
58
|
+
format.html { redirect_to spree.edit_admin_order_path(@order) }
|
59
|
+
|
60
|
+
format.turbo_stream { render turbo_stream: '<turbo-stream action="refresh" />' }
|
61
|
+
end
|
58
62
|
end
|
59
63
|
|
60
64
|
def edit
|
@@ -11,6 +11,8 @@ module SolidusAdmin
|
|
11
11
|
search_scope(:in_stock) { _1.where(id: Spree::Variant.in_stock.distinct.select(:product_id)) }
|
12
12
|
search_scope(:out_of_stock) { _1.where.not(id: Spree::Variant.in_stock.distinct.select(:product_id)) }
|
13
13
|
|
14
|
+
before_action :split_params, only: [:update]
|
15
|
+
|
14
16
|
def index
|
15
17
|
products = apply_search_to(
|
16
18
|
Spree::Product.includes(:master, :variants),
|
@@ -98,5 +100,14 @@ module SolidusAdmin
|
|
98
100
|
flash[:notice] = t('.success')
|
99
101
|
redirect_to products_path, status: :see_other
|
100
102
|
end
|
103
|
+
|
104
|
+
def split_params
|
105
|
+
if params[:product][:taxon_ids].present?
|
106
|
+
params[:product][:taxon_ids] = params[:product][:taxon_ids].split(',')
|
107
|
+
end
|
108
|
+
if params[:product][:option_type_ids].present?
|
109
|
+
params[:product][:option_type_ids] = params[:product][:option_type_ids].split(',')
|
110
|
+
end
|
111
|
+
end
|
101
112
|
end
|
102
113
|
end
|
@@ -4,19 +4,86 @@ module SolidusAdmin
|
|
4
4
|
class RefundReasonsController < SolidusAdmin::BaseController
|
5
5
|
include SolidusAdmin::ControllerHelpers::Search
|
6
6
|
|
7
|
-
|
8
|
-
refund_reasons = apply_search_to(
|
9
|
-
Spree::RefundReason.unscoped.order(id: :desc),
|
10
|
-
param: :q,
|
11
|
-
)
|
7
|
+
before_action :set_refund_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('refund_reasons/index').new(page: @page) }
|
17
14
|
end
|
18
15
|
end
|
19
16
|
|
17
|
+
def new
|
18
|
+
@refund_reason = Spree::RefundReason.new
|
19
|
+
|
20
|
+
set_index_page
|
21
|
+
|
22
|
+
respond_to do |format|
|
23
|
+
format.html { render component('refund_reasons/new').new(page: @page, refund_reason: @refund_reason) }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def create
|
28
|
+
@refund_reason = Spree::RefundReason.new(refund_reason_params)
|
29
|
+
|
30
|
+
if @refund_reason.save
|
31
|
+
respond_to do |format|
|
32
|
+
flash[:notice] = t('.success')
|
33
|
+
|
34
|
+
format.html do
|
35
|
+
redirect_to solidus_admin.refund_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('refund_reasons/new').new(page: @page, refund_reason: @refund_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('refund_reasons/edit').new(page: @page, refund_reason: @refund_reason) }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def update
|
63
|
+
if @refund_reason.update(refund_reason_params)
|
64
|
+
respond_to do |format|
|
65
|
+
flash[:notice] = t('.success')
|
66
|
+
|
67
|
+
format.html do
|
68
|
+
redirect_to solidus_admin.refund_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('refund_reasons/edit').new(page: @page, refund_reason: @refund_reason)
|
81
|
+
render page_component, status: :unprocessable_entity
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
20
87
|
def destroy
|
21
88
|
@refund_reason = Spree::RefundReason.find_by!(id: params[:id])
|
22
89
|
|
@@ -28,13 +95,21 @@ module SolidusAdmin
|
|
28
95
|
|
29
96
|
private
|
30
97
|
|
31
|
-
def
|
32
|
-
@refund_reason = Spree::RefundReason.
|
33
|
-
authorize! action_name, @refund_reason
|
98
|
+
def set_refund_reason
|
99
|
+
@refund_reason = Spree::RefundReason.find(params[:id])
|
34
100
|
end
|
35
101
|
|
36
102
|
def refund_reason_params
|
37
|
-
params.require(:refund_reason).permit(:
|
103
|
+
params.require(:refund_reason).permit(:name, :code, :active)
|
104
|
+
end
|
105
|
+
|
106
|
+
def set_index_page
|
107
|
+
refund_reasons = apply_search_to(
|
108
|
+
Spree::RefundReason.unscoped.order(id: :desc),
|
109
|
+
param: :q,
|
110
|
+
)
|
111
|
+
|
112
|
+
set_page_and_extract_portion_from(refund_reasons)
|
38
113
|
end
|
39
114
|
end
|
40
115
|
end
|
@@ -19,11 +19,6 @@ module SolidusAdmin
|
|
19
19
|
|
20
20
|
private
|
21
21
|
|
22
|
-
def load_reimbursement_type
|
23
|
-
@reimbursement_type = Spree::ReimbursementType.find_by!(id: params[:id])
|
24
|
-
authorize! action_name, @reimbursement_type
|
25
|
-
end
|
26
|
-
|
27
22
|
def reimbursement_type_params
|
28
23
|
params.require(:reimbursement_type).permit(:reimbursement_type_id, permitted_reimbursement_type_attributes)
|
29
24
|
end
|
@@ -4,19 +4,86 @@ module SolidusAdmin
|
|
4
4
|
class ReturnReasonsController < SolidusAdmin::BaseController
|
5
5
|
include SolidusAdmin::ControllerHelpers::Search
|
6
6
|
|
7
|
-
|
8
|
-
return_reasons = apply_search_to(
|
9
|
-
Spree::ReturnReason.unscoped.order(id: :desc),
|
10
|
-
param: :q,
|
11
|
-
)
|
7
|
+
before_action :set_return_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('return_reasons/index').new(page: @page) }
|
17
14
|
end
|
18
15
|
end
|
19
16
|
|
17
|
+
def new
|
18
|
+
@return_reason = Spree::ReturnReason.new
|
19
|
+
|
20
|
+
set_index_page
|
21
|
+
|
22
|
+
respond_to do |format|
|
23
|
+
format.html { render component('return_reasons/new').new(page: @page, return_reason: @return_reason) }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def create
|
28
|
+
@return_reason = Spree::ReturnReason.new(return_reason_params)
|
29
|
+
|
30
|
+
if @return_reason.save
|
31
|
+
respond_to do |format|
|
32
|
+
flash[:notice] = t('.success')
|
33
|
+
|
34
|
+
format.html do
|
35
|
+
redirect_to solidus_admin.return_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('return_reasons/new').new(page: @page, return_reason: @return_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('return_reasons/edit').new(page: @page, return_reason: @return_reason) }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def update
|
63
|
+
if @return_reason.update(return_reason_params)
|
64
|
+
respond_to do |format|
|
65
|
+
flash[:notice] = t('.success')
|
66
|
+
|
67
|
+
format.html do
|
68
|
+
redirect_to solidus_admin.return_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('return_reasons/edit').new(page: @page, return_reason: @return_reason)
|
81
|
+
render page_component, status: :unprocessable_entity
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
20
87
|
def destroy
|
21
88
|
@return_reason = Spree::ReturnReason.find_by!(id: params[:id])
|
22
89
|
|
@@ -28,13 +95,21 @@ module SolidusAdmin
|
|
28
95
|
|
29
96
|
private
|
30
97
|
|
31
|
-
def
|
32
|
-
@return_reason = Spree::ReturnReason.
|
33
|
-
|
98
|
+
def set_return_reason
|
99
|
+
@return_reason = Spree::ReturnReason.find(params[:id])
|
100
|
+
end
|
101
|
+
|
102
|
+
def set_index_page
|
103
|
+
return_reasons = apply_search_to(
|
104
|
+
Spree::ReturnReason.unscoped.order(id: :desc),
|
105
|
+
param: :q,
|
106
|
+
)
|
107
|
+
|
108
|
+
set_page_and_extract_portion_from(return_reasons)
|
34
109
|
end
|
35
110
|
|
36
111
|
def return_reason_params
|
37
|
-
params.require(:return_reason).permit(:
|
112
|
+
params.require(:return_reason).permit(:name, :active)
|
38
113
|
end
|
39
114
|
end
|
40
115
|
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusAdmin
|
4
|
+
class RolesController < SolidusAdmin::BaseController
|
5
|
+
include SolidusAdmin::ControllerHelpers::Search
|
6
|
+
|
7
|
+
before_action :set_role, only: %i[edit update]
|
8
|
+
|
9
|
+
search_scope(:all)
|
10
|
+
search_scope(:admin) { _1.where(name: "admin") }
|
11
|
+
|
12
|
+
def index
|
13
|
+
set_index_page
|
14
|
+
|
15
|
+
respond_to do |format|
|
16
|
+
format.html { render component('roles/index').new(page: @page) }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def new
|
21
|
+
@role = Spree::Role.new
|
22
|
+
|
23
|
+
set_index_page
|
24
|
+
|
25
|
+
respond_to do |format|
|
26
|
+
format.html { render component('roles/new').new(page: @page, role: @role) }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def create
|
31
|
+
@role = Spree::Role.new(role_params)
|
32
|
+
|
33
|
+
if @role.save
|
34
|
+
respond_to do |format|
|
35
|
+
flash[:notice] = t('.success')
|
36
|
+
|
37
|
+
format.html do
|
38
|
+
redirect_to solidus_admin.roles_path, status: :see_other
|
39
|
+
end
|
40
|
+
|
41
|
+
format.turbo_stream do
|
42
|
+
render turbo_stream: '<turbo-stream action="refresh" />'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
else
|
46
|
+
set_index_page
|
47
|
+
|
48
|
+
respond_to do |format|
|
49
|
+
format.html do
|
50
|
+
page_component = component('roles/new').new(page: @page, role: @role)
|
51
|
+
render page_component, status: :unprocessable_entity
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def edit
|
58
|
+
set_index_page
|
59
|
+
|
60
|
+
respond_to do |format|
|
61
|
+
format.html { render component('roles/edit').new(page: @page, role: @role) }
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def update
|
66
|
+
if @role.update(role_params)
|
67
|
+
respond_to do |format|
|
68
|
+
flash[:notice] = t('.success')
|
69
|
+
|
70
|
+
format.html do
|
71
|
+
redirect_to solidus_admin.roles_path, status: :see_other
|
72
|
+
end
|
73
|
+
|
74
|
+
format.turbo_stream do
|
75
|
+
render turbo_stream: '<turbo-stream action="refresh" />'
|
76
|
+
end
|
77
|
+
end
|
78
|
+
else
|
79
|
+
set_index_page
|
80
|
+
|
81
|
+
respond_to do |format|
|
82
|
+
format.html do
|
83
|
+
page_component = component('roles/edit').new(page: @page, role: @role)
|
84
|
+
render page_component, status: :unprocessable_entity
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def destroy
|
91
|
+
@roles = Spree::Role.where(id: params[:id])
|
92
|
+
|
93
|
+
Spree::Role.transaction { @roles.destroy_all }
|
94
|
+
|
95
|
+
flash[:notice] = t('.success')
|
96
|
+
redirect_back_or_to solidus_admin.roles_path, status: :see_other
|
97
|
+
end
|
98
|
+
|
99
|
+
private
|
100
|
+
|
101
|
+
def set_role
|
102
|
+
@role = Spree::Role.find(params[:id])
|
103
|
+
end
|
104
|
+
|
105
|
+
def set_index_page
|
106
|
+
roles = apply_search_to(
|
107
|
+
Spree::Role.unscoped.order(id: :desc),
|
108
|
+
param: :q,
|
109
|
+
)
|
110
|
+
|
111
|
+
set_page_and_extract_portion_from(roles)
|
112
|
+
end
|
113
|
+
|
114
|
+
def role_params
|
115
|
+
params.require(:role).permit(:role_id, :name, :description, permission_set_ids: [])
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|