solidus_admin 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +60 -6
- data/Rakefile +1 -0
- data/app/assets/builds/solidus_admin/tailwind.css +198 -163
- 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 +19 -2
- 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 +0 -25
- data/app/components/solidus_admin/option_types/index/component.rb +1 -1
- data/app/components/solidus_admin/orders/index/component.rb +8 -8
- data/app/components/solidus_admin/orders/index/component.yml +1 -0
- 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 +1 -1
- data/app/components/solidus_admin/products/index/component.rb +8 -5
- 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 +1 -1
- 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 +11 -4
- 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/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 +20 -2
- 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_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 +20 -3
- 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 +2 -2
- 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 +5 -6
- data/app/components/solidus_admin/stock_locations/index/component.rb +1 -1
- 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 +11 -4
- 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 +1 -1
- 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 +11 -4
- 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 +3 -3
- data/app/components/solidus_admin/taxonomies/index/component.rb +1 -1
- 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 +17 -3
- data/app/components/solidus_admin/ui/pages/index/component.rb +29 -43
- 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.js +31 -2
- data/app/components/solidus_admin/ui/table/component.rb +23 -7
- 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 +10 -8
- 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 +1 -1
- 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/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/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 +2 -26
- data/lib/solidus_admin/install_tailwindcss.rb +4 -2
- 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 +108 -19
- data/app/components/solidus_admin/promotion_categories/index/component.rb +0 -56
- data/app/components/solidus_admin/promotions/index/component.rb +0 -104
- data/app/components/solidus_admin/promotions/index/component.yml +0 -10
- data/app/controllers/solidus_admin/promotion_categories_controller.rb +0 -29
- 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
|
@@ -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
|
|
@@ -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
|