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.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/spree/backend.js +7 -7
  3. data/app/assets/javascripts/spree/backend/address_states.js +21 -21
  4. data/app/assets/javascripts/spree/backend/adjustments.js +25 -0
  5. data/app/assets/javascripts/spree/backend/admin.js +253 -244
  6. data/app/assets/javascripts/spree/backend/calculator.js +14 -13
  7. data/app/assets/javascripts/spree/backend/checkouts/edit.js +48 -52
  8. data/app/assets/javascripts/spree/backend/gateway.js +11 -10
  9. data/app/assets/javascripts/spree/backend/general_settings.js +18 -0
  10. data/app/assets/javascripts/spree/backend/handlebar_extensions.js +6 -6
  11. data/app/assets/javascripts/spree/backend/line_items.js +72 -0
  12. data/app/assets/javascripts/spree/backend/line_items_on_order_edit.js +48 -47
  13. data/app/assets/javascripts/spree/backend/option_type_autocomplete.js +10 -10
  14. data/app/assets/javascripts/spree/backend/option_value_picker.js +13 -14
  15. data/app/assets/javascripts/spree/backend/orders/edit.js +3 -4
  16. data/app/assets/javascripts/spree/backend/payments/edit.js +230 -0
  17. data/app/assets/javascripts/spree/backend/payments/new.js +31 -31
  18. data/app/assets/javascripts/spree/backend/product_picker.js +15 -15
  19. data/app/assets/javascripts/spree/backend/progress.js +8 -0
  20. data/app/assets/javascripts/spree/backend/promotions.js +102 -107
  21. data/app/assets/javascripts/spree/backend/returns/expedited_exchanges_warning.js +5 -0
  22. data/app/assets/javascripts/spree/backend/returns/return_item_selection.js +32 -33
  23. data/app/assets/javascripts/spree/backend/shipments.js +246 -241
  24. data/app/assets/javascripts/spree/backend/spree-select2.js +3 -3
  25. data/app/assets/javascripts/spree/backend/states.js +8 -8
  26. data/app/assets/javascripts/spree/backend/stock_location.js +4 -3
  27. data/app/assets/javascripts/spree/backend/stock_management.js +13 -0
  28. data/app/assets/javascripts/spree/backend/stock_movement.js +35 -0
  29. data/app/assets/javascripts/spree/backend/stock_transfer.js +260 -0
  30. data/app/assets/javascripts/spree/backend/tag_picker.js +21 -21
  31. data/app/assets/javascripts/spree/backend/taxon_autocomplete.js +13 -13
  32. data/app/assets/javascripts/spree/backend/taxon_permalink_preview.js +8 -9
  33. data/app/assets/javascripts/spree/backend/taxon_tree_menu.js +35 -0
  34. data/app/assets/javascripts/spree/backend/taxonomy.js +165 -0
  35. data/app/assets/javascripts/spree/backend/taxons.js +122 -0
  36. data/app/assets/javascripts/spree/backend/user_picker.js +11 -11
  37. data/app/assets/javascripts/spree/backend/users/edit.js +14 -15
  38. data/app/assets/javascripts/spree/backend/variant_autocomplete.js +61 -0
  39. data/app/assets/javascripts/spree/backend/variant_management.js +14 -0
  40. data/app/assets/javascripts/spree/backend/zone.js +44 -0
  41. data/app/controllers/spree/admin/countries_controller.rb +3 -3
  42. data/app/controllers/spree/admin/customer_returns_controller.rb +1 -0
  43. data/app/controllers/spree/admin/general_settings_controller.rb +1 -0
  44. data/app/controllers/spree/admin/orders_controller.rb +4 -4
  45. data/app/controllers/spree/admin/payment_methods_controller.rb +1 -0
  46. data/app/controllers/spree/admin/payments_controller.rb +3 -2
  47. data/app/controllers/spree/admin/products_controller.rb +3 -1
  48. data/app/controllers/spree/admin/promotions_controller.rb +1 -0
  49. data/app/controllers/spree/admin/properties_controller.rb +1 -0
  50. data/app/controllers/spree/admin/reports_controller.rb +4 -4
  51. data/app/controllers/spree/admin/resource_controller.rb +3 -1
  52. data/app/controllers/spree/admin/return_authorizations_controller.rb +1 -1
  53. data/app/controllers/spree/admin/return_index_controller.rb +1 -0
  54. data/app/controllers/spree/admin/shipping_methods_controller.rb +2 -0
  55. data/app/controllers/spree/admin/store_credits_controller.rb +1 -2
  56. data/app/controllers/spree/admin/users_controller.rb +3 -1
  57. data/app/helpers/spree/admin/base_helper.rb +8 -5
  58. data/app/helpers/spree/admin/{general_settings_helper.rb → currency_helper.rb} +4 -3
  59. data/app/helpers/spree/admin/navigation_helper.rb +0 -8
  60. data/app/helpers/spree/admin/orders_helper.rb +2 -1
  61. data/app/models/spree/admin/resource.rb +1 -0
  62. data/app/views/spree/admin/orders/_line_items.html.erb +3 -1
  63. data/app/views/spree/admin/orders/_shipment_manifest.html.erb +3 -1
  64. data/app/views/spree/admin/orders/index.html.erb +15 -8
  65. data/app/views/spree/admin/products/index.html.erb +2 -2
  66. data/app/views/spree/admin/promotions/index.html.erb +4 -4
  67. data/app/views/spree/admin/properties/index.html.erb +2 -2
  68. data/app/views/spree/admin/return_index/customer_returns.html.erb +1 -1
  69. data/app/views/spree/admin/return_index/return_authorizations.html.erb +2 -2
  70. data/app/views/spree/admin/shared/_order_summary.html.erb +6 -0
  71. data/app/views/spree/admin/store_credits/_form.html.erb +15 -6
  72. data/app/views/spree/admin/store_credits/edit.html.erb +1 -1
  73. data/app/views/spree/admin/store_credits/new.html.erb +1 -1
  74. data/app/views/spree/admin/users/_addresses_form.html.erb +1 -1
  75. data/app/views/spree/admin/users/index.html.erb +8 -8
  76. data/app/views/spree/admin/users/items.html.erb +3 -1
  77. data/app/views/spree/admin/variants/index.html.erb +2 -2
  78. data/lib/generators/spree/backend/copy_views/copy_views_generator.rb +1 -1
  79. data/lib/spree/backend/callbacks.rb +1 -0
  80. data/spree_backend.gemspec +2 -2
  81. data/vendor/assets/javascripts/jquery.jstree/jquery.jstree.js +4358 -4358
  82. data/vendor/assets/javascripts/js.cookie.js +165 -0
  83. metadata +28 -28
  84. data/app/assets/javascripts/spree/backend/adjustments.js.coffee +0 -17
  85. data/app/assets/javascripts/spree/backend/general_settings.js.coffee +0 -15
  86. data/app/assets/javascripts/spree/backend/line_items.js.coffee +0 -64
  87. data/app/assets/javascripts/spree/backend/payments/edit.js.coffee +0 -145
  88. data/app/assets/javascripts/spree/backend/progress.js.coffee +0 -6
  89. data/app/assets/javascripts/spree/backend/returns/expedited_exchanges_warning.coffee +0 -4
  90. data/app/assets/javascripts/spree/backend/stock_management.js.coffee +0 -9
  91. data/app/assets/javascripts/spree/backend/stock_movement.js.coffee +0 -19
  92. data/app/assets/javascripts/spree/backend/stock_transfer.js.coffee +0 -201
  93. data/app/assets/javascripts/spree/backend/taxon_tree_menu.js.coffee +0 -22
  94. data/app/assets/javascripts/spree/backend/taxonomy.js.coffee +0 -153
  95. data/app/assets/javascripts/spree/backend/taxons.js.coffee +0 -82
  96. data/app/assets/javascripts/spree/backend/variant_autocomplete.js.coffee +0 -38
  97. data/app/assets/javascripts/spree/backend/variant_management.js.coffee +0 -10
  98. data/app/assets/javascripts/spree/backend/zone.js.coffee +0 -43
  99. data/vendor/assets/javascripts/jquery.cookie.js +0 -117
@@ -1,11 +1,10 @@
1
1
  $.fn.optionValueAutocomplete = function (options) {
2
- /* globals Spree */
3
- 'use strict';
2
+ 'use strict'
4
3
 
5
4
  // Default options
6
- options = options || {};
7
- var multiple = typeof(options.multiple) !== 'undefined' ? options.multiple : true;
8
- var productSelect = options.productSelect;
5
+ options = options || {}
6
+ var multiple = typeof (options.multiple) !== 'undefined' ? options.multiple : true
7
+ var productSelect = options.productSelect
9
8
 
10
9
  this.select2({
11
10
  minimumInputLength: 3,
@@ -15,31 +14,31 @@ $.fn.optionValueAutocomplete = function (options) {
15
14
  ids: element.val().split(','),
16
15
  token: Spree.api_key
17
16
  }, function (data) {
18
- callback(multiple ? data : data[0]);
19
- });
17
+ callback(multiple ? data : data[0])
18
+ })
20
19
  },
21
20
  ajax: {
22
21
  url: Spree.routes.option_values_api,
23
22
  datatype: 'json',
24
23
  data: function (term) {
25
- var productId = typeof(productSelect) !== 'undefined' ? $(productSelect).select2('val') : null;
24
+ var productId = typeof (productSelect) !== 'undefined' ? $(productSelect).select2('val') : null
26
25
  return {
27
26
  q: {
28
27
  name_cont: term,
29
28
  variants_product_id_eq: productId
30
29
  },
31
30
  token: Spree.api_key
32
- };
31
+ }
33
32
  },
34
33
  results: function (data) {
35
- return { results: data };
34
+ return { results: data }
36
35
  }
37
36
  },
38
37
  formatResult: function (optionValue) {
39
- return optionValue.name;
38
+ return optionValue.name
40
39
  },
41
40
  formatSelection: function (optionValue) {
42
- return optionValue.name;
41
+ return optionValue.name
43
42
  }
44
- });
45
- };
43
+ })
44
+ }
@@ -1,5 +1,4 @@
1
1
  $(document).ready(function () {
2
- 'use strict';
3
-
4
- $('[data-hook="add_product_name"]').find('.variant_autocomplete').variantAutocomplete();
5
- });
2
+ 'use strict'
3
+ $('[data-hook="add_product_name"]').find('.variant_autocomplete').variantAutocomplete()
4
+ })
@@ -0,0 +1,230 @@
1
+ /* global show_flash */
2
+ jQuery(function ($) {
3
+ var extend = function (child, parent) {
4
+ for (var key in parent) {
5
+ if (hasProp.call(parent, key)) child[key] = parent[key]
6
+ }
7
+ function Ctor () {
8
+ this.constructor = child
9
+ }
10
+ Ctor.prototype = parent.prototype
11
+ child.prototype = new Ctor()
12
+ child.__super__ = parent.prototype
13
+ return child
14
+ }
15
+ var hasProp = {}.hasOwnProperty
16
+ var EditPaymentView, Payment, PaymentView, ShowPaymentView, orderId
17
+ orderId = $('#payments').data('order-id')
18
+ Payment = (function () {
19
+ function Payment (number) {
20
+ this.url = Spree.url(((Spree.routes.payments_api(orderId)) + '/' + number + '.json') + '?token=' + Spree.api_key)
21
+ this.json = $.getJSON(this.url.toString(), function (data) {
22
+ this.data = data
23
+ }.bind(this))
24
+ this.updating = false
25
+ }
26
+
27
+ Payment.prototype.if_editable = function (callback) {
28
+ return this.json.done(function (data) {
29
+ var ref
30
+ if ((ref = data.state) === 'checkout' || ref === 'pending') {
31
+ return callback()
32
+ }
33
+ })
34
+ }
35
+
36
+ Payment.prototype.update = function (attributes) {
37
+ this.updating = true
38
+ var jqXHR = $.ajax({
39
+ type: 'PUT',
40
+ url: this.url.toString(),
41
+ data: {
42
+ payment: attributes
43
+ }
44
+ })
45
+ jqXHR.always(function () {
46
+ this.updating = false
47
+ }.bind(this))
48
+ jqXHR.done(function (data) {
49
+ this.data = data
50
+ }.bind(this))
51
+ jqXHR.fail(function () {
52
+ var response = (jqXHR.responseJSON && jqXHR.responseJSON.error) || jqXHR.statusText
53
+ show_flash('error', response)
54
+ })
55
+ return jqXHR
56
+ }
57
+
58
+ Payment.prototype.amount = function () {
59
+ return this.data.amount
60
+ }
61
+
62
+ Payment.prototype.display_amount = function () {
63
+ return this.data.display_amount
64
+ }
65
+ return Payment
66
+ })()
67
+
68
+ PaymentView = (function () {
69
+ function PaymentView ($el1, payment1) {
70
+ this.$el = $el1
71
+ this.payment = payment1
72
+ this.render()
73
+ }
74
+
75
+ PaymentView.prototype.render = function () {
76
+ return this.add_action_button()
77
+ }
78
+
79
+ PaymentView.prototype.show = function () {
80
+ this.remove_buttons()
81
+ return new ShowPaymentView(this.$el, this.payment)
82
+ }
83
+
84
+ PaymentView.prototype.edit = function () {
85
+ this.remove_buttons()
86
+ return new EditPaymentView(this.$el, this.payment)
87
+ }
88
+
89
+ PaymentView.prototype.add_action_button = function () {
90
+ return this.$actions().prepend(this.$new_button(this.action))
91
+ }
92
+
93
+ PaymentView.prototype.remove_buttons = function () {
94
+ return this.$buttons().remove()
95
+ }
96
+
97
+ PaymentView.prototype.$new_button = function (action) {
98
+ return $('<a><span class="icon icon-' + action + '"></span></a>').attr({
99
+ 'class': 'payment-action-' + action + ' btn btn-default btn-sm icon-link no-text with-tip',
100
+ title: Spree.translations[action]
101
+ }).data({
102
+ action: action
103
+ }).one({
104
+ click: function (event) {
105
+ event.preventDefault()
106
+ },
107
+ mouseup: function () {
108
+ this[action]()
109
+ }.bind(this)
110
+ })
111
+ }
112
+
113
+ PaymentView.prototype.$buttons = function () {
114
+ return this.$actions().find('.payment-action-' + this.action + ', .payment-action-cancel')
115
+ }
116
+
117
+ PaymentView.prototype.$actions = function () {
118
+ return this.$el.find('.actions')
119
+ }
120
+
121
+ PaymentView.prototype.$amount = function () {
122
+ return this.$el.find('td.amount')
123
+ }
124
+
125
+ return PaymentView
126
+ })()
127
+ ShowPaymentView = (function (superClass) {
128
+ extend(ShowPaymentView, superClass)
129
+
130
+ function ShowPaymentView () {
131
+ return ShowPaymentView.__super__.constructor.apply(this, arguments)
132
+ }
133
+
134
+ ShowPaymentView.prototype.action = 'edit'
135
+
136
+ ShowPaymentView.prototype.render = function () {
137
+ ShowPaymentView.__super__.render.apply(this, arguments)
138
+ this.set_actions_display()
139
+ this.show_actions()
140
+ return this.show_amount()
141
+ }
142
+
143
+ ShowPaymentView.prototype.set_actions_display = function () {
144
+ var width = this.$actions().width()
145
+ return this.$actions().width(width).css('text-align', 'left')
146
+ }
147
+
148
+ ShowPaymentView.prototype.show_actions = function () {
149
+ return this.$actions().find('a').show()
150
+ }
151
+
152
+ ShowPaymentView.prototype.show_amount = function () {
153
+ var amount = $('<span />').html(this.payment.display_amount()).one('click', function () {
154
+ this.edit().$input().focus()
155
+ }.bind(this))
156
+ return this.$amount().html(amount)
157
+ }
158
+
159
+ return ShowPaymentView
160
+ })(PaymentView)
161
+ EditPaymentView = (function (superClass) {
162
+ extend(EditPaymentView, superClass)
163
+
164
+ function EditPaymentView () {
165
+ return EditPaymentView.__super__.constructor.apply(this, arguments)
166
+ }
167
+
168
+ EditPaymentView.prototype.action = 'save'
169
+
170
+ EditPaymentView.prototype.render = function () {
171
+ EditPaymentView.__super__.render.apply(this, arguments)
172
+ this.hide_actions()
173
+ this.edit_amount()
174
+ return this.add_cancel_button()
175
+ }
176
+
177
+ EditPaymentView.prototype.add_cancel_button = function () {
178
+ return this.$actions().append(this.$new_button('cancel'))
179
+ }
180
+
181
+ EditPaymentView.prototype.hide_actions = function () {
182
+ return this.$actions().find('a').not(this.$buttons()).hide()
183
+ }
184
+
185
+ EditPaymentView.prototype.edit_amount = function () {
186
+ var amount = this.$amount()
187
+ return amount.html(this.$new_input(amount.find('span').width()))
188
+ }
189
+
190
+ EditPaymentView.prototype.save = function () {
191
+ if (!this.payment.updating) {
192
+ return this.payment.update({
193
+ amount: this.$input().val()
194
+ }).done(function () {
195
+ return this.show()
196
+ }.bind(this))
197
+ }
198
+ }
199
+
200
+ EditPaymentView.prototype.cancel = EditPaymentView.prototype.show
201
+
202
+ EditPaymentView.prototype.$new_input = function (width) {
203
+ var amount = this.constructor.normalize_amount(this.payment.display_amount())
204
+ return $('<input />').prop({
205
+ id: 'amount',
206
+ value: amount
207
+ }).width(width).css({
208
+ 'text-align': 'right'
209
+ })
210
+ }
211
+
212
+ EditPaymentView.prototype.$input = function () {
213
+ return this.$amount().find('input')
214
+ }
215
+
216
+ EditPaymentView.normalize_amount = function (amount) {
217
+ var separator = Spree.translations.currency_separator
218
+ return amount.replace(RegExp('[^\\d' + separator + ']', 'g'), '')
219
+ }
220
+
221
+ return EditPaymentView
222
+ })(PaymentView)
223
+ return $('.admin tr[data-hook=payments_row]').each(function () {
224
+ var $el = $(this)
225
+ var payment = new Payment($el.attr('data-number'))
226
+ return payment.if_editable(function () {
227
+ return new ShowPaymentView($el, payment)
228
+ })
229
+ })
230
+ })
@@ -1,50 +1,50 @@
1
1
  //= require jquery.payment
2
- $(document).ready(function() {
3
- if ($("#new_payment").length) {
4
- $(".cardNumber").payment('formatCardNumber');
5
- $(".cardExpiry").payment('formatCardExpiry');
6
- $(".cardCode").payment('formatCardCVC');
2
+ $(document).ready(function () {
3
+ if ($('#new_payment').length) {
4
+ $('.cardNumber').payment('formatCardNumber')
5
+ $('.cardExpiry').payment('formatCardExpiry')
6
+ $('.cardCode').payment('formatCardCVC')
7
7
 
8
- $(".cardNumber").change(function() {
9
- $(".ccType").val($.payment.cardType(this.value))
8
+ $('.cardNumber').change(function () {
9
+ $('.ccType').val($.payment.cardType(this.value))
10
10
  })
11
11
 
12
12
  $('.payment_methods_radios').click(
13
- function() {
14
- $('.payment-methods').hide();
15
- $('.payment-methods :input').prop('disabled', true);
13
+ function () {
14
+ $('.payment-methods').hide()
15
+ $('.payment-methods :input').prop('disabled', true)
16
16
  if (this.checked) {
17
- $('#payment_method_' + this.value + ' :input').prop('disabled', false);
18
- $('#payment_method_' + this.value).show();
17
+ $('#payment_method_' + this.value + ' :input').prop('disabled', false)
18
+ $('#payment_method_' + this.value).show()
19
19
  }
20
20
  }
21
- );
21
+ )
22
22
 
23
23
  $('.payment_methods_radios').each(
24
- function() {
24
+ function () {
25
25
  if (this.checked) {
26
- $('#payment_method_' + this.value + ' :input').prop('disabled', false);
27
- $('#payment_method_' + this.value).show();
26
+ $('#payment_method_' + this.value + ' :input').prop('disabled', false)
27
+ $('#payment_method_' + this.value).show()
28
28
  } else {
29
- $('#payment_method_' + this.value).hide();
30
- $('#payment_method_' + this.value + ' :input').prop('disabled', true);
29
+ $('#payment_method_' + this.value).hide()
30
+ $('#payment_method_' + this.value + ' :input').prop('disabled', true)
31
31
  }
32
32
 
33
- if ($("#card_new" + this.value).is("*")) {
34
- $("#card_new" + this.value).radioControlsVisibilityOfElement('#card_form' + this.value);
33
+ if ($('#card_new' + this.value).is('*')) {
34
+ $('#card_new' + this.value).radioControlsVisibilityOfElement('#card_form' + this.value)
35
35
  }
36
36
  }
37
- );
37
+ )
38
38
 
39
- $('.cvvLink').click(function(event){
40
- window_name = 'cvv_info';
41
- window_options = 'left=20,top=20,width=500,height=500,toolbar=0,resizable=0,scrollbars=1';
42
- window.open($(this).prop('href'), window_name, window_options);
43
- event.preventDefault();
44
- });
39
+ $('.cvvLink').click(function (event) {
40
+ var windowName = 'cvv_info'
41
+ var windowOptions = 'left=20,top=20,width=500,height=500,toolbar=0,resizable=0,scrollbars=1'
42
+ window.open($(this).prop('href'), windowName, windowOptions)
43
+ event.preventDefault()
44
+ })
45
45
 
46
- $('select.jump_menu').change(function(){
47
- window.location = this.options[this.selectedIndex].value;
48
- });
46
+ $('select.jump_menu').change(function () {
47
+ window.location = this.options[this.selectedIndex].value
48
+ })
49
49
  }
50
- });
50
+ })
@@ -1,12 +1,12 @@
1
1
  $.fn.productAutocomplete = function (options) {
2
- 'use strict';
2
+ 'use strict'
3
3
 
4
4
  // Default options
5
- options = options || {};
6
- var multiple = typeof(options.multiple) !== 'undefined' ? options.multiple : true;
5
+ options = options || {}
6
+ var multiple = typeof (options.multiple) !== 'undefined' ? options.multiple : true
7
7
 
8
- function formatProduct(product) {
9
- return Select2.util.escapeMarkup(product.name);
8
+ function formatProduct (product) {
9
+ return Select2.util.escapeMarkup(product.name)
10
10
  }
11
11
 
12
12
  this.select2({
@@ -17,8 +17,8 @@ $.fn.productAutocomplete = function (options) {
17
17
  ids: element.val().split(','),
18
18
  token: Spree.api_key
19
19
  }, function (data) {
20
- callback(multiple ? data.products : data.products[0]);
21
- });
20
+ callback(multiple ? data.products : data.products[0])
21
+ })
22
22
  },
23
23
  ajax: {
24
24
  url: Spree.routes.products_api,
@@ -27,24 +27,24 @@ $.fn.productAutocomplete = function (options) {
27
27
  data: function (term, page) {
28
28
  return {
29
29
  q: {
30
- name_or_master_sku_cont: term,
30
+ name_or_master_sku_cont: term
31
31
  },
32
32
  m: 'OR',
33
33
  token: Spree.api_key
34
- };
34
+ }
35
35
  },
36
36
  results: function (data, page) {
37
- var products = data.products ? data.products : [];
37
+ var products = data.products ? data.products : []
38
38
  return {
39
39
  results: products
40
- };
40
+ }
41
41
  }
42
42
  },
43
43
  formatResult: formatProduct,
44
44
  formatSelection: formatProduct
45
- });
46
- };
45
+ })
46
+ }
47
47
 
48
48
  $(document).ready(function () {
49
- $('.product_picker').productAutocomplete();
50
- });
49
+ $('.product_picker').productAutocomplete()
50
+ })
@@ -0,0 +1,8 @@
1
+ $(function () {
2
+ $(document).ajaxStart(function () {
3
+ $('#progress').stop(true, true).fadeIn()
4
+ })
5
+ $(document).ajaxStop(function () {
6
+ $('#progress').fadeOut()
7
+ })
8
+ })