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
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SolidusAdmin
|
|
4
|
+
class StoreCreditsController < SolidusAdmin::ResourcesController
|
|
5
|
+
before_action :set_user
|
|
6
|
+
before_action :set_store_credit, only: [:show, :edit_amount, :update_amount, :edit_memo, :update_memo, :edit_validity, :invalidate]
|
|
7
|
+
before_action :set_store_credit_reasons, only: [:edit_amount, :update_amount, :edit_validity, :invalidate]
|
|
8
|
+
before_action :set_store_credit_events, only: [:show]
|
|
9
|
+
before_action :set_store_credit_categories, only: [:new]
|
|
10
|
+
|
|
11
|
+
def index
|
|
12
|
+
@store_credits = Spree::StoreCredit.where(user_id: @user.id).order(id: :desc)
|
|
13
|
+
|
|
14
|
+
respond_to do |format|
|
|
15
|
+
format.html { render component("users/store_credits/index").new(user: @user, store_credits: @store_credits) }
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def show
|
|
20
|
+
respond_to do |format|
|
|
21
|
+
format.html { render component("users/store_credits/show").new(user: @user, store_credit: @store_credit, events: @store_credit_events) }
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def new
|
|
26
|
+
@store_credit ||= Spree::StoreCredit.new
|
|
27
|
+
|
|
28
|
+
respond_to do |format|
|
|
29
|
+
format.html {
|
|
30
|
+
render component("users/store_credits/new").new(
|
|
31
|
+
user: @user,
|
|
32
|
+
store_credit: @store_credit,
|
|
33
|
+
categories: @store_credit_categories
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def create
|
|
40
|
+
@store_credit = @user.store_credits.build(
|
|
41
|
+
permitted_resource_params.merge({
|
|
42
|
+
created_by: spree_current_user,
|
|
43
|
+
action_originator: spree_current_user
|
|
44
|
+
})
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
return unless ensure_amount { render_new_with_errors }
|
|
48
|
+
return unless ensure_store_credit_category { render_new_with_errors }
|
|
49
|
+
|
|
50
|
+
if @store_credit.save
|
|
51
|
+
flash[:notice] = t('.success')
|
|
52
|
+
redirect_to after_create_path, status: :see_other
|
|
53
|
+
else
|
|
54
|
+
render_new_with_errors
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def edit_amount
|
|
59
|
+
respond_to do |format|
|
|
60
|
+
format.html {
|
|
61
|
+
render component("users/store_credits/edit_amount").new(
|
|
62
|
+
user: @user,
|
|
63
|
+
store_credit: @store_credit,
|
|
64
|
+
reasons: @store_credit_reasons
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def update_amount
|
|
71
|
+
return unless ensure_amount { render_edit_with_errors }
|
|
72
|
+
return unless ensure_store_credit_reason { render_edit_with_errors }
|
|
73
|
+
|
|
74
|
+
if @store_credit.update_amount(permitted_resource_params[:amount], @store_credit_reason, spree_current_user)
|
|
75
|
+
flash[:notice] = t('.success')
|
|
76
|
+
redirect_to after_update_path, status: :see_other
|
|
77
|
+
else
|
|
78
|
+
render_edit_with_errors
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def edit_memo
|
|
83
|
+
respond_to do |format|
|
|
84
|
+
format.html {
|
|
85
|
+
render component("users/store_credits/edit_memo").new(
|
|
86
|
+
user: @user,
|
|
87
|
+
store_credit: @store_credit,
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def update_memo
|
|
94
|
+
if @store_credit.update(memo: permitted_resource_params[:memo])
|
|
95
|
+
flash[:notice] = t('.success')
|
|
96
|
+
else
|
|
97
|
+
# Memo update failures are nearly impossible to trigger due to lack of validation.
|
|
98
|
+
flash[:error] = t('.failure')
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
redirect_to after_update_path, status: :see_other
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def edit_validity
|
|
105
|
+
respond_to do |format|
|
|
106
|
+
format.html {
|
|
107
|
+
render component("users/store_credits/edit_validity").new(
|
|
108
|
+
user: @user,
|
|
109
|
+
store_credit: @store_credit,
|
|
110
|
+
reasons: @store_credit_reasons
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def invalidate
|
|
117
|
+
return unless ensure_store_credit_reason { render_edit_with_errors }
|
|
118
|
+
|
|
119
|
+
if @store_credit.invalidate(@store_credit_reason, spree_current_user)
|
|
120
|
+
flash[:notice] = t('.success')
|
|
121
|
+
else
|
|
122
|
+
# Ensure store_credit_reason handles invalid param/form submissions and modal re-rendering.
|
|
123
|
+
# This is just a fallback error state in case anything goes wrong with StoreCredit#invalidate.
|
|
124
|
+
flash[:error] = t('.failure')
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
redirect_to after_update_path, status: :see_other
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
private
|
|
131
|
+
|
|
132
|
+
def resource_class = Spree::StoreCredit
|
|
133
|
+
|
|
134
|
+
def set_store_credit
|
|
135
|
+
@store_credit ||= Spree::StoreCredit.find(params[:id])
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def set_user
|
|
139
|
+
@user = Spree.user_class.find(params[:user_id])
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def set_store_credit_reasons
|
|
143
|
+
@store_credit_reasons = Spree::StoreCreditReason.active.order(:name)
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def set_store_credit_categories
|
|
147
|
+
@store_credit_categories = Spree::StoreCreditCategory.all.order(:name)
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def set_store_credit_events
|
|
151
|
+
@store_credit_events = @store_credit.store_credit_events.chronological
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
def permitted_resource_params
|
|
155
|
+
permitted_params = [:amount, :currency, :category_id, :memo]
|
|
156
|
+
permitted_params << :category_id if action_name.to_sym == :create
|
|
157
|
+
permitted_params << :store_credit_reason_id if [:update_amount, :invalidate].include?(action_name.to_sym)
|
|
158
|
+
|
|
159
|
+
params.require(:store_credit).permit(permitted_params).merge(created_by: spree_current_user)
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def render_new_with_errors
|
|
163
|
+
set_store_credit_categories
|
|
164
|
+
|
|
165
|
+
page_component = component("users/store_credits/new").new(
|
|
166
|
+
user: @user,
|
|
167
|
+
store_credit: @store_credit,
|
|
168
|
+
categories: @store_credit_categories
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
render_resource_form_with_errors(page_component)
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def render_edit_with_errors
|
|
175
|
+
set_store_credit_events
|
|
176
|
+
|
|
177
|
+
template = if action_name.to_sym == :invalidate
|
|
178
|
+
"edit_validity"
|
|
179
|
+
else
|
|
180
|
+
"edit_amount"
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
page_component = component("users/store_credits/#{template}").new(
|
|
184
|
+
user: @user,
|
|
185
|
+
store_credit: @store_credit,
|
|
186
|
+
reasons: @store_credit_reasons
|
|
187
|
+
)
|
|
188
|
+
|
|
189
|
+
render_resource_form_with_errors(page_component)
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
def ensure_amount
|
|
193
|
+
if permitted_resource_params[:amount].blank?
|
|
194
|
+
@store_credit.errors.add(:amount, :greater_than, count: 0, value: permitted_resource_params[:amount])
|
|
195
|
+
yield if block_given? # Block is for error template rendering on a per-action basis so this can be re-used.
|
|
196
|
+
return false
|
|
197
|
+
end
|
|
198
|
+
true
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
def ensure_store_credit_reason
|
|
202
|
+
@store_credit_reason = Spree::StoreCreditReason.find_by(id: permitted_resource_params[:store_credit_reason_id])
|
|
203
|
+
|
|
204
|
+
if @store_credit_reason.blank?
|
|
205
|
+
@store_credit.errors.add(:store_credit_reason_id, "Store Credit reason must be provided")
|
|
206
|
+
yield if block_given? # Block is for error template rendering on a per-action basis so this can be re-used.
|
|
207
|
+
return false
|
|
208
|
+
end
|
|
209
|
+
true
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
def ensure_store_credit_category
|
|
213
|
+
@store_credit_category = Spree::StoreCreditCategory.find_by(id: permitted_resource_params[:category_id])
|
|
214
|
+
|
|
215
|
+
if @store_credit_category.blank?
|
|
216
|
+
@store_credit.errors.add(:category_id, "Store Credit category must be provided")
|
|
217
|
+
yield if block_given? # Block is for error template rendering on a per-action basis so this can be re-used.
|
|
218
|
+
return false
|
|
219
|
+
end
|
|
220
|
+
true
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
def after_create_path
|
|
224
|
+
solidus_admin.user_store_credits_path(@user)
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
def after_update_path
|
|
228
|
+
solidus_admin.user_store_credit_path(@user, @store_credit)
|
|
229
|
+
end
|
|
230
|
+
end
|
|
231
|
+
end
|
|
@@ -1,119 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module SolidusAdmin
|
|
4
|
-
class TaxCategoriesController < SolidusAdmin::
|
|
5
|
-
include SolidusAdmin::ControllerHelpers::Search
|
|
6
|
-
|
|
7
|
-
before_action :set_tax_category, only: %i[edit update]
|
|
8
|
-
|
|
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
|
|
85
|
-
|
|
86
|
-
respond_to do |format|
|
|
87
|
-
format.html { render component('tax_categories/index').new(page: @page) }
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
def destroy
|
|
92
|
-
@tax_categories = Spree::TaxCategory.where(id: params[:id])
|
|
93
|
-
|
|
94
|
-
Spree::TaxCategory.transaction { @tax_categories.destroy_all }
|
|
95
|
-
|
|
96
|
-
flash[:notice] = t('.success')
|
|
97
|
-
redirect_back_or_to tax_categories_path, status: :see_other
|
|
98
|
-
end
|
|
99
|
-
|
|
4
|
+
class TaxCategoriesController < SolidusAdmin::ResourcesController
|
|
100
5
|
private
|
|
101
6
|
|
|
102
|
-
def
|
|
103
|
-
@tax_category = Spree::TaxCategory.find(params[:id])
|
|
104
|
-
end
|
|
7
|
+
def resource_class = Spree::TaxCategory
|
|
105
8
|
|
|
106
|
-
def
|
|
9
|
+
def permitted_resource_params
|
|
107
10
|
params.require(:tax_category).permit(:name, :description, :is_default, :tax_code)
|
|
108
11
|
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)
|
|
117
|
-
end
|
|
118
12
|
end
|
|
119
13
|
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SolidusAdmin
|
|
4
|
+
module VoidElementsHelper
|
|
5
|
+
# https://github.com/rails/rails/blob/194d697036c61af0caa66de5659721ded2478ce9/actionview/lib/action_view/helpers/tag_helper.rb#L84
|
|
6
|
+
HTML_VOID_ELEMENTS = %i(area base br col embed hr img input keygen link meta source track wbr)
|
|
7
|
+
|
|
8
|
+
# @param element [Symbol]
|
|
9
|
+
def void_element?(element)
|
|
10
|
+
HTML_VOID_ELEMENTS.include?(element)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
|
|
6
6
|
<title><%= solidus_admin_title %></title>
|
|
7
7
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
8
|
+
<meta name="turbo-cache-control" content="no-cache">
|
|
9
|
+
<meta name="turbo-prefetch" content="false">
|
|
10
|
+
|
|
8
11
|
<%= csrf_meta_tags %>
|
|
9
12
|
<%= csp_meta_tag %>
|
|
10
13
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
en:
|
|
2
|
+
solidus_admin:
|
|
3
|
+
store_credits:
|
|
4
|
+
title: "Store Credits"
|
|
5
|
+
destroy:
|
|
6
|
+
success: "Store credit was successfully removed."
|
|
7
|
+
create:
|
|
8
|
+
success: "Store credit was successfully created."
|
|
9
|
+
update_amount:
|
|
10
|
+
success: "Store credit was successfully updated."
|
|
11
|
+
update_memo:
|
|
12
|
+
success: "Store credit was successfully updated."
|
|
13
|
+
failure: "Something went wrong. Store credit could not be updated."
|
|
14
|
+
invalidate:
|
|
15
|
+
success: "Store credit was successfully invalidated."
|
|
16
|
+
failure: "Something went wrong. Store credit could not be invalidated."
|
data/config/routes.rb
CHANGED
|
@@ -52,10 +52,21 @@ SolidusAdmin::Engine.routes.draw do
|
|
|
52
52
|
get :orders
|
|
53
53
|
get :items
|
|
54
54
|
end
|
|
55
|
+
|
|
56
|
+
resources :store_credits, only: [:index, :show, :new, :create], controller: "store_credits" do
|
|
57
|
+
member do
|
|
58
|
+
get :edit_amount
|
|
59
|
+
put :update_amount
|
|
60
|
+
get :edit_memo
|
|
61
|
+
put :update_memo
|
|
62
|
+
get :edit_validity
|
|
63
|
+
put :invalidate
|
|
64
|
+
end
|
|
65
|
+
end
|
|
55
66
|
end
|
|
56
67
|
|
|
57
68
|
admin_resources :promotions, only: [:index, :destroy]
|
|
58
|
-
admin_resources :properties,
|
|
69
|
+
admin_resources :properties, except: [:show]
|
|
59
70
|
admin_resources :option_types, only: [:index, :destroy], sortable: true
|
|
60
71
|
admin_resources :taxonomies, only: [:index, :destroy], sortable: true
|
|
61
72
|
admin_resources :promotion_categories, only: [:index, :destroy]
|
|
@@ -28,7 +28,7 @@ module SolidusAdmin
|
|
|
28
28
|
prefix = "#{SolidusAdmin::Configuration::ENGINE_ROOT}/app/components/solidus_admin/"
|
|
29
29
|
suffix = "/component.rb"
|
|
30
30
|
dictionary = Dir["#{prefix}**#{suffix}"].map { _1.delete_prefix(prefix).delete_suffix(suffix) }
|
|
31
|
-
corrections = DidYouMean::SpellChecker.new(dictionary:
|
|
31
|
+
corrections = DidYouMean::SpellChecker.new(dictionary:).correct(key.to_s)
|
|
32
32
|
|
|
33
33
|
raise ComponentNotFoundError.new(
|
|
34
34
|
"Unknown component #{key}#{DidYouMean.formatter.message_for(corrections)}",
|
|
@@ -102,11 +102,6 @@ module SolidusAdmin
|
|
|
102
102
|
key: "taxonomies",
|
|
103
103
|
route: -> { spree.admin_taxonomies_path },
|
|
104
104
|
position: 30
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
key: "taxons",
|
|
108
|
-
route: -> { spree.admin_taxons_path },
|
|
109
|
-
position: 40
|
|
110
105
|
}
|
|
111
106
|
]
|
|
112
107
|
},
|
|
@@ -169,10 +164,10 @@ module SolidusAdmin
|
|
|
169
164
|
{
|
|
170
165
|
position: index,
|
|
171
166
|
key: item.label,
|
|
172
|
-
icon
|
|
173
|
-
route
|
|
167
|
+
icon:,
|
|
168
|
+
route:,
|
|
174
169
|
children: item.children.map.with_index(&menu_item_to_hash),
|
|
175
|
-
match_path
|
|
170
|
+
match_path:,
|
|
176
171
|
}
|
|
177
172
|
end
|
|
178
173
|
|
data/lib/solidus_admin/engine.rb
CHANGED
|
@@ -63,5 +63,11 @@ module SolidusAdmin
|
|
|
63
63
|
SolidusAdmin::Engine.root.join("app/components"),
|
|
64
64
|
]
|
|
65
65
|
end
|
|
66
|
+
|
|
67
|
+
initializer "solidus_admin.routing_proxies" do |app|
|
|
68
|
+
ActiveSupport.on_load(:after_routes_loaded) do
|
|
69
|
+
SolidusAdmin::BaseComponent.include app.routes.mounted_helpers
|
|
70
|
+
end
|
|
71
|
+
end
|
|
66
72
|
end
|
|
67
73
|
end
|
|
@@ -8,7 +8,7 @@ input_path = "app/assets/stylesheets/solidus_admin/application.tailwind.css"
|
|
|
8
8
|
output_path = "app/assets/builds/solidus_admin/tailwind.css"
|
|
9
9
|
|
|
10
10
|
unless bundle_command "show tailwindcss-rails"
|
|
11
|
-
bundle_command "add tailwindcss-rails"
|
|
11
|
+
bundle_command "add tailwindcss-rails --version '~>3.0'"
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
# Copy the Tailwind CSS main file.
|
|
@@ -12,15 +12,9 @@ module SolidusAdmin
|
|
|
12
12
|
# "Rendered"
|
|
13
13
|
# end
|
|
14
14
|
# end
|
|
15
|
-
def mock_component(&definition)
|
|
16
|
-
|
|
17
|
-
component_class
|
|
18
|
-
# ViewComponent will complain if we don't fake a class name:
|
|
19
|
-
# @see https://github.com/ViewComponent/view_component/blob/5decd07842c48cbad82527daefa3fe9c65a4226a/lib/view_component/base.rb#L371
|
|
20
|
-
component_class.define_singleton_method(:name) { "Foo" }
|
|
21
|
-
component_class.define_singleton_method(:to_s) { "#{name} (#{location})" }
|
|
22
|
-
component_class.class_eval(&definition) if definition
|
|
23
|
-
component_class
|
|
15
|
+
def mock_component(class_name = "Foo::Component", &definition)
|
|
16
|
+
component_class = stub_const(class_name, Class.new(described_class, &definition))
|
|
17
|
+
component_class.new
|
|
24
18
|
end
|
|
25
19
|
end
|
|
26
20
|
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.shared_examples_for 'feature: bulk delete resources' do
|
|
4
|
+
it 'allows to bulk delete resources' do
|
|
5
|
+
create(resource_factory, name: 'Bulk delete item 1')
|
|
6
|
+
create(resource_factory, name: 'Bulk delete item 2')
|
|
7
|
+
|
|
8
|
+
visit index_path
|
|
9
|
+
expect(page).to have_content('Bulk delete item 1')
|
|
10
|
+
expect(page).to have_content('Bulk delete item 2')
|
|
11
|
+
|
|
12
|
+
select_row('Bulk delete item 1')
|
|
13
|
+
select_row('Bulk delete item 2')
|
|
14
|
+
click_on 'Delete'
|
|
15
|
+
|
|
16
|
+
expect(page).to have_content('were successfully removed.')
|
|
17
|
+
expect(page).not_to have_content('Bulk delete item 1')
|
|
18
|
+
expect(page).not_to have_content('Bulk delete item 2')
|
|
19
|
+
end
|
|
20
|
+
end
|