spree_backend 3.6.6 → 3.7.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/spree/backend.js +7 -7
- data/app/assets/javascripts/spree/backend/address_states.js +21 -21
- data/app/assets/javascripts/spree/backend/adjustments.js +25 -0
- data/app/assets/javascripts/spree/backend/admin.js +253 -244
- data/app/assets/javascripts/spree/backend/calculator.js +14 -13
- data/app/assets/javascripts/spree/backend/checkouts/edit.js +48 -52
- data/app/assets/javascripts/spree/backend/gateway.js +11 -10
- data/app/assets/javascripts/spree/backend/general_settings.js +18 -0
- data/app/assets/javascripts/spree/backend/handlebar_extensions.js +6 -6
- data/app/assets/javascripts/spree/backend/line_items.js +72 -0
- data/app/assets/javascripts/spree/backend/line_items_on_order_edit.js +48 -47
- data/app/assets/javascripts/spree/backend/option_type_autocomplete.js +10 -10
- data/app/assets/javascripts/spree/backend/option_value_picker.js +13 -14
- data/app/assets/javascripts/spree/backend/orders/edit.js +3 -4
- data/app/assets/javascripts/spree/backend/payments/edit.js +230 -0
- data/app/assets/javascripts/spree/backend/payments/new.js +31 -31
- data/app/assets/javascripts/spree/backend/product_picker.js +15 -15
- data/app/assets/javascripts/spree/backend/progress.js +8 -0
- data/app/assets/javascripts/spree/backend/promotions.js +102 -107
- data/app/assets/javascripts/spree/backend/returns/expedited_exchanges_warning.js +5 -0
- data/app/assets/javascripts/spree/backend/returns/return_item_selection.js +32 -33
- data/app/assets/javascripts/spree/backend/shipments.js +246 -241
- data/app/assets/javascripts/spree/backend/spree-select2.js +3 -3
- data/app/assets/javascripts/spree/backend/states.js +8 -8
- data/app/assets/javascripts/spree/backend/stock_location.js +4 -3
- data/app/assets/javascripts/spree/backend/stock_management.js +13 -0
- data/app/assets/javascripts/spree/backend/stock_movement.js +35 -0
- data/app/assets/javascripts/spree/backend/stock_transfer.js +260 -0
- data/app/assets/javascripts/spree/backend/tag_picker.js +21 -21
- data/app/assets/javascripts/spree/backend/taxon_autocomplete.js +13 -13
- data/app/assets/javascripts/spree/backend/taxon_permalink_preview.js +8 -9
- data/app/assets/javascripts/spree/backend/taxon_tree_menu.js +35 -0
- data/app/assets/javascripts/spree/backend/taxonomy.js +165 -0
- data/app/assets/javascripts/spree/backend/taxons.js +122 -0
- data/app/assets/javascripts/spree/backend/user_picker.js +11 -11
- data/app/assets/javascripts/spree/backend/users/edit.js +14 -15
- data/app/assets/javascripts/spree/backend/variant_autocomplete.js +61 -0
- data/app/assets/javascripts/spree/backend/variant_management.js +14 -0
- data/app/assets/javascripts/spree/backend/zone.js +44 -0
- data/app/controllers/spree/admin/countries_controller.rb +3 -3
- data/app/controllers/spree/admin/customer_returns_controller.rb +1 -0
- data/app/controllers/spree/admin/general_settings_controller.rb +1 -0
- data/app/controllers/spree/admin/orders_controller.rb +4 -4
- data/app/controllers/spree/admin/payment_methods_controller.rb +1 -0
- data/app/controllers/spree/admin/payments_controller.rb +3 -2
- data/app/controllers/spree/admin/products_controller.rb +3 -1
- data/app/controllers/spree/admin/promotions_controller.rb +1 -0
- data/app/controllers/spree/admin/properties_controller.rb +1 -0
- data/app/controllers/spree/admin/reports_controller.rb +4 -4
- data/app/controllers/spree/admin/resource_controller.rb +3 -1
- data/app/controllers/spree/admin/return_authorizations_controller.rb +1 -1
- data/app/controllers/spree/admin/return_index_controller.rb +1 -0
- data/app/controllers/spree/admin/shipping_methods_controller.rb +2 -0
- data/app/controllers/spree/admin/store_credits_controller.rb +1 -2
- data/app/controllers/spree/admin/users_controller.rb +3 -1
- data/app/helpers/spree/admin/base_helper.rb +8 -5
- data/app/helpers/spree/admin/{general_settings_helper.rb → currency_helper.rb} +4 -3
- data/app/helpers/spree/admin/navigation_helper.rb +0 -8
- data/app/helpers/spree/admin/orders_helper.rb +2 -1
- data/app/models/spree/admin/resource.rb +1 -0
- data/app/views/spree/admin/orders/_line_items.html.erb +3 -1
- data/app/views/spree/admin/orders/_shipment_manifest.html.erb +3 -1
- data/app/views/spree/admin/orders/index.html.erb +15 -8
- data/app/views/spree/admin/products/index.html.erb +2 -2
- data/app/views/spree/admin/promotions/index.html.erb +4 -4
- data/app/views/spree/admin/properties/index.html.erb +2 -2
- data/app/views/spree/admin/return_index/customer_returns.html.erb +1 -1
- data/app/views/spree/admin/return_index/return_authorizations.html.erb +2 -2
- data/app/views/spree/admin/shared/_order_summary.html.erb +6 -0
- data/app/views/spree/admin/store_credits/_form.html.erb +15 -6
- data/app/views/spree/admin/store_credits/edit.html.erb +1 -1
- data/app/views/spree/admin/store_credits/new.html.erb +1 -1
- data/app/views/spree/admin/users/_addresses_form.html.erb +1 -1
- data/app/views/spree/admin/users/index.html.erb +8 -8
- data/app/views/spree/admin/users/items.html.erb +3 -1
- data/app/views/spree/admin/variants/index.html.erb +2 -2
- data/lib/generators/spree/backend/copy_views/copy_views_generator.rb +1 -1
- data/lib/spree/backend/callbacks.rb +1 -0
- data/spree_backend.gemspec +2 -2
- data/vendor/assets/javascripts/jquery.jstree/jquery.jstree.js +4358 -4358
- data/vendor/assets/javascripts/js.cookie.js +165 -0
- metadata +28 -28
- data/app/assets/javascripts/spree/backend/adjustments.js.coffee +0 -17
- data/app/assets/javascripts/spree/backend/general_settings.js.coffee +0 -15
- data/app/assets/javascripts/spree/backend/line_items.js.coffee +0 -64
- data/app/assets/javascripts/spree/backend/payments/edit.js.coffee +0 -145
- data/app/assets/javascripts/spree/backend/progress.js.coffee +0 -6
- data/app/assets/javascripts/spree/backend/returns/expedited_exchanges_warning.coffee +0 -4
- data/app/assets/javascripts/spree/backend/stock_management.js.coffee +0 -9
- data/app/assets/javascripts/spree/backend/stock_movement.js.coffee +0 -19
- data/app/assets/javascripts/spree/backend/stock_transfer.js.coffee +0 -201
- data/app/assets/javascripts/spree/backend/taxon_tree_menu.js.coffee +0 -22
- data/app/assets/javascripts/spree/backend/taxonomy.js.coffee +0 -153
- data/app/assets/javascripts/spree/backend/taxons.js.coffee +0 -82
- data/app/assets/javascripts/spree/backend/variant_autocomplete.js.coffee +0 -38
- data/app/assets/javascripts/spree/backend/variant_management.js.coffee +0 -10
- data/app/assets/javascripts/spree/backend/zone.js.coffee +0 -43
- data/vendor/assets/javascripts/jquery.cookie.js +0 -117
@@ -0,0 +1,165 @@
|
|
1
|
+
/*!
|
2
|
+
* JavaScript Cookie v2.2.0
|
3
|
+
* https://github.com/js-cookie/js-cookie
|
4
|
+
*
|
5
|
+
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack
|
6
|
+
* Released under the MIT license
|
7
|
+
*/
|
8
|
+
;(function (factory) {
|
9
|
+
var registeredInModuleLoader = false;
|
10
|
+
if (typeof define === 'function' && define.amd) {
|
11
|
+
define(factory);
|
12
|
+
registeredInModuleLoader = true;
|
13
|
+
}
|
14
|
+
if (typeof exports === 'object') {
|
15
|
+
module.exports = factory();
|
16
|
+
registeredInModuleLoader = true;
|
17
|
+
}
|
18
|
+
if (!registeredInModuleLoader) {
|
19
|
+
var OldCookies = window.Cookies;
|
20
|
+
var api = window.Cookies = factory();
|
21
|
+
api.noConflict = function () {
|
22
|
+
window.Cookies = OldCookies;
|
23
|
+
return api;
|
24
|
+
};
|
25
|
+
}
|
26
|
+
}(function () {
|
27
|
+
function extend () {
|
28
|
+
var i = 0;
|
29
|
+
var result = {};
|
30
|
+
for (; i < arguments.length; i++) {
|
31
|
+
var attributes = arguments[ i ];
|
32
|
+
for (var key in attributes) {
|
33
|
+
result[key] = attributes[key];
|
34
|
+
}
|
35
|
+
}
|
36
|
+
return result;
|
37
|
+
}
|
38
|
+
|
39
|
+
function init (converter) {
|
40
|
+
function api (key, value, attributes) {
|
41
|
+
var result;
|
42
|
+
if (typeof document === 'undefined') {
|
43
|
+
return;
|
44
|
+
}
|
45
|
+
|
46
|
+
// Write
|
47
|
+
|
48
|
+
if (arguments.length > 1) {
|
49
|
+
attributes = extend({
|
50
|
+
path: '/'
|
51
|
+
}, api.defaults, attributes);
|
52
|
+
|
53
|
+
if (typeof attributes.expires === 'number') {
|
54
|
+
var expires = new Date();
|
55
|
+
expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5);
|
56
|
+
attributes.expires = expires;
|
57
|
+
}
|
58
|
+
|
59
|
+
// We're using "expires" because "max-age" is not supported by IE
|
60
|
+
attributes.expires = attributes.expires ? attributes.expires.toUTCString() : '';
|
61
|
+
|
62
|
+
try {
|
63
|
+
result = JSON.stringify(value);
|
64
|
+
if (/^[\{\[]/.test(result)) {
|
65
|
+
value = result;
|
66
|
+
}
|
67
|
+
} catch (e) {}
|
68
|
+
|
69
|
+
if (!converter.write) {
|
70
|
+
value = encodeURIComponent(String(value))
|
71
|
+
.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);
|
72
|
+
} else {
|
73
|
+
value = converter.write(value, key);
|
74
|
+
}
|
75
|
+
|
76
|
+
key = encodeURIComponent(String(key));
|
77
|
+
key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent);
|
78
|
+
key = key.replace(/[\(\)]/g, escape);
|
79
|
+
|
80
|
+
var stringifiedAttributes = '';
|
81
|
+
|
82
|
+
for (var attributeName in attributes) {
|
83
|
+
if (!attributes[attributeName]) {
|
84
|
+
continue;
|
85
|
+
}
|
86
|
+
stringifiedAttributes += '; ' + attributeName;
|
87
|
+
if (attributes[attributeName] === true) {
|
88
|
+
continue;
|
89
|
+
}
|
90
|
+
stringifiedAttributes += '=' + attributes[attributeName];
|
91
|
+
}
|
92
|
+
return (document.cookie = key + '=' + value + stringifiedAttributes);
|
93
|
+
}
|
94
|
+
|
95
|
+
// Read
|
96
|
+
|
97
|
+
if (!key) {
|
98
|
+
result = {};
|
99
|
+
}
|
100
|
+
|
101
|
+
// To prevent the for loop in the first place assign an empty array
|
102
|
+
// in case there are no cookies at all. Also prevents odd result when
|
103
|
+
// calling "get()"
|
104
|
+
var cookies = document.cookie ? document.cookie.split('; ') : [];
|
105
|
+
var rdecode = /(%[0-9A-Z]{2})+/g;
|
106
|
+
var i = 0;
|
107
|
+
|
108
|
+
for (; i < cookies.length; i++) {
|
109
|
+
var parts = cookies[i].split('=');
|
110
|
+
var cookie = parts.slice(1).join('=');
|
111
|
+
|
112
|
+
if (!this.json && cookie.charAt(0) === '"') {
|
113
|
+
cookie = cookie.slice(1, -1);
|
114
|
+
}
|
115
|
+
|
116
|
+
try {
|
117
|
+
var name = parts[0].replace(rdecode, decodeURIComponent);
|
118
|
+
cookie = converter.read ?
|
119
|
+
converter.read(cookie, name) : converter(cookie, name) ||
|
120
|
+
cookie.replace(rdecode, decodeURIComponent);
|
121
|
+
|
122
|
+
if (this.json) {
|
123
|
+
try {
|
124
|
+
cookie = JSON.parse(cookie);
|
125
|
+
} catch (e) {}
|
126
|
+
}
|
127
|
+
|
128
|
+
if (key === name) {
|
129
|
+
result = cookie;
|
130
|
+
break;
|
131
|
+
}
|
132
|
+
|
133
|
+
if (!key) {
|
134
|
+
result[name] = cookie;
|
135
|
+
}
|
136
|
+
} catch (e) {}
|
137
|
+
}
|
138
|
+
|
139
|
+
return result;
|
140
|
+
}
|
141
|
+
|
142
|
+
api.set = api;
|
143
|
+
api.get = function (key) {
|
144
|
+
return api.call(api, key);
|
145
|
+
};
|
146
|
+
api.getJSON = function () {
|
147
|
+
return api.apply({
|
148
|
+
json: true
|
149
|
+
}, [].slice.call(arguments));
|
150
|
+
};
|
151
|
+
api.defaults = {};
|
152
|
+
|
153
|
+
api.remove = function (key, attributes) {
|
154
|
+
api(key, '', extend(attributes, {
|
155
|
+
expires: -1
|
156
|
+
}));
|
157
|
+
};
|
158
|
+
|
159
|
+
api.withConverter = init;
|
160
|
+
|
161
|
+
return api;
|
162
|
+
}
|
163
|
+
|
164
|
+
return init(function () {});
|
165
|
+
}));
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_backend
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.7.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Schofield
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: spree_api
|
@@ -16,42 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 3.
|
19
|
+
version: 3.7.0.rc1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 3.
|
26
|
+
version: 3.7.0.rc1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: spree_core
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 3.
|
33
|
+
version: 3.7.0.rc1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 3.
|
40
|
+
version: 3.7.0.rc1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bootstrap-sass
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '3.
|
47
|
+
version: '3.4'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '3.
|
54
|
+
version: '3.4'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: jquery-rails
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -106,43 +106,43 @@ files:
|
|
106
106
|
- app/assets/images/credit_cards/credit_card.gif
|
107
107
|
- app/assets/javascripts/spree/backend.js
|
108
108
|
- app/assets/javascripts/spree/backend/address_states.js
|
109
|
-
- app/assets/javascripts/spree/backend/adjustments.js
|
109
|
+
- app/assets/javascripts/spree/backend/adjustments.js
|
110
110
|
- app/assets/javascripts/spree/backend/admin.js
|
111
111
|
- app/assets/javascripts/spree/backend/calculator.js
|
112
112
|
- app/assets/javascripts/spree/backend/checkouts/edit.js
|
113
113
|
- app/assets/javascripts/spree/backend/gateway.js
|
114
|
-
- app/assets/javascripts/spree/backend/general_settings.js
|
114
|
+
- app/assets/javascripts/spree/backend/general_settings.js
|
115
115
|
- app/assets/javascripts/spree/backend/handlebar_extensions.js
|
116
|
-
- app/assets/javascripts/spree/backend/line_items.js
|
116
|
+
- app/assets/javascripts/spree/backend/line_items.js
|
117
117
|
- app/assets/javascripts/spree/backend/line_items_on_order_edit.js
|
118
118
|
- app/assets/javascripts/spree/backend/option_type_autocomplete.js
|
119
119
|
- app/assets/javascripts/spree/backend/option_value_picker.js
|
120
120
|
- app/assets/javascripts/spree/backend/orders/edit.js
|
121
|
-
- app/assets/javascripts/spree/backend/payments/edit.js
|
121
|
+
- app/assets/javascripts/spree/backend/payments/edit.js
|
122
122
|
- app/assets/javascripts/spree/backend/payments/new.js
|
123
123
|
- app/assets/javascripts/spree/backend/product_picker.js
|
124
|
-
- app/assets/javascripts/spree/backend/progress.js
|
124
|
+
- app/assets/javascripts/spree/backend/progress.js
|
125
125
|
- app/assets/javascripts/spree/backend/promotions.js
|
126
|
-
- app/assets/javascripts/spree/backend/returns/expedited_exchanges_warning.
|
126
|
+
- app/assets/javascripts/spree/backend/returns/expedited_exchanges_warning.js
|
127
127
|
- app/assets/javascripts/spree/backend/returns/return_item_selection.js
|
128
128
|
- app/assets/javascripts/spree/backend/shipments.js
|
129
129
|
- app/assets/javascripts/spree/backend/spree-select2.js
|
130
130
|
- app/assets/javascripts/spree/backend/states.js
|
131
131
|
- app/assets/javascripts/spree/backend/stock_location.js
|
132
|
-
- app/assets/javascripts/spree/backend/stock_management.js
|
133
|
-
- app/assets/javascripts/spree/backend/stock_movement.js
|
134
|
-
- app/assets/javascripts/spree/backend/stock_transfer.js
|
132
|
+
- app/assets/javascripts/spree/backend/stock_management.js
|
133
|
+
- app/assets/javascripts/spree/backend/stock_movement.js
|
134
|
+
- app/assets/javascripts/spree/backend/stock_transfer.js
|
135
135
|
- app/assets/javascripts/spree/backend/tag_picker.js
|
136
136
|
- app/assets/javascripts/spree/backend/taxon_autocomplete.js
|
137
137
|
- app/assets/javascripts/spree/backend/taxon_permalink_preview.js
|
138
|
-
- app/assets/javascripts/spree/backend/taxon_tree_menu.js
|
139
|
-
- app/assets/javascripts/spree/backend/taxonomy.js
|
140
|
-
- app/assets/javascripts/spree/backend/taxons.js
|
138
|
+
- app/assets/javascripts/spree/backend/taxon_tree_menu.js
|
139
|
+
- app/assets/javascripts/spree/backend/taxonomy.js
|
140
|
+
- app/assets/javascripts/spree/backend/taxons.js
|
141
141
|
- app/assets/javascripts/spree/backend/user_picker.js
|
142
142
|
- app/assets/javascripts/spree/backend/users/edit.js
|
143
|
-
- app/assets/javascripts/spree/backend/variant_autocomplete.js
|
144
|
-
- app/assets/javascripts/spree/backend/variant_management.js
|
145
|
-
- app/assets/javascripts/spree/backend/zone.js
|
143
|
+
- app/assets/javascripts/spree/backend/variant_autocomplete.js
|
144
|
+
- app/assets/javascripts/spree/backend/variant_management.js
|
145
|
+
- app/assets/javascripts/spree/backend/zone.js
|
146
146
|
- app/assets/javascripts/spree/frontend/backend.js
|
147
147
|
- app/assets/stylesheets/spree/backend.css
|
148
148
|
- app/assets/stylesheets/spree/backend/components/_buttons.scss
|
@@ -220,8 +220,8 @@ files:
|
|
220
220
|
- app/controllers/spree/admin/zones_controller.rb
|
221
221
|
- app/helpers/spree/admin/adjustments_helper.rb
|
222
222
|
- app/helpers/spree/admin/base_helper.rb
|
223
|
+
- app/helpers/spree/admin/currency_helper.rb
|
223
224
|
- app/helpers/spree/admin/customer_returns_helper.rb
|
224
|
-
- app/helpers/spree/admin/general_settings_helper.rb
|
225
225
|
- app/helpers/spree/admin/images_helper.rb
|
226
226
|
- app/helpers/spree/admin/navigation_helper.rb
|
227
227
|
- app/helpers/spree/admin/orders_helper.rb
|
@@ -513,8 +513,8 @@ files:
|
|
513
513
|
- script/rails
|
514
514
|
- spree_backend.gemspec
|
515
515
|
- vendor/assets/javascripts/handlebars.js
|
516
|
-
- vendor/assets/javascripts/jquery.cookie.js
|
517
516
|
- vendor/assets/javascripts/jquery.jstree/jquery.jstree.js
|
517
|
+
- vendor/assets/javascripts/js.cookie.js
|
518
518
|
- vendor/assets/javascripts/modernizr.js
|
519
519
|
- vendor/assets/javascripts/underscore-min.js
|
520
520
|
- vendor/assets/stylesheets/animate.css
|
@@ -532,12 +532,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
532
532
|
requirements:
|
533
533
|
- - ">="
|
534
534
|
- !ruby/object:Gem::Version
|
535
|
-
version: 2.
|
535
|
+
version: 2.3.0
|
536
536
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
537
537
|
requirements:
|
538
|
-
- - "
|
538
|
+
- - ">"
|
539
539
|
- !ruby/object:Gem::Version
|
540
|
-
version:
|
540
|
+
version: 1.3.1
|
541
541
|
requirements:
|
542
542
|
- none
|
543
543
|
rubyforge_project:
|
@@ -1,17 +0,0 @@
|
|
1
|
-
$(@).ready( ->
|
2
|
-
$('[data-hook=adjustments_new_coupon_code] #add_coupon_code').click ->
|
3
|
-
return if $("#coupon_code").val().length == 0
|
4
|
-
$.ajax
|
5
|
-
type: 'PUT'
|
6
|
-
url: Spree.url(Spree.routes.apply_coupon_code(order_number))
|
7
|
-
data:
|
8
|
-
coupon_code: $("#coupon_code").val()
|
9
|
-
token: Spree.api_key
|
10
|
-
success: ->
|
11
|
-
window.location.reload();
|
12
|
-
error: (msg) ->
|
13
|
-
if msg.responseJSON["error"]
|
14
|
-
show_flash 'error', msg.responseJSON["error"]
|
15
|
-
else
|
16
|
-
show_flash 'error', "There was a problem adding this coupon code."
|
17
|
-
)
|
@@ -1,15 +0,0 @@
|
|
1
|
-
$(@).ready( ->
|
2
|
-
$('[data-hook=general_settings_clear_cache] #clear_cache').click ->
|
3
|
-
response = confirm(Spree.translations.are_you_sure)
|
4
|
-
if response
|
5
|
-
$.ajax
|
6
|
-
type: 'POST'
|
7
|
-
url: Spree.routes.clear_cache
|
8
|
-
success: ->
|
9
|
-
show_flash 'success', "Cache was flushed."
|
10
|
-
error: (msg) ->
|
11
|
-
if msg.responseJSON["error"]
|
12
|
-
show_flash 'error', msg.responseJSON["error"]
|
13
|
-
else
|
14
|
-
show_flash 'error', "There was a problem while flushing cache."
|
15
|
-
)
|
@@ -1,64 +0,0 @@
|
|
1
|
-
$(document).ready ->
|
2
|
-
#handle edit click
|
3
|
-
$('a.edit-line-item').click toggleLineItemEdit
|
4
|
-
|
5
|
-
#handle cancel click
|
6
|
-
$('a.cancel-line-item').click toggleLineItemEdit
|
7
|
-
|
8
|
-
#handle save click
|
9
|
-
$('a.save-line-item').click ->
|
10
|
-
save = $ this
|
11
|
-
line_item_id = save.data('line-item-id')
|
12
|
-
quantity = parseInt(save.parents('tr').find('input.line_item_quantity').val())
|
13
|
-
|
14
|
-
toggleItemEdit()
|
15
|
-
adjustLineItem(line_item_id, quantity)
|
16
|
-
false
|
17
|
-
|
18
|
-
# handle delete click
|
19
|
-
$('a.delete-line-item').click ->
|
20
|
-
if confirm(Spree.translations.are_you_sure_delete)
|
21
|
-
del = $(this);
|
22
|
-
line_item_id = del.data('line-item-id');
|
23
|
-
|
24
|
-
toggleItemEdit()
|
25
|
-
deleteLineItem(line_item_id)
|
26
|
-
|
27
|
-
toggleLineItemEdit = ->
|
28
|
-
link = $(this);
|
29
|
-
link.parent().find('a.edit-line-item').toggle();
|
30
|
-
link.parent().find('a.cancel-line-item').toggle();
|
31
|
-
link.parent().find('a.save-line-item').toggle();
|
32
|
-
link.parent().find('a.delete-line-item').toggle();
|
33
|
-
link.parents('tr').find('td.line-item-qty-show').toggle();
|
34
|
-
link.parents('tr').find('td.line-item-qty-edit').toggle();
|
35
|
-
|
36
|
-
false
|
37
|
-
|
38
|
-
lineItemURL = (line_item_id) ->
|
39
|
-
url = Spree.routes.orders_api + "/" + order_number + "/line_items/" + line_item_id + ".json"
|
40
|
-
|
41
|
-
adjustLineItem = (line_item_id, quantity) ->
|
42
|
-
url = lineItemURL(line_item_id)
|
43
|
-
$.ajax(
|
44
|
-
type: "PUT",
|
45
|
-
url: Spree.url(url),
|
46
|
-
data:
|
47
|
-
line_item:
|
48
|
-
quantity: quantity
|
49
|
-
token: Spree.api_key
|
50
|
-
).done (msg) ->
|
51
|
-
window.Spree.advanceOrder()
|
52
|
-
|
53
|
-
deleteLineItem = (line_item_id) ->
|
54
|
-
url = lineItemURL(line_item_id)
|
55
|
-
$.ajax(
|
56
|
-
type: "DELETE"
|
57
|
-
url: Spree.url(url)
|
58
|
-
headers:
|
59
|
-
'X-Spree-Token': Spree.api_key
|
60
|
-
).done (msg) ->
|
61
|
-
$('#line-item-' + line_item_id).remove()
|
62
|
-
if $('.line-items tr.line-item').length == 0
|
63
|
-
$('.line-items').remove()
|
64
|
-
window.Spree.advanceOrder()
|
@@ -1,145 +0,0 @@
|
|
1
|
-
jQuery ($) ->
|
2
|
-
# Payment model
|
3
|
-
order_id = $('#payments').data('order-id')
|
4
|
-
class Payment
|
5
|
-
constructor: (number) ->
|
6
|
-
@url = Spree.url("#{Spree.routes.payments_api(order_id)}/#{number}.json" + '?token=' + Spree.api_key)
|
7
|
-
@json = $.getJSON @url.toString(), (data) =>
|
8
|
-
@data = data
|
9
|
-
@updating = false
|
10
|
-
|
11
|
-
if_editable: (callback) ->
|
12
|
-
@json.done (data) ->
|
13
|
-
callback() if data.state in ['checkout', 'pending']
|
14
|
-
|
15
|
-
update: (attributes, success) ->
|
16
|
-
@updating = true
|
17
|
-
|
18
|
-
jqXHR = $.ajax
|
19
|
-
type: 'PUT'
|
20
|
-
url: @url.toString()
|
21
|
-
data: { payment: attributes }
|
22
|
-
jqXHR.always =>
|
23
|
-
@updating = false
|
24
|
-
jqXHR.done (data) =>
|
25
|
-
@data = data
|
26
|
-
jqXHR.fail ->
|
27
|
-
response = jqXHR.responseJSON and jqXHR.responseJSON.error or jqXHR.statusText
|
28
|
-
show_flash('error', response)
|
29
|
-
|
30
|
-
amount: -> @data.amount
|
31
|
-
display_amount: -> @data.display_amount
|
32
|
-
|
33
|
-
# Payment base view
|
34
|
-
class PaymentView
|
35
|
-
constructor: (@$el, @payment) ->
|
36
|
-
@render()
|
37
|
-
|
38
|
-
render: ->
|
39
|
-
@add_action_button()
|
40
|
-
|
41
|
-
show: ->
|
42
|
-
@remove_buttons()
|
43
|
-
new ShowPaymentView(@$el, @payment)
|
44
|
-
|
45
|
-
edit: ->
|
46
|
-
@remove_buttons()
|
47
|
-
new EditPaymentView(@$el, @payment)
|
48
|
-
|
49
|
-
add_action_button: ->
|
50
|
-
@$actions().prepend @$new_button(@action)
|
51
|
-
|
52
|
-
remove_buttons: ->
|
53
|
-
@$buttons().remove()
|
54
|
-
|
55
|
-
$new_button: (action) ->
|
56
|
-
$("<a><span class='icon icon-#{action}'></span></a>")
|
57
|
-
.attr
|
58
|
-
class: "payment-action-#{action} btn btn-default btn-sm icon-link no-text with-tip"
|
59
|
-
title: Spree.translations[action]
|
60
|
-
.data
|
61
|
-
action: action
|
62
|
-
.one
|
63
|
-
click: (event) ->
|
64
|
-
event.preventDefault()
|
65
|
-
mouseup: =>
|
66
|
-
@[action]()
|
67
|
-
|
68
|
-
$buttons: ->
|
69
|
-
@$actions().find(".payment-action-#{@action}, .payment-action-cancel")
|
70
|
-
|
71
|
-
$actions: ->
|
72
|
-
@$el.find('.actions')
|
73
|
-
|
74
|
-
$amount: ->
|
75
|
-
@$el.find('td.amount')
|
76
|
-
|
77
|
-
# Payment show view
|
78
|
-
class ShowPaymentView extends PaymentView
|
79
|
-
action: 'edit'
|
80
|
-
|
81
|
-
render: ->
|
82
|
-
super
|
83
|
-
@set_actions_display()
|
84
|
-
@show_actions()
|
85
|
-
@show_amount()
|
86
|
-
|
87
|
-
set_actions_display: ->
|
88
|
-
width = @$actions().width()
|
89
|
-
@$actions().width(width).css('text-align', 'left')
|
90
|
-
|
91
|
-
show_actions: ->
|
92
|
-
@$actions().find('a').show()
|
93
|
-
|
94
|
-
show_amount: ->
|
95
|
-
amount = $('<span />')
|
96
|
-
.html(@payment.display_amount())
|
97
|
-
.one('click', => @edit().$input().focus())
|
98
|
-
@$amount().html(amount)
|
99
|
-
|
100
|
-
# Payment edit view
|
101
|
-
class EditPaymentView extends PaymentView
|
102
|
-
action: 'save'
|
103
|
-
|
104
|
-
render: ->
|
105
|
-
super
|
106
|
-
@hide_actions()
|
107
|
-
@edit_amount()
|
108
|
-
@add_cancel_button()
|
109
|
-
|
110
|
-
add_cancel_button: ->
|
111
|
-
@$actions().append @$new_button('cancel')
|
112
|
-
|
113
|
-
hide_actions: ->
|
114
|
-
@$actions().find('a').not(@$buttons()).hide()
|
115
|
-
|
116
|
-
edit_amount: ->
|
117
|
-
amount = @$amount()
|
118
|
-
amount.html(@$new_input(amount.find('span').width()))
|
119
|
-
|
120
|
-
save: (event) ->
|
121
|
-
unless @payment.updating
|
122
|
-
@payment.update(amount: @$input().val())
|
123
|
-
.done(=> @show())
|
124
|
-
|
125
|
-
cancel: @::show
|
126
|
-
|
127
|
-
$new_input: (width) ->
|
128
|
-
amount = @constructor.normalize_amount(@payment.display_amount())
|
129
|
-
$('<input />')
|
130
|
-
.prop(id: 'amount', value: amount)
|
131
|
-
.width(width)
|
132
|
-
.css('text-align': 'right')
|
133
|
-
|
134
|
-
$input: ->
|
135
|
-
@$amount().find('input')
|
136
|
-
|
137
|
-
@normalize_amount: (amount) ->
|
138
|
-
separator = Spree.translations.currency_separator
|
139
|
-
amount.replace(///[^\d#{separator}]///g, '')
|
140
|
-
|
141
|
-
# Attach ShowPaymentView to each editable payment in the table
|
142
|
-
$('.admin tr[data-hook=payments_row]').each ->
|
143
|
-
$el = $(@)
|
144
|
-
payment = new Payment($el.attr('data-number'))
|
145
|
-
payment.if_editable -> new ShowPaymentView($el, payment)
|