solidus_admin 0.3.1 → 0.4.0
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/.prettierrc +4 -0
- data/app/assets/builds/solidus_admin/tailwind.css +164 -132
- data/app/components/solidus_admin/adjustment_reasons/edit/component.html.erb +2 -3
- data/app/components/solidus_admin/adjustment_reasons/edit/component.rb +1 -9
- data/app/components/solidus_admin/adjustment_reasons/index/component.rb +22 -8
- data/app/components/solidus_admin/adjustment_reasons/new/component.html.erb +2 -4
- data/app/components/solidus_admin/adjustment_reasons/new/component.rb +1 -9
- data/app/components/solidus_admin/base_component.rb +7 -9
- data/app/components/solidus_admin/layout/navigation/account/component.rb +2 -2
- data/app/components/solidus_admin/layout/navigation/component.js +1 -1
- data/app/components/solidus_admin/layout/navigation/component.rb +1 -1
- data/app/components/solidus_admin/layout/navigation/item/component.html.erb +2 -2
- data/app/components/solidus_admin/layout/navigation/item/component.rb +3 -6
- data/app/components/solidus_admin/orders/index/component.rb +3 -3
- data/app/components/solidus_admin/orders/show/address/component.js +2 -2
- data/app/components/solidus_admin/orders/show/adjustments/index/adjustable/component.rb +1 -1
- data/app/components/solidus_admin/orders/show/adjustments/index/source/component.rb +1 -1
- data/app/components/solidus_admin/orders/show/component.js +2 -2
- data/app/components/solidus_admin/orders/show/customer_search/component.js +5 -4
- data/app/components/solidus_admin/orders/show/summary/component.html.erb +6 -6
- data/app/components/solidus_admin/products/show/component.html.erb +7 -1
- data/app/components/solidus_admin/products/show/component.rb +6 -0
- data/app/components/solidus_admin/products/status/component.rb +1 -1
- data/app/components/solidus_admin/properties/edit/component.html.erb +16 -0
- data/app/components/solidus_admin/properties/edit/component.rb +4 -0
- data/app/components/solidus_admin/properties/edit/component.yml +4 -0
- data/app/components/solidus_admin/properties/index/component.rb +19 -6
- data/app/components/solidus_admin/properties/new/component.html.erb +16 -0
- data/app/components/solidus_admin/properties/new/component.rb +4 -0
- data/app/components/solidus_admin/properties/new/component.yml +4 -0
- data/app/components/solidus_admin/refund_reasons/edit/component.html.erb +2 -3
- data/app/components/solidus_admin/refund_reasons/edit/component.rb +1 -9
- data/app/components/solidus_admin/refund_reasons/index/component.rb +22 -8
- data/app/components/solidus_admin/refund_reasons/new/component.html.erb +2 -4
- data/app/components/solidus_admin/refund_reasons/new/component.rb +1 -9
- data/app/components/solidus_admin/resources/base_component.rb +20 -0
- data/app/components/solidus_admin/resources/edit/component.rb +11 -0
- data/app/components/solidus_admin/resources/new/component.rb +11 -0
- data/app/components/solidus_admin/return_reasons/edit/component.html.erb +2 -3
- data/app/components/solidus_admin/return_reasons/edit/component.rb +1 -9
- data/app/components/solidus_admin/return_reasons/index/component.rb +13 -7
- data/app/components/solidus_admin/return_reasons/new/component.html.erb +2 -4
- data/app/components/solidus_admin/return_reasons/new/component.rb +1 -9
- data/app/components/solidus_admin/roles/edit/component.html.erb +2 -4
- data/app/components/solidus_admin/roles/edit/component.rb +1 -10
- data/app/components/solidus_admin/roles/index/component.rb +16 -8
- data/app/components/solidus_admin/roles/new/component.html.erb +2 -4
- data/app/components/solidus_admin/roles/new/component.rb +1 -10
- data/app/components/solidus_admin/shipping_categories/edit/component.html.erb +2 -3
- data/app/components/solidus_admin/shipping_categories/edit/component.rb +1 -9
- data/app/components/solidus_admin/shipping_categories/index/component.rb +14 -17
- data/app/components/solidus_admin/shipping_categories/new/component.html.erb +2 -4
- data/app/components/solidus_admin/shipping_categories/new/component.rb +1 -9
- data/app/components/solidus_admin/stock_items/edit/component.html.erb +74 -73
- data/app/components/solidus_admin/stock_items/edit/component.js +4 -3
- data/app/components/solidus_admin/stock_items/edit/component.rb +1 -10
- data/app/components/solidus_admin/stock_items/index/component.rb +10 -6
- data/app/components/solidus_admin/stock_locations/index/component.rb +2 -2
- data/app/components/solidus_admin/store_credit_reasons/edit/component.html.erb +2 -3
- data/app/components/solidus_admin/store_credit_reasons/edit/component.rb +1 -9
- data/app/components/solidus_admin/store_credit_reasons/index/component.rb +14 -7
- data/app/components/solidus_admin/store_credit_reasons/new/component.html.erb +2 -4
- data/app/components/solidus_admin/store_credit_reasons/new/component.rb +1 -9
- data/app/components/solidus_admin/tax_categories/edit/component.html.erb +2 -4
- data/app/components/solidus_admin/tax_categories/edit/component.rb +1 -9
- data/app/components/solidus_admin/tax_categories/index/component.rb +30 -9
- data/app/components/solidus_admin/tax_categories/new/component.html.erb +2 -4
- data/app/components/solidus_admin/tax_categories/new/component.rb +1 -9
- data/app/components/solidus_admin/ui/dropdown/component.js +3 -3
- data/app/components/solidus_admin/ui/forms/address/component.js +5 -6
- data/app/components/solidus_admin/ui/forms/field/component.rb +18 -18
- data/app/components/solidus_admin/ui/forms/input/component.js +3 -4
- data/app/components/solidus_admin/ui/forms/input/component.rb +15 -4
- data/app/components/solidus_admin/ui/icon/component.rb +3 -1
- data/app/components/solidus_admin/ui/modal/component.js +2 -2
- data/app/components/solidus_admin/ui/pages/index/component.html.erb +3 -3
- data/app/components/solidus_admin/ui/pages/index/component.rb +11 -6
- data/app/components/solidus_admin/ui/table/component.html.erb +4 -3
- data/app/components/solidus_admin/ui/table/component.js +13 -17
- data/app/components/solidus_admin/ui/table/component.rb +1 -1
- data/app/components/solidus_admin/ui/table/ransack_filter/component.js +18 -16
- data/app/components/solidus_admin/ui/thumbnail_with_caption/component.rb +1 -1
- data/app/components/solidus_admin/ui/toast/component.html.erb +1 -1
- data/app/components/solidus_admin/ui/toast/component.js +3 -3
- data/app/components/solidus_admin/ui/toggletip/component.js +14 -12
- data/app/components/solidus_admin/users/index/component.rb +1 -1
- data/app/components/solidus_admin/users/orders/component.rb +1 -1
- data/app/components/solidus_admin/users/store_credits/edit_amount/component.html.erb +22 -0
- data/app/components/solidus_admin/users/store_credits/edit_amount/component.rb +22 -0
- data/app/components/solidus_admin/users/store_credits/edit_amount/component.yml +5 -0
- data/app/components/solidus_admin/users/store_credits/edit_memo/component.html.erb +15 -0
- data/app/components/solidus_admin/users/store_credits/edit_memo/component.rb +16 -0
- data/app/components/solidus_admin/users/store_credits/edit_memo/component.yml +4 -0
- data/app/components/solidus_admin/users/store_credits/edit_validity/component.html.erb +21 -0
- data/app/components/solidus_admin/users/store_credits/edit_validity/component.rb +22 -0
- data/app/components/solidus_admin/users/store_credits/edit_validity/component.yml +5 -0
- data/app/components/solidus_admin/users/store_credits/index/component.html.erb +65 -0
- data/app/components/solidus_admin/users/store_credits/index/component.rb +114 -0
- data/app/components/solidus_admin/users/store_credits/index/component.yml +12 -0
- data/app/components/solidus_admin/users/store_credits/new/component.html.erb +30 -0
- data/app/components/solidus_admin/users/store_credits/new/component.rb +22 -0
- data/app/components/solidus_admin/users/store_credits/new/component.yml +5 -0
- data/app/components/solidus_admin/users/store_credits/show/component.html.erb +83 -0
- data/app/components/solidus_admin/users/store_credits/show/component.rb +120 -0
- data/app/components/solidus_admin/users/store_credits/show/component.yml +18 -0
- data/app/controllers/solidus_admin/adjustment_reasons_controller.rb +3 -105
- data/app/controllers/solidus_admin/authentication_adapters/backend.rb +1 -1
- data/app/controllers/solidus_admin/base_controller.rb +12 -1
- data/app/controllers/solidus_admin/controller_helpers/search.rb +4 -4
- data/app/controllers/solidus_admin/properties_controller.rb +6 -24
- data/app/controllers/solidus_admin/refund_reasons_controller.rb +5 -105
- data/app/controllers/solidus_admin/resources_controller.rb +152 -0
- data/app/controllers/solidus_admin/return_reasons_controller.rb +4 -104
- data/app/controllers/solidus_admin/roles_controller.rb +3 -105
- data/app/controllers/solidus_admin/shipping_categories_controller.rb +3 -107
- data/app/controllers/solidus_admin/stock_items_controller.rb +12 -29
- data/app/controllers/solidus_admin/store_credit_reasons_controller.rb +5 -105
- data/app/controllers/solidus_admin/store_credits_controller.rb +231 -0
- data/app/controllers/solidus_admin/tax_categories_controller.rb +3 -109
- data/app/helpers/solidus_admin/void_elements_helper.rb +13 -0
- data/app/views/layouts/solidus_admin/application.html.erb +3 -0
- data/config/locales/menu_item.en.yml +0 -1
- data/config/locales/properties.en.yml +4 -0
- data/config/locales/store_credits.en.yml +16 -0
- data/config/routes.rb +12 -1
- data/lib/generators/solidus_admin/install/install_generator.rb +2 -0
- data/lib/solidus_admin/component_registry.rb +1 -1
- data/lib/solidus_admin/configuration.rb +3 -8
- data/lib/solidus_admin/engine.rb +6 -0
- data/lib/solidus_admin/install_tailwindcss.rb +1 -1
- data/lib/solidus_admin/testing_support/component_helpers.rb +3 -9
- data/lib/solidus_admin/testing_support/feature_helpers.rb +1 -1
- data/lib/solidus_admin/testing_support/shared_examples/bulk_delete_resources.rb +20 -0
- data/lib/solidus_admin/testing_support/shared_examples/crud_resource_requests.rb +138 -0
- data/lib/solidus_admin/testing_support/shared_examples/promotion_categories_features.rb +72 -0
- data/lib/solidus_admin/version.rb +1 -1
- data/solidus_admin.gemspec +2 -2
- metadata +39 -8
- data/bin/rails +0 -13
|
@@ -1,114 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module SolidusAdmin
|
|
4
|
-
class ReturnReasonsController < SolidusAdmin::
|
|
5
|
-
include SolidusAdmin::ControllerHelpers::Search
|
|
6
|
-
|
|
7
|
-
before_action :set_return_reason, only: %i[edit update]
|
|
8
|
-
|
|
9
|
-
def index
|
|
10
|
-
set_index_page
|
|
11
|
-
|
|
12
|
-
respond_to do |format|
|
|
13
|
-
format.html { render component('return_reasons/index').new(page: @page) }
|
|
14
|
-
end
|
|
15
|
-
end
|
|
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
|
-
|
|
87
|
-
def destroy
|
|
88
|
-
@return_reason = Spree::ReturnReason.find_by!(id: params[:id])
|
|
89
|
-
|
|
90
|
-
Spree::ReturnReason.transaction { @return_reason.destroy }
|
|
91
|
-
|
|
92
|
-
flash[:notice] = t('.success')
|
|
93
|
-
redirect_back_or_to return_reasons_path, status: :see_other
|
|
94
|
-
end
|
|
95
|
-
|
|
4
|
+
class ReturnReasonsController < SolidusAdmin::ResourcesController
|
|
96
5
|
private
|
|
97
6
|
|
|
98
|
-
def
|
|
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
|
-
)
|
|
7
|
+
def resource_class = Spree::ReturnReason
|
|
107
8
|
|
|
108
|
-
|
|
109
|
-
end
|
|
9
|
+
def resources_collection = Spree::ReturnReason.unscoped
|
|
110
10
|
|
|
111
|
-
def
|
|
11
|
+
def permitted_resource_params
|
|
112
12
|
params.require(:return_reason).permit(:name, :active)
|
|
113
13
|
end
|
|
114
14
|
end
|
|
@@ -1,117 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module SolidusAdmin
|
|
4
|
-
class RolesController < SolidusAdmin::
|
|
5
|
-
include SolidusAdmin::ControllerHelpers::Search
|
|
6
|
-
|
|
7
|
-
before_action :set_role, only: %i[edit update]
|
|
8
|
-
|
|
4
|
+
class RolesController < SolidusAdmin::ResourcesController
|
|
9
5
|
search_scope(:all)
|
|
10
6
|
search_scope(:admin) { _1.where(name: "admin") }
|
|
11
7
|
|
|
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
8
|
private
|
|
100
9
|
|
|
101
|
-
def
|
|
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
|
|
10
|
+
def resource_class = Spree::Role
|
|
113
11
|
|
|
114
|
-
def
|
|
12
|
+
def permitted_resource_params
|
|
115
13
|
params.require(:role).permit(:role_id, :name, :description, permission_set_ids: [])
|
|
116
14
|
end
|
|
117
15
|
end
|
|
@@ -1,117 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module SolidusAdmin
|
|
4
|
-
class ShippingCategoriesController < SolidusAdmin::
|
|
5
|
-
include SolidusAdmin::ControllerHelpers::Search
|
|
6
|
-
|
|
7
|
-
before_action :set_shipping_category, only: %i[edit update]
|
|
8
|
-
|
|
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
|
|
50
|
-
|
|
51
|
-
respond_to do |format|
|
|
52
|
-
format.html { render component('shipping_categories/index').new(page: @page) }
|
|
53
|
-
end
|
|
54
|
-
end
|
|
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
|
-
|
|
89
|
-
def destroy
|
|
90
|
-
@shipping_category = Spree::ShippingCategory.find_by!(id: params[:id])
|
|
91
|
-
|
|
92
|
-
Spree::ShippingCategory.transaction { @shipping_category.destroy }
|
|
93
|
-
|
|
94
|
-
flash[:notice] = t('.success')
|
|
95
|
-
redirect_back_or_to shipping_categories_path, status: :see_other
|
|
96
|
-
end
|
|
97
|
-
|
|
4
|
+
class ShippingCategoriesController < SolidusAdmin::ResourcesController
|
|
98
5
|
private
|
|
99
6
|
|
|
100
|
-
def
|
|
101
|
-
@shipping_category = Spree::ShippingCategory.find(params[:id])
|
|
102
|
-
end
|
|
7
|
+
def resource_class = Spree::ShippingCategory
|
|
103
8
|
|
|
104
|
-
def
|
|
9
|
+
def permitted_resource_params
|
|
105
10
|
params.require(:shipping_category).permit(:name)
|
|
106
11
|
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)
|
|
115
|
-
end
|
|
116
12
|
end
|
|
117
13
|
end
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module SolidusAdmin
|
|
4
|
-
class StockItemsController < SolidusAdmin::
|
|
4
|
+
class StockItemsController < SolidusAdmin::ResourcesController
|
|
5
5
|
include SolidusAdmin::ControllerHelpers::Search
|
|
6
|
-
before_action :load_stock_items, only: [:index, :edit, :update]
|
|
7
|
-
before_action :load_stock_item, only: [:edit, :update]
|
|
8
6
|
|
|
9
7
|
search_scope(:all, default: true) { _1 }
|
|
10
8
|
search_scope(:back_orderable) { _1.where(backorderable: true) }
|
|
@@ -18,49 +16,34 @@ module SolidusAdmin
|
|
|
18
16
|
end
|
|
19
17
|
end
|
|
20
18
|
|
|
21
|
-
def edit
|
|
22
|
-
respond_to do |format|
|
|
23
|
-
format.html { render component('stock_items/edit').new(stock_item: @stock_item, page: @page) }
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
19
|
def update
|
|
28
20
|
quantity_adjustment = params[:quantity_adjustment].to_i
|
|
29
|
-
@stock_item.assign_attributes(
|
|
21
|
+
@stock_item.assign_attributes(permitted_resource_params)
|
|
30
22
|
@stock_item.stock_movements.build(quantity: quantity_adjustment, originator: current_solidus_admin_user)
|
|
31
23
|
|
|
32
24
|
if @stock_item.save
|
|
33
|
-
|
|
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
|
|
25
|
+
redirect_to after_update_path, status: :see_other
|
|
37
26
|
else
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
end
|
|
27
|
+
page_component = edit_component.new(@stock_item)
|
|
28
|
+
render_resource_form_with_errors(page_component)
|
|
41
29
|
end
|
|
42
30
|
end
|
|
43
31
|
|
|
44
32
|
private
|
|
45
33
|
|
|
46
|
-
def
|
|
47
|
-
@stock_items = apply_search_to(
|
|
48
|
-
Spree::StockItem.reorder(nil),
|
|
49
|
-
param: :q,
|
|
50
|
-
)
|
|
34
|
+
def resource_class = Spree::StockItem
|
|
51
35
|
|
|
52
|
-
|
|
36
|
+
def resources_collection = Spree::StockItem.reorder(nil)
|
|
37
|
+
|
|
38
|
+
def resources_sorting_options
|
|
39
|
+
{
|
|
53
40
|
variant_id: :desc,
|
|
54
41
|
stock_location_id: :desc,
|
|
55
42
|
id: :desc,
|
|
56
|
-
}
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def load_stock_item
|
|
60
|
-
@stock_item = Spree::StockItem.find(params[:id])
|
|
43
|
+
}
|
|
61
44
|
end
|
|
62
45
|
|
|
63
|
-
def
|
|
46
|
+
def permitted_resource_params
|
|
64
47
|
params.require(:stock_item).permit(:backorderable)
|
|
65
48
|
end
|
|
66
49
|
end
|
|
@@ -1,115 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module SolidusAdmin
|
|
4
|
-
class StoreCreditReasonsController < SolidusAdmin::
|
|
5
|
-
include SolidusAdmin::ControllerHelpers::Search
|
|
6
|
-
|
|
7
|
-
before_action :set_store_credit_reason, only: %i[edit update]
|
|
8
|
-
|
|
9
|
-
def index
|
|
10
|
-
set_index_page
|
|
11
|
-
|
|
12
|
-
respond_to do |format|
|
|
13
|
-
format.html { render component('store_credit_reasons/index').new(page: @page) }
|
|
14
|
-
end
|
|
15
|
-
end
|
|
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
|
-
|
|
87
|
-
def destroy
|
|
88
|
-
@store_credit_reason = Spree::StoreCreditReason.find_by!(id: params[:id])
|
|
89
|
-
|
|
90
|
-
Spree::StoreCreditReason.transaction { @store_credit_reason.destroy }
|
|
91
|
-
|
|
92
|
-
flash[:notice] = t('.success')
|
|
93
|
-
redirect_back_or_to store_credit_reasons_path, status: :see_other
|
|
94
|
-
end
|
|
95
|
-
|
|
4
|
+
class StoreCreditReasonsController < SolidusAdmin::ResourcesController
|
|
96
5
|
private
|
|
97
6
|
|
|
98
|
-
def
|
|
99
|
-
@store_credit_reason = Spree::StoreCreditReason.find(params[:id])
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
def store_credit_reason_params
|
|
103
|
-
params.require(:store_credit_reason).permit(:name, :active)
|
|
104
|
-
end
|
|
7
|
+
def resource_class = Spree::StoreCreditReason
|
|
105
8
|
|
|
106
|
-
def
|
|
107
|
-
store_credit_reasons = apply_search_to(
|
|
108
|
-
Spree::StoreCreditReason.unscoped.order(id: :desc),
|
|
109
|
-
param: :q,
|
|
110
|
-
)
|
|
9
|
+
def resources_collection = Spree::StoreCreditReason.unscoped
|
|
111
10
|
|
|
112
|
-
|
|
11
|
+
def permitted_resource_params
|
|
12
|
+
params.require(:store_credit_reason).permit(:name, :active)
|
|
113
13
|
end
|
|
114
14
|
end
|
|
115
15
|
end
|