solidus_backend 2.2.2 → 2.3.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of solidus_backend might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/assets/javascripts/spree/backend.js +1 -2
- data/app/assets/javascripts/spree/backend/address_states.js +1 -1
- data/app/assets/javascripts/spree/backend/adjustments.js.coffee +1 -1
- data/app/assets/javascripts/spree/backend/admin.js +37 -41
- data/app/assets/javascripts/spree/backend/components/editable_table.js.coffee +3 -0
- data/app/assets/javascripts/spree/backend/images/index.js.coffee +1 -1
- data/app/assets/javascripts/spree/backend/images/upload.js +13 -189
- data/app/assets/javascripts/spree/backend/models/image_upload.js +76 -0
- data/app/assets/javascripts/spree/backend/models/index.js +2 -0
- data/app/assets/javascripts/spree/backend/models/taxonomy.js +3 -0
- data/app/assets/javascripts/spree/backend/namespaces.js +3 -1
- data/app/assets/javascripts/spree/backend/payments/new.js +8 -36
- data/app/assets/javascripts/spree/backend/promotions.js.coffee +1 -1
- data/app/assets/javascripts/spree/backend/select_payments.js.coffee +0 -12
- data/app/assets/javascripts/spree/backend/shipments.js +1 -1
- data/app/assets/javascripts/spree/backend/spree-select2.js +1 -1
- data/app/assets/javascripts/spree/backend/taxonomy.js.coffee +101 -95
- data/app/assets/javascripts/spree/backend/templates/products/upload_progress.hbs +5 -3
- data/app/assets/javascripts/spree/backend/views/images/upload_progress.js +48 -0
- data/app/assets/javascripts/spree/backend/views/images/upload_zone.js +39 -0
- data/app/assets/javascripts/spree/backend/views/index.js +6 -0
- data/app/assets/javascripts/spree/backend/views/order/address.js +1 -5
- data/app/assets/javascripts/spree/backend/views/payment/edit_credit_card.js +23 -0
- data/app/assets/javascripts/spree/backend/views/payment/new.js +25 -0
- data/app/assets/javascripts/spree/backend/views/state_select.js +4 -4
- data/app/assets/javascripts/spree/backend/views/tables/editable_table.js.coffee +14 -0
- data/app/assets/javascripts/spree/backend/views/tables/editable_table_row.js.coffee +45 -0
- data/app/assets/stylesheets/spree/backend/components/_date-picker.scss +0 -1
- data/app/assets/stylesheets/spree/backend/components/_editable_table.scss +37 -0
- data/app/assets/stylesheets/spree/backend/plugins/_bootstrap_tooltip.scss +2 -2
- data/app/assets/stylesheets/spree/backend/sections/_products.scss +0 -8
- data/app/assets/stylesheets/spree/backend/sections/_style_guide.scss +15 -9
- data/app/assets/stylesheets/spree/backend/shared/_icons.scss +14 -14
- data/app/assets/stylesheets/spree/backend/shared/_tables.scss +1 -2
- data/app/assets/stylesheets/spree/backend/shared/_utilities.scss +13 -0
- data/app/assets/stylesheets/spree/backend/spree_admin.scss +1 -1
- data/app/controllers/spree/admin/cancellations_controller.rb +1 -1
- data/app/controllers/spree/admin/orders/customer_details_controller.rb +1 -1
- data/app/controllers/spree/admin/orders_controller.rb +3 -10
- data/app/controllers/spree/admin/payment_methods_controller.rb +19 -6
- data/app/controllers/spree/admin/payments_controller.rb +2 -2
- data/app/controllers/spree/admin/products_controller.rb +3 -9
- data/app/controllers/spree/admin/promotion_rules_controller.rb +5 -1
- data/app/controllers/spree/admin/promotions_controller.rb +1 -1
- data/app/controllers/spree/admin/properties_controller.rb +1 -1
- data/app/controllers/spree/admin/reports_controller.rb +24 -21
- data/app/controllers/spree/admin/resource_controller.rb +25 -14
- data/app/controllers/spree/admin/style_guide_controller.rb +4 -0
- data/app/controllers/spree/admin/users_controller.rb +1 -1
- data/app/controllers/spree/admin/variants_controller.rb +5 -0
- data/app/helpers/spree/admin/navigation_helper.rb +6 -2
- data/app/helpers/spree/promotion_rules_helper.rb +2 -2
- data/app/models/spree/backend_configuration.rb +1 -0
- data/app/views/spree/admin/adjustments/_form.html.erb +1 -1
- data/app/views/spree/admin/customer_returns/_return_item_selection.html.erb +2 -2
- data/app/views/spree/admin/customer_returns/new.html.erb +1 -1
- data/app/views/spree/admin/images/_form.html.erb +1 -1
- data/app/views/spree/admin/images/_image_row.html.erb +22 -4
- data/app/views/spree/admin/images/create.js.erb +8 -5
- data/app/views/spree/admin/images/index.html.erb +4 -8
- data/app/views/spree/admin/orders/_risk_analysis.html.erb +6 -7
- data/app/views/spree/admin/orders/_shipment.html.erb +1 -1
- data/app/views/spree/admin/orders/confirm/_customer_details.html.erb +1 -1
- data/app/views/spree/admin/orders/confirm/_payments.html.erb +1 -1
- data/app/views/spree/admin/orders/index.html.erb +3 -3
- data/app/views/spree/admin/payment_methods/_form.html.erb +5 -5
- data/app/views/spree/admin/payments/_form.html.erb +2 -2
- data/app/views/spree/admin/payments/_list.html.erb +1 -1
- data/app/views/spree/admin/payments/show.html.erb +1 -1
- data/app/views/spree/admin/payments/source_forms/_gateway.html.erb +2 -7
- data/app/views/spree/admin/prices/_form.html.erb +2 -2
- data/app/views/spree/admin/prices/edit.html.erb +2 -0
- data/app/views/spree/admin/prices/index.html.erb +5 -4
- data/app/views/spree/admin/prices/new.html.erb +4 -0
- data/app/views/spree/admin/product_properties/index.html.erb +1 -1
- data/app/views/spree/admin/products/_form.html.erb +4 -3
- data/app/views/spree/admin/products/index.html.erb +3 -3
- data/app/views/spree/admin/products/new.html.erb +2 -2
- data/app/views/spree/admin/products/new.js.erb +0 -3
- data/app/views/spree/admin/promotion_actions/create.js.erb +2 -6
- data/app/views/spree/admin/promotion_rules/create.js.erb +0 -8
- data/app/views/spree/admin/promotions/_actions.html.erb +2 -2
- data/app/views/spree/admin/promotions/_form.html.erb +1 -1
- data/app/views/spree/admin/promotions/_promotion_action.html.erb +3 -4
- data/app/views/spree/admin/promotions/_promotion_rule.html.erb +3 -3
- data/app/views/spree/admin/promotions/_rules.html.erb +1 -1
- data/app/views/spree/admin/promotions/actions/_create_item_adjustments.html.erb +6 -2
- data/app/views/spree/admin/promotions/actions/_promotion_calculators_with_custom_fields.html.erb +1 -1
- data/app/views/spree/admin/promotions/calculators/distributed_amount/_fields.html.erb +54 -0
- data/app/views/spree/admin/promotions/calculators/tiered_flat_rate/_fields.html.erb +33 -14
- data/app/views/spree/admin/promotions/calculators/tiered_percent/_fields.html.erb +33 -14
- data/app/views/spree/admin/promotions/index.html.erb +1 -1
- data/app/views/spree/admin/promotions/rules/_first_repeat_purchase_since.html.erb +1 -1
- data/app/views/spree/admin/promotions/rules/_item_total.html.erb +1 -1
- data/app/views/spree/admin/promotions/rules/_landing_page.html.erb +1 -1
- data/app/views/spree/admin/promotions/rules/_nth_order.html.erb +1 -1
- data/app/views/spree/admin/promotions/rules/_product.html.erb +1 -1
- data/app/views/spree/admin/promotions/rules/_taxon.html.erb +1 -1
- data/app/views/spree/admin/promotions/rules/_user_role.html.erb +2 -2
- data/app/views/spree/admin/refunds/edit.html.erb +1 -1
- data/app/views/spree/admin/refunds/new.html.erb +1 -1
- data/app/views/spree/admin/reimbursements/edit.html.erb +2 -2
- data/app/views/spree/admin/reports/sales_total.html.erb +1 -1
- data/app/views/spree/admin/return_authorizations/_form.html.erb +4 -4
- data/app/views/spree/admin/shared/_address_form.html.erb +2 -2
- data/app/views/spree/admin/shared/_calculator_fields.html.erb +1 -1
- data/app/views/spree/admin/shared/_product_tabs.html.erb +4 -4
- data/app/views/spree/admin/shared/_report_order_criteria.html.erb +1 -1
- data/app/views/spree/admin/shared/_variant_search.html.erb +1 -1
- data/app/views/spree/admin/shipping_methods/_form.html.erb +1 -1
- data/app/views/spree/admin/states/index.html.erb +1 -1
- data/app/views/spree/admin/stock_items/_stock_management.html.erb +1 -1
- data/app/views/spree/admin/stock_locations/_form.html.erb +1 -1
- data/app/views/spree/admin/stock_transfers/edit.html.erb +1 -1
- data/app/views/spree/admin/stock_transfers/index.html.erb +1 -1
- data/app/views/spree/admin/stock_transfers/new.html.erb +1 -1
- data/app/views/spree/admin/store_credits/_form.html.erb +1 -1
- data/app/views/spree/admin/store_credits/_update_reason_field.html.erb +1 -1
- data/app/views/spree/admin/stores/_form.html.erb +1 -1
- data/app/views/spree/admin/style_guide/topics/forms/_building_forms.html.erb +4 -8
- data/app/views/spree/admin/style_guide/topics/forms/_buttons.html.erb +6 -0
- data/app/views/spree/admin/style_guide/topics/forms/_helper_text.html.erb +13 -0
- data/app/views/spree/admin/style_guide/topics/forms/_inputs.html.erb +96 -0
- data/app/views/spree/admin/style_guide/topics/forms/_labels.html.erb +6 -0
- data/app/views/spree/admin/style_guide/topics/forms/_validation.html.erb +8 -1
- data/app/views/spree/admin/style_guide/topics/layout/_full_width_table_layout.html.erb +10 -0
- data/app/views/spree/admin/style_guide/topics/layout/_helpful_layout.html.erb +0 -0
- data/app/views/spree/admin/style_guide/topics/layout/_sidebar_layout.html.erb +4 -0
- data/app/views/spree/admin/style_guide/topics/messaging/_flashes.html.erb +10 -4
- data/app/views/spree/admin/style_guide/topics/messaging/_tooltips.html.erb +45 -0
- data/app/views/spree/admin/style_guide/topics/tables/_forms_in_tables.html.erb +4 -0
- data/app/views/spree/admin/style_guide/topics/typography/_lists.html.erb +1 -1
- data/app/views/spree/admin/tax_rates/_form.html.erb +17 -3
- data/app/views/spree/admin/tax_rates/index.html.erb +12 -3
- data/app/views/spree/admin/taxonomies/edit.erb +1 -8
- data/app/views/spree/admin/taxons/_form.html.erb +6 -4
- data/app/views/spree/admin/taxons/edit.html.erb +0 -15
- data/app/views/spree/admin/taxons/index.html.erb +1 -1
- data/app/views/spree/admin/variants/_form.html.erb +8 -9
- data/app/views/spree/admin/variants/new.js.erb +0 -1
- data/config/routes.rb +1 -1
- data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +1 -1
- data/spec/controllers/spree/admin/orders_controller_spec.rb +16 -4
- data/spec/controllers/spree/admin/payment_methods_controller_spec.rb +2 -2
- data/spec/controllers/spree/admin/payments_controller_spec.rb +1 -1
- data/spec/controllers/spree/admin/products_controller_spec.rb +33 -0
- data/spec/controllers/spree/admin/variants_controller_spec.rb +39 -13
- data/spec/features/admin/configuration/payment_methods_spec.rb +11 -11
- data/spec/features/admin/configuration/shipping_methods_spec.rb +1 -1
- data/spec/features/admin/configuration/states_spec.rb +4 -4
- data/spec/features/admin/configuration/store_spec.rb +3 -3
- data/spec/features/admin/configuration/tax_rates_spec.rb +1 -1
- data/spec/features/admin/orders/adjustments_spec.rb +1 -1
- data/spec/features/admin/orders/customer_details_spec.rb +10 -11
- data/spec/features/admin/orders/listing_spec.rb +1 -1
- data/spec/features/admin/orders/new_order_spec.rb +4 -11
- data/spec/features/admin/orders/order_details_spec.rb +20 -30
- data/spec/features/admin/orders/return_payment_state_spec.rb +60 -0
- data/spec/features/admin/orders/shipments_spec.rb +7 -0
- data/spec/features/admin/products/edit/images_spec.rb +48 -9
- data/spec/features/admin/products/edit/variants_spec.rb +1 -1
- data/spec/features/admin/products/option_types_spec.rb +2 -2
- data/spec/features/admin/products/products_spec.rb +49 -3
- data/spec/features/admin/products/stock_management_spec.rb +1 -3
- data/spec/features/admin/products/variant_spec.rb +20 -0
- data/spec/features/admin/promotion_adjustments_spec.rb +35 -34
- data/spec/features/admin/promotions/option_value_rule_spec.rb +2 -2
- data/spec/features/admin/promotions/product_rule_spec.rb +1 -1
- data/spec/features/admin/promotions/tiered_calculator_spec.rb +2 -2
- data/spec/features/admin/promotions/user_rule_spec.rb +2 -2
- data/spec/features/admin/stock_transfer_spec.rb +11 -8
- data/spec/helpers/admin/navigation_helper_spec.rb +23 -0
- metadata +26 -18
- data/app/assets/javascripts/spree/backend/images/new.js.coffee +0 -7
- data/app/assets/stylesheets/spree/backend/sections/_payments.scss +0 -14
- data/app/helpers/spree/admin/images_helper.rb +0 -17
- data/app/views/spree/admin/orders/_add_line_item.html.erb +0 -15
- data/app/views/spree/admin/prices/new.js.erb +0 -2
- data/app/views/spree/admin/products/_properties_form.erb +0 -10
- data/app/views/spree/admin/promotions/_tab.html.erb +0 -1
- data/app/views/spree/admin/shared/_report_criteria.html.erb +0 -17
- data/app/views/spree/admin/states/_new.html.erb +0 -7
- data/app/views/spree/admin/stock_locations/_transfer_stock_form.html.erb +0 -38
- data/app/views/spree/admin/stock_transfers/_stock_movements.html.erb +0 -27
- data/app/views/spree/admin/taxons/_taxon_table.html.erb +0 -23
@@ -24,7 +24,7 @@ module Spree
|
|
24
24
|
def create
|
25
25
|
@payment = PaymentCreate.new(@order, object_params).build
|
26
26
|
if @payment.payment_method.source_required? && params[:card].present? && params[:card] != 'new'
|
27
|
-
@payment.source = @payment.payment_method.payment_source_class.
|
27
|
+
@payment.source = @payment.payment_method.payment_source_class.find_by(id: params[:card])
|
28
28
|
end
|
29
29
|
|
30
30
|
begin
|
@@ -87,7 +87,7 @@ module Spree
|
|
87
87
|
end
|
88
88
|
|
89
89
|
def load_order
|
90
|
-
@order = Spree::Order.
|
90
|
+
@order = Spree::Order.find_by!(number: params[:order_id])
|
91
91
|
authorize! action, @order
|
92
92
|
@order
|
93
93
|
end
|
@@ -96,22 +96,16 @@ module Spree
|
|
96
96
|
end
|
97
97
|
|
98
98
|
def collection
|
99
|
-
return @collection if @collection
|
99
|
+
return @collection if @collection
|
100
100
|
params[:q] ||= {}
|
101
|
-
params[:q][:deleted_at_null] ||= "1"
|
102
|
-
|
103
101
|
params[:q][:s] ||= "name asc"
|
104
|
-
@collection = super
|
105
|
-
@collection = @collection.with_deleted if params[:q].delete(:deleted_at_null) == '0'
|
106
102
|
# @search needs to be defined as this is passed to search_form_for
|
107
|
-
@search =
|
103
|
+
@search = super.ransack(params[:q])
|
108
104
|
@collection = @search.result.
|
109
|
-
|
105
|
+
order(id: :asc).
|
110
106
|
includes(product_includes).
|
111
107
|
page(params[:page]).
|
112
108
|
per(Spree::Config[:admin_products_per_page])
|
113
|
-
|
114
|
-
@collection
|
115
109
|
end
|
116
110
|
|
117
111
|
def update_before
|
@@ -5,7 +5,7 @@ class Spree::Admin::PromotionRulesController < Spree::Admin::BaseController
|
|
5
5
|
before_action :validate_promotion_rule_type, only: :create
|
6
6
|
|
7
7
|
def create
|
8
|
-
@promotion_rule = @promotion_rule_type.new(
|
8
|
+
@promotion_rule = @promotion_rule_type.new(promotion_rule_params)
|
9
9
|
@promotion_rule.promotion = @promotion
|
10
10
|
if @promotion_rule.save
|
11
11
|
flash[:success] = Spree.t(:successfully_created, resource: Spree.t(:promotion_rule))
|
@@ -47,4 +47,8 @@ class Spree::Admin::PromotionRulesController < Spree::Admin::BaseController
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
50
|
+
|
51
|
+
def promotion_rule_params
|
52
|
+
params[:promotion_rule].permit!
|
53
|
+
end
|
50
54
|
end
|
@@ -26,27 +26,7 @@ module Spree
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def sales_total
|
29
|
-
params[:q] =
|
30
|
-
|
31
|
-
if params[:q][:completed_at_gt].blank?
|
32
|
-
params[:q][:completed_at_gt] = Time.current.beginning_of_month
|
33
|
-
else
|
34
|
-
params[:q][:completed_at_gt] = begin
|
35
|
-
Time.zone.parse(params[:q][:completed_at_gt]).beginning_of_day
|
36
|
-
rescue
|
37
|
-
Time.current.beginning_of_month
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
if params[:q] && !params[:q][:completed_at_lt].blank?
|
42
|
-
params[:q][:completed_at_lt] = begin
|
43
|
-
Time.zone.parse(params[:q][:completed_at_lt]).end_of_day
|
44
|
-
rescue
|
45
|
-
""
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
params[:q][:s] ||= "completed_at desc"
|
29
|
+
params[:q] = search_params
|
50
30
|
|
51
31
|
@search = Order.complete.ransack(params[:q])
|
52
32
|
@orders = @search.result
|
@@ -68,6 +48,29 @@ module Spree
|
|
68
48
|
end
|
69
49
|
|
70
50
|
@@available_reports = {}
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def search_params
|
55
|
+
params.fetch(:q, {}).tap do |q|
|
56
|
+
q[:completed_at_gt] = adjust_start_date q[:completed_at_gt]
|
57
|
+
q[:completed_at_lt] = adjust_end_date(q[:completed_at_lt]) if q[:completed_at_lt].present?
|
58
|
+
q[:s] ||= 'completed_at desc'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def adjust_start_date(string_date = nil)
|
63
|
+
return Time.current.beginning_of_month if string_date.blank?
|
64
|
+
Time.zone.parse(string_date).beginning_of_day
|
65
|
+
rescue ArgumentError
|
66
|
+
Time.current.beginning_of_month
|
67
|
+
end
|
68
|
+
|
69
|
+
def adjust_end_date(string_date)
|
70
|
+
Time.zone.parse(string_date).end_of_day
|
71
|
+
rescue ArgumentError
|
72
|
+
""
|
73
|
+
end
|
71
74
|
end
|
72
75
|
end
|
73
76
|
end
|
@@ -122,10 +122,13 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
|
|
122
122
|
"Spree::#{controller_name.classify}".constantize
|
123
123
|
end
|
124
124
|
|
125
|
-
def
|
126
|
-
parent_data[:model_name].gsub('spree/', '')
|
125
|
+
def parent_model_name
|
126
|
+
self.class.parent_data[:model_name].gsub('spree/', '')
|
127
127
|
end
|
128
128
|
|
129
|
+
alias_method :model_name, :parent_model_name
|
130
|
+
deprecate model_name: :parent_model_name, deprecator: Spree::Deprecation
|
131
|
+
|
129
132
|
def object_name
|
130
133
|
controller_name.singularize
|
131
134
|
end
|
@@ -161,16 +164,24 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
|
|
161
164
|
def parent_data
|
162
165
|
self.class.parent_data
|
163
166
|
end
|
167
|
+
deprecate :parent_data, deprecator: Spree::Deprecation
|
164
168
|
|
165
169
|
def parent
|
166
|
-
if
|
167
|
-
@parent ||= parent_data[:model_class].
|
168
|
-
instance_variable_set("@#{
|
170
|
+
if parent?
|
171
|
+
@parent ||= self.class.parent_data[:model_class].find_by(self.class.parent_data[:find_by] => params["#{parent_model_name}_id"])
|
172
|
+
instance_variable_set("@#{parent_model_name}", @parent)
|
173
|
+
else
|
174
|
+
Spree::Deprecation.warn "Calling #parent is deprecated on a ResourceController which has not defined a belongs_to"
|
175
|
+
nil
|
169
176
|
end
|
170
177
|
end
|
171
178
|
|
179
|
+
def parent?
|
180
|
+
self.class.parent_data.present?
|
181
|
+
end
|
182
|
+
|
172
183
|
def find_resource
|
173
|
-
if
|
184
|
+
if parent?
|
174
185
|
parent.send(controller_name).find(params[:id])
|
175
186
|
else
|
176
187
|
model_class.find(params[:id])
|
@@ -178,7 +189,7 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
|
|
178
189
|
end
|
179
190
|
|
180
191
|
def build_resource
|
181
|
-
if
|
192
|
+
if parent?
|
182
193
|
parent.send(controller_name).build
|
183
194
|
else
|
184
195
|
model_class.new
|
@@ -186,11 +197,11 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
|
|
186
197
|
end
|
187
198
|
|
188
199
|
def collection
|
189
|
-
return parent.send(controller_name) if
|
200
|
+
return parent.send(controller_name) if parent?
|
190
201
|
if model_class.respond_to?(:accessible_by) && !current_ability.has_block?(params[:action], model_class)
|
191
202
|
model_class.accessible_by(current_ability, action)
|
192
203
|
else
|
193
|
-
model_class.
|
204
|
+
model_class.all
|
194
205
|
end
|
195
206
|
end
|
196
207
|
|
@@ -205,7 +216,7 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
|
|
205
216
|
# URL helpers
|
206
217
|
|
207
218
|
def new_object_url(options = {})
|
208
|
-
if
|
219
|
+
if parent?
|
209
220
|
spree.new_polymorphic_url([:admin, parent, model_class], options)
|
210
221
|
else
|
211
222
|
spree.new_polymorphic_url([:admin, model_class], options)
|
@@ -213,7 +224,7 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
|
|
213
224
|
end
|
214
225
|
|
215
226
|
def edit_object_url(object, options = {})
|
216
|
-
if
|
227
|
+
if parent?
|
217
228
|
spree.polymorphic_url([:edit, :admin, parent, object], options)
|
218
229
|
else
|
219
230
|
spree.polymorphic_url([:edit, :admin, object], options)
|
@@ -223,7 +234,7 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
|
|
223
234
|
def object_url(object = nil, options = {})
|
224
235
|
target = object ? object : @object
|
225
236
|
|
226
|
-
if
|
237
|
+
if parent?
|
227
238
|
spree.polymorphic_url([:admin, parent, target], options)
|
228
239
|
else
|
229
240
|
spree.polymorphic_url([:admin, target], options)
|
@@ -231,7 +242,7 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
|
|
231
242
|
end
|
232
243
|
|
233
244
|
def collection_url(options = {})
|
234
|
-
if
|
245
|
+
if parent?
|
235
246
|
spree.polymorphic_url([:admin, parent, model_class], options)
|
236
247
|
else
|
237
248
|
spree.polymorphic_url([:admin, model_class], options)
|
@@ -242,7 +253,7 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
|
|
242
253
|
#
|
243
254
|
# Other controllers can, should, override it to set custom logic
|
244
255
|
def permitted_resource_params
|
245
|
-
params[object_name].present? ? params.require(object_name).permit! : ActionController::Parameters.new
|
256
|
+
params[object_name].present? ? params.require(object_name).permit! : ActionController::Parameters.new.permit!
|
246
257
|
end
|
247
258
|
|
248
259
|
def collection_actions
|
@@ -96,7 +96,7 @@ module Spree
|
|
96
96
|
private
|
97
97
|
|
98
98
|
def collection
|
99
|
-
return @collection if @collection
|
99
|
+
return @collection if @collection
|
100
100
|
if request.xhr? && params[:q].present?
|
101
101
|
@collection = Spree.user_class.includes(:bill_address, :ship_address)
|
102
102
|
.where("spree_users.email #{LIKE} :search
|
@@ -55,6 +55,11 @@ module Spree
|
|
55
55
|
def redirect_on_empty_option_values
|
56
56
|
redirect_to admin_product_variants_url(params[:product_id]) if @product.empty_option_values?
|
57
57
|
end
|
58
|
+
|
59
|
+
def parent
|
60
|
+
@parent ||= Spree::Product.with_deleted.find_by(slug: params[:product_id])
|
61
|
+
@product = @parent
|
62
|
+
end
|
58
63
|
end
|
59
64
|
end
|
60
65
|
end
|
@@ -79,6 +79,7 @@ module Spree
|
|
79
79
|
|
80
80
|
def link_to_clone(resource, options = {})
|
81
81
|
options[:data] = { action: 'clone' }
|
82
|
+
options[:method] = :post
|
82
83
|
link_to_with_icon('copy', Spree.t(:clone), clone_object_url(resource), options)
|
83
84
|
end
|
84
85
|
|
@@ -102,7 +103,7 @@ module Spree
|
|
102
103
|
url = options[:url] || object_url(resource)
|
103
104
|
name = options[:name] || Spree.t('actions.delete')
|
104
105
|
confirm = options[:confirm] || Spree.t(:are_you_sure)
|
105
|
-
options[:class] = "delete-resource"
|
106
|
+
options[:class] = "#{options[:class]} delete-resource".strip
|
106
107
|
options[:data] = { confirm: confirm, action: 'remove' }
|
107
108
|
link_to_with_icon 'trash', name, url, options
|
108
109
|
end
|
@@ -116,10 +117,13 @@ module Spree
|
|
116
117
|
link_to(text, url, options)
|
117
118
|
end
|
118
119
|
|
119
|
-
def
|
120
|
+
def solidus_icon(icon_name)
|
120
121
|
icon_name ? content_tag(:i, '', class: icon_name) : ''
|
121
122
|
end
|
122
123
|
|
124
|
+
alias_method :icon, :solidus_icon
|
125
|
+
deprecate icon: :solidus_icon, deprecator: Spree::Deprecation
|
126
|
+
|
123
127
|
def button(text, icon_name = nil, button_type = 'submit', options = {})
|
124
128
|
class_names = "button"
|
125
129
|
if icon_name
|
@@ -2,8 +2,8 @@ module Spree
|
|
2
2
|
module PromotionRulesHelper
|
3
3
|
def options_for_promotion_rule_types(promotion)
|
4
4
|
existing = promotion.rules.map { |rule| rule.class.name }
|
5
|
-
|
6
|
-
options =
|
5
|
+
rules = Rails.application.config.spree.promotions.rules.reject { |r| existing.include? r.name }
|
6
|
+
options = rules.map { |rule| [rule.model_name.human, rule.name] }
|
7
7
|
options_for_select(options)
|
8
8
|
end
|
9
9
|
end
|
@@ -20,7 +20,7 @@
|
|
20
20
|
<div class="col-3">
|
21
21
|
<%= f.field_container :label do %>
|
22
22
|
<%= f.label :adjustment_reason_id %><br/>
|
23
|
-
<%= f.collection_select(:adjustment_reason_id, reasons_for(@adjustment), :id, :name, {include_blank: true}, {"data-placeholder" => Spree.t(:select_a_reason), class: '
|
23
|
+
<%= f.collection_select(:adjustment_reason_id, reasons_for(@adjustment), :id, :name, {include_blank: true}, {"data-placeholder" => Spree.t(:select_a_reason), class: 'custom-select fullwidth'}) %>
|
24
24
|
<% end %>
|
25
25
|
</div>
|
26
26
|
|
@@ -47,10 +47,10 @@
|
|
47
47
|
<%= item_fields.check_box :resellable, { checked: return_item.resellable } %>
|
48
48
|
</td>
|
49
49
|
<td class="align-center">
|
50
|
-
<%= item_fields.select :reception_status_event, return_item.potential_reception_transitions, {include_blank: true}, {class: 'add-item
|
50
|
+
<%= item_fields.select :reception_status_event, return_item.potential_reception_transitions, {include_blank: true}, {class: 'add-item custom-select fullwidth'} %>
|
51
51
|
</td>
|
52
52
|
<td class="align-center">
|
53
|
-
<%= item_fields.select :return_reason_id, @reasons.collect{|r|[r.name, r.id]}, {include_blank: true}, {class: '
|
53
|
+
<%= item_fields.select :return_reason_id, @reasons.collect{|r|[r.name, r.id]}, {include_blank: true}, {class: 'custom-select fullwidth'} %>
|
54
54
|
</td>
|
55
55
|
</tr>
|
56
56
|
<% end %>
|
@@ -33,7 +33,7 @@
|
|
33
33
|
|
34
34
|
<%= f.field_container :stock_location do %>
|
35
35
|
<%= f.label :stock_location_id, Spree::StockLocation.model_name.human %>
|
36
|
-
<%= f.select :stock_location_id, Spree::StockLocation.order_default.to_a.collect{|l|[l.name
|
36
|
+
<%= f.select :stock_location_id, Spree::StockLocation.order_default.to_a.collect{|l|[l.name, l.id]}, {include_blank: true}, {class: 'custom-select fullwidth', "data-placeholder" => Spree.t(:select_a_stock_location)} %>
|
37
37
|
<%= f.error_message_on :stock_location_id %>
|
38
38
|
<% end %>
|
39
39
|
|
@@ -7,7 +7,7 @@
|
|
7
7
|
</div>
|
8
8
|
<div data-hook="variant" class="field">
|
9
9
|
<%= f.label :viewable_id, Spree::Variant.model_name.human %><br>
|
10
|
-
<%= f.select :viewable_id, @variants, {}, { class: '
|
10
|
+
<%= f.select :viewable_id, @variants, {}, { class: 'custom-select fullwidth' } %>
|
11
11
|
</div>
|
12
12
|
</div>
|
13
13
|
<div data-hook="alt_text" class="field col-4">
|
@@ -1,22 +1,40 @@
|
|
1
1
|
<tr id="<%= spree_dom_id image %>" data-hook="images_row" class="<%= cycle('odd', 'even')%>">
|
2
|
+
|
2
3
|
<td class="no-border">
|
3
4
|
<% if can?(:update_positions, Spree::Image) %>
|
4
5
|
<span class="handle"></span>
|
5
6
|
<% end %>
|
6
7
|
</td>
|
8
|
+
|
7
9
|
<td>
|
8
10
|
<%= link_to image.attachment.url(:product) do %>
|
9
11
|
<%= render 'spree/admin/shared/image', image: image, size: :mini %>
|
10
12
|
<% end %>
|
11
13
|
</td>
|
14
|
+
|
12
15
|
<% if @product.has_variants? %>
|
13
|
-
<td
|
14
|
-
|
15
|
-
|
16
|
+
<td>
|
17
|
+
<%= fields_for image do |f| %>
|
18
|
+
<%= f.select :viewable_id, options_for_select(@variants, image.viewable_id), {}, class: 'select2 fullwidth', autocomplete: "off" %>
|
19
|
+
<% end %>
|
20
|
+
</td>
|
21
|
+
<% end # @product.has_variants? %>
|
22
|
+
|
23
|
+
<td>
|
24
|
+
<%= fields_for image do |f| %>
|
25
|
+
<%= f.text_field :alt %>
|
26
|
+
<% end %>
|
27
|
+
</td>
|
28
|
+
|
16
29
|
<td class="actions">
|
17
30
|
<% if can?(:update, image) %>
|
18
|
-
<%= link_to_with_icon '
|
31
|
+
<%= link_to_with_icon 'check', Spree.t('actions.save'), api_variant_image_path(@product, image), no_text: true, data: {action: 'save'} %>
|
32
|
+
|
33
|
+
<%= link_to_with_icon 'cancel', Spree.t('actions.cancel'), nil, no_text: true, data: {action: 'cancel'} %>
|
34
|
+
|
35
|
+
<%= link_to_with_icon 'edit', Spree.t('actions.edit'), edit_admin_product_image_path(@product, image), no_text: true, data: {action: 'edit'} %>
|
19
36
|
<% end %>
|
37
|
+
|
20
38
|
<% if can?(:destroy, image) %>
|
21
39
|
<%= link_to_delete image, { url: admin_product_image_url(@product, image), no_text: true } %>
|
22
40
|
<% end %>
|
@@ -1,9 +1,12 @@
|
|
1
|
-
var
|
1
|
+
var $uploadEl = $('[data-upload-id="<%= params[:upload_id] %>"]');
|
2
2
|
|
3
3
|
<% if @image.persisted? %>
|
4
|
-
|
5
|
-
$
|
6
|
-
|
4
|
+
|
5
|
+
$uploadEl.trigger('clear');
|
6
|
+
Spree.Views.Tables.EditableTable.append('<%= j render "image_row", image: @image %>');
|
7
|
+
|
7
8
|
<% else %>
|
8
|
-
|
9
|
+
|
10
|
+
$uploadEl.find('error').removeClass('hidden').html('<%= j @image.errors.full_messages.join("<br>").html_safe %>');
|
11
|
+
|
9
12
|
<% end %>
|