solidus_backend 1.0.7 → 1.1.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.

Files changed (201) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/spree/backend.js +3 -0
  3. data/app/assets/javascripts/spree/backend/admin.js.erb +17 -24
  4. data/app/assets/javascripts/spree/backend/checkouts/edit.js +3 -5
  5. data/app/assets/javascripts/spree/backend/flash.coffee +17 -0
  6. data/app/assets/javascripts/spree/backend/handlebars_extensions.coffee +9 -0
  7. data/app/assets/javascripts/spree/backend/option_type_autocomplete.js.erb +6 -6
  8. data/app/assets/javascripts/spree/backend/option_value_picker.js +43 -0
  9. data/app/assets/javascripts/spree/backend/product_picker.js +10 -8
  10. data/app/assets/javascripts/spree/backend/promotions.js.coffee +101 -0
  11. data/app/assets/javascripts/spree/backend/routes.js +2 -1
  12. data/app/assets/javascripts/spree/backend/shipments.js.erb +1 -1
  13. data/app/assets/javascripts/spree/backend/stock_management/index_add_forms.coffee +1 -1
  14. data/app/assets/javascripts/spree/backend/stock_movement.js.coffee +2 -2
  15. data/app/assets/javascripts/spree/backend/stock_transfers/variant_form.coffee +1 -1
  16. data/app/assets/javascripts/spree/backend/taxon_autocomplete.js.erb +6 -6
  17. data/app/assets/javascripts/spree/backend/taxons.js.coffee +6 -7
  18. data/app/assets/javascripts/spree/backend/templates/orders/customer_details/autocomplete.hbs +17 -0
  19. data/app/assets/javascripts/spree/backend/templates/products/sortable.hbs +5 -0
  20. data/app/assets/javascripts/spree/backend/templates/promotions/calculators/fields/tiered_flat_rate.hbs +17 -0
  21. data/app/assets/javascripts/spree/backend/templates/promotions/calculators/fields/tiered_percent.hbs +17 -0
  22. data/app/assets/javascripts/spree/backend/templates/promotions/rules/option_values.hbs +10 -0
  23. data/app/assets/javascripts/spree/backend/templates/promotions/rules/option_values_select.hbs +1 -0
  24. data/app/assets/javascripts/spree/backend/templates/stock_items/stock_location_stock_item.hbs +19 -0
  25. data/app/assets/javascripts/spree/backend/templates/stock_transfers/transfer_item.hbs.erb +52 -0
  26. data/app/assets/javascripts/spree/backend/templates/variants/autocomplete.hbs.erb +23 -0
  27. data/app/assets/javascripts/spree/backend/templates/variants/autocomplete_stock.hbs +51 -0
  28. data/app/assets/javascripts/spree/backend/templates/variants/line_items_autocomplete_stock.hbs +67 -0
  29. data/app/assets/javascripts/spree/backend/templates/variants/split.hbs +27 -0
  30. data/app/assets/javascripts/spree/backend/user_picker.js +8 -8
  31. data/app/assets/javascripts/spree/backend/variant_autocomplete.js.coffee.erb +6 -8
  32. data/app/assets/stylesheets/spree/backend/components/_messages.scss +6 -3
  33. data/app/assets/stylesheets/spree/backend/sections/_promotions.scss +16 -0
  34. data/app/controllers/spree/admin/base_controller.rb +1 -1
  35. data/app/controllers/spree/admin/option_types_controller.rb +1 -3
  36. data/app/controllers/spree/admin/orders/customer_details_controller.rb +1 -1
  37. data/app/controllers/spree/admin/orders_controller.rb +6 -11
  38. data/app/controllers/spree/admin/product_properties_controller.rb +9 -0
  39. data/app/controllers/spree/admin/products_controller.rb +20 -5
  40. data/app/controllers/spree/admin/promotions_controller.rb +2 -1
  41. data/app/controllers/spree/admin/reimbursements_controller.rb +20 -0
  42. data/app/controllers/spree/admin/resource_controller.rb +1 -1
  43. data/app/controllers/spree/admin/return_authorizations_controller.rb +5 -0
  44. data/app/controllers/spree/admin/root_controller.rb +1 -1
  45. data/app/controllers/spree/admin/search_controller.rb +2 -4
  46. data/app/controllers/spree/admin/states_controller.rb +1 -1
  47. data/app/controllers/spree/admin/stock_items_controller.rb +1 -1
  48. data/app/controllers/spree/admin/stock_transfers_controller.rb +3 -14
  49. data/app/controllers/spree/admin/users_controller.rb +2 -3
  50. data/app/controllers/spree/admin/variant_property_rule_values_controller.rb +7 -0
  51. data/app/controllers/spree/admin/variants_controller.rb +1 -1
  52. data/app/controllers/spree/admin/zones_controller.rb +1 -1
  53. data/app/helpers/spree/admin/adjustments_helper.rb +4 -9
  54. data/app/helpers/spree/admin/base_helper.rb +7 -6
  55. data/app/helpers/spree/admin/navigation_helper.rb +8 -2
  56. data/app/helpers/spree/admin/orders_helper.rb +1 -1
  57. data/app/helpers/spree/admin/products_helper.rb +2 -4
  58. data/app/helpers/spree/admin/stock_movements_helper.rb +3 -3
  59. data/app/views/spree/admin/adjustments/_adjustment.html.erb +1 -1
  60. data/app/views/spree/admin/orders/_add_line_item.html.erb +0 -5
  61. data/app/views/spree/admin/orders/_add_product.html.erb +0 -3
  62. data/app/views/spree/admin/orders/_carton.html.erb +0 -1
  63. data/app/views/spree/admin/orders/_shipment.html.erb +0 -1
  64. data/app/views/spree/admin/orders/confirm/_shipment.html.erb +0 -1
  65. data/app/views/spree/admin/orders/customer_details/_form.html.erb +1 -1
  66. data/app/views/spree/admin/orders/customer_details/edit.html.erb +0 -1
  67. data/app/views/spree/admin/orders/index.html.erb +1 -2
  68. data/app/views/spree/admin/payment_methods/_form.html.erb +0 -4
  69. data/app/views/spree/admin/payment_methods/index.html.erb +0 -2
  70. data/app/views/spree/admin/payments/source_views/_gateway.html.erb +3 -0
  71. data/app/views/spree/admin/product_properties/index.html.erb +52 -2
  72. data/app/views/spree/admin/promotions/_actions.html.erb +14 -10
  73. data/app/views/spree/admin/promotions/_promotion_action.html.erb +5 -3
  74. data/app/views/spree/admin/promotions/_promotion_rule.html.erb +5 -3
  75. data/app/views/spree/admin/promotions/_rules.html.erb +18 -14
  76. data/app/views/spree/admin/promotions/calculators/tiered_flat_rate/_fields.html.erb +5 -28
  77. data/app/views/spree/admin/promotions/calculators/tiered_percent/_fields.html.erb +5 -27
  78. data/app/views/spree/admin/promotions/edit.html.erb +6 -4
  79. data/app/views/spree/admin/promotions/index.html.erb +1 -1
  80. data/app/views/spree/admin/promotions/rules/_option_value.html.erb +13 -0
  81. data/app/views/spree/admin/refund_reasons/index.html.erb +2 -2
  82. data/app/views/spree/admin/reimbursements/edit.html.erb +1 -1
  83. data/app/views/spree/admin/return_authorizations/_form.html.erb +2 -2
  84. data/app/views/spree/admin/search/users.rabl +1 -1
  85. data/app/views/spree/admin/shared/_order_summary.html.erb +6 -0
  86. data/app/views/spree/admin/shared/_tabs.html.erb +2 -2
  87. data/app/views/spree/admin/shared/_translations.html.erb +16 -46
  88. data/app/views/spree/admin/shared/named_types/_index.html.erb +2 -2
  89. data/app/views/spree/admin/stock_items/_stock_management.html.erb +0 -2
  90. data/app/views/spree/admin/stock_movements/_form.html.erb +0 -2
  91. data/app/views/spree/admin/stock_transfers/edit.html.erb +0 -3
  92. data/app/views/spree/admin/stock_transfers/receive.html.erb +0 -2
  93. data/app/views/spree/admin/stock_transfers/show.html.erb +1 -1
  94. data/app/views/spree/admin/taxons/index.html.erb +0 -1
  95. data/app/views/spree/admin/users/_addresses_form.html.erb +4 -4
  96. data/app/views/spree/layouts/admin.html.erb +11 -9
  97. data/config/routes.rb +5 -0
  98. data/lib/spree/backend.rb +1 -2
  99. metadata +41 -139
  100. data/CHANGELOG.md +0 -1
  101. data/Gemfile +0 -6
  102. data/Rakefile +0 -15
  103. data/app/assets/javascripts/spree/backend/handlebar_extensions.js +0 -9
  104. data/app/assets/javascripts/spree/backend/promotions.js +0 -73
  105. data/app/assets/javascripts/spree/backend/stock_transfer.js.coffee +0 -196
  106. data/app/views/spree/admin/products/_autocomplete.js.erb +0 -14
  107. data/app/views/spree/admin/products/_sortable.html +0 -7
  108. data/app/views/spree/admin/stock_items/_stock_location_stock_item_template.html.erb +0 -21
  109. data/app/views/spree/admin/stock_transfers/_transfer_item_template.html.erb +0 -54
  110. data/app/views/spree/admin/variants/_autocomplete.js.erb +0 -25
  111. data/app/views/spree/admin/variants/_autocomplete_line_items_stock.js.erb +0 -69
  112. data/app/views/spree/admin/variants/_autocomplete_stock.js.erb +0 -53
  113. data/app/views/spree/admin/variants/_split.js.erb +0 -29
  114. data/script/rails +0 -9
  115. data/solidus_backend.gemspec +0 -30
  116. data/spec/controllers/spree/admin/base_controller_spec.rb +0 -24
  117. data/spec/controllers/spree/admin/cancellations_controller_spec.rb +0 -77
  118. data/spec/controllers/spree/admin/customer_returns_controller_spec.rb +0 -234
  119. data/spec/controllers/spree/admin/general_settings_controller_spec.rb +0 -41
  120. data/spec/controllers/spree/admin/missing_products_controller_spec.rb +0 -18
  121. data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +0 -80
  122. data/spec/controllers/spree/admin/orders_controller_spec.rb +0 -472
  123. data/spec/controllers/spree/admin/payment_methods_controller_spec.rb +0 -49
  124. data/spec/controllers/spree/admin/payments_controller_spec.rb +0 -175
  125. data/spec/controllers/spree/admin/products_controller_spec.rb +0 -45
  126. data/spec/controllers/spree/admin/promotion_actions_controller_spec.rb +0 -21
  127. data/spec/controllers/spree/admin/promotion_codes_controller_spec.rb +0 -18
  128. data/spec/controllers/spree/admin/promotion_rules_controller_spec.rb +0 -21
  129. data/spec/controllers/spree/admin/promotions_controller_spec.rb +0 -122
  130. data/spec/controllers/spree/admin/refunds_controller_spec.rb +0 -32
  131. data/spec/controllers/spree/admin/reimbursements_controller_spec.rb +0 -75
  132. data/spec/controllers/spree/admin/reports_controller_spec.rb +0 -134
  133. data/spec/controllers/spree/admin/resource_controller_spec.rb +0 -166
  134. data/spec/controllers/spree/admin/return_authorizations_controller_spec.rb +0 -226
  135. data/spec/controllers/spree/admin/return_items_controller_spec.rb +0 -27
  136. data/spec/controllers/spree/admin/root_controller_spec.rb +0 -41
  137. data/spec/controllers/spree/admin/search_controller_spec.rb +0 -104
  138. data/spec/controllers/spree/admin/shipping_methods_controller_spec.rb +0 -14
  139. data/spec/controllers/spree/admin/stock_items_controller_spec.rb +0 -50
  140. data/spec/controllers/spree/admin/stock_locations_controller_spec.rb +0 -41
  141. data/spec/controllers/spree/admin/stock_transfers_controller_spec.rb +0 -331
  142. data/spec/controllers/spree/admin/store_credits_controller_spec.rb +0 -309
  143. data/spec/controllers/spree/admin/users_controller_spec.rb +0 -236
  144. data/spec/controllers/spree/admin/variants_controller_spec.rb +0 -32
  145. data/spec/features/admin/configuration/analytics_tracker_spec.rb +0 -54
  146. data/spec/features/admin/configuration/countries_spec.rb +0 -22
  147. data/spec/features/admin/configuration/general_settings_spec.rb +0 -45
  148. data/spec/features/admin/configuration/payment_methods_spec.rb +0 -125
  149. data/spec/features/admin/configuration/shipping_methods_spec.rb +0 -64
  150. data/spec/features/admin/configuration/states_spec.rb +0 -64
  151. data/spec/features/admin/configuration/stock_locations_spec.rb +0 -50
  152. data/spec/features/admin/configuration/tax_categories_spec.rb +0 -56
  153. data/spec/features/admin/configuration/tax_rates_spec.rb +0 -30
  154. data/spec/features/admin/configuration/taxonomies_spec.rb +0 -52
  155. data/spec/features/admin/configuration/zones_spec.rb +0 -39
  156. data/spec/features/admin/homepage_spec.rb +0 -78
  157. data/spec/features/admin/locale_spec.rb +0 -30
  158. data/spec/features/admin/orders/adjustments_promotions_spec.rb +0 -53
  159. data/spec/features/admin/orders/adjustments_spec.rb +0 -126
  160. data/spec/features/admin/orders/cancelling_and_resuming_spec.rb +0 -48
  161. data/spec/features/admin/orders/cancelling_inventory_spec.rb +0 -48
  162. data/spec/features/admin/orders/customer_details_spec.rb +0 -163
  163. data/spec/features/admin/orders/line_items_spec.rb +0 -50
  164. data/spec/features/admin/orders/listing_spec.rb +0 -130
  165. data/spec/features/admin/orders/log_entries_spec.rb +0 -55
  166. data/spec/features/admin/orders/new_order_spec.rb +0 -197
  167. data/spec/features/admin/orders/order_details_spec.rb +0 -533
  168. data/spec/features/admin/orders/payments_spec.rb +0 -228
  169. data/spec/features/admin/orders/risk_analysis_spec.rb +0 -47
  170. data/spec/features/admin/orders/shipments_spec.rb +0 -65
  171. data/spec/features/admin/payments/store_credits_spec.rb +0 -21
  172. data/spec/features/admin/products/edit/images_spec.rb +0 -87
  173. data/spec/features/admin/products/edit/products_spec.rb +0 -66
  174. data/spec/features/admin/products/edit/taxons_spec.rb +0 -56
  175. data/spec/features/admin/products/edit/variants_spec.rb +0 -61
  176. data/spec/features/admin/products/option_types_spec.rb +0 -114
  177. data/spec/features/admin/products/products_spec.rb +0 -392
  178. data/spec/features/admin/products/properties_spec.rb +0 -139
  179. data/spec/features/admin/products/prototypes_spec.rb +0 -110
  180. data/spec/features/admin/products/stock_management_spec.rb +0 -82
  181. data/spec/features/admin/products/variant_spec.rb +0 -51
  182. data/spec/features/admin/promotion_adjustments_spec.rb +0 -220
  183. data/spec/features/admin/promotions/tiered_calculator_spec.rb +0 -69
  184. data/spec/features/admin/promotions/user_rule_spec.rb +0 -25
  185. data/spec/features/admin/reports_spec.rb +0 -61
  186. data/spec/features/admin/stock_transfer_spec.rb +0 -86
  187. data/spec/features/admin/store_credits_spec.rb +0 -82
  188. data/spec/features/admin/taxons_spec.rb +0 -31
  189. data/spec/features/admin/users_spec.rb +0 -270
  190. data/spec/helpers/admin/base_helper_spec.rb +0 -24
  191. data/spec/helpers/admin/navigation_helper_spec.rb +0 -73
  192. data/spec/helpers/admin/reimbursements_helper_spec.rb +0 -34
  193. data/spec/helpers/admin/stock_movements_helper_spec.rb +0 -29
  194. data/spec/helpers/admin/store_credit_events_helper_spec.rb +0 -95
  195. data/spec/helpers/promotion_rules_helper_spec.rb +0 -12
  196. data/spec/spec_helper.rb +0 -108
  197. data/spec/support/appear_before_matcher.rb +0 -8
  198. data/spec/support/ror_ringer.jpeg +0 -0
  199. data/spec/test_views/spree/admin/widgets/edit.html.erb +0 -1
  200. data/spec/test_views/spree/admin/widgets/new.html.erb +0 -1
  201. data/vendor/assets/javascripts/handlebars.js +0 -2746
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4dbbf7a5f419e4c7ff6f2ec55a6623f97d29c846
4
- data.tar.gz: e5b5eae32640e97530ea948f9963c758ff7b021c
3
+ metadata.gz: 31c0e6ee035ec9c8679843792c20cf6ccffbd137
4
+ data.tar.gz: a9f07294542aaaceea52e73fbafd7ff7b011421a
5
5
  SHA512:
6
- metadata.gz: 7284f3d05bc0c3c4acda21dcdb2a2304b868f9f15dff52d3f41e205c91aeb81799e06fd53127d56bf21c4c2267f9e29f06f799805fbf40761f1f8c069756b9a7
7
- data.tar.gz: 2e7b0c1455a7e2a2711bbf77910993c5023139ee117a24f8415c5472ca21467aeeb9cba1ed9fe2a1f1ea8e31a40703abc7ce502bae83d2a775ad040e62dfb044
6
+ metadata.gz: 9f3b42161d63c0439952e919e1588864b45cff766e70a4a94f2b6ee32a5dcdb7ad252d869a59d3ab02cd47ae36614c9552a0b199ffb4f1d0827913e7c9099620
7
+ data.tar.gz: 35aa2571b81598639e3e0ab1694a7991351f45ba29f781185cca9c300067b55f918c038e3c3db238a8807266f17dbe88af955b7b18f5f7620f0af0e050bd07a0
@@ -1,5 +1,7 @@
1
+ //= require handlebars
1
2
  //= require jquery
2
3
  //= require jquery_ujs
4
+ //= require jquery-migrate-1.0.0
3
5
  //= require jquery-ui/datepicker
4
6
  //= require jquery-ui/sortable
5
7
  //= require jquery-ui/autocomplete
@@ -15,5 +17,6 @@
15
17
  //= require spree
16
18
  //= require ./backend/backbone-overrides
17
19
  //= require spree/backend/spree-select2
20
+ //= require_tree ./backend/templates
18
21
  //= require_tree .
19
22
 
@@ -1,10 +1,11 @@
1
1
  //= require_self
2
- //= require spree/backend/handlebar_extensions
2
+ //= require spree/backend/handlebars_extensions
3
3
  //= require spree/backend/variant_autocomplete
4
4
  //= require spree/backend/taxon_autocomplete
5
5
  //= require spree/backend/option_type_autocomplete
6
6
  //= require spree/backend/user_picker
7
7
  //= require spree/backend/product_picker
8
+ //= require spree/backend/option_value_picker
8
9
  //= require spree/backend/taxons
9
10
 
10
11
  /**
@@ -34,9 +35,6 @@ jQuery(function($) {
34
35
  $('#powerTip').removeClass($(this).data('action'));
35
36
  })
36
37
 
37
- // Make flash messages dissapear
38
- setTimeout('$(".flash").fadeOut()', 5000);
39
-
40
38
  // Highlight hovered table column
41
39
  $('table tbody tr td.actions').find('a, button').hover(function(){
42
40
  var tr = $(this).closest('tr');
@@ -58,16 +56,6 @@ jQuery(function($) {
58
56
 
59
57
  $.fn.visible = function(cond) { this[cond ? 'show' : 'hide' ]() };
60
58
 
61
- show_flash = function(type, message) {
62
- var flash_div = $('.flash.' + type);
63
- if (flash_div.length == 0) {
64
- flash_div = $('<div class="flash ' + type + '" />');
65
- $('#wrapper').prepend(flash_div);
66
- }
67
- flash_div.html(message).show().delay(5000).fadeOut(500);
68
- }
69
-
70
-
71
59
  // Apply to individual radio button that makes another element visible when checked
72
60
  $.fn.radioControlsVisibilityOfElement = function(dependentElementSelector){
73
61
  if(!this.get(0)){ return }
@@ -124,8 +112,9 @@ $(document).ready(function(){
124
112
  new_table_row.find("input, select").each(function () {
125
113
  var el = $(this);
126
114
  el.val("");
127
- el.prop("id", el.prop("id").replace(/\d+/, new_id))
128
- el.prop("name", el.prop("name").replace(/\d+/, new_id))
115
+ // Replace last occurrence of a number
116
+ el.prop("id", el.prop("id").replace(/\d+(?=[^\d]*$)/, new_id))
117
+ el.prop("name", el.prop("name").replace(/\d+(?=[^\d]*$)/, new_id))
129
118
  })
130
119
  // When cloning a new row, set the href of all icons to be an empty "#"
131
120
  // This is so that clicking on them does not perform the actions for the
@@ -216,18 +205,21 @@ $(document).ready(function(){
216
205
  placeholder: 'ui-sortable-placeholder',
217
206
  update: function(event, ui) {
218
207
  $("#progress").show();
208
+ tableEl = $(ui.item).closest("table.sortable")
219
209
  positions = {};
220
- $.each($('table.sortable tbody tr'), function(position, obj){
221
- reg = /spree_(\w+_?)+_(\d+)/;
222
- parts = reg.exec($(obj).prop('id'));
223
- if (parts) {
224
- positions['positions['+parts[2]+']'] = position;
210
+ $.each(tableEl.find('tbody tr'), function(position, obj){
211
+ idAttr = $(obj).prop('id');
212
+ if (idAttr) {
213
+ objId = idAttr.split('_').slice(-1);
214
+ if (!isNaN(objId)) {
215
+ positions['positions['+objId+']'] = position;
216
+ }
225
217
  }
226
218
  });
227
219
  Spree.ajax({
228
220
  type: 'POST',
229
221
  dataType: 'script',
230
- url: $(ui.item).closest("table.sortable").data("sortable-link"),
222
+ url: tableEl.data("sortable-link"),
231
223
  data: positions,
232
224
  success: function(data){ $("#progress").hide(); }
233
225
  });
@@ -239,9 +231,10 @@ $(document).ready(function(){
239
231
  ui.placeholder.html("<td colspan='"+(td_count-1)+"'></td><td class='actions'></td>")
240
232
  },
241
233
  stop: function (event, ui) {
234
+ tableEl = $(ui.item).closest("table.sortable")
242
235
  // Fix odd/even classes after reorder
243
- $("table.sortable tr:even").removeClass("odd even").addClass("even");
244
- $("table.sortable tr:odd").removeClass("odd even").addClass("odd");
236
+ tableEl.find("tr:even").removeClass("odd even").addClass("even");
237
+ tableEl.find("tr:odd").removeClass("odd even").addClass("odd");
245
238
  }
246
239
 
247
240
  });
@@ -1,8 +1,6 @@
1
1
  //= require_self
2
2
  $(document).ready(function() {
3
- if ($('#customer_autocomplete_template').length > 0) {
4
- window.customerTemplate = Handlebars.compile($('#customer_autocomplete_template').text());
5
- }
3
+ window.customerTemplate = HandlebarsTemplates['orders/customer_details/autocomplete'];
6
4
 
7
5
  formatCustomerResult = function(customer) {
8
6
  return customerTemplate({
@@ -26,7 +24,7 @@ $(document).ready(function() {
26
24
  }
27
25
  },
28
26
  results: function(data, page) {
29
- return { results: data.users }
27
+ return { results: data }
30
28
  }
31
29
  },
32
30
  dropdownCssClass: 'customer_search',
@@ -54,7 +52,7 @@ $(document).ready(function() {
54
52
  });
55
53
  });
56
54
  }
57
- return Select2.util.escapeMarkup(customer.email);
55
+ return customer.email;
58
56
  }
59
57
  })
60
58
  }
@@ -0,0 +1,17 @@
1
+ showTime = 5000
2
+ fadeOutTime = 500
3
+
4
+ $ ->
5
+ # Make flash messages dissapear
6
+ # We only want to target the flash messages which are initially on the page.
7
+ # Otherwise we risk hiding messages added by show_flash
8
+ $initialFlash = $(".flash")
9
+ setTimeout (->
10
+ $initialFlash.fadeOut(fadeOutTime)
11
+ ), showTime
12
+
13
+ window.show_flash = (type, message) ->
14
+ $flashWrapper = $(".js-flash-wrapper")
15
+ flash_div = $("<div class=\"flash #{type}\" />")
16
+ $flashWrapper.prepend(flash_div)
17
+ flash_div.html(message).show().delay(showTime).fadeOut(fadeOutTime)
@@ -0,0 +1,9 @@
1
+ #= require handlebars
2
+
3
+ Handlebars.registerHelper "t", (key)->
4
+ if Spree.translations[key]
5
+ Spree.translations[key]
6
+ else
7
+ console.error "No translation found for #{key}."
8
+ key
9
+
@@ -1,10 +1,6 @@
1
1
  $(document).ready(function () {
2
2
  'use strict';
3
3
 
4
- function formatOptionType(option_type) {
5
- return Select2.util.escapeMarkup(option_type.presentation + ' (' + option_type.name + ')');
6
- }
7
-
8
4
  if ($('#product_option_type_ids').length > 0) {
9
5
  $('#product_option_type_ids').select2({
10
6
  placeholder: Spree.translations.option_type_placeholder,
@@ -35,8 +31,12 @@ $(document).ready(function () {
35
31
  };
36
32
  }
37
33
  },
38
- formatResult: formatOptionType,
39
- formatSelection: formatOptionType
34
+ formatResult: function (option_type) {
35
+ return option_type.presentation + ' (' + option_type.name + ')';
36
+ },
37
+ formatSelection: function (option_type) {
38
+ return option_type.presentation + ' (' + option_type.name + ')';
39
+ }
40
40
  });
41
41
  }
42
42
  });
@@ -0,0 +1,43 @@
1
+ $.fn.optionValueAutocomplete = function (options) {
2
+ 'use strict';
3
+
4
+ // Default options
5
+ options = options || {}
6
+ var multiple = typeof(options['multiple']) !== 'undefined' ? options['multiple'] : true;
7
+ var productSelect = options['productSelect'];
8
+
9
+ this.select2({
10
+ minimumInputLength: 3,
11
+ multiple: multiple,
12
+ initSelection: function (element, callback) {
13
+ $.get(Spree.routes.option_value_search, {
14
+ ids: element.val().split(',')
15
+ }, function (data) {
16
+ callback(multiple ? data : data[0]);
17
+ });
18
+ },
19
+ ajax: {
20
+ url: Spree.routes.option_value_search,
21
+ datatype: 'json',
22
+ data: function (term, page) {
23
+ var productId = typeof(productSelect) !== 'undefined' ? $(productSelect).select2('val') : null;
24
+ return {
25
+ q: {
26
+ name_cont: term,
27
+ variants_product_id_eq: productId
28
+ },
29
+ token: Spree.api_key
30
+ };
31
+ },
32
+ results: function (data, page) {
33
+ return { results: data };
34
+ }
35
+ },
36
+ formatResult: function (option_value) {
37
+ return option_value.name;
38
+ },
39
+ formatSelection: function (option_value) {
40
+ return option_value.name;
41
+ }
42
+ });
43
+ };
@@ -5,10 +5,6 @@ $.fn.productAutocomplete = function (options) {
5
5
  options = options || {}
6
6
  var multiple = typeof(options['multiple']) !== 'undefined' ? options['multiple'] : true
7
7
 
8
- function formatProduct(product) {
9
- return Select2.util.escapeMarkup(product.name);
10
- }
11
-
12
8
  this.select2({
13
9
  minimumInputLength: 3,
14
10
  multiple: multiple,
@@ -31,18 +27,24 @@ $.fn.productAutocomplete = function (options) {
31
27
  sku_cont: term
32
28
  },
33
29
  m: 'OR',
34
- token: Spree.api_key
30
+ token: Spree.api_key,
31
+ page: page
35
32
  };
36
33
  },
37
34
  results: function (data, page) {
38
35
  var products = data.products ? data.products : [];
39
36
  return {
40
- results: products
37
+ results: products,
38
+ more: (data.current_page * data.per_page) < data.total_count
41
39
  };
42
40
  }
43
41
  },
44
- formatResult: formatProduct,
45
- formatSelection: formatProduct
42
+ formatResult: function (product) {
43
+ return product.name;
44
+ },
45
+ formatSelection: function (product) {
46
+ return product.name;
47
+ }
46
48
  });
47
49
  };
48
50
 
@@ -0,0 +1,101 @@
1
+ window.initProductActions = ->
2
+ # Add classes on promotion items for design
3
+ $(document).on 'mouseover', 'a.delete', (event) ->
4
+ $(this).parent().addClass 'action-remove'
5
+
6
+ $(document).on 'mouseout', 'a.delete', (event) ->
7
+ $(this).parent().removeClass 'action-remove'
8
+
9
+ $('#promotion-filters').find('.variant_autocomplete').variantAutocomplete()
10
+
11
+ $('.calculator-fields').each ->
12
+ $fields_container = $(this)
13
+ $type_select = $fields_container.find('.type-select')
14
+ $settings = $fields_container.find('.settings')
15
+ $warning = $fields_container.find('.warning')
16
+ originalType = $type_select.val()
17
+ $warning.hide()
18
+ $type_select.change ->
19
+ if $(this).val() == originalType
20
+ $warning.hide()
21
+ $settings.show()
22
+ $settings.find('input').removeProp 'disabled'
23
+ else
24
+ $warning.show()
25
+ $settings.hide()
26
+ $settings.find('input').prop 'disabled', 'disabled'
27
+
28
+ #
29
+ # Option Value Promo Rule
30
+ #
31
+ if $('.promo-rule-option-values').length
32
+ optionValueSelectNameTemplate = HandlebarsTemplates['promotions/rules/option_values_select']
33
+ optionValueTemplate = HandlebarsTemplates['promotions/rules/option_values']
34
+
35
+ addOptionValue = (product, values) ->
36
+ paramPrefix = $('.promo-rule-option-values').find('.param-prefix').data('param-prefix')
37
+ $('.js-promo-rule-option-values').append optionValueTemplate(
38
+ productSelect: value: product
39
+ optionValuesSelect: value: values
40
+ paramPrefix: paramPrefix)
41
+ optionValue = $('.js-promo-rule-option-values .promo-rule-option-value').last()
42
+ optionValue.find('.js-promo-rule-option-value-product-select').productAutocomplete multiple: false
43
+ optionValue.find('.js-promo-rule-option-value-option-values-select').optionValueAutocomplete productSelect: '.js-promo-rule-option-value-product-select'
44
+ if product == null
45
+ optionValue.find('.js-promo-rule-option-value-option-values-select').prop 'disabled', true
46
+ return
47
+
48
+ originalOptionValues = $('.js-original-promo-rule-option-values').data('original-option-values')
49
+ if !$('.js-original-promo-rule-option-values').data('loaded')
50
+ if $.isEmptyObject(originalOptionValues)
51
+ addOptionValue null, null
52
+ else
53
+ $.each originalOptionValues, addOptionValue
54
+ $('.js-original-promo-rule-option-values').data 'loaded', true
55
+ $(document).on 'click', '.js-add-promo-rule-option-value', (event) ->
56
+ event.preventDefault()
57
+ addOptionValue null, null
58
+ return
59
+ $(document).on 'click', '.js-remove-promo-rule-option-value', ->
60
+ $(this).parents('.promo-rule-option-value').remove()
61
+ return
62
+ $(document).on 'change', '.js-promo-rule-option-value-product-select', ->
63
+ optionValueSelect = $(this).parents('.promo-rule-option-value').find('input.js-promo-rule-option-value-option-values-select')
64
+ paramPrefix = $('.promo-rule-option-values').find('.param-prefix').data('param-prefix')
65
+ optionValueSelect.attr 'name', optionValueSelectNameTemplate(product_id: $(this).val(), param_prefix: paramPrefix).trim()
66
+ optionValueSelect.prop('disabled', $(this).val() == '').select2 'val', ''
67
+ return
68
+
69
+ #
70
+ # Tiered Calculator
71
+ #
72
+ if $('.js-tiers').length
73
+ calculatorName = $('.js-tiers').data('calculator')
74
+ tierFieldsTemplate = HandlebarsTemplates["promotions/calculators/fields/#{calculatorName}"]
75
+ originalTiers = $('.js-tiers').data('original-tiers')
76
+ formPrefix = $('.js-tiers').data('form-prefix')
77
+
78
+ tierInputName = (base) ->
79
+ "#{formPrefix}[calculator_attributes][preferred_tiers][#{base}]"
80
+
81
+ $.each originalTiers, (base, value) ->
82
+ $('.js-tiers').append tierFieldsTemplate
83
+ baseField:
84
+ value: base
85
+ valueField:
86
+ name: tierInputName(base)
87
+ value: value
88
+
89
+ $(document).on 'click', '.js-add-tier', (event) ->
90
+ event.preventDefault()
91
+ $('.js-tiers').append tierFieldsTemplate(valueField: name: null)
92
+
93
+ $(document).on 'click', '.js-remove-tier', (event) ->
94
+ event.preventDefault()
95
+ $(this).parents('.tier').remove()
96
+
97
+ $(document).on 'change', '.js-base-input', (event) ->
98
+ valueInput = $(this).parents('.tier').find('.js-value-input')
99
+ valueInput.attr 'name', tierInputName($(this).val())
100
+
101
+ $ initProductActions
@@ -1,6 +1,7 @@
1
1
  Spree.routes.checkouts_api = Spree.pathFor('api/checkouts')
2
2
  Spree.routes.classifications_api = Spree.pathFor('api/classifications')
3
3
  Spree.routes.clear_cache = Spree.pathFor('admin/general_settings/clear_cache')
4
+ Spree.routes.option_value_search = Spree.pathFor('api/option_values')
4
5
  Spree.routes.option_type_search = Spree.pathFor('api/option_types')
5
6
  Spree.routes.orders_api = Spree.pathFor('api/orders')
6
7
  Spree.routes.product_search = Spree.pathFor('api/products')
@@ -25,7 +26,7 @@ Spree.routes.stock_items_api = function(stock_location_id) {
25
26
  return Spree.pathFor('api/stock_locations/' + stock_location_id + '/stock_items')
26
27
  }
27
28
 
28
- Spree.routes.receive_transfer_items_api = function(stockTransferNumber) {
29
+ Spree.routes.receive_stock_transfer_api = function(stockTransferNumber) {
29
30
  return Spree.pathFor('api/stock_transfers/' + stockTransferNumber + '/receive')
30
31
  }
31
32
 
@@ -218,7 +218,7 @@ startItemSplit = function(event){
218
218
  });
219
219
 
220
220
  var max_quantity = link.closest('tr').data('item-quantity');
221
- var split_item_template = Handlebars.compile($('#variant_split_template').text());
221
+ var split_item_template = HandlebarsTemplates['variants/split'];
222
222
  link.closest('tr').after(split_item_template({ variant: variant, shipments: shipments, max_quantity: max_quantity }));
223
223
  $('a.cancel-split').click(cancelItemSplit);
224
224
  $('a.save-split').click(completeItemSplit);
@@ -42,7 +42,7 @@ class IndexAddForms
42
42
  stockLocationName = selectedStockLocationOption.text().trim()
43
43
  selectedStockLocationOption.remove()
44
44
 
45
- rowTemplate = Handlebars.compile($('#stock-item-count-for-location-template').html())
45
+ rowTemplate = HandlebarsTemplates['stock_items/stock_location_stock_item']
46
46
  $("tr[data-variant-id='#{variantId}']:last").before(
47
47
  rowTemplate
48
48
  id: stockItem.id
@@ -17,5 +17,5 @@ jQuery ->
17
17
  return { results: data.stock_items, more: more }
18
18
  formatResult: (stock_item) ->
19
19
  variantTemplate({ variant: stock_item.variant })
20
- formatSelection: (stock_item, container, excapeMarkup) ->
21
- Select2.util.escapeMarkup("#{stock_item.variant.name} (#{stock_item.variant.options_text})")
20
+ formatSelection: (stock_item) ->
21
+ "#{stock_item.variant.name} (#{stock_item.variant.options_text})"
@@ -77,7 +77,7 @@ class VariantForm
77
77
 
78
78
  successHandler = (transferItem, isReceiving) =>
79
79
  resetVariantAutocomplete()
80
- rowTemplate = Handlebars.compile($('#transfer-item-template').html())
80
+ rowTemplate = HandlebarsTemplates['stock_transfers/transfer_item']
81
81
  templateAttributes =
82
82
  id: transferItem.id
83
83
  isReceiving: isReceiving