|
1 | 1 | // Shipments AJAX API
|
2 | 2 | /* eslint no-extra-semi: "off", no-unused-vars: "off" */
|
3 | 3 |
|
4 |
| -var ShipmentAddVariantView = Backbone.View.extend({ |
5 |
| - events: { |
6 |
| - "change #add_variant_id": "onSelect", |
7 |
| - "click .add_variant": "onAdd", |
8 |
| - "submit form": "onAdd" |
9 |
| - }, |
10 |
| - onSelect: function(e) { |
11 |
| - var variant_id = this.$("#add_variant_id").val(); |
12 |
| - var template = HandlebarsTemplates["variants/autocomplete_stock"]; |
13 |
| - var $stock_details = this.$('#stock_details'); |
14 |
| - Spree.ajax({ |
15 |
| - url: Spree.routes.variants_api + "/" + variant_id, |
16 |
| - success: function(variant){ |
17 |
| - $stock_details.html(template({variant: variant})).show() |
18 |
| - } |
19 |
| - }); |
20 |
| - }, |
21 |
| - onAdd: function(e){ |
22 |
| - e.preventDefault(); |
23 |
| - |
24 |
| - this.$('#stock_details').hide(); |
25 |
| - |
26 |
| - var variant_id = this.$('input.variant_autocomplete').val(); |
27 |
| - var stock_location_id = $(e.target).data('stock-location-id'); |
28 |
| - var quantity = this.$("input.quantity[data-stock-location-id='" + stock_location_id + "']").val(); |
29 |
| - |
30 |
| - addVariantFromStockLocation(stock_location_id, variant_id, quantity) |
31 |
| - } |
32 |
| -}); |
33 |
| - |
34 |
| -Spree.ready(function(){ |
35 |
| - $(".js-shipment-add-variant").each(function(){ |
36 |
| - new ShipmentAddVariantView({el: this}); |
37 |
| - }); |
38 |
| -}); |
39 |
| - |
40 | 4 | var ShipShipmentView = Backbone.View.extend({
|
41 | 5 | initialize: function(options){
|
42 | 6 | this.shipment_number = options.shipment_number;
|
@@ -97,32 +61,6 @@ adjustShipmentItems = function(shipment_number, variant_id, quantity){
|
97 | 61 | }
|
98 | 62 | };
|
99 | 63 |
|
100 |
| -addVariantFromStockLocation = function(stock_location_id, variant_id, quantity) { |
101 |
| - var shipment = _.find(shipments, function(shipment){ |
102 |
| - return shipment.stock_location_id == stock_location_id && (shipment.state == 'ready' || shipment.state == 'pending'); |
103 |
| - }); |
104 |
| - |
105 |
| - if(shipment==undefined){ |
106 |
| - Spree.ajax({ |
107 |
| - type: "POST", |
108 |
| - url: Spree.routes.shipments_api, |
109 |
| - data: { |
110 |
| - shipment: { |
111 |
| - order_id: window.order_number |
112 |
| - }, |
113 |
| - variant_id: variant_id, |
114 |
| - quantity: quantity, |
115 |
| - stock_location_id: stock_location_id, |
116 |
| - } |
117 |
| - }).done(function(){ |
118 |
| - window.location.reload(); |
119 |
| - }); |
120 |
| - }else{ |
121 |
| - //add to existing shipment |
122 |
| - adjustShipmentItems(shipment.number, variant_id, quantity); |
123 |
| - } |
124 |
| -}; |
125 |
| - |
126 | 64 | var ShipmentSplitItemView = Backbone.View.extend({
|
127 | 65 | tagName: 'tr',
|
128 | 66 | className: 'stock-item-split',
|
|
0 commit comments