spree_backend 3.3.6 → 3.4.0.rc1
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/app/assets/javascripts/spree/backend/checkouts/edit.js +1 -8
- data/app/assets/javascripts/spree/backend/handlebar_extensions.js +3 -0
- data/app/assets/javascripts/spree/backend/returns/return_item_selection.js +1 -1
- data/app/assets/javascripts/spree/backend/shipments.js +8 -25
- data/app/assets/javascripts/spree/backend/taxons.js.coffee +1 -6
- data/app/assets/stylesheets/spree/backend/sections/_account.scss +8 -4
- data/app/controllers/spree/admin/adjustments_controller.rb +0 -2
- data/app/controllers/spree/admin/base_controller.rb +5 -5
- data/app/controllers/spree/admin/countries_controller.rb +1 -2
- data/app/controllers/spree/admin/customer_returns_controller.rb +4 -5
- data/app/controllers/spree/admin/general_settings_controller.rb +1 -0
- data/app/controllers/spree/admin/log_entries_controller.rb +0 -1
- data/app/controllers/spree/admin/option_types_controller.rb +10 -10
- data/app/controllers/spree/admin/orders_controller.rb +30 -21
- data/app/controllers/spree/admin/payment_methods_controller.rb +5 -7
- data/app/controllers/spree/admin/payments_controller.rb +3 -3
- data/app/controllers/spree/admin/product_properties_controller.rb +7 -6
- data/app/controllers/spree/admin/products_controller.rb +8 -9
- data/app/controllers/spree/admin/promotion_actions_controller.rb +4 -4
- data/app/controllers/spree/admin/promotion_rules_controller.rb +4 -4
- data/app/controllers/spree/admin/promotions_controller.rb +22 -21
- data/app/controllers/spree/admin/properties_controller.rb +2 -2
- data/app/controllers/spree/admin/prototypes_controller.rb +0 -1
- data/app/controllers/spree/admin/reports_controller.rb +17 -10
- data/app/controllers/spree/admin/resource_controller.rb +6 -15
- data/app/controllers/spree/admin/shipping_methods_controller.rb +5 -5
- data/app/controllers/spree/admin/states_controller.rb +9 -9
- data/app/controllers/spree/admin/stock_items_controller.rb +10 -9
- data/app/controllers/spree/admin/stock_movements_controller.rb +2 -2
- data/app/controllers/spree/admin/stock_transfers_controller.rb +20 -15
- data/app/controllers/spree/admin/store_credits_controller.rb +1 -1
- data/app/controllers/spree/admin/taxons_controller.rb +9 -18
- data/app/controllers/spree/admin/users_controller.rb +7 -7
- data/app/controllers/spree/admin/variants_controller.rb +1 -1
- data/app/controllers/spree/admin/variants_including_master_controller.rb +2 -3
- data/app/controllers/spree/admin/zones_controller.rb +11 -11
- data/app/helpers/spree/admin/adjustments_helper.rb +8 -10
- data/app/helpers/spree/admin/base_helper.rb +43 -49
- data/app/helpers/spree/admin/general_settings_helper.rb +1 -1
- data/app/helpers/spree/admin/images_helper.rb +0 -1
- data/app/helpers/spree/admin/navigation_helper.rb +39 -45
- data/app/helpers/spree/admin/orders_helper.rb +42 -43
- data/app/helpers/spree/admin/payments_helper.rb +1 -1
- data/app/helpers/spree/admin/promotion_rules_helper.rb +2 -2
- data/app/helpers/spree/admin/stock_locations_helper.rb +1 -1
- data/app/helpers/spree/admin/stock_movements_helper.rb +1 -1
- data/app/helpers/spree/admin/taxons_helper.rb +1 -1
- data/app/models/spree/admin/resource.rb +4 -4
- data/app/views/spree/admin/products/_autocomplete.js.erb +1 -1
- data/app/views/spree/admin/return_authorizations/_form.html.erb +1 -1
- data/app/views/spree/admin/shared/_account_nav.html.erb +59 -0
- data/app/views/spree/admin/shared/_header.html.erb +3 -1
- data/app/views/spree/admin/shared/_main_menu.html.erb +0 -6
- data/app/views/spree/admin/shared/_version.html.erb +5 -0
- data/app/views/spree/admin/stock_transfers/new.html.erb +1 -1
- data/app/views/spree/admin/stock_transfers/show.html.erb +1 -1
- data/app/views/spree/admin/users/index.html.erb +1 -1
- data/app/views/spree/layouts/admin.html.erb +2 -0
- data/config/initializers/assets.rb +1 -1
- data/config/initializers/form_builder.rb +2 -3
- data/config/routes.rb +5 -5
- data/lib/spree/backend/action_callbacks.rb +0 -1
- data/lib/spree/backend/callbacks.rb +3 -5
- data/lib/spree/backend/engine.rb +4 -4
- metadata +11 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36eab3a9676906861059532cd8d26dbdb623d3f7
|
4
|
+
data.tar.gz: ef850027dc86fad30a13802b2c5061e3a021b632
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f438859a49d14c1dfa65d67c74763510d67e6ed03179b8944f0253fc8246040dfb7a96c27dc4edfe512bb225b12249fc2cae1063135a2b6c7717f2ce7e6f45d0
|
7
|
+
data.tar.gz: e73b0c399415e40b089eae1373f5a4c8b9a7d830c9c00c2c044f0642c027d320109a89ec0458d8eff1c0fcbf35693f46846078a6e99f83f7d389ab13c8b0b2f4
|
@@ -31,14 +31,7 @@ $(document).ready(function() {
|
|
31
31
|
cache: true,
|
32
32
|
data: function(term, page) {
|
33
33
|
return {
|
34
|
-
q:
|
35
|
-
'm': 'or',
|
36
|
-
'email_start': term,
|
37
|
-
'ship_address_firstname_start': term,
|
38
|
-
'ship_address_lastname_start': term,
|
39
|
-
'bill_address_firstname_start': term,
|
40
|
-
'bill_address_lastname_start': term
|
41
|
-
},
|
34
|
+
q: term,
|
42
35
|
token: Spree.api_key
|
43
36
|
}
|
44
37
|
},
|
@@ -5,3 +5,6 @@ Handlebars.registerHelper("t", function(key) {
|
|
5
5
|
console.error("No translation found for " + key + ". Does it exist within spree/admin/shared/_translations.html.erb?")
|
6
6
|
}
|
7
7
|
});
|
8
|
+
Handlebars.registerHelper("edit_product_url", function(product_id) {
|
9
|
+
return Spree.routes.edit_product(product_id)
|
10
|
+
});
|
@@ -34,7 +34,7 @@ $(document).ready(function() {
|
|
34
34
|
|
35
35
|
formFields.find('input.add-item').on('change', updateSuggestedAmount);
|
36
36
|
formFields.find('.refund-amount-input').on('keyup', updateSuggestedAmount);
|
37
|
-
formFields.find('.refund-quantity-input').on('keyup', updateSuggestedAmount);
|
37
|
+
formFields.find('.refund-quantity-input').on('keyup mouseup', updateSuggestedAmount);
|
38
38
|
|
39
39
|
formFields.find('input, select').not('.add-item').on('change', checkAddItemBox);
|
40
40
|
}
|
@@ -43,23 +43,9 @@ $(document).ready(function () {
|
|
43
43
|
var del = $(this);
|
44
44
|
var shipment_number = del.data('shipment-number');
|
45
45
|
var variant_id = del.data('variant-id');
|
46
|
-
var shipment = _.findWhere(shipments, {number: shipment_number + ''});
|
47
|
-
var url = Spree.routes.shipments_api + "/" + shipment_number + '/remove';
|
48
46
|
|
49
47
|
toggleItemEdit();
|
50
|
-
|
51
|
-
$.ajax({
|
52
|
-
type: "PUT",
|
53
|
-
url: Spree.url(url),
|
54
|
-
data: {
|
55
|
-
variant_id: variant_id,
|
56
|
-
token: Spree.api_key
|
57
|
-
}
|
58
|
-
}).done(function( msg ) {
|
59
|
-
window.location.reload();
|
60
|
-
}).fail(function(msg) {
|
61
|
-
alert(msg.responseJSON.message)
|
62
|
-
});
|
48
|
+
adjustShipmentItems(shipment_number, variant_id, 0);
|
63
49
|
}
|
64
50
|
return false;
|
65
51
|
});
|
@@ -159,16 +145,13 @@ adjustShipmentItems = function(shipment_number, variant_id, quantity){
|
|
159
145
|
|
160
146
|
var url = Spree.routes.shipments_api + "/" + shipment_number;
|
161
147
|
|
162
|
-
var
|
163
|
-
|
164
|
-
}, 0);
|
165
|
-
|
166
|
-
if(previous_quantity<quantity){
|
148
|
+
var new_quantity = 0;
|
149
|
+
if(inventory_units.length<quantity){
|
167
150
|
url += "/add"
|
168
|
-
new_quantity = (quantity -
|
169
|
-
}else if(
|
151
|
+
new_quantity = (quantity - inventory_units.length);
|
152
|
+
}else if(inventory_units.length>quantity){
|
170
153
|
url += "/remove"
|
171
|
-
new_quantity = (
|
154
|
+
new_quantity = (inventory_units.length - quantity);
|
172
155
|
}
|
173
156
|
url += '.json';
|
174
157
|
|
@@ -281,7 +264,7 @@ completeItemSplit = function(event) {
|
|
281
264
|
}).error(function(msg) {
|
282
265
|
alert(msg.responseJSON['message']);
|
283
266
|
}).done(function(msg) {
|
284
|
-
|
267
|
+
window.Spree.advanceOrder();
|
285
268
|
});
|
286
269
|
} else {
|
287
270
|
// TRANSFER TO AN EXISTING SHIPMENT
|
@@ -299,7 +282,7 @@ completeItemSplit = function(event) {
|
|
299
282
|
}).error(function(msg) {
|
300
283
|
alert(msg.responseJSON['message']);
|
301
284
|
}).done(function(msg) {
|
302
|
-
window.
|
285
|
+
window.Spree.advanceOrder();
|
303
286
|
});
|
304
287
|
}
|
305
288
|
}
|
@@ -79,9 +79,4 @@ $(document).ready ->
|
|
79
79
|
product.fadeOut 400, (e) ->
|
80
80
|
product.remove()
|
81
81
|
|
82
|
-
$(
|
83
|
-
product = $(this).parents(".product")
|
84
|
-
product_id = product.data("product-id")
|
85
|
-
window.location = Spree.routes.edit_product(product_id)
|
86
|
-
|
87
|
-
$(".variant_autocomplete").variantAutocomplete();
|
82
|
+
$(".variant_autocomplete").variantAutocomplete()
|
@@ -5,12 +5,16 @@
|
|
5
5
|
}
|
6
6
|
|
7
7
|
.dropdown-menu {
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
width: 100%;
|
9
|
+
padding: 0 0;
|
10
|
+
|
11
|
+
hr {
|
12
|
+
margin: 0 0;
|
13
|
+
}
|
11
14
|
|
12
15
|
a {
|
13
16
|
color: $dropdown-link-color !important;
|
17
|
+
padding: 15px;
|
14
18
|
}
|
15
19
|
}
|
16
|
-
}
|
20
|
+
}
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module Spree
|
2
2
|
module Admin
|
3
3
|
class AdjustmentsController < ResourceController
|
4
|
-
|
5
4
|
belongs_to 'spree/order', find_by: :number
|
6
5
|
|
7
6
|
create.after :update_totals
|
@@ -32,7 +31,6 @@ module Spree
|
|
32
31
|
def build_resource
|
33
32
|
parent.adjustments.build(order: parent)
|
34
33
|
end
|
35
|
-
|
36
34
|
end
|
37
35
|
end
|
38
36
|
end
|
@@ -14,11 +14,11 @@ module Spree
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def authorize_admin
|
17
|
-
if respond_to?(:model_class, true) && model_class
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
record = if respond_to?(:model_class, true) && model_class
|
18
|
+
model_class
|
19
|
+
else
|
20
|
+
controller_name.to_sym
|
21
|
+
end
|
22
22
|
authorize! :admin, record
|
23
23
|
authorize! action, record
|
24
24
|
end
|
@@ -36,10 +36,10 @@ module Spree
|
|
36
36
|
|
37
37
|
def collection
|
38
38
|
parent # trigger loading the order
|
39
|
-
@collection ||= Spree::ReturnItem
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
@collection ||= Spree::ReturnItem.
|
40
|
+
accessible_by(current_ability, :read).
|
41
|
+
where(inventory_unit_id: @order.inventory_units.pluck(:id)).
|
42
|
+
map(&:customer_return).uniq.compact
|
43
43
|
@customer_returns = @collection
|
44
44
|
end
|
45
45
|
|
@@ -62,7 +62,6 @@ module Spree
|
|
62
62
|
return_item
|
63
63
|
end.compact
|
64
64
|
end
|
65
|
-
|
66
65
|
end
|
67
66
|
end
|
68
67
|
end
|
@@ -18,19 +18,19 @@ module Spree
|
|
18
18
|
|
19
19
|
protected
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
21
|
+
def location_after_save
|
22
|
+
if @option_type.created_at == @option_type.updated_at
|
23
|
+
edit_admin_option_type_url(@option_type)
|
24
|
+
else
|
25
|
+
admin_option_types_url
|
27
26
|
end
|
28
|
-
|
27
|
+
end
|
29
28
|
|
30
29
|
private
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
|
31
|
+
def setup_new_option_value
|
32
|
+
@option_type.option_values.build if @option_type.option_values.empty?
|
33
|
+
end
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
@@ -19,14 +19,22 @@ module Spree
|
|
19
19
|
created_at_gt = params[:q][:created_at_gt]
|
20
20
|
created_at_lt = params[:q][:created_at_lt]
|
21
21
|
|
22
|
-
params[:q].delete(:inventory_units_shipment_id_null) if params[:q][:inventory_units_shipment_id_null] ==
|
22
|
+
params[:q].delete(:inventory_units_shipment_id_null) if params[:q][:inventory_units_shipment_id_null] == '0'
|
23
23
|
|
24
24
|
if params[:q][:created_at_gt].present?
|
25
|
-
params[:q][:created_at_gt] =
|
25
|
+
params[:q][:created_at_gt] = begin
|
26
|
+
Time.zone.parse(params[:q][:created_at_gt]).beginning_of_day
|
27
|
+
rescue
|
28
|
+
''
|
29
|
+
end
|
26
30
|
end
|
27
31
|
|
28
32
|
if params[:q][:created_at_lt].present?
|
29
|
-
params[:q][:created_at_lt] =
|
33
|
+
params[:q][:created_at_lt] = begin
|
34
|
+
Time.zone.parse(params[:q][:created_at_lt]).end_of_day
|
35
|
+
rescue
|
36
|
+
''
|
37
|
+
end
|
30
38
|
end
|
31
39
|
|
32
40
|
if @show_only_completed
|
@@ -40,8 +48,8 @@ module Spree
|
|
40
48
|
# e.g. SELECT DISTINCT DISTINCT "spree_orders".id, "spree_orders"."created_at" AS alias_0 FROM "spree_orders"
|
41
49
|
# see https://github.com/spree/spree/pull/3919
|
42
50
|
@orders = @search.result(distinct: true).
|
43
|
-
|
44
|
-
|
51
|
+
page(params[:page]).
|
52
|
+
per(params[:per_page] || Spree::Config[:admin_orders_per_page])
|
45
53
|
|
46
54
|
# Restore dates
|
47
55
|
params[:q][:created_at_gt] = created_at_gt
|
@@ -62,7 +70,7 @@ module Spree
|
|
62
70
|
def cart
|
63
71
|
@order.refresh_shipment_rates(ShippingMethod::DISPLAY_ON_BACK_END) unless @order.completed?
|
64
72
|
|
65
|
-
if @order.shipments.shipped.
|
73
|
+
if @order.shipments.shipped.exists?
|
66
74
|
redirect_to edit_admin_order_url(@order)
|
67
75
|
end
|
68
76
|
end
|
@@ -123,24 +131,25 @@ module Spree
|
|
123
131
|
end
|
124
132
|
|
125
133
|
private
|
126
|
-
def order_params
|
127
|
-
params[:created_by_id] = try_spree_current_user.try(:id)
|
128
|
-
params.permit(:created_by_id, :user_id)
|
129
|
-
end
|
130
134
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
+
def order_params
|
136
|
+
params[:created_by_id] = try_spree_current_user.try(:id)
|
137
|
+
params.permit(:created_by_id, :user_id, :store_id)
|
138
|
+
end
|
135
139
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
+
def load_order
|
141
|
+
@order = Spree::Order.includes(:adjustments).find_by!(number: params[:id])
|
142
|
+
authorize! action, @order
|
143
|
+
end
|
140
144
|
|
141
|
-
|
142
|
-
|
143
|
-
|
145
|
+
# Used for extensions which need to provide their own custom event links on the order details view.
|
146
|
+
def initialize_order_events
|
147
|
+
@order_events = %w{approve cancel resume}
|
148
|
+
end
|
149
|
+
|
150
|
+
def model_class
|
151
|
+
Spree::Order
|
152
|
+
end
|
144
153
|
end
|
145
154
|
end
|
146
155
|
end
|
@@ -27,16 +27,14 @@ module Spree
|
|
27
27
|
if @payment_method['type'].to_s != payment_method_type
|
28
28
|
@payment_method.update_columns(
|
29
29
|
type: payment_method_type,
|
30
|
-
updated_at: Time.current
|
30
|
+
updated_at: Time.current
|
31
31
|
)
|
32
32
|
@payment_method = PaymentMethod.find(params[:id])
|
33
33
|
end
|
34
34
|
|
35
35
|
attributes = payment_method_params.merge(preferences_params)
|
36
|
-
attributes.each do |k,
|
37
|
-
if k.include?(
|
38
|
-
attributes.delete(k)
|
39
|
-
end
|
36
|
+
attributes.each do |k, _v|
|
37
|
+
attributes.delete(k) if k.include?('password') && attributes[k].blank?
|
40
38
|
end
|
41
39
|
|
42
40
|
if @payment_method.update_attributes(attributes)
|
@@ -56,12 +54,12 @@ module Spree
|
|
56
54
|
end
|
57
55
|
|
58
56
|
def load_data
|
59
|
-
@providers = Gateway.providers.
|
57
|
+
@providers = Gateway.providers.sort_by(&:name)
|
60
58
|
end
|
61
59
|
|
62
60
|
def validate_payment_method_provider
|
63
61
|
valid_payment_methods = Rails.application.config.spree.payment_methods.map(&:to_s)
|
64
|
-
|
62
|
+
unless valid_payment_methods.include?(params[:payment_method][:type])
|
65
63
|
flash[:error] = Spree.t(:invalid_payment_provider)
|
66
64
|
redirect_to new_admin_payment_method_path
|
67
65
|
end
|
@@ -56,7 +56,7 @@ module Spree
|
|
56
56
|
end
|
57
57
|
rescue Spree::Core::GatewayError => e
|
58
58
|
invoke_callbacks(:create, :fails)
|
59
|
-
flash[:error] =
|
59
|
+
flash[:error] = e.message.to_s
|
60
60
|
redirect_to new_admin_order_payment_path(@order)
|
61
61
|
end
|
62
62
|
end
|
@@ -65,14 +65,14 @@ module Spree
|
|
65
65
|
return unless event = params[:e] and @payment.payment_source
|
66
66
|
|
67
67
|
# Because we have a transition method also called void, we do this to avoid conflicts.
|
68
|
-
event =
|
68
|
+
event = 'void_transaction' if event == 'void'
|
69
69
|
if @payment.send("#{event}!")
|
70
70
|
flash[:success] = Spree.t(:payment_updated)
|
71
71
|
else
|
72
72
|
flash[:error] = Spree.t(:cannot_perform_operation)
|
73
73
|
end
|
74
74
|
rescue Spree::Core::GatewayError => ge
|
75
|
-
flash[:error] =
|
75
|
+
flash[:error] = ge.message.to_s
|
76
76
|
ensure
|
77
77
|
redirect_to admin_order_payments_path(@order)
|
78
78
|
end
|
@@ -6,13 +6,14 @@ module Spree
|
|
6
6
|
before_action :setup_property, only: :index
|
7
7
|
|
8
8
|
private
|
9
|
-
def find_properties
|
10
|
-
@properties = Spree::Property.pluck(:name)
|
11
|
-
end
|
12
9
|
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
def find_properties
|
11
|
+
@properties = Spree::Property.pluck(:name)
|
12
|
+
end
|
13
|
+
|
14
|
+
def setup_property
|
15
|
+
@product.product_properties.build
|
16
|
+
end
|
16
17
|
end
|
17
18
|
end
|
18
19
|
end
|
@@ -58,7 +58,7 @@ module Spree
|
|
58
58
|
|
59
59
|
respond_with(@product) do |format|
|
60
60
|
format.html { redirect_to collection_url }
|
61
|
-
format.js
|
61
|
+
format.js { render_js_for_destroy }
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
@@ -72,7 +72,6 @@ module Spree
|
|
72
72
|
flash[:error] = Spree.t('notice_messages.product_not_cloned')
|
73
73
|
redirect_to admin_products_url
|
74
74
|
end
|
75
|
-
|
76
75
|
rescue ActiveRecord::RecordInvalid
|
77
76
|
# Handle error on uniqueness validation on product fields
|
78
77
|
flash[:error] = Spree.t('notice_messages.product_not_cloned')
|
@@ -109,10 +108,10 @@ module Spree
|
|
109
108
|
def collection
|
110
109
|
return @collection if @collection.present?
|
111
110
|
params[:q] ||= {}
|
112
|
-
params[:q][:deleted_at_null] ||=
|
113
|
-
params[:q][:not_discontinued] ||=
|
111
|
+
params[:q][:deleted_at_null] ||= '1'
|
112
|
+
params[:q][:not_discontinued] ||= '1'
|
114
113
|
|
115
|
-
params[:q][:s] ||=
|
114
|
+
params[:q][:s] ||= 'name asc'
|
116
115
|
@collection = super
|
117
116
|
# Don't delete params[:q][:deleted_at_null] here because it is used in view to check the
|
118
117
|
# checkbox for 'q[deleted_at_null]'. This also messed with pagination when deleted_at_null is checked.
|
@@ -124,10 +123,10 @@ module Spree
|
|
124
123
|
# This is to include all products and not just deleted products.
|
125
124
|
@search = @collection.ransack(params[:q].reject { |k, _v| k.to_s == 'deleted_at_null' })
|
126
125
|
@collection = @search.result.
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
126
|
+
distinct_by_product_ids(params[:q][:s]).
|
127
|
+
includes(product_includes).
|
128
|
+
page(params[:page]).
|
129
|
+
per(params[:per_page] || Spree::Config[:admin_products_per_page])
|
131
130
|
@collection
|
132
131
|
end
|
133
132
|
|
@@ -10,7 +10,7 @@ class Spree::Admin::PromotionActionsController < Spree::Admin::BaseController
|
|
10
10
|
flash[:success] = Spree.t(:successfully_created, resource: Spree.t(:promotion_action))
|
11
11
|
end
|
12
12
|
respond_to do |format|
|
13
|
-
format.html { redirect_to spree.edit_admin_promotion_path(@promotion)}
|
13
|
+
format.html { redirect_to spree.edit_admin_promotion_path(@promotion) }
|
14
14
|
format.js { render layout: false }
|
15
15
|
end
|
16
16
|
end
|
@@ -21,7 +21,7 @@ class Spree::Admin::PromotionActionsController < Spree::Admin::BaseController
|
|
21
21
|
flash[:success] = Spree.t(:successfully_removed, resource: Spree.t(:promotion_action))
|
22
22
|
end
|
23
23
|
respond_to do |format|
|
24
|
-
format.html { redirect_to spree.edit_admin_promotion_path(@promotion)}
|
24
|
+
format.html { redirect_to spree.edit_admin_promotion_path(@promotion) }
|
25
25
|
format.js { render layout: false }
|
26
26
|
end
|
27
27
|
end
|
@@ -34,10 +34,10 @@ class Spree::Admin::PromotionActionsController < Spree::Admin::BaseController
|
|
34
34
|
|
35
35
|
def validate_promotion_action_type
|
36
36
|
valid_promotion_action_types = Rails.application.config.spree.promotions.actions.map(&:to_s)
|
37
|
-
|
37
|
+
unless valid_promotion_action_types.include?(params[:action_type])
|
38
38
|
flash[:error] = Spree.t(:invalid_promotion_action)
|
39
39
|
respond_to do |format|
|
40
|
-
format.html { redirect_to spree.edit_admin_promotion_path(@promotion)}
|
40
|
+
format.html { redirect_to spree.edit_admin_promotion_path(@promotion) }
|
41
41
|
format.js { render layout: false }
|
42
42
|
end
|
43
43
|
end
|
@@ -11,7 +11,7 @@ class Spree::Admin::PromotionRulesController < Spree::Admin::BaseController
|
|
11
11
|
flash[:success] = Spree.t(:successfully_created, resource: Spree.t(:promotion_rule))
|
12
12
|
end
|
13
13
|
respond_to do |format|
|
14
|
-
format.html { redirect_to spree.edit_admin_promotion_path(@promotion)}
|
14
|
+
format.html { redirect_to spree.edit_admin_promotion_path(@promotion) }
|
15
15
|
format.js { render layout: false }
|
16
16
|
end
|
17
17
|
end
|
@@ -22,7 +22,7 @@ class Spree::Admin::PromotionRulesController < Spree::Admin::BaseController
|
|
22
22
|
flash[:success] = Spree.t(:successfully_removed, resource: Spree.t(:promotion_rule))
|
23
23
|
end
|
24
24
|
respond_to do |format|
|
25
|
-
format.html { redirect_to spree.edit_admin_promotion_path(@promotion)}
|
25
|
+
format.html { redirect_to spree.edit_admin_promotion_path(@promotion) }
|
26
26
|
format.js { render layout: false }
|
27
27
|
end
|
28
28
|
end
|
@@ -39,10 +39,10 @@ class Spree::Admin::PromotionRulesController < Spree::Admin::BaseController
|
|
39
39
|
@promotion_rule_type = promotion_rule_types.detect do |klass|
|
40
40
|
klass.name == requested_type
|
41
41
|
end
|
42
|
-
|
42
|
+
unless @promotion_rule_type
|
43
43
|
flash[:error] = Spree.t(:invalid_promotion_rule)
|
44
44
|
respond_to do |format|
|
45
|
-
format.html { redirect_to spree.edit_admin_promotion_path(@promotion)}
|
45
|
+
format.html { redirect_to spree.edit_admin_promotion_path(@promotion) }
|
46
46
|
format.js { render layout: false }
|
47
47
|
end
|
48
48
|
end
|
@@ -6,31 +6,32 @@ module Spree
|
|
6
6
|
helper 'spree/admin/promotion_rules'
|
7
7
|
|
8
8
|
protected
|
9
|
-
def location_after_save
|
10
|
-
spree.edit_admin_promotion_url(@promotion)
|
11
|
-
end
|
12
9
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
10
|
+
def location_after_save
|
11
|
+
spree.edit_admin_promotion_url(@promotion)
|
12
|
+
end
|
17
13
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
14
|
+
def load_data
|
15
|
+
@calculators = Rails.application.config.spree.calculators.promotion_actions_create_adjustments
|
16
|
+
@promotion_categories = Spree::PromotionCategory.order(:name)
|
17
|
+
end
|
22
18
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
page(params[:page]).
|
28
|
-
per(params[:per_page] || Spree::Config[:admin_promotions_per_page])
|
29
|
-
end
|
19
|
+
def collection
|
20
|
+
return @collection if defined?(@collection)
|
21
|
+
params[:q] ||= HashWithIndifferentAccess.new
|
22
|
+
params[:q][:s] ||= 'id desc'
|
30
23
|
|
31
|
-
|
32
|
-
|
33
|
-
|
24
|
+
@collection = super
|
25
|
+
@search = @collection.ransack(params[:q])
|
26
|
+
@collection = @search.result(distinct: true).
|
27
|
+
includes(promotion_includes).
|
28
|
+
page(params[:page]).
|
29
|
+
per(params[:per_page] || Spree::Config[:admin_promotions_per_page])
|
30
|
+
end
|
31
|
+
|
32
|
+
def promotion_includes
|
33
|
+
[:promotion_actions]
|
34
|
+
end
|
34
35
|
end
|
35
36
|
end
|
36
37
|
end
|
@@ -15,8 +15,8 @@ module Spree
|
|
15
15
|
@collection = super
|
16
16
|
@search = @collection.ransack(params[:q])
|
17
17
|
@collection = @search.result.
|
18
|
-
|
19
|
-
|
18
|
+
page(params[:page]).
|
19
|
+
per(Spree::Config[:admin_properties_per_page])
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|