solidus_backend 2.2.2 → 2.3.0.beta1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of solidus_backend might be problematic. Click here for more details.

Files changed (186) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/spree/backend.js +1 -2
  3. data/app/assets/javascripts/spree/backend/address_states.js +1 -1
  4. data/app/assets/javascripts/spree/backend/adjustments.js.coffee +1 -1
  5. data/app/assets/javascripts/spree/backend/admin.js +37 -41
  6. data/app/assets/javascripts/spree/backend/components/editable_table.js.coffee +3 -0
  7. data/app/assets/javascripts/spree/backend/images/index.js.coffee +1 -1
  8. data/app/assets/javascripts/spree/backend/images/upload.js +13 -189
  9. data/app/assets/javascripts/spree/backend/models/image_upload.js +76 -0
  10. data/app/assets/javascripts/spree/backend/models/index.js +2 -0
  11. data/app/assets/javascripts/spree/backend/models/taxonomy.js +3 -0
  12. data/app/assets/javascripts/spree/backend/namespaces.js +3 -1
  13. data/app/assets/javascripts/spree/backend/payments/new.js +8 -36
  14. data/app/assets/javascripts/spree/backend/promotions.js.coffee +1 -1
  15. data/app/assets/javascripts/spree/backend/select_payments.js.coffee +0 -12
  16. data/app/assets/javascripts/spree/backend/shipments.js +1 -1
  17. data/app/assets/javascripts/spree/backend/spree-select2.js +1 -1
  18. data/app/assets/javascripts/spree/backend/taxonomy.js.coffee +101 -95
  19. data/app/assets/javascripts/spree/backend/templates/products/upload_progress.hbs +5 -3
  20. data/app/assets/javascripts/spree/backend/views/images/upload_progress.js +48 -0
  21. data/app/assets/javascripts/spree/backend/views/images/upload_zone.js +39 -0
  22. data/app/assets/javascripts/spree/backend/views/index.js +6 -0
  23. data/app/assets/javascripts/spree/backend/views/order/address.js +1 -5
  24. data/app/assets/javascripts/spree/backend/views/payment/edit_credit_card.js +23 -0
  25. data/app/assets/javascripts/spree/backend/views/payment/new.js +25 -0
  26. data/app/assets/javascripts/spree/backend/views/state_select.js +4 -4
  27. data/app/assets/javascripts/spree/backend/views/tables/editable_table.js.coffee +14 -0
  28. data/app/assets/javascripts/spree/backend/views/tables/editable_table_row.js.coffee +45 -0
  29. data/app/assets/stylesheets/spree/backend/components/_date-picker.scss +0 -1
  30. data/app/assets/stylesheets/spree/backend/components/_editable_table.scss +37 -0
  31. data/app/assets/stylesheets/spree/backend/plugins/_bootstrap_tooltip.scss +2 -2
  32. data/app/assets/stylesheets/spree/backend/sections/_products.scss +0 -8
  33. data/app/assets/stylesheets/spree/backend/sections/_style_guide.scss +15 -9
  34. data/app/assets/stylesheets/spree/backend/shared/_icons.scss +14 -14
  35. data/app/assets/stylesheets/spree/backend/shared/_tables.scss +1 -2
  36. data/app/assets/stylesheets/spree/backend/shared/_utilities.scss +13 -0
  37. data/app/assets/stylesheets/spree/backend/spree_admin.scss +1 -1
  38. data/app/controllers/spree/admin/cancellations_controller.rb +1 -1
  39. data/app/controllers/spree/admin/orders/customer_details_controller.rb +1 -1
  40. data/app/controllers/spree/admin/orders_controller.rb +3 -10
  41. data/app/controllers/spree/admin/payment_methods_controller.rb +19 -6
  42. data/app/controllers/spree/admin/payments_controller.rb +2 -2
  43. data/app/controllers/spree/admin/products_controller.rb +3 -9
  44. data/app/controllers/spree/admin/promotion_rules_controller.rb +5 -1
  45. data/app/controllers/spree/admin/promotions_controller.rb +1 -1
  46. data/app/controllers/spree/admin/properties_controller.rb +1 -1
  47. data/app/controllers/spree/admin/reports_controller.rb +24 -21
  48. data/app/controllers/spree/admin/resource_controller.rb +25 -14
  49. data/app/controllers/spree/admin/style_guide_controller.rb +4 -0
  50. data/app/controllers/spree/admin/users_controller.rb +1 -1
  51. data/app/controllers/spree/admin/variants_controller.rb +5 -0
  52. data/app/helpers/spree/admin/navigation_helper.rb +6 -2
  53. data/app/helpers/spree/promotion_rules_helper.rb +2 -2
  54. data/app/models/spree/backend_configuration.rb +1 -0
  55. data/app/views/spree/admin/adjustments/_form.html.erb +1 -1
  56. data/app/views/spree/admin/customer_returns/_return_item_selection.html.erb +2 -2
  57. data/app/views/spree/admin/customer_returns/new.html.erb +1 -1
  58. data/app/views/spree/admin/images/_form.html.erb +1 -1
  59. data/app/views/spree/admin/images/_image_row.html.erb +22 -4
  60. data/app/views/spree/admin/images/create.js.erb +8 -5
  61. data/app/views/spree/admin/images/index.html.erb +4 -8
  62. data/app/views/spree/admin/orders/_risk_analysis.html.erb +6 -7
  63. data/app/views/spree/admin/orders/_shipment.html.erb +1 -1
  64. data/app/views/spree/admin/orders/confirm/_customer_details.html.erb +1 -1
  65. data/app/views/spree/admin/orders/confirm/_payments.html.erb +1 -1
  66. data/app/views/spree/admin/orders/index.html.erb +3 -3
  67. data/app/views/spree/admin/payment_methods/_form.html.erb +5 -5
  68. data/app/views/spree/admin/payments/_form.html.erb +2 -2
  69. data/app/views/spree/admin/payments/_list.html.erb +1 -1
  70. data/app/views/spree/admin/payments/show.html.erb +1 -1
  71. data/app/views/spree/admin/payments/source_forms/_gateway.html.erb +2 -7
  72. data/app/views/spree/admin/prices/_form.html.erb +2 -2
  73. data/app/views/spree/admin/prices/edit.html.erb +2 -0
  74. data/app/views/spree/admin/prices/index.html.erb +5 -4
  75. data/app/views/spree/admin/prices/new.html.erb +4 -0
  76. data/app/views/spree/admin/product_properties/index.html.erb +1 -1
  77. data/app/views/spree/admin/products/_form.html.erb +4 -3
  78. data/app/views/spree/admin/products/index.html.erb +3 -3
  79. data/app/views/spree/admin/products/new.html.erb +2 -2
  80. data/app/views/spree/admin/products/new.js.erb +0 -3
  81. data/app/views/spree/admin/promotion_actions/create.js.erb +2 -6
  82. data/app/views/spree/admin/promotion_rules/create.js.erb +0 -8
  83. data/app/views/spree/admin/promotions/_actions.html.erb +2 -2
  84. data/app/views/spree/admin/promotions/_form.html.erb +1 -1
  85. data/app/views/spree/admin/promotions/_promotion_action.html.erb +3 -4
  86. data/app/views/spree/admin/promotions/_promotion_rule.html.erb +3 -3
  87. data/app/views/spree/admin/promotions/_rules.html.erb +1 -1
  88. data/app/views/spree/admin/promotions/actions/_create_item_adjustments.html.erb +6 -2
  89. data/app/views/spree/admin/promotions/actions/_promotion_calculators_with_custom_fields.html.erb +1 -1
  90. data/app/views/spree/admin/promotions/calculators/distributed_amount/_fields.html.erb +54 -0
  91. data/app/views/spree/admin/promotions/calculators/tiered_flat_rate/_fields.html.erb +33 -14
  92. data/app/views/spree/admin/promotions/calculators/tiered_percent/_fields.html.erb +33 -14
  93. data/app/views/spree/admin/promotions/index.html.erb +1 -1
  94. data/app/views/spree/admin/promotions/rules/_first_repeat_purchase_since.html.erb +1 -1
  95. data/app/views/spree/admin/promotions/rules/_item_total.html.erb +1 -1
  96. data/app/views/spree/admin/promotions/rules/_landing_page.html.erb +1 -1
  97. data/app/views/spree/admin/promotions/rules/_nth_order.html.erb +1 -1
  98. data/app/views/spree/admin/promotions/rules/_product.html.erb +1 -1
  99. data/app/views/spree/admin/promotions/rules/_taxon.html.erb +1 -1
  100. data/app/views/spree/admin/promotions/rules/_user_role.html.erb +2 -2
  101. data/app/views/spree/admin/refunds/edit.html.erb +1 -1
  102. data/app/views/spree/admin/refunds/new.html.erb +1 -1
  103. data/app/views/spree/admin/reimbursements/edit.html.erb +2 -2
  104. data/app/views/spree/admin/reports/sales_total.html.erb +1 -1
  105. data/app/views/spree/admin/return_authorizations/_form.html.erb +4 -4
  106. data/app/views/spree/admin/shared/_address_form.html.erb +2 -2
  107. data/app/views/spree/admin/shared/_calculator_fields.html.erb +1 -1
  108. data/app/views/spree/admin/shared/_product_tabs.html.erb +4 -4
  109. data/app/views/spree/admin/shared/_report_order_criteria.html.erb +1 -1
  110. data/app/views/spree/admin/shared/_variant_search.html.erb +1 -1
  111. data/app/views/spree/admin/shipping_methods/_form.html.erb +1 -1
  112. data/app/views/spree/admin/states/index.html.erb +1 -1
  113. data/app/views/spree/admin/stock_items/_stock_management.html.erb +1 -1
  114. data/app/views/spree/admin/stock_locations/_form.html.erb +1 -1
  115. data/app/views/spree/admin/stock_transfers/edit.html.erb +1 -1
  116. data/app/views/spree/admin/stock_transfers/index.html.erb +1 -1
  117. data/app/views/spree/admin/stock_transfers/new.html.erb +1 -1
  118. data/app/views/spree/admin/store_credits/_form.html.erb +1 -1
  119. data/app/views/spree/admin/store_credits/_update_reason_field.html.erb +1 -1
  120. data/app/views/spree/admin/stores/_form.html.erb +1 -1
  121. data/app/views/spree/admin/style_guide/topics/forms/_building_forms.html.erb +4 -8
  122. data/app/views/spree/admin/style_guide/topics/forms/_buttons.html.erb +6 -0
  123. data/app/views/spree/admin/style_guide/topics/forms/_helper_text.html.erb +13 -0
  124. data/app/views/spree/admin/style_guide/topics/forms/_inputs.html.erb +96 -0
  125. data/app/views/spree/admin/style_guide/topics/forms/_labels.html.erb +6 -0
  126. data/app/views/spree/admin/style_guide/topics/forms/_validation.html.erb +8 -1
  127. data/app/views/spree/admin/style_guide/topics/layout/_full_width_table_layout.html.erb +10 -0
  128. data/app/views/spree/admin/style_guide/topics/layout/_helpful_layout.html.erb +0 -0
  129. data/app/views/spree/admin/style_guide/topics/layout/_sidebar_layout.html.erb +4 -0
  130. data/app/views/spree/admin/style_guide/topics/messaging/_flashes.html.erb +10 -4
  131. data/app/views/spree/admin/style_guide/topics/messaging/_tooltips.html.erb +45 -0
  132. data/app/views/spree/admin/style_guide/topics/tables/_forms_in_tables.html.erb +4 -0
  133. data/app/views/spree/admin/style_guide/topics/typography/_lists.html.erb +1 -1
  134. data/app/views/spree/admin/tax_rates/_form.html.erb +17 -3
  135. data/app/views/spree/admin/tax_rates/index.html.erb +12 -3
  136. data/app/views/spree/admin/taxonomies/edit.erb +1 -8
  137. data/app/views/spree/admin/taxons/_form.html.erb +6 -4
  138. data/app/views/spree/admin/taxons/edit.html.erb +0 -15
  139. data/app/views/spree/admin/taxons/index.html.erb +1 -1
  140. data/app/views/spree/admin/variants/_form.html.erb +8 -9
  141. data/app/views/spree/admin/variants/new.js.erb +0 -1
  142. data/config/routes.rb +1 -1
  143. data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +1 -1
  144. data/spec/controllers/spree/admin/orders_controller_spec.rb +16 -4
  145. data/spec/controllers/spree/admin/payment_methods_controller_spec.rb +2 -2
  146. data/spec/controllers/spree/admin/payments_controller_spec.rb +1 -1
  147. data/spec/controllers/spree/admin/products_controller_spec.rb +33 -0
  148. data/spec/controllers/spree/admin/variants_controller_spec.rb +39 -13
  149. data/spec/features/admin/configuration/payment_methods_spec.rb +11 -11
  150. data/spec/features/admin/configuration/shipping_methods_spec.rb +1 -1
  151. data/spec/features/admin/configuration/states_spec.rb +4 -4
  152. data/spec/features/admin/configuration/store_spec.rb +3 -3
  153. data/spec/features/admin/configuration/tax_rates_spec.rb +1 -1
  154. data/spec/features/admin/orders/adjustments_spec.rb +1 -1
  155. data/spec/features/admin/orders/customer_details_spec.rb +10 -11
  156. data/spec/features/admin/orders/listing_spec.rb +1 -1
  157. data/spec/features/admin/orders/new_order_spec.rb +4 -11
  158. data/spec/features/admin/orders/order_details_spec.rb +20 -30
  159. data/spec/features/admin/orders/return_payment_state_spec.rb +60 -0
  160. data/spec/features/admin/orders/shipments_spec.rb +7 -0
  161. data/spec/features/admin/products/edit/images_spec.rb +48 -9
  162. data/spec/features/admin/products/edit/variants_spec.rb +1 -1
  163. data/spec/features/admin/products/option_types_spec.rb +2 -2
  164. data/spec/features/admin/products/products_spec.rb +49 -3
  165. data/spec/features/admin/products/stock_management_spec.rb +1 -3
  166. data/spec/features/admin/products/variant_spec.rb +20 -0
  167. data/spec/features/admin/promotion_adjustments_spec.rb +35 -34
  168. data/spec/features/admin/promotions/option_value_rule_spec.rb +2 -2
  169. data/spec/features/admin/promotions/product_rule_spec.rb +1 -1
  170. data/spec/features/admin/promotions/tiered_calculator_spec.rb +2 -2
  171. data/spec/features/admin/promotions/user_rule_spec.rb +2 -2
  172. data/spec/features/admin/stock_transfer_spec.rb +11 -8
  173. data/spec/helpers/admin/navigation_helper_spec.rb +23 -0
  174. metadata +26 -18
  175. data/app/assets/javascripts/spree/backend/images/new.js.coffee +0 -7
  176. data/app/assets/stylesheets/spree/backend/sections/_payments.scss +0 -14
  177. data/app/helpers/spree/admin/images_helper.rb +0 -17
  178. data/app/views/spree/admin/orders/_add_line_item.html.erb +0 -15
  179. data/app/views/spree/admin/prices/new.js.erb +0 -2
  180. data/app/views/spree/admin/products/_properties_form.erb +0 -10
  181. data/app/views/spree/admin/promotions/_tab.html.erb +0 -1
  182. data/app/views/spree/admin/shared/_report_criteria.html.erb +0 -17
  183. data/app/views/spree/admin/states/_new.html.erb +0 -7
  184. data/app/views/spree/admin/stock_locations/_transfer_stock_form.html.erb +0 -38
  185. data/app/views/spree/admin/stock_transfers/_stock_movements.html.erb +0 -27
  186. data/app/views/spree/admin/taxons/_taxon_table.html.erb +0 -23
@@ -0,0 +1,3 @@
1
+ Spree.Models.Taxonomy = Backbone.Model.extend({
2
+ urlRoot: Spree.pathFor('api/taxonomies')
3
+ });
@@ -2,8 +2,10 @@ _.extend(window.Spree, {
2
2
  Models: {},
3
3
  Collections: {},
4
4
  Views: {
5
+ Images: {},
5
6
  Order: {},
6
7
  Cart: {},
7
- Zones: {}
8
+ Zones: {},
9
+ Payment: {}
8
10
  }
9
11
  })
@@ -1,39 +1,11 @@
1
- //= require jquery.payment
2
- $(document).ready(function() {
3
- if ($("#new_payment").is("*")) {
4
- $(".cardNumber").payment('formatCardNumber');
5
- $(".cardExpiry").payment('formatCardExpiry');
6
- $(".cardCode").payment('formatCardCVC');
7
-
8
- $(".cardNumber").change(function() {
9
- $(".ccType").val($.payment.cardType(this.value))
1
+ $(function() {
2
+ if ($("#new_payment").length) {
3
+ new Spree.Views.Payment.New({
4
+ el: $('#new_payment')
10
5
  })
11
-
12
- $('.payment_methods_radios').click(
13
- function() {
14
- $('.payment-methods').hide();
15
- $('.payment-methods :input').prop('disabled', true);
16
- if (this.checked) {
17
- $('#payment_method_' + this.value + ' :input').prop('disabled', false);
18
- $('#payment_method_' + this.value).show();
19
- }
20
- }
21
- );
22
-
23
- $('.payment_methods_radios').each(
24
- function() {
25
- if (this.checked) {
26
- $('#payment_method_' + this.value + ' :input').prop('disabled', false);
27
- $('#payment_method_' + this.value).show();
28
- } else {
29
- $('#payment_method_' + this.value).hide();
30
- $('#payment_method_' + this.value + ' :input').prop('disabled', true);
31
- }
32
-
33
- if ($("#card_new" + this.value).is("*")) {
34
- $("#card_new" + this.value).radioControlsVisibilityOfElement('#card_form' + this.value);
35
- }
36
- }
37
- );
38
6
  }
7
+
8
+ $(".js-edit-credit-card").each(function() {
9
+ new Spree.Views.Payment.EditCreditCard({ el: this })
10
+ });
39
11
  });
@@ -96,4 +96,4 @@ window.initPromotionActions = ->
96
96
 
97
97
  initTieredCalculators()
98
98
 
99
- $ initPromotionActions
99
+ Spree.ready(initPromotionActions)
@@ -1,12 +0,0 @@
1
- $ ->
2
- if $('.new_payment').is('*')
3
- $input = $('input[name="payment[payment_method_id]"]')
4
- $paymentMethods = $('.payment-method-settings .payment-methods')
5
-
6
- updateSelected = ->
7
- id = $input.filter(":checked").val()
8
- $paymentMethods.addClass('hidden')
9
- $paymentMethods.filter("#payment_method_#{id}").removeClass('hidden')
10
-
11
- $input.on('click', updateSelected)
12
- updateSelected()
@@ -188,7 +188,7 @@ var ShipmentSplitItemView = Backbone.View.extend({
188
188
  return false;
189
189
  }
190
190
  jqXHR.error(function(msg) {
191
- alert(msg.responseJSON['message']);
191
+ alert(Spree.t("split_failed"));
192
192
  }).done(function() {
193
193
  window.Spree.advanceOrder();
194
194
  });
@@ -1,5 +1,5 @@
1
1
  //= require solidus_admin/select2
2
- jQuery(function($) {
2
+ Spree.ready(function() {
3
3
  // Make select beautiful
4
4
  $('select.select2').select2({
5
5
  allowClear: true,
@@ -1,102 +1,108 @@
1
1
  Handlebars.registerHelper 'isRootTaxon', ->
2
2
  !@parent_id?
3
3
 
4
- get_taxonomy = ->
5
- Spree.ajax
6
- url: "#{Spree.routes.taxonomy_path}?set=nested"
7
-
8
- create_taxon = ({name, parent_id, child_index}) ->
9
- Spree.ajax
10
- type: "POST",
11
- dataType: "json",
12
- url: Spree.routes.taxonomy_taxons_path,
13
- data:
14
- taxon: {name, parent_id, child_index}
15
- complete: redraw_tree
16
-
17
- update_taxon = ({id, parent_id, child_index}) ->
18
- Spree.ajax
19
- type: "PUT"
20
- dataType: "json"
21
- url: "#{Spree.routes.taxonomy_taxons_path}/#{id}"
22
- data:
23
- taxon: {parent_id, child_index}
24
- error: redraw_tree
25
-
26
- delete_taxon = ({id}) ->
27
- Spree.ajax
28
- type: "DELETE"
29
- dataType: "json"
30
- url: "#{Spree.routes.taxonomy_taxons_path}/#{id}"
31
- error: redraw_tree
32
-
33
- draw_tree = (taxonomy) ->
34
- taxons_template = HandlebarsTemplates["taxons/tree"]
35
- $('#taxonomy_tree')
36
- .html( taxons_template({ taxons: [taxonomy.root] }) )
37
- .find('ul')
38
- .sortable
39
- connectWith: '#taxonomy_tree ul'
40
- placeholder: 'sortable-placeholder ui-state-highlight'
41
- tolerance: 'pointer'
42
- cursorAt: { left: 5 }
43
-
44
- redraw_tree = ->
45
- get_taxonomy().done(draw_tree)
46
-
47
- resize_placeholder = (ui) ->
48
- handleHeight = ui.helper.find('.sortable-handle').outerHeight()
49
- ui.placeholder.height(handleHeight)
50
-
51
- restore_sort_targets = ->
52
- $('.ui-sortable-over').removeClass('ui-sortable-over')
53
-
54
- highlight_sort_targets = (ui) ->
55
- restore_sort_targets()
56
- ui.placeholder.parents('ul').addClass('ui-sortable-over')
57
-
58
- handle_move = (el) ->
59
- update_taxon
60
- id: el.data('taxon-id')
61
- parent_id: el.parent().closest('li').data('taxon-id')
62
- child_index: el.index()
63
-
64
- handle_delete = (e) ->
65
- el = $(e.target).closest('li')
66
- if confirm(Spree.translations.are_you_sure_delete)
67
- delete_taxon({id: el.data('taxon-id')})
68
- el.remove()
69
-
70
- handle_add_child = (e) ->
71
- el = $(e.target).closest('li')
72
- parent_id = el.data('taxon-id')
73
- name = 'New node'
74
- child_index = 0
75
- create_taxon({name, parent_id, child_index})
76
-
77
- get_create_handler = (taxonomy_id) ->
78
- handle_create = (e) ->
4
+ TaxonTreeView = Backbone.View.extend
5
+ create_taxon: ({name, parent_id, child_index}) ->
6
+ Spree.ajax
7
+ type: "POST",
8
+ dataType: "json",
9
+ url: "#{this.model.url()}/taxons",
10
+ data:
11
+ taxon: {name, parent_id, child_index}
12
+ complete: @redraw_tree
13
+
14
+ update_taxon: ({id, parent_id, child_index}) ->
15
+ Spree.ajax
16
+ type: "PUT"
17
+ dataType: "json"
18
+ url: "#{this.model.url()}/taxons/#{id}",
19
+ data:
20
+ taxon: {parent_id, child_index}
21
+ error: @redraw_tree
22
+
23
+ delete_taxon: ({id}) ->
24
+ Spree.ajax
25
+ type: "DELETE"
26
+ dataType: "json"
27
+ url: "#{this.model.url()}/taxons/#{id}",
28
+ error: @redraw_tree
29
+
30
+ render: ->
31
+ taxons_template = HandlebarsTemplates["taxons/tree"]
32
+ this.$el
33
+ .html( taxons_template({ taxons: [this.model.get("root")] }) )
34
+ .find('ul')
35
+ .sortable
36
+ connectWith: '#taxonomy_tree ul'
37
+ placeholder: 'sortable-placeholder ui-state-highlight'
38
+ tolerance: 'pointer'
39
+ cursorAt: { left: 5 }
40
+
41
+ redraw_tree: ->
42
+ this.model.fetch({
43
+ url: this.model.url() + '?set=nested'
44
+ })
45
+
46
+ resize_placeholder: (e, ui) ->
47
+ handleHeight = ui.helper.find('.sortable-handle').outerHeight()
48
+ ui.placeholder.height(handleHeight)
49
+
50
+ restore_sort_targets: ->
51
+ $('.ui-sortable-over').removeClass('ui-sortable-over')
52
+
53
+ highlight_sort_targets: (e, ui) ->
54
+ @restore_sort_targets()
55
+ ui.placeholder.parents('ul').addClass('ui-sortable-over')
56
+
57
+ handle_move: (e, ui) ->
58
+ return if ui.sender?
59
+ el = ui.item
60
+ @update_taxon
61
+ id: el.data('taxon-id')
62
+ parent_id: el.parent().closest('li').data('taxon-id')
63
+ child_index: el.index()
64
+
65
+ handle_delete: (e) ->
66
+ el = $(e.target).closest('li')
67
+ if confirm(Spree.translations.are_you_sure_delete)
68
+ @delete_taxon({id: el.data('taxon-id')})
69
+ el.remove()
70
+
71
+ handle_add_child: (e) ->
72
+ el = $(e.target).closest('li')
73
+ parent_id = el.data('taxon-id')
74
+ name = 'New node'
75
+ child_index = 0
76
+ @create_taxon({name, parent_id, child_index})
77
+
78
+ handle_create: (e) ->
79
79
  e.preventDefault()
80
- get_taxonomy().done (taxonomy) ->
81
- name = 'New node'
82
- parent_id = taxonomy.root.id
83
- child_index = 0
84
- create_taxon({name, parent_id, child_index})
85
-
86
- setup_taxonomy_tree = (taxonomy_id) ->
87
- redraw_tree()
88
- $("#taxonomy_tree").on
89
- sortstart: (e, ui) ->
90
- resize_placeholder(ui)
91
- sortover: (e, ui) ->
92
- highlight_sort_targets(ui)
93
- sortstop: restore_sort_targets
94
- sortupdate: (e, ui) ->
95
- handle_move(ui.item) unless ui.sender?
96
- .on('click', '.js-taxon-delete', handle_delete)
97
- .on('click', '.js-taxon-add-child', handle_add_child)
98
- $('.add-taxon-button').on('click', get_create_handler(taxonomy_id))
80
+ name = 'New node'
81
+ parent_id = this.model.get("root").id
82
+ child_index = 0
83
+ @create_taxon({name, parent_id, child_index})
84
+
85
+ events: {
86
+ 'sortstart': 'resize_placeholder',
87
+ 'sortover': 'highlight_sort_targets',
88
+ 'sortstop': 'restore_sort_targets',
89
+ 'sortupdate': 'handle_move',
90
+
91
+ 'click .js-taxon-delete': 'handle_delete',
92
+ 'click .js-taxon-add-child': 'handle_add_child',
93
+ }
94
+
95
+ initialize: ->
96
+ _.bindAll(this, 'redraw_tree', 'handle_create')
97
+ $('.add-taxon-button').on('click', @handle_create)
98
+
99
+ this.listenTo(this.model, 'sync', this.render)
100
+
101
+ @redraw_tree()
99
102
 
100
103
  $ ->
101
104
  if $('#taxonomy_tree').length
102
- setup_taxonomy_tree($('#taxonomy_tree').data("taxonomy-id"))
105
+ model = new Spree.Models.Taxonomy({id: $('#taxonomy_tree').data("taxonomy-id")})
106
+ new TaxonTreeView
107
+ el: $('#taxonomy_tree')
108
+ model: model
@@ -2,10 +2,12 @@
2
2
  <img src="{{ imgSrc }}" class="card-img-top img-fluid">
3
3
 
4
4
  <div class="card-block">
5
- <progress min="0" max="100" value="{{ progress }}">{{ progress }}</progress>
5
+ <div class="progress">
6
+ <div class="progress-bar progress-bar-animated" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
7
+ </div>
6
8
 
7
- <summary>{{ summary }}</summary>
8
- <br>
9
+ <div class="filename">{{ filename }}</div>
10
+ <div class="size">{{ size }}B</div>
9
11
 
10
12
  <error class="text-danger {{#unless serverError}} hidden {{/unless}}">{{t 'admin.images.index.image_process_failed' }}</error>
11
13
  </div>
@@ -0,0 +1,48 @@
1
+ Spree.Views.Images.UploadProgress = Backbone.View.extend({
2
+ tagName: "div",
3
+
4
+ // Cache the template function for a single item.
5
+ template: HandlebarsTemplates["products/upload_progress"],
6
+
7
+ initialize: function() {
8
+ this.listenTo(this.model, 'change:progress', this.updateProgressBar);
9
+ this.listenTo(this.model, 'change', this.render);
10
+ this.listenTo(this.model, 'destroy', this.remove);
11
+ },
12
+
13
+ events: {
14
+ "clear" : "clear"
15
+ },
16
+
17
+ className: 'col-sm-6 col-md-4 mb-3',
18
+
19
+ attributes: function() {
20
+ return {
21
+ "data-upload-id": this.model.cid
22
+ }
23
+ },
24
+
25
+ render: function() {
26
+ // Skip progress bar update for better performance
27
+ var changedAttrs = Object.keys(this.model.changed);
28
+ if(changedAttrs.length === 1 && changedAttrs[0] == 'progress') return this;
29
+
30
+ this.el.innerHTML = this.template(this.model.toJSON());
31
+ this.updateProgressBar();
32
+ return this;
33
+ },
34
+
35
+ updateProgressBar: function() {
36
+ var progressBar = this.el.querySelector('.progress-bar');
37
+ var percent = this.model.get('progress');
38
+ progressBar.setAttribute('aria-valuenow', percent);
39
+ progressBar.style.width = percent + '%';
40
+ progressBar.innerHTML = percent + '%';
41
+ return this;
42
+ },
43
+
44
+ // Remove the item, destroy the model
45
+ clear: function() {
46
+ this.model.destroy();
47
+ }
48
+ });
@@ -0,0 +1,39 @@
1
+ Spree.Views.Images.UploadZone = Backbone.View.extend({
2
+ events: {
3
+ "dragover" : "onDragOver",
4
+ "dragleave" : "onDragLeave",
5
+ "drop" : "onDrop",
6
+ 'change input[type="file"]' : "onFileBrowserSelect"
7
+ },
8
+
9
+ upload: function(file) {
10
+ var progressModel = new Spree.Models.ImageUpload({file: file});
11
+
12
+ this.collection.add(progressModel);
13
+
14
+ progressModel.previewFile();
15
+ progressModel.uploadFile();
16
+ },
17
+
18
+ dragClass: 'with-images',
19
+
20
+ onDragOver: function(e) {
21
+ this.el.classList.add(this.dragClass);
22
+ e.preventDefault();
23
+ },
24
+
25
+ onDragLeave: function() {
26
+ this.el.classList.remove(this.dragClass);
27
+ },
28
+
29
+ onDrop: function(e) {
30
+ this.el.classList.remove(this.dragClass);
31
+ e.preventDefault();
32
+
33
+ _.each(e.originalEvent.dataTransfer.files, this.upload, this);
34
+ },
35
+
36
+ onFileBrowserSelect: function(e) {
37
+ _.each(e.target.files, this.upload, this);
38
+ }
39
+ });
@@ -1,6 +1,8 @@
1
1
  //= require 'spree/backend/views/cart/add_line_item_button'
2
2
  //= require 'spree/backend/views/cart/line_item_row'
3
3
  //= require 'spree/backend/views/cart/line_item_table'
4
+ //= require 'spree/backend/views/images/upload_zone'
5
+ //= require 'spree/backend/views/images/upload_progress'
4
6
  //= require 'spree/backend/views/order/address'
5
7
  //= require 'spree/backend/views/order/details_adjustments'
6
8
  //= require 'spree/backend/views/order/details_total'
@@ -10,3 +12,7 @@
10
12
  //= require 'spree/backend/views/state_select'
11
13
  //= require 'spree/backend/views/zones/form'
12
14
  //= require 'spree/backend/views/number_with_currency'
15
+ //= require 'spree/backend/views/payment/new'
16
+ //= require 'spree/backend/views/payment/edit_credit_card'
17
+ //= require 'spree/backend/views/tables/editable_table'
18
+ //= require 'spree/backend/views/tables/editable_table_row'
@@ -1,7 +1,5 @@
1
1
  Spree.Views.Order.Address = Backbone.View.extend({
2
2
  initialize: function(options) {
3
- this.$(".js-country_id").select2();
4
-
5
3
  // read initial values from page
6
4
  this.onChange();
7
5
 
@@ -26,7 +24,7 @@ Spree.Views.Order.Address = Backbone.View.extend({
26
24
  eachField: function(callback){
27
25
  var view = this;
28
26
  var fields = ["firstname", "lastname", "company", "address1", "address2",
29
- "city", "zipcode", "phone"];
27
+ "city", "zipcode", "phone", "country_id"];
30
28
  _.each(fields, function(field) {
31
29
  var el = view.$('[name$="[' + field + ']"]');
32
30
  if (el.length) callback(field, el);
@@ -38,7 +36,6 @@ Spree.Views.Order.Address = Backbone.View.extend({
38
36
  this.eachField(function(name, el) {
39
37
  attributes[name] = el.val();
40
38
  });
41
- attributes['country_id'] = this.$(".js-country_id").select2("val")
42
39
  return attributes;
43
40
  },
44
41
 
@@ -47,6 +44,5 @@ Spree.Views.Order.Address = Backbone.View.extend({
47
44
  this.eachField(function(name, el) {
48
45
  el.val(model.get(name))
49
46
  })
50
- this.$(".js-country_id").select2("val", this.model.get("country_id"))
51
47
  }
52
48
  });