solidus_backend 4.6.5 → 4.7.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/Rakefile +17 -17
- data/app/assets/javascripts/spree/backend/components/tabs.js +0 -2
- data/app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js +1 -1
- data/app/controllers/spree/admin/adjustment_reasons_controller.rb +0 -5
- data/app/controllers/spree/admin/adjustments_controller.rb +1 -5
- data/app/controllers/spree/admin/base_controller.rb +9 -9
- data/app/controllers/spree/admin/cancellations_controller.rb +3 -3
- data/app/controllers/spree/admin/customer_returns_controller.rb +6 -6
- data/app/controllers/spree/admin/images_controller.rb +2 -9
- data/app/controllers/spree/admin/locale_controller.rb +4 -4
- data/app/controllers/spree/admin/option_types_controller.rb +1 -11
- data/app/controllers/spree/admin/orders/customer_details_controller.rb +2 -2
- data/app/controllers/spree/admin/orders_controller.rb +29 -29
- data/app/controllers/spree/admin/payment_methods_controller.rb +4 -9
- data/app/controllers/spree/admin/payments_controller.rb +10 -12
- data/app/controllers/spree/admin/prices_controller.rb +1 -7
- data/app/controllers/spree/admin/product_properties_controller.rb +1 -5
- data/app/controllers/spree/admin/products_controller.rb +14 -30
- data/app/controllers/spree/admin/properties_controller.rb +3 -7
- data/app/controllers/spree/admin/refund_reasons_controller.rb +0 -5
- data/app/controllers/spree/admin/refunds_controller.rb +3 -7
- data/app/controllers/spree/admin/reimbursements_controller.rb +4 -14
- data/app/controllers/spree/admin/resource_controller.rb +11 -25
- data/app/controllers/spree/admin/return_authorizations_controller.rb +11 -23
- data/app/controllers/spree/admin/return_items_controller.rb +1 -5
- data/app/controllers/spree/admin/return_reasons_controller.rb +0 -5
- data/app/controllers/spree/admin/search_controller.rb +9 -7
- data/app/controllers/spree/admin/shipping_categories_controller.rb +0 -5
- data/app/controllers/spree/admin/shipping_methods_controller.rb +0 -16
- data/app/controllers/spree/admin/stock_items_controller.rb +5 -5
- data/app/controllers/spree/admin/stock_locations_controller.rb +1 -8
- data/app/controllers/spree/admin/stock_movements_controller.rb +5 -5
- data/app/controllers/spree/admin/store_credit_reasons_controller.rb +0 -5
- data/app/controllers/spree/admin/store_credits_controller.rb +10 -10
- data/app/controllers/spree/admin/stores_controller.rb +4 -11
- data/app/controllers/spree/admin/style_guide_controller.rb +19 -19
- data/app/controllers/spree/admin/tax_categories_controller.rb +0 -5
- data/app/controllers/spree/admin/tax_rates_controller.rb +0 -15
- data/app/controllers/spree/admin/taxonomies_controller.rb +0 -4
- data/app/controllers/spree/admin/taxons/attachment_controller.rb +2 -2
- data/app/controllers/spree/admin/taxons_controller.rb +5 -5
- data/app/controllers/spree/admin/theme_controller.rb +3 -3
- data/app/controllers/spree/admin/users/api_key_controller.rb +2 -2
- data/app/controllers/spree/admin/users_controller.rb +6 -6
- data/app/controllers/spree/admin/variant_property_rule_values_controller.rb +1 -1
- data/app/controllers/spree/admin/variants_controller.rb +8 -12
- data/app/controllers/spree/admin/zones_controller.rb +0 -4
- data/app/helpers/spree/admin/adjustments_helper.rb +7 -7
- data/app/helpers/spree/admin/base_helper.rb +10 -10
- data/app/helpers/spree/admin/navigation_helper.rb +37 -37
- data/app/helpers/spree/admin/orders_helper.rb +2 -2
- data/app/helpers/spree/admin/reimbursement_type_helper.rb +1 -1
- data/app/helpers/spree/admin/stock_locations_helper.rb +1 -1
- data/app/helpers/spree/admin/store_credit_events_helper.rb +9 -9
- data/app/views/spree/admin/search/users.json.jbuilder +2 -2
- data/config/initializers/assets.rb +1 -1
- data/config/initializers/form_builder.rb +1 -1
- data/config/routes.rb +9 -9
- data/lib/solidus_backend.rb +1 -1
- data/lib/spree/backend/callbacks.rb +2 -2
- data/lib/spree/backend/config.rb +1 -1
- data/lib/spree/backend/engine.rb +3 -3
- data/lib/spree/backend.rb +12 -12
- data/lib/spree/backend_configuration/deprecated_tab_constants.rb +2 -0
- data/lib/spree/backend_configuration.rb +46 -48
- data/lib/spree_backend.rb +1 -1
- data/solidus_backend.gemspec +22 -21
- metadata +30 -19
- data/app/assets/images/spree/backend/themes/solidus_admin/remixicon.license.txt +0 -222
- data/vendor/assets/fonts/inter/inter.license.txt +0 -97
- data/vendor/assets/javascripts/solidus_admin/backbone-nested-models.license.txt +0 -29
- data/vendor/assets/javascripts/solidus_admin/bind-polyfill.license.txt +0 -9
- data/vendor/assets/javascripts/solidus_admin/flatpickr/flatpickr.license.txt +0 -244
- data/vendor/assets/javascripts/solidus_admin/select2.license.txt +0 -226
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module Spree
|
|
4
4
|
module Admin
|
|
5
5
|
class ProductsController < ResourceController
|
|
6
|
-
helper
|
|
6
|
+
helper "spree/products"
|
|
7
7
|
|
|
8
8
|
before_action :load_data, except: [:index]
|
|
9
9
|
update.before :update_before
|
|
@@ -25,7 +25,7 @@ module Spree
|
|
|
25
25
|
@product = Spree::Product.friendly.find(params[:id])
|
|
26
26
|
@product.discard
|
|
27
27
|
|
|
28
|
-
flash[:success] = t(
|
|
28
|
+
flash[:success] = t("spree.notice_messages.product_deleted")
|
|
29
29
|
|
|
30
30
|
respond_with(@product) do |format|
|
|
31
31
|
format.html { redirect_to collection_url }
|
|
@@ -37,9 +37,9 @@ module Spree
|
|
|
37
37
|
@new = @product.duplicate
|
|
38
38
|
|
|
39
39
|
if @new.save
|
|
40
|
-
flash[:success] = t(
|
|
40
|
+
flash[:success] = t("spree.notice_messages.product_cloned")
|
|
41
41
|
else
|
|
42
|
-
flash[:error] = t(
|
|
42
|
+
flash[:error] = t("spree.notice_messages.product_not_cloned")
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
redirect_to edit_admin_product_url(@new)
|
|
@@ -47,32 +47,16 @@ module Spree
|
|
|
47
47
|
|
|
48
48
|
private
|
|
49
49
|
|
|
50
|
-
def permitted_resource_params
|
|
51
|
-
# update_before may clear params[:product] when removing all product properties
|
|
52
|
-
params.require(:product).permit(
|
|
53
|
-
*(permitted_attributes.product_attributes - [:deleted_at, :option_values_hash]),
|
|
54
|
-
:slug, :meta_title, :rebuild_vat_prices, :promotionable, :track_inventory,
|
|
55
|
-
taxon_ids: [],
|
|
56
|
-
option_type_ids: [],
|
|
57
|
-
product_properties_attributes: [:id, *permitted_product_properties_attributes],
|
|
58
|
-
variant_property_rules_attributes: [
|
|
59
|
-
:id, :apply_to_all,
|
|
60
|
-
option_value_ids: [],
|
|
61
|
-
values_attributes: [:id, :property_name, :value]
|
|
62
|
-
]
|
|
63
|
-
)
|
|
64
|
-
end
|
|
65
|
-
|
|
66
50
|
def set_default_tax_category
|
|
67
51
|
@product.tax_category_id ||= @default_tax_category&.id
|
|
68
52
|
end
|
|
69
53
|
|
|
70
54
|
def split_params
|
|
71
55
|
if params[:product][:taxon_ids].present?
|
|
72
|
-
params[:product][:taxon_ids] = params[:product][:taxon_ids].split(
|
|
56
|
+
params[:product][:taxon_ids] = params[:product][:taxon_ids].split(",")
|
|
73
57
|
end
|
|
74
58
|
if params[:product][:option_type_ids].present?
|
|
75
|
-
params[:product][:option_type_ids] = params[:product][:option_type_ids].split(
|
|
59
|
+
params[:product][:option_type_ids] = params[:product][:option_type_ids].split(",")
|
|
76
60
|
end
|
|
77
61
|
end
|
|
78
62
|
|
|
@@ -105,11 +89,11 @@ module Spree
|
|
|
105
89
|
params[:q][:s] ||= "name asc"
|
|
106
90
|
# @search needs to be defined as this is passed to search_form_for
|
|
107
91
|
@search = super.ransack(params[:q])
|
|
108
|
-
@collection = @search.result
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
92
|
+
@collection = @search.result
|
|
93
|
+
.order(id: :asc)
|
|
94
|
+
.includes(product_includes)
|
|
95
|
+
.page(params[:page])
|
|
96
|
+
.per(Spree::Config[:admin_products_per_page])
|
|
113
97
|
end
|
|
114
98
|
|
|
115
99
|
def update_before
|
|
@@ -120,7 +104,7 @@ module Spree
|
|
|
120
104
|
end
|
|
121
105
|
|
|
122
106
|
def product_includes
|
|
123
|
-
[:variant_images, {
|
|
107
|
+
[:variant_images, {variants: [:images], master: [:images, :prices]}]
|
|
124
108
|
end
|
|
125
109
|
|
|
126
110
|
def clone_object_url(resource)
|
|
@@ -143,14 +127,14 @@ module Spree
|
|
|
143
127
|
# Stops people submitting blank slugs, causing errors when they try to
|
|
144
128
|
# update the product again
|
|
145
129
|
@product.slug = @product.slug_was if @product.slug.blank?
|
|
146
|
-
render action:
|
|
130
|
+
render action: "edit"
|
|
147
131
|
end
|
|
148
132
|
|
|
149
133
|
def normalize_variant_property_rules
|
|
150
134
|
return unless updating_variant_property_rules?
|
|
151
135
|
|
|
152
136
|
params[:product][:variant_property_rules_attributes].each_value do |param_attrs|
|
|
153
|
-
param_attrs[:option_value_ids] = param_attrs[:option_value_ids].split(
|
|
137
|
+
param_attrs[:option_value_ids] = param_attrs[:option_value_ids].split(",")
|
|
154
138
|
end
|
|
155
139
|
end
|
|
156
140
|
end
|
|
@@ -9,10 +9,6 @@ module Spree
|
|
|
9
9
|
|
|
10
10
|
private
|
|
11
11
|
|
|
12
|
-
def permitted_resource_params
|
|
13
|
-
params.require(:property).permit(permitted_property_attributes)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
12
|
def collection
|
|
17
13
|
return @collection if @collection
|
|
18
14
|
# params[:q] can be blank upon pagination
|
|
@@ -20,9 +16,9 @@ module Spree
|
|
|
20
16
|
|
|
21
17
|
@collection = super
|
|
22
18
|
@search = @collection.ransack(params[:q])
|
|
23
|
-
@collection = @search.result
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
@collection = @search.result
|
|
20
|
+
.page(params[:page])
|
|
21
|
+
.per(Spree::Config[:properties_per_page])
|
|
26
22
|
|
|
27
23
|
@collection
|
|
28
24
|
end
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module Spree
|
|
4
4
|
module Admin
|
|
5
5
|
class RefundsController < ResourceController
|
|
6
|
-
belongs_to
|
|
6
|
+
belongs_to "spree/payment"
|
|
7
7
|
before_action :load_order
|
|
8
8
|
|
|
9
9
|
helper_method :refund_reasons
|
|
@@ -21,7 +21,7 @@ module Spree
|
|
|
21
21
|
else
|
|
22
22
|
flash.now[:error] = @refund.errors.full_messages.join(", ")
|
|
23
23
|
respond_with(@refund) do |format|
|
|
24
|
-
format.html { render action:
|
|
24
|
+
format.html { render action: "new" }
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
end
|
|
@@ -42,11 +42,7 @@ module Spree
|
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
def refund_params
|
|
45
|
-
params.require(:refund).permit
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def permitted_resource_params
|
|
49
|
-
params.require(:refund).permit(:refund_reason_id)
|
|
45
|
+
params.require(:refund).permit!
|
|
50
46
|
end
|
|
51
47
|
|
|
52
48
|
def build_resource
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
module Spree
|
|
4
4
|
module Admin
|
|
5
5
|
class ReimbursementsController < ResourceController
|
|
6
|
-
helper
|
|
7
|
-
helper
|
|
8
|
-
belongs_to
|
|
6
|
+
helper "spree/admin/reimbursement_type"
|
|
7
|
+
helper "spree/admin/customer_returns"
|
|
8
|
+
belongs_to "spree/order", find_by: :number
|
|
9
9
|
|
|
10
10
|
before_action :load_stock_locations, only: :edit
|
|
11
11
|
before_action :load_simulated_refunds, only: :edit
|
|
@@ -20,12 +20,6 @@ module Spree
|
|
|
20
20
|
|
|
21
21
|
private
|
|
22
22
|
|
|
23
|
-
def permitted_resource_params
|
|
24
|
-
params.fetch(:reimbursement, {}).permit(
|
|
25
|
-
return_items_attributes: [:id, :amount, :override_reimbursement_type_id, :exchange_variant_id]
|
|
26
|
-
)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
23
|
def recalculate_order
|
|
30
24
|
@reimbursement.order.recalculate
|
|
31
25
|
end
|
|
@@ -56,11 +50,7 @@ module Spree
|
|
|
56
50
|
# Perhaps we should add a reimbursement new page of some sort.
|
|
57
51
|
def render_after_create_error
|
|
58
52
|
flash.keep
|
|
59
|
-
|
|
60
|
-
redirect_to request.referer
|
|
61
|
-
else
|
|
62
|
-
redirect_to admin_url
|
|
63
|
-
end
|
|
53
|
+
redirect_to request.referer || admin_url
|
|
64
54
|
end
|
|
65
55
|
|
|
66
56
|
def load_stock_locations
|
|
@@ -62,7 +62,7 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
|
|
|
62
62
|
flash[:success] = flash_message_for(@object, :successfully_created)
|
|
63
63
|
respond_with(@object) do |format|
|
|
64
64
|
format.html { redirect_to location_after_save }
|
|
65
|
-
format.js
|
|
65
|
+
format.js { render layout: false }
|
|
66
66
|
end
|
|
67
67
|
else
|
|
68
68
|
invoke_callbacks(:create, :fails)
|
|
@@ -112,7 +112,7 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
|
|
|
112
112
|
flash[:success] = flash_message_for(@object, :successfully_removed)
|
|
113
113
|
respond_with(@object) do |format|
|
|
114
114
|
format.html { redirect_to location_after_destroy }
|
|
115
|
-
format.js
|
|
115
|
+
format.js { render partial: "spree/admin/shared/destroy" }
|
|
116
116
|
end
|
|
117
117
|
else
|
|
118
118
|
invoke_callbacks(:destroy, :fails)
|
|
@@ -152,7 +152,7 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
|
|
|
152
152
|
end
|
|
153
153
|
|
|
154
154
|
def parent_model_name
|
|
155
|
-
self.class.parent_data[:model_name].gsub(
|
|
155
|
+
self.class.parent_data[:model_name].gsub("spree/", "")
|
|
156
156
|
end
|
|
157
157
|
|
|
158
158
|
def object_name
|
|
@@ -189,8 +189,8 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
|
|
|
189
189
|
|
|
190
190
|
def parent
|
|
191
191
|
@parent ||= self.class.parent_data[:model_class]
|
|
192
|
-
|
|
193
|
-
|
|
192
|
+
.includes(self.class.parent_data[:includes])
|
|
193
|
+
.find_by!(self.class.parent_data[:find_by] => params["#{parent_model_name}_id"])
|
|
194
194
|
instance_variable_set("@#{parent_model_name}", @parent)
|
|
195
195
|
rescue ActiveRecord::RecordNotFound => e
|
|
196
196
|
resource_not_found(flash_class: e.model.constantize, redirect_url: routes_proxy.polymorphic_url([:admin, parent_model_name.pluralize.to_sym]))
|
|
@@ -253,7 +253,7 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
|
|
|
253
253
|
end
|
|
254
254
|
|
|
255
255
|
def object_url(object = nil, options = {})
|
|
256
|
-
target = object
|
|
256
|
+
target = object || @object
|
|
257
257
|
|
|
258
258
|
if parent?
|
|
259
259
|
routes_proxy.polymorphic_url([:admin, parent, target], options)
|
|
@@ -274,25 +274,11 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
|
|
|
274
274
|
spree
|
|
275
275
|
end
|
|
276
276
|
|
|
277
|
-
#
|
|
278
|
-
# attributes.
|
|
277
|
+
# Allow all attributes to be updatable.
|
|
279
278
|
#
|
|
280
|
-
#
|
|
281
|
-
# That legacy behaviour is preserved here behind a configuration flag. We
|
|
282
|
-
# strongly recommend disabling the flag and implementing this method in your
|
|
283
|
-
# controller to explicitly permit only the attributes you want to allow.
|
|
279
|
+
# Other controllers can, should, override it to set custom logic
|
|
284
280
|
def permitted_resource_params
|
|
285
|
-
|
|
286
|
-
Spree.deprecator.warn(
|
|
287
|
-
"Using `permit_all_resource_params_fallback` is not safe and will be " \
|
|
288
|
-
"removed in a future version of Solidus. Please implement " \
|
|
289
|
-
"`permitted_resource_params` in your controller to explicitly permit only " \
|
|
290
|
-
"the attributes you want to allow."
|
|
291
|
-
)
|
|
292
|
-
params[object_name].present? ? params.require(object_name).permit! : ActionController::Parameters.new.permit!
|
|
293
|
-
else
|
|
294
|
-
raise NotImplementedError, "You must implement permitted_resource_params in your controller"
|
|
295
|
-
end
|
|
281
|
+
params[object_name].present? ? params.require(object_name).permit! : ActionController::Parameters.new.permit!
|
|
296
282
|
end
|
|
297
283
|
|
|
298
284
|
def collection_actions
|
|
@@ -308,11 +294,11 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
|
|
|
308
294
|
end
|
|
309
295
|
|
|
310
296
|
def render_after_create_error
|
|
311
|
-
render action:
|
|
297
|
+
render action: "new"
|
|
312
298
|
end
|
|
313
299
|
|
|
314
300
|
def render_after_update_error
|
|
315
|
-
render action:
|
|
301
|
+
render action: "edit"
|
|
316
302
|
end
|
|
317
303
|
|
|
318
304
|
def resource_invalid(exception)
|
|
@@ -3,41 +3,29 @@
|
|
|
3
3
|
module Spree
|
|
4
4
|
module Admin
|
|
5
5
|
class ReturnAuthorizationsController < ResourceController
|
|
6
|
-
belongs_to
|
|
6
|
+
belongs_to "spree/order", find_by: :number
|
|
7
7
|
|
|
8
8
|
before_action :load_form_data, only: [:new, :edit]
|
|
9
|
-
create.fails
|
|
10
|
-
update.fails
|
|
9
|
+
create.fails :load_form_data
|
|
10
|
+
update.fails :load_form_data
|
|
11
11
|
|
|
12
12
|
def fire
|
|
13
13
|
action_from_params = "#{params[:e]}!"
|
|
14
14
|
|
|
15
|
-
if @return_authorization.state_events.include?(params[:e].to_sym) &&
|
|
16
|
-
|
|
15
|
+
flash_message = if @return_authorization.state_events.include?(params[:e].to_sym) &&
|
|
16
|
+
@return_authorization.send(action_from_params)
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
{success: t("spree.return_authorization_updated")}
|
|
19
19
|
else
|
|
20
|
-
|
|
20
|
+
{error: t("spree.return_authorization_fire_error")}
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
redirect_back(fallback_location: admin_order_return_authorizations_path(@order),
|
|
24
|
-
|
|
24
|
+
flash: flash_message)
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
private
|
|
28
28
|
|
|
29
|
-
def permitted_resource_params
|
|
30
|
-
attributes = permitted_return_authorization_attributes.map do |attribute|
|
|
31
|
-
next attribute unless attribute.is_a?(Hash) && attribute.key?(:return_items_attributes)
|
|
32
|
-
|
|
33
|
-
attribute.except(:customer_metadata).merge(
|
|
34
|
-
return_items_attributes: [:id, :_destroy, :amount, *attribute[:return_items_attributes]]
|
|
35
|
-
)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
params.require(:return_authorization).permit(attributes)
|
|
39
|
-
end
|
|
40
|
-
|
|
41
29
|
def load_form_data
|
|
42
30
|
load_return_items
|
|
43
31
|
load_reimbursement_types
|
|
@@ -53,9 +41,9 @@ module Spree
|
|
|
53
41
|
unassociated_inventory_units = all_inventory_units - associated_inventory_units
|
|
54
42
|
|
|
55
43
|
unassociated_inventory_units.each do |new_unit|
|
|
56
|
-
@return_authorization.return_items
|
|
57
|
-
build(inventory_unit: new_unit)
|
|
58
|
-
tap(&:set_default_amount)
|
|
44
|
+
@return_authorization.return_items
|
|
45
|
+
.build(inventory_unit: new_unit)
|
|
46
|
+
.tap(&:set_default_amount)
|
|
59
47
|
end
|
|
60
48
|
|
|
61
49
|
@form_return_items = @return_authorization.return_items.sort_by(&:inventory_unit_id)
|
|
@@ -5,17 +5,13 @@ module Spree
|
|
|
5
5
|
class ReturnItemsController < ResourceController
|
|
6
6
|
private
|
|
7
7
|
|
|
8
|
-
def permitted_resource_params
|
|
9
|
-
params.require(:return_item).permit(:acceptance_status, :reception_status_event)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
8
|
def location_after_save
|
|
13
9
|
url_for([:edit, :admin, @return_item.customer_return.order, @return_item.customer_return])
|
|
14
10
|
end
|
|
15
11
|
|
|
16
12
|
def render_after_update_error
|
|
17
13
|
redirect_back(fallback_location: location_after_save,
|
|
18
|
-
|
|
14
|
+
flash: {error: @object.errors.full_messages.join(", ")})
|
|
19
15
|
end
|
|
20
16
|
end
|
|
21
17
|
end
|
|
@@ -9,12 +9,12 @@ module Spree
|
|
|
9
9
|
# TODO: Clean this up by moving searching out to user_class_extensions
|
|
10
10
|
# And then JSON building with something like Active Model Serializers
|
|
11
11
|
def users
|
|
12
|
-
if params[:ids]
|
|
12
|
+
@users = if params[:ids]
|
|
13
13
|
# split here may be String#split or Array#split, so we must flatten the results
|
|
14
|
-
|
|
14
|
+
Spree.user_class.where(id: params[:ids].split(",").flatten)
|
|
15
15
|
else
|
|
16
|
-
|
|
17
|
-
m:
|
|
16
|
+
Spree.user_class.ransack({
|
|
17
|
+
m: "or",
|
|
18
18
|
email_start: params[:q],
|
|
19
19
|
name_start: params[:q]
|
|
20
20
|
}).result.limit(10)
|
|
@@ -22,14 +22,16 @@ module Spree
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def products
|
|
25
|
-
if params[:ids]
|
|
25
|
+
@products = if params[:ids]
|
|
26
26
|
# split here may be String#split or Array#split, so we must flatten the results
|
|
27
|
-
|
|
27
|
+
Spree::Product.where(id: params[:ids].split(",").flatten)
|
|
28
28
|
else
|
|
29
|
-
|
|
29
|
+
Spree::Product.ransack(params[:q]).result
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
@products = list_products
|
|
33
|
+
expires_in 15.minutes, public: true
|
|
34
|
+
headers["Surrogate-Control"] = "max-age=#{15.minutes}"
|
|
33
35
|
end
|
|
34
36
|
|
|
35
37
|
private
|
|
@@ -20,22 +20,6 @@ module Spree
|
|
|
20
20
|
|
|
21
21
|
private
|
|
22
22
|
|
|
23
|
-
def permitted_resource_params
|
|
24
|
-
params.require(:shipping_method).permit(
|
|
25
|
-
:name, :admin_name, :code, :carrier, :service_level, :tracking_url,
|
|
26
|
-
:available_to_all, :available_to_users, :tax_category_id, :calculator_type,
|
|
27
|
-
store_ids: [],
|
|
28
|
-
stock_location_ids: [],
|
|
29
|
-
calculator_attributes: [:id, *calculator_attributes]
|
|
30
|
-
)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def calculator_attributes
|
|
34
|
-
@calculators.flat_map do |calculator_class|
|
|
35
|
-
calculator_class.permitted_preference_attributes
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
23
|
def set_shipping_category
|
|
40
24
|
return true if params["shipping_method"][:shipping_categories] == ""
|
|
41
25
|
@shipping_method.shipping_categories = Spree::ShippingCategory.where(id: params["shipping_method"][:shipping_categories])
|
|
@@ -5,8 +5,8 @@ module Spree
|
|
|
5
5
|
class StockItemsController < ResourceController
|
|
6
6
|
class_attribute :variant_display_attributes
|
|
7
7
|
self.variant_display_attributes = [
|
|
8
|
-
{
|
|
9
|
-
{
|
|
8
|
+
{translation_key: :sku, attr_name: :sku},
|
|
9
|
+
{translation_key: :name, attr_name: :name}
|
|
10
10
|
]
|
|
11
11
|
|
|
12
12
|
update.before :determine_backorderable
|
|
@@ -46,11 +46,11 @@ module Spree
|
|
|
46
46
|
:@stock_locations,
|
|
47
47
|
:stock_item_stock_locations,
|
|
48
48
|
Spree.deprecator,
|
|
49
|
-
"Please, do not use @stock_item_stock_locations anymore in the views, use @stock_locations"
|
|
49
|
+
"Please, do not use @stock_item_stock_locations anymore in the views, use @stock_locations"
|
|
50
50
|
)
|
|
51
51
|
@variant_display_attributes = self.class.variant_display_attributes
|
|
52
|
-
@variants = Spree::Config.variant_search_class.new(params[:variant_search_term], scope: variant_scope).results
|
|
53
|
-
|
|
52
|
+
@variants = Spree::Config.variant_search_class.new(params[:variant_search_term], scope: variant_scope).results
|
|
53
|
+
.order(id: :desc).page(params[:page]).per(params[:per_page] || Spree::Config[:orders_per_page])
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
def variant_scope
|
|
@@ -7,17 +7,10 @@ module Spree
|
|
|
7
7
|
|
|
8
8
|
private
|
|
9
9
|
|
|
10
|
-
def permitted_resource_params
|
|
11
|
-
params.require(:stock_location).permit(
|
|
12
|
-
*permitted_stock_location_attributes,
|
|
13
|
-
:code, :admin_name, :default, :restock_inventory, :fulfillable, :check_stock_on_transfer
|
|
14
|
-
)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
10
|
def set_country
|
|
18
11
|
@stock_location.country = Spree::Country.default
|
|
19
12
|
rescue ActiveRecord::RecordNotFound
|
|
20
|
-
flash[:error] = t(
|
|
13
|
+
flash[:error] = t("spree.stock_locations_need_a_default_country")
|
|
21
14
|
redirect_to(admin_stock_locations_path) && return
|
|
22
15
|
end
|
|
23
16
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module Spree
|
|
4
4
|
module Admin
|
|
5
5
|
class StockMovementsController < ResourceController
|
|
6
|
-
belongs_to
|
|
6
|
+
belongs_to "spree/stock_location"
|
|
7
7
|
before_action :parent
|
|
8
8
|
|
|
9
9
|
def index
|
|
@@ -20,10 +20,10 @@ module Spree
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def collection
|
|
23
|
-
super
|
|
24
|
-
recent
|
|
25
|
-
includes(stock_item: {
|
|
26
|
-
page(params[:page])
|
|
23
|
+
super
|
|
24
|
+
.recent
|
|
25
|
+
.includes(stock_item: {variant: :product})
|
|
26
|
+
.page(params[:page])
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
end
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module Spree
|
|
4
4
|
module Admin
|
|
5
5
|
class StoreCreditsController < ResourceController
|
|
6
|
-
belongs_to
|
|
6
|
+
belongs_to "spree/user", model_class: Spree.user_class
|
|
7
7
|
before_action :load_categories, only: [:new]
|
|
8
8
|
before_action :load_reasons, only: [:edit_amount, :edit_validity]
|
|
9
9
|
before_action :ensure_store_credit_reason, only: [:update_amount, :invalidate]
|
|
@@ -27,7 +27,7 @@ module Spree
|
|
|
27
27
|
redirect_to admin_user_store_credits_path(@user)
|
|
28
28
|
else
|
|
29
29
|
load_categories
|
|
30
|
-
flash[:error] = "#{t(
|
|
30
|
+
flash[:error] = "#{t("spree.admin.store_credits.unable_to_create")} #{@store_credit.errors.full_messages}"
|
|
31
31
|
render :new
|
|
32
32
|
end
|
|
33
33
|
end
|
|
@@ -38,11 +38,11 @@ module Spree
|
|
|
38
38
|
|
|
39
39
|
if @store_credit.save
|
|
40
40
|
respond_to do |format|
|
|
41
|
-
format.json { render json: {
|
|
41
|
+
format.json { render json: {message: flash_message_for(@store_credit, :successfully_updated)}, status: :ok }
|
|
42
42
|
end
|
|
43
43
|
else
|
|
44
44
|
respond_to do |format|
|
|
45
|
-
format.json { render json: {
|
|
45
|
+
format.json { render json: {message: "#{t("spree.admin.store_credits.unable_to_update")} #{@store_credit.errors.full_messages}"}, status: :bad_request }
|
|
46
46
|
end
|
|
47
47
|
end
|
|
48
48
|
end
|
|
@@ -70,8 +70,8 @@ module Spree
|
|
|
70
70
|
private
|
|
71
71
|
|
|
72
72
|
def permitted_resource_params
|
|
73
|
-
params.require(:store_credit).permit([:amount, :currency, :category_id, :memo])
|
|
74
|
-
merge(created_by: spree_current_user)
|
|
73
|
+
params.require(:store_credit).permit([:amount, :currency, :category_id, :memo])
|
|
74
|
+
.merge(created_by: spree_current_user)
|
|
75
75
|
end
|
|
76
76
|
|
|
77
77
|
def collection
|
|
@@ -89,7 +89,7 @@ module Spree
|
|
|
89
89
|
def ensure_store_credit_reason
|
|
90
90
|
@store_credit_reason = Spree::StoreCreditReason.find_by(id: params[:store_credit_reason_id])
|
|
91
91
|
unless @store_credit_reason
|
|
92
|
-
@store_credit.errors.add(:base, t(
|
|
92
|
+
@store_credit.errors.add(:base, t("spree.admin.store_credits.errors.store_credit_reason_required"))
|
|
93
93
|
render_edit_page
|
|
94
94
|
end
|
|
95
95
|
end
|
|
@@ -97,14 +97,14 @@ module Spree
|
|
|
97
97
|
def render_edit_page
|
|
98
98
|
if action == :update_amount
|
|
99
99
|
template = :edit_amount
|
|
100
|
-
translation_key =
|
|
100
|
+
translation_key = "update"
|
|
101
101
|
else
|
|
102
102
|
template = :edit_validity
|
|
103
|
-
translation_key =
|
|
103
|
+
translation_key = "invalidate"
|
|
104
104
|
end
|
|
105
105
|
|
|
106
106
|
load_reasons
|
|
107
|
-
flash[:error] = "#{t("spree.admin.store_credits.unable_to_#{translation_key}")}: #{@store_credit.errors.full_messages.join(
|
|
107
|
+
flash[:error] = "#{t("spree.admin.store_credits.unable_to_#{translation_key}")}: #{@store_credit.errors.full_messages.join(", ")}"
|
|
108
108
|
render(template) && return
|
|
109
109
|
end
|
|
110
110
|
|
|
@@ -13,19 +13,12 @@ module Spree
|
|
|
13
13
|
|
|
14
14
|
private
|
|
15
15
|
|
|
16
|
-
def
|
|
17
|
-
|
|
18
|
-
without_address_parameters = permitted[:address_attributes]&.except(:country_id, :state_id, :reverse_charge_status)&.compact_blank&.empty?
|
|
19
|
-
permitted.delete(:address_attributes) if without_address_parameters
|
|
20
|
-
end
|
|
16
|
+
def store_params
|
|
17
|
+
params.require(:store).permit(permitted_params)
|
|
21
18
|
end
|
|
22
19
|
|
|
23
|
-
def
|
|
24
|
-
|
|
25
|
-
*permitted_store_attributes,
|
|
26
|
-
:code,
|
|
27
|
-
available_locales: []
|
|
28
|
-
)
|
|
20
|
+
def permitted_params
|
|
21
|
+
Spree::PermittedAttributes.store_attributes
|
|
29
22
|
end
|
|
30
23
|
end
|
|
31
24
|
end
|