solidus_admin 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.prettierrc +4 -0
- data/app/assets/builds/solidus_admin/tailwind.css +13 -1
- 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 +2 -18
- data/app/components/solidus_admin/layout/navigation/component.js +1 -1
- data/app/components/solidus_admin/orders/index/component.rb +2 -2
- data/app/components/solidus_admin/orders/show/address/component.js +2 -2
- 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/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 +9 -5
- 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 +1 -1
- 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/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 +6 -1
- 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/ransack_filter/component.js +18 -16
- 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/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 +27 -11
- data/app/components/solidus_admin/users/store_credits/index/component.rb +18 -10
- 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/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/controllers/solidus_admin/users_controller.rb +1 -9
- 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 -2
- data/lib/solidus_admin/configuration.rb +0 -5
- 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/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
- metadata +35 -6
@@ -15,8 +15,19 @@ module SolidusAdmin
|
|
15
15
|
include SolidusAdmin::ComponentsHelper
|
16
16
|
include SolidusAdmin::AuthenticationAdapters::Backend if defined?(Spree::Backend)
|
17
17
|
|
18
|
-
layout
|
18
|
+
layout :set_layout
|
19
|
+
|
19
20
|
helper 'solidus_admin/components'
|
20
21
|
helper 'solidus_admin/layout'
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def set_layout
|
26
|
+
if turbo_frame_request?
|
27
|
+
'turbo_rails/frame'
|
28
|
+
else
|
29
|
+
'solidus_admin/application'
|
30
|
+
end
|
31
|
+
end
|
21
32
|
end
|
22
33
|
end
|
@@ -1,33 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module SolidusAdmin
|
4
|
-
class PropertiesController < SolidusAdmin::
|
5
|
-
|
4
|
+
class PropertiesController < SolidusAdmin::ResourcesController
|
5
|
+
private
|
6
6
|
|
7
|
-
def
|
8
|
-
properties = apply_search_to(
|
9
|
-
Spree::Property.order(created_at: :desc, id: :desc),
|
10
|
-
param: :q,
|
11
|
-
)
|
7
|
+
def resource_class = Spree::Property
|
12
8
|
|
13
|
-
|
14
|
-
|
15
|
-
)
|
16
|
-
|
17
|
-
respond_to do |format|
|
18
|
-
format.html { render component('properties/index').new(page: @page) }
|
19
|
-
end
|
9
|
+
def permitted_resource_params
|
10
|
+
params.require(:property).permit(:name, :presentation)
|
20
11
|
end
|
21
12
|
|
22
|
-
def
|
23
|
-
@properties = Spree::Property.where(id: params[:id])
|
24
|
-
|
25
|
-
Spree::Property.transaction do
|
26
|
-
@properties.destroy_all
|
27
|
-
end
|
28
|
-
|
29
|
-
flash[:notice] = t('.success')
|
30
|
-
redirect_to properties_path, status: :see_other
|
31
|
-
end
|
13
|
+
def resources_collection = Spree::Property.unscoped
|
32
14
|
end
|
33
15
|
end
|
@@ -1,115 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module SolidusAdmin
|
4
|
-
class RefundReasonsController < SolidusAdmin::
|
5
|
-
include SolidusAdmin::ControllerHelpers::Search
|
6
|
-
|
7
|
-
before_action :set_refund_reason, only: %i[edit update]
|
8
|
-
|
9
|
-
def index
|
10
|
-
set_index_page
|
11
|
-
|
12
|
-
respond_to do |format|
|
13
|
-
format.html { render component('refund_reasons/index').new(page: @page) }
|
14
|
-
end
|
15
|
-
end
|
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
|
-
|
87
|
-
def destroy
|
88
|
-
@refund_reason = Spree::RefundReason.find_by!(id: params[:id])
|
89
|
-
|
90
|
-
Spree::RefundReason.transaction { @refund_reason.destroy }
|
91
|
-
|
92
|
-
flash[:notice] = t('.success')
|
93
|
-
redirect_back_or_to refund_reasons_path, status: :see_other
|
94
|
-
end
|
95
|
-
|
4
|
+
class RefundReasonsController < SolidusAdmin::ResourcesController
|
96
5
|
private
|
97
6
|
|
98
|
-
def
|
99
|
-
@refund_reason = Spree::RefundReason.find(params[:id])
|
100
|
-
end
|
101
|
-
|
102
|
-
def refund_reason_params
|
103
|
-
params.require(:refund_reason).permit(:name, :code, :active)
|
104
|
-
end
|
7
|
+
def resource_class = Spree::RefundReason
|
105
8
|
|
106
|
-
def
|
107
|
-
refund_reasons = apply_search_to(
|
108
|
-
Spree::RefundReason.unscoped.order(id: :desc),
|
109
|
-
param: :q,
|
110
|
-
)
|
9
|
+
def resources_collection = Spree::RefundReason.unscoped
|
111
10
|
|
112
|
-
|
11
|
+
def permitted_resource_params
|
12
|
+
params.require(:refund_reason).permit(:name, :code, :active)
|
113
13
|
end
|
114
14
|
end
|
115
15
|
end
|
@@ -0,0 +1,152 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusAdmin
|
4
|
+
class ResourcesController < SolidusAdmin::BaseController
|
5
|
+
include SolidusAdmin::ControllerHelpers::Search
|
6
|
+
|
7
|
+
helper_method :search_filter_params
|
8
|
+
|
9
|
+
before_action :set_paginated_resources, only: %i[index]
|
10
|
+
before_action :set_resource, only: %i[edit update]
|
11
|
+
|
12
|
+
# GET /index
|
13
|
+
#
|
14
|
+
# Uses {set_paginated_resources} to set @resources
|
15
|
+
# and a instance variable with the plural name of the resource.
|
16
|
+
#
|
17
|
+
# Uses the geared_pagination gem to set @page for pagination.
|
18
|
+
#
|
19
|
+
# @see set_paginated_resources
|
20
|
+
# @see resources_collection
|
21
|
+
def index
|
22
|
+
respond_to do |format|
|
23
|
+
format.html { render index_component.new(page: @page) }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def new
|
28
|
+
@resource = resource_class.new
|
29
|
+
render new_component.new(@resource)
|
30
|
+
end
|
31
|
+
|
32
|
+
def create
|
33
|
+
@resource = resource_class.new(permitted_resource_params)
|
34
|
+
|
35
|
+
if @resource.save
|
36
|
+
flash[:notice] = t('.success')
|
37
|
+
redirect_to after_create_path, status: :see_other
|
38
|
+
else
|
39
|
+
page_component = new_component.new(@resource)
|
40
|
+
render_resource_form_with_errors(page_component)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def edit
|
45
|
+
render edit_component.new(@resource)
|
46
|
+
end
|
47
|
+
|
48
|
+
def update
|
49
|
+
if @resource.update(permitted_resource_params)
|
50
|
+
flash[:notice] = t('.success')
|
51
|
+
redirect_to after_update_path, status: :see_other
|
52
|
+
else
|
53
|
+
page_component = edit_component.new(@resource)
|
54
|
+
render_resource_form_with_errors(page_component)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def destroy
|
59
|
+
@resource = resource_class.where(id: params[:id])
|
60
|
+
|
61
|
+
resource_class.transaction { @resource.destroy_all }
|
62
|
+
|
63
|
+
flash[:notice] = t('.success')
|
64
|
+
redirect_back_or_to after_destroy_path, status: :see_other
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
def search_filter_params
|
70
|
+
request.params.slice(:q, :page)
|
71
|
+
end
|
72
|
+
|
73
|
+
def set_paginated_resources
|
74
|
+
@resources ||= apply_search_to(
|
75
|
+
resources_collection,
|
76
|
+
param: :q,
|
77
|
+
).tap do |resources|
|
78
|
+
instance_variable_set("@#{plural_resource_name}", resources)
|
79
|
+
# sets @page instance variable in geared_pagination gem
|
80
|
+
set_page_and_extract_portion_from(resources, ordered_by: resources_sorting_options)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def resources_sorting_options
|
85
|
+
{ id: :desc }
|
86
|
+
end
|
87
|
+
|
88
|
+
def resources_collection
|
89
|
+
resource_class.all
|
90
|
+
end
|
91
|
+
|
92
|
+
def set_resource
|
93
|
+
@resource ||= resource_class.find(params[:id]).tap do |resource|
|
94
|
+
instance_variable_set("@#{resource_name}", resource)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def resource_class
|
99
|
+
raise NotImplementedError,
|
100
|
+
"You must implement the resource_class method in #{self.class}"
|
101
|
+
end
|
102
|
+
|
103
|
+
def resource_name
|
104
|
+
resource_class.model_name.singular_route_key
|
105
|
+
end
|
106
|
+
|
107
|
+
def plural_resource_name
|
108
|
+
resource_class.model_name.route_key
|
109
|
+
end
|
110
|
+
|
111
|
+
def index_component
|
112
|
+
component("#{plural_resource_name}/index")
|
113
|
+
end
|
114
|
+
|
115
|
+
def new_component
|
116
|
+
component("#{plural_resource_name}/new")
|
117
|
+
end
|
118
|
+
|
119
|
+
def edit_component
|
120
|
+
component("#{plural_resource_name}/edit")
|
121
|
+
end
|
122
|
+
|
123
|
+
def render_resource_form_with_errors(page_component)
|
124
|
+
respond_to do |format|
|
125
|
+
format.html do
|
126
|
+
render page_component, status: :unprocessable_entity
|
127
|
+
end
|
128
|
+
format.turbo_stream do
|
129
|
+
render turbo_stream: turbo_stream.replace(:resource_modal, page_component),
|
130
|
+
status: :unprocessable_entity
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def permitted_resource_params
|
136
|
+
raise NotImplementedError,
|
137
|
+
"You must implement the permitted_resource_params method in #{self.class}"
|
138
|
+
end
|
139
|
+
|
140
|
+
def after_create_path
|
141
|
+
solidus_admin.send("#{plural_resource_name}_path", **search_filter_params)
|
142
|
+
end
|
143
|
+
|
144
|
+
def after_update_path
|
145
|
+
solidus_admin.send("#{plural_resource_name}_path", **search_filter_params)
|
146
|
+
end
|
147
|
+
|
148
|
+
def after_destroy_path
|
149
|
+
solidus_admin.send("#{plural_resource_name}_path", **search_filter_params)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
@@ -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
|