diff --git a/app/assets/javascripts/admin/spree/orders/variant_autocomplete.js.erb b/app/assets/javascripts/admin/spree/orders/variant_autocomplete.js.erb index 59678b0432..c30053facb 100644 --- a/app/assets/javascripts/admin/spree/orders/variant_autocomplete.js.erb +++ b/app/assets/javascripts/admin/spree/orders/variant_autocomplete.js.erb @@ -34,9 +34,6 @@ $(document).ready(function() { //handle cancel click // $('a.cancel-item').click(toggleItemEdit); - //handle split click - // $('a.split-item').click(startItemSplit); - handle_save_click = function(){ var save = $(this); var shipment_number = save.data('shipment-number'); @@ -107,7 +104,6 @@ toggleItemEdit = function(){ var link = $(this); link.parent().find('a.edit-item').toggle(); link.parent().find('a.cancel-item').toggle(); - link.parent().find('a.split-item').toggle(); link.parent().find('a.save-item').toggle(); link.parent().find('a.delete-item').toggle(); link.parents('tr').find('td.item-qty-show').toggle(); @@ -116,100 +112,6 @@ toggleItemEdit = function(){ return false; } -startItemSplit = function(event){ - event.preventDefault(); - var link = $(this); - link.parent().find('a.edit-item').toggle(); - link.parent().find('a.split-item').toggle(); - link.parent().find('a.delete-item').toggle(); - var variant_id = link.data('variant-id'); - - var variant = {}; - $.ajax({ - type: "GET", - async: false, - url: Spree.url(Spree.routes.variants_api), - data: { - q: { - "id_eq": variant_id - } - } - }).success(function( data ) { - variant = data['variants'][0]; - }).error(function( msg ) { - console.log(msg); - }); - - var max_quantity = link.closest('tr').data('item-quantity'); - var split_item_template = Handlebars.compile($('#variant_split_template').text()); - link.closest('tr').after(split_item_template({ variant: variant, shipments: shipments, max_quantity: max_quantity })); - // $('a.cancel-split').click(cancelItemSplit); - // $('a.save-split').click(completeItemSplit); - - // Add some tips - $('.with-tip').powerTip({ - smartPlacement: true, - fadeInTime: 50, - fadeOutTime: 50, - intentPollInterval: 300 - }); - $('#item_stock_location').select2({ width: 'resolve', placeholder: 'Choose Location' }); -} - -completeItemSplit = function(event) { - event.preventDefault(); - var link = $(this); - var order_number = link.closest('tbody').data('order-number'); - var stock_item_row = link.closest('tr'); - var variant_id = stock_item_row.data('variant-id'); - var quantity = stock_item_row.find('#item_quantity').val(); - - var stock_location_id = stock_item_row.find('#item_stock_location').val(); - var original_shipment_number = link.closest('tbody').data('shipment-number'); - - var selected_shipment = stock_item_row.find($('#item_stock_location').select2('data').element); - var target_shipment_number = selected_shipment.data('shipment-number'); - var new_shipment = selected_shipment.data('new-shipment'); - - if (stock_location_id != 'new_shipment') { - // first remove item(s) from original shipment - $.ajax({ - type: "PUT", - async: false, - url: Spree.url(Spree.routes.orders_api + "/" + order_number + "/shipments/" + original_shipment_number + "/remove.json"), - data: { variant_id: variant_id, quantity: quantity } - }).done(function(msg) { - window.location.reload(); - }); - - if (new_shipment != undefined) { - $.ajax({ - type: "POST", - async: false, - url: Spree.url(Spree.routes.orders_api + "/" + order_number + "/shipments.json"), - data: { variant_id: variant_id, quantity: quantity, stock_location_id: stock_location_id } - }); - } else { - $.ajax({ - type: "PUT", - async: false, - url: Spree.url(Spree.routes.orders_api + "/" + order_number + "/shipments/" + target_shipment_number + "/add.json"), - data: { variant_id: variant_id, quantity: quantity } - }); - } - } -} - -cancelItemSplit = function(event) { - event.preventDefault(); - var link = $(this); - var prev_row = link.closest('tr').prev(); - link.closest('tr').remove(); - prev_row.find('a.edit-item').toggle(); - prev_row.find('a.split-item').toggle(); - prev_row.find('a.delete-item').toggle(); -} - addVariantFromStockLocation = function() { $('#stock_details').hide();