solidus_backend 4.6.2 → 4.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +17 -17
- data/app/assets/images/spree/backend/themes/solidus_admin/remixicon.license.txt +222 -0
- 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/adjustments_controller.rb +1 -1
- 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 -2
- data/app/controllers/spree/admin/locale_controller.rb +4 -4
- data/app/controllers/spree/admin/option_types_controller.rb +1 -1
- 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 +3 -3
- data/app/controllers/spree/admin/payments_controller.rb +12 -10
- data/app/controllers/spree/admin/prices_controller.rb +1 -1
- data/app/controllers/spree/admin/product_properties_controller.rb +1 -1
- data/app/controllers/spree/admin/products_controller.rb +14 -14
- data/app/controllers/spree/admin/properties_controller.rb +3 -3
- data/app/controllers/spree/admin/refunds_controller.rb +2 -2
- data/app/controllers/spree/admin/reimbursements_controller.rb +4 -8
- data/app/controllers/spree/admin/resource_controller.rb +10 -10
- data/app/controllers/spree/admin/return_authorizations_controller.rb +14 -11
- data/app/controllers/spree/admin/return_items_controller.rb +1 -1
- data/app/controllers/spree/admin/search_controller.rb +8 -8
- data/app/controllers/spree/admin/stock_items_controller.rb +5 -5
- data/app/controllers/spree/admin/stock_locations_controller.rb +1 -1
- data/app/controllers/spree/admin/stock_movements_controller.rb +5 -5
- data/app/controllers/spree/admin/store_credits_controller.rb +10 -10
- data/app/controllers/spree/admin/style_guide_controller.rb +19 -19
- 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 -8
- 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/orders/_shipment.html.erb +1 -0
- 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 -46
- data/lib/spree_backend.rb +1 -1
- data/solidus_backend.gemspec +22 -21
- data/vendor/assets/fonts/inter/inter.license.txt +97 -0
- data/vendor/assets/javascripts/solidus_admin/backbone-nested-models.license.txt +29 -0
- data/vendor/assets/javascripts/solidus_admin/bind-polyfill.license.txt +9 -0
- data/vendor/assets/javascripts/solidus_admin/flatpickr/flatpickr.license.txt +244 -0
- data/vendor/assets/javascripts/solidus_admin/select2.license.txt +226 -0
- metadata +32 -12
|
@@ -16,10 +16,10 @@ module Spree
|
|
|
16
16
|
|
|
17
17
|
def index
|
|
18
18
|
params[:q] ||= {}
|
|
19
|
-
params[:q][:completed_at_not_null] ||=
|
|
20
|
-
@show_only_completed = params[:q][:completed_at_not_null] ==
|
|
21
|
-
params[:q][:s] ||= @show_only_completed ?
|
|
22
|
-
params[:q][:completed_at_not_null] =
|
|
19
|
+
params[:q][:completed_at_not_null] ||= "1" if Spree::Config[:show_only_complete_orders_by_default]
|
|
20
|
+
@show_only_completed = params[:q][:completed_at_not_null] == "1"
|
|
21
|
+
params[:q][:s] ||= @show_only_completed ? "completed_at desc" : "created_at desc"
|
|
22
|
+
params[:q][:completed_at_not_null] = "" unless @show_only_completed
|
|
23
23
|
|
|
24
24
|
# As date params are deleted if @show_only_completed, store
|
|
25
25
|
# the original date so we can restore them into the params
|
|
@@ -31,18 +31,18 @@ module Spree
|
|
|
31
31
|
|
|
32
32
|
if params[:q][:created_at_gt].present?
|
|
33
33
|
params[:q][:created_at_gt] = begin
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
Time.zone.parse(params[:q][:created_at_gt]).beginning_of_day
|
|
35
|
+
rescue
|
|
36
|
+
""
|
|
37
|
+
end
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
if params[:q][:created_at_lt].present?
|
|
41
41
|
params[:q][:created_at_lt] = begin
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
Time.zone.parse(params[:q][:created_at_lt]).end_of_day
|
|
43
|
+
rescue
|
|
44
|
+
""
|
|
45
|
+
end
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
if @show_only_completed
|
|
@@ -51,9 +51,9 @@ module Spree
|
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
@search = Spree::Order.accessible_by(current_ability, :index).ransack(params[:q])
|
|
54
|
-
@orders = @search.result.includes([:user])
|
|
55
|
-
page(params[:page])
|
|
56
|
-
per(params[:per_page] || Spree::Config[:orders_per_page])
|
|
54
|
+
@orders = @search.result.includes([:user])
|
|
55
|
+
.page(params[:page])
|
|
56
|
+
.per(params[:per_page] || Spree::Config[:orders_per_page])
|
|
57
57
|
|
|
58
58
|
# Restore dates
|
|
59
59
|
params[:q][:created_at_gt] = created_at_gt
|
|
@@ -82,15 +82,15 @@ module Spree
|
|
|
82
82
|
|
|
83
83
|
def advance
|
|
84
84
|
if @order.completed?
|
|
85
|
-
flash[:notice] = t(
|
|
85
|
+
flash[:notice] = t("spree.order_already_completed")
|
|
86
86
|
redirect_to edit_admin_order_url(@order)
|
|
87
87
|
else
|
|
88
88
|
@order.contents.advance
|
|
89
89
|
|
|
90
90
|
if @order.can_complete?
|
|
91
|
-
flash[:success] = t(
|
|
91
|
+
flash[:success] = t("spree.order_ready_for_confirm")
|
|
92
92
|
else
|
|
93
|
-
flash[:error] = @order.errors.full_messages.join(
|
|
93
|
+
flash[:error] = @order.errors.full_messages.join(", ")
|
|
94
94
|
end
|
|
95
95
|
redirect_to confirm_admin_order_url(@order)
|
|
96
96
|
end
|
|
@@ -101,14 +101,14 @@ module Spree
|
|
|
101
101
|
if @order.completed?
|
|
102
102
|
redirect_to edit_admin_order_url(@order)
|
|
103
103
|
elsif !@order.can_complete?
|
|
104
|
-
render template:
|
|
104
|
+
render template: "spree/admin/orders/confirm_advance"
|
|
105
105
|
end
|
|
106
106
|
end
|
|
107
107
|
|
|
108
108
|
# PUT
|
|
109
109
|
def complete
|
|
110
110
|
@order.complete!
|
|
111
|
-
flash[:success] = t(
|
|
111
|
+
flash[:success] = t("spree.order_completed")
|
|
112
112
|
redirect_to edit_admin_order_url(@order)
|
|
113
113
|
rescue StateMachines::InvalidTransition => error
|
|
114
114
|
flash[:error] = error.message
|
|
@@ -117,25 +117,25 @@ module Spree
|
|
|
117
117
|
|
|
118
118
|
def cancel
|
|
119
119
|
@order.canceled_by(spree_current_user)
|
|
120
|
-
flash[:success] = t(
|
|
120
|
+
flash[:success] = t("spree.order_canceled")
|
|
121
121
|
redirect_to(spree.edit_admin_order_path(@order))
|
|
122
122
|
end
|
|
123
123
|
|
|
124
124
|
def resume
|
|
125
125
|
@order.resume!
|
|
126
|
-
flash[:success] = t(
|
|
126
|
+
flash[:success] = t("spree.order_resumed")
|
|
127
127
|
redirect_to(spree.edit_admin_order_path(@order))
|
|
128
128
|
end
|
|
129
129
|
|
|
130
130
|
def approve
|
|
131
131
|
@order.contents.approve(user: spree_current_user)
|
|
132
|
-
flash[:success] = t(
|
|
132
|
+
flash[:success] = t("spree.order_approved")
|
|
133
133
|
redirect_to(spree.edit_admin_order_path(@order))
|
|
134
134
|
end
|
|
135
135
|
|
|
136
136
|
def resend
|
|
137
137
|
Spree::Config.order_mailer_class.confirm_email(@order, true).deliver_later
|
|
138
|
-
flash[:success] = t(
|
|
138
|
+
flash[:success] = t("spree.order_email_resent")
|
|
139
139
|
|
|
140
140
|
redirect_to(spree.edit_admin_order_path(@order))
|
|
141
141
|
end
|
|
@@ -143,7 +143,7 @@ module Spree
|
|
|
143
143
|
def unfinalize_adjustments
|
|
144
144
|
adjustments = @order.all_adjustments.finalized
|
|
145
145
|
adjustments.each(&:unfinalize!)
|
|
146
|
-
flash[:success] = t(
|
|
146
|
+
flash[:success] = t("spree.all_adjustments_unfinalized")
|
|
147
147
|
|
|
148
148
|
respond_with(@order) { |format| format.html { redirect_to(spree.admin_order_adjustments_path(@order)) } }
|
|
149
149
|
end
|
|
@@ -151,7 +151,7 @@ module Spree
|
|
|
151
151
|
def finalize_adjustments
|
|
152
152
|
adjustments = @order.all_adjustments.not_finalized
|
|
153
153
|
adjustments.each(&:finalize!)
|
|
154
|
-
flash[:success] = t(
|
|
154
|
+
flash[:success] = t("spree.all_adjustments_finalized")
|
|
155
155
|
|
|
156
156
|
respond_with(@order) { |format| format.html { redirect_to(spree.admin_order_adjustments_path(@order)) } }
|
|
157
157
|
end
|
|
@@ -175,7 +175,7 @@ module Spree
|
|
|
175
175
|
|
|
176
176
|
# Used for extensions which need to provide their own custom event links on the order details view.
|
|
177
177
|
def initialize_order_events
|
|
178
|
-
@order_events = %w
|
|
178
|
+
@order_events = %w[approve cancel resume]
|
|
179
179
|
end
|
|
180
180
|
|
|
181
181
|
def model_class
|
|
@@ -183,13 +183,13 @@ module Spree
|
|
|
183
183
|
end
|
|
184
184
|
|
|
185
185
|
def insufficient_stock_error
|
|
186
|
-
flash[:error] = t(
|
|
186
|
+
flash[:error] = t("spree.insufficient_stock_for_order")
|
|
187
187
|
redirect_to cart_admin_order_url(@order)
|
|
188
188
|
end
|
|
189
189
|
|
|
190
190
|
def require_ship_address
|
|
191
191
|
if @order.ship_address.nil?
|
|
192
|
-
flash[:notice] = t(
|
|
192
|
+
flash[:notice] = t("spree.fill_in_customer_info")
|
|
193
193
|
redirect_to edit_admin_order_customer_url(@order)
|
|
194
194
|
end
|
|
195
195
|
end
|
|
@@ -15,7 +15,7 @@ module Spree
|
|
|
15
15
|
invoke_callbacks(:create, :before)
|
|
16
16
|
if @payment_method.save
|
|
17
17
|
invoke_callbacks(:create, :after)
|
|
18
|
-
flash[:success] = t(
|
|
18
|
+
flash[:success] = t("spree.successfully_created", resource: t("spree.payment_method"))
|
|
19
19
|
redirect_to edit_admin_payment_method_path(@payment_method)
|
|
20
20
|
else
|
|
21
21
|
invoke_callbacks(:create, :fails)
|
|
@@ -36,7 +36,7 @@ module Spree
|
|
|
36
36
|
|
|
37
37
|
if @payment_method.update(attributes)
|
|
38
38
|
invoke_callbacks(:update, :after)
|
|
39
|
-
flash[:success] = t(
|
|
39
|
+
flash[:success] = t("spree.successfully_updated", resource: t("spree.payment_method"))
|
|
40
40
|
redirect_to edit_admin_payment_method_path(@payment_method)
|
|
41
41
|
else
|
|
42
42
|
invoke_callbacks(:update, :fails)
|
|
@@ -61,7 +61,7 @@ module Spree
|
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
if !@payment_method_type
|
|
64
|
-
flash[:error] = t(
|
|
64
|
+
flash[:error] = t("spree.invalid_payment_method_type")
|
|
65
65
|
redirect_to new_admin_payment_method_path
|
|
66
66
|
end
|
|
67
67
|
end
|
|
@@ -27,7 +27,7 @@ module Spree
|
|
|
27
27
|
|
|
28
28
|
def create
|
|
29
29
|
@payment = PaymentCreate.new(@order, object_params).build
|
|
30
|
-
if @payment.payment_method.source_required? && params[:card].present? && params[:card] !=
|
|
30
|
+
if @payment.payment_method.source_required? && params[:card].present? && params[:card] != "new"
|
|
31
31
|
@payment.source = @payment.payment_method.payment_source_class.find_by(id: params[:card])
|
|
32
32
|
end
|
|
33
33
|
|
|
@@ -45,7 +45,7 @@ module Spree
|
|
|
45
45
|
flash[:success] = flash_message_for(@payment, :successfully_created)
|
|
46
46
|
redirect_to admin_order_payments_path(@order)
|
|
47
47
|
else
|
|
48
|
-
flash[:error] = t(
|
|
48
|
+
flash[:error] = t("spree.payment_could_not_be_created")
|
|
49
49
|
render :new
|
|
50
50
|
end
|
|
51
51
|
rescue Spree::Core::GatewayError => error
|
|
@@ -60,9 +60,9 @@ module Spree
|
|
|
60
60
|
# Because we have a transition method also called void, we do this to avoid conflicts.
|
|
61
61
|
event = "void_transaction" if event == "void"
|
|
62
62
|
if @payment.send("#{event}!")
|
|
63
|
-
flash[:success] = t(
|
|
63
|
+
flash[:success] = t("spree.payment_updated")
|
|
64
64
|
else
|
|
65
|
-
flash[:error] = t(
|
|
65
|
+
flash[:error] = t("spree.cannot_perform_operation")
|
|
66
66
|
end
|
|
67
67
|
rescue Spree::Core::GatewayError => ge
|
|
68
68
|
flash[:error] = ge.message.to_s
|
|
@@ -77,16 +77,18 @@ module Spree
|
|
|
77
77
|
params[:payment][:source_attributes] = source_params
|
|
78
78
|
end
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
# Admins are allowed to set the amount of a payment, so we need to
|
|
81
|
+
# permit it here. This is not permitted for non-admin users.
|
|
82
|
+
params.require(:payment).permit(permitted_payment_attributes + [:amount])
|
|
81
83
|
end
|
|
82
84
|
|
|
83
85
|
def load_data
|
|
84
86
|
@amount = params[:amount] || load_order.total
|
|
85
87
|
@payment_methods = Spree::PaymentMethod.active.available_to_admin.ordered_by_position
|
|
86
|
-
|
|
87
|
-
@
|
|
88
|
+
@payment_method = if @payment&.payment_method
|
|
89
|
+
@payment.payment_method
|
|
88
90
|
else
|
|
89
|
-
@
|
|
91
|
+
@payment_methods.first
|
|
90
92
|
end
|
|
91
93
|
end
|
|
92
94
|
|
|
@@ -113,13 +115,13 @@ module Spree
|
|
|
113
115
|
|
|
114
116
|
def require_bill_address
|
|
115
117
|
if Spree::Config[:order_bill_address_used] && @order.bill_address.nil?
|
|
116
|
-
flash[:notice] = t(
|
|
118
|
+
flash[:notice] = t("spree.fill_in_customer_info")
|
|
117
119
|
redirect_to edit_admin_order_customer_url(@order)
|
|
118
120
|
end
|
|
119
121
|
end
|
|
120
122
|
|
|
121
123
|
def insufficient_stock_error
|
|
122
|
-
flash[:error] = t(
|
|
124
|
+
flash[:error] = t("spree.insufficient_stock_for_order")
|
|
123
125
|
redirect_to new_admin_order_payment_url(@order)
|
|
124
126
|
end
|
|
125
127
|
end
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module Spree
|
|
4
4
|
module Admin
|
|
5
5
|
class ProductPropertiesController < ResourceController
|
|
6
|
-
belongs_to
|
|
6
|
+
belongs_to "spree/product", find_by: :slug, includes: {product_properties: :property}
|
|
7
7
|
before_action :find_properties
|
|
8
8
|
before_action :setup_property, only: :index, if: -> { can?(:create, model_class) }
|
|
9
9
|
before_action :setup_variant_property_rules, only: :index
|
|
@@ -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)
|
|
@@ -53,10 +53,10 @@ module Spree
|
|
|
53
53
|
|
|
54
54
|
def split_params
|
|
55
55
|
if params[:product][:taxon_ids].present?
|
|
56
|
-
params[:product][:taxon_ids] = params[:product][:taxon_ids].split(
|
|
56
|
+
params[:product][:taxon_ids] = params[:product][:taxon_ids].split(",")
|
|
57
57
|
end
|
|
58
58
|
if params[:product][:option_type_ids].present?
|
|
59
|
-
params[:product][:option_type_ids] = params[:product][:option_type_ids].split(
|
|
59
|
+
params[:product][:option_type_ids] = params[:product][:option_type_ids].split(",")
|
|
60
60
|
end
|
|
61
61
|
end
|
|
62
62
|
|
|
@@ -89,11 +89,11 @@ module Spree
|
|
|
89
89
|
params[:q][:s] ||= "name asc"
|
|
90
90
|
# @search needs to be defined as this is passed to search_form_for
|
|
91
91
|
@search = super.ransack(params[:q])
|
|
92
|
-
@collection = @search.result
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
92
|
+
@collection = @search.result
|
|
93
|
+
.order(id: :asc)
|
|
94
|
+
.includes(product_includes)
|
|
95
|
+
.page(params[:page])
|
|
96
|
+
.per(Spree::Config[:admin_products_per_page])
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
def update_before
|
|
@@ -104,7 +104,7 @@ module Spree
|
|
|
104
104
|
end
|
|
105
105
|
|
|
106
106
|
def product_includes
|
|
107
|
-
[:variant_images, {
|
|
107
|
+
[:variant_images, {variants: [:images], master: [:images, :prices]}]
|
|
108
108
|
end
|
|
109
109
|
|
|
110
110
|
def clone_object_url(resource)
|
|
@@ -127,14 +127,14 @@ module Spree
|
|
|
127
127
|
# Stops people submitting blank slugs, causing errors when they try to
|
|
128
128
|
# update the product again
|
|
129
129
|
@product.slug = @product.slug_was if @product.slug.blank?
|
|
130
|
-
render action:
|
|
130
|
+
render action: "edit"
|
|
131
131
|
end
|
|
132
132
|
|
|
133
133
|
def normalize_variant_property_rules
|
|
134
134
|
return unless updating_variant_property_rules?
|
|
135
135
|
|
|
136
136
|
params[:product][:variant_property_rules_attributes].each_value do |param_attrs|
|
|
137
|
-
param_attrs[:option_value_ids] = param_attrs[:option_value_ids].split(
|
|
137
|
+
param_attrs[:option_value_ids] = param_attrs[:option_value_ids].split(",")
|
|
138
138
|
end
|
|
139
139
|
end
|
|
140
140
|
end
|
|
@@ -16,9 +16,9 @@ module Spree
|
|
|
16
16
|
|
|
17
17
|
@collection = super
|
|
18
18
|
@search = @collection.ransack(params[:q])
|
|
19
|
-
@collection = @search.result
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
@collection = @search.result
|
|
20
|
+
.page(params[:page])
|
|
21
|
+
.per(Spree::Config[:properties_per_page])
|
|
22
22
|
|
|
23
23
|
@collection
|
|
24
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
|
|
@@ -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
|
|
@@ -50,11 +50,7 @@ module Spree
|
|
|
50
50
|
# Perhaps we should add a reimbursement new page of some sort.
|
|
51
51
|
def render_after_create_error
|
|
52
52
|
flash.keep
|
|
53
|
-
|
|
54
|
-
redirect_to request.referer
|
|
55
|
-
else
|
|
56
|
-
redirect_to admin_url
|
|
57
|
-
end
|
|
53
|
+
redirect_to request.referer || admin_url
|
|
58
54
|
end
|
|
59
55
|
|
|
60
56
|
def load_stock_locations
|
|
@@ -17,7 +17,7 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
|
|
|
17
17
|
respond_with(@object) do |format|
|
|
18
18
|
format.html { render layout: !request.xhr? }
|
|
19
19
|
if request.xhr?
|
|
20
|
-
format.js
|
|
20
|
+
format.js { render layout: false }
|
|
21
21
|
end
|
|
22
22
|
end
|
|
23
23
|
end
|
|
@@ -26,7 +26,7 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
|
|
|
26
26
|
respond_with(@object) do |format|
|
|
27
27
|
format.html { render layout: !request.xhr? }
|
|
28
28
|
if request.xhr?
|
|
29
|
-
format.js
|
|
29
|
+
format.js { render layout: false }
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
32
|
end
|
|
@@ -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)
|
|
@@ -294,11 +294,11 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
|
|
|
294
294
|
end
|
|
295
295
|
|
|
296
296
|
def render_after_create_error
|
|
297
|
-
render action:
|
|
297
|
+
render action: "new"
|
|
298
298
|
end
|
|
299
299
|
|
|
300
300
|
def render_after_update_error
|
|
301
|
-
render action:
|
|
301
|
+
render action: "edit"
|
|
302
302
|
end
|
|
303
303
|
|
|
304
304
|
def resource_invalid(exception)
|
|
@@ -3,25 +3,25 @@
|
|
|
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
|
|
@@ -40,10 +40,13 @@ module Spree
|
|
|
40
40
|
associated_inventory_units = @return_authorization.return_items.map(&:inventory_unit)
|
|
41
41
|
unassociated_inventory_units = all_inventory_units - associated_inventory_units
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
unassociated_inventory_units.each do |new_unit|
|
|
44
|
+
@return_authorization.return_items
|
|
45
|
+
.build(inventory_unit: new_unit)
|
|
46
|
+
.tap(&:set_default_amount)
|
|
45
47
|
end
|
|
46
|
-
|
|
48
|
+
|
|
49
|
+
@form_return_items = @return_authorization.return_items.sort_by(&:inventory_unit_id)
|
|
47
50
|
end
|
|
48
51
|
|
|
49
52
|
def load_reimbursement_types
|
|
@@ -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,16 +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
33
|
expires_in 15.minutes, public: true
|
|
34
|
-
headers[
|
|
34
|
+
headers["Surrogate-Control"] = "max-age=#{15.minutes}"
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
private
|
|
@@ -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
|
|
@@ -10,7 +10,7 @@ module Spree
|
|
|
10
10
|
def set_country
|
|
11
11
|
@stock_location.country = Spree::Country.default
|
|
12
12
|
rescue ActiveRecord::RecordNotFound
|
|
13
|
-
flash[:error] = t(
|
|
13
|
+
flash[:error] = t("spree.stock_locations_need_a_default_country")
|
|
14
14
|
redirect_to(admin_stock_locations_path) && return
|
|
15
15
|
end
|
|
16
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
|