From d5373eedadb7525e984ee52f0c25ddb8d3db5a36 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Sat, 28 Dec 2019 20:03:24 +0000 Subject: [PATCH] Uncomment events in order edit page and remove unused spree autocomplete js code --- .../spree/orders/variant_autocomplete.js.erb | 44 ++----------------- .../directives/variant_autocomplete.js.coffee | 4 -- 2 files changed, 4 insertions(+), 44 deletions(-) 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 c30053facbd6..c7237e65534b 100644 --- a/app/assets/javascripts/admin/spree/orders/variant_autocomplete.js.erb +++ b/app/assets/javascripts/admin/spree/orders/variant_autocomplete.js.erb @@ -29,10 +29,10 @@ $(document).ready(function() { }); //handle edit click - // $('a.edit-item').click(toggleItemEdit); + $('a.edit-item').click(toggleItemEdit); //handle cancel click - // $('a.cancel-item').click(toggleItemEdit); + $('a.cancel-item').click(toggleItemEdit); handle_save_click = function(){ var save = $(this); @@ -46,7 +46,7 @@ $(document).ready(function() { adjustItems(shipment_number, variant_id, quantity); return false; } - // $('a.save-item').click(handle_save_click); + $('a.save-item').click(handle_save_click); handle_delete_click = function(){ var del = $(this); @@ -57,7 +57,7 @@ $(document).ready(function() { adjustItems(shipment_number, variant_id, 0); } - // $('a.delete-item').click(handle_delete_click); + $('a.delete-item').click(handle_delete_click); } }); @@ -139,39 +139,3 @@ addVariantFromStockLocation = function() { } return 1 } - -formatVariantResult = function(variant) { - if (variant["images"][0] != undefined && variant["images"][0].urls != undefined) { - variant.image = variant.images[0].urls.mini - } - return variantTemplate({ variant: variant }) -} - -$.fn.variantAutocomplete = function() { - this.parent().children(".options_placeholder").attr('id', this.parent().data('index')) - this.select2({ - placeholder: Spree.translations.variant_placeholder, - minimumInputLength: 3, - ajax: { - url: Spree.url(Spree.routes.variants_search), - datatype: 'json', - data: function(term, page) { - return { - q: { - "product_name_or_sku_cont": term - } - } - }, - results: function (data, page) { - window.variants = data['variants']; - - return { results: data['variants'] } - } - }, - formatResult: formatVariantResult, - formatSelection: function (variant) { - $(this.element).parent().children('.options_placeholder').html(variant.options_text) - return variant.name; - } - }) -} diff --git a/app/assets/javascripts/admin/utils/directives/variant_autocomplete.js.coffee b/app/assets/javascripts/admin/utils/directives/variant_autocomplete.js.coffee index dd8c9247eb5b..2b5fca20a678 100644 --- a/app/assets/javascripts/admin/utils/directives/variant_autocomplete.js.coffee +++ b/app/assets/javascripts/admin/utils/directives/variant_autocomplete.js.coffee @@ -1,10 +1,6 @@ angular.module("admin.utils").directive "variantAutocomplete", ($timeout) -> restrict: 'C' link: (scope, element, attrs) -> - # Make variantAutocomplete do nothing because it is called - # from core/app/assets/javascripts/admin/orders/edit.js - $.fn.variantAutocomplete = angular.noop - $timeout -> if $("#variant_autocomplete_template").length > 0 variantTemplate = Handlebars.compile($("#variant_autocomplete_template").text())