From 56fb50f64468b22a4fd1f87dac1d50c248c8fc66 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Wed, 30 Nov 2016 14:07:49 +1100 Subject: [PATCH] Refactoring customer_search_override directive Passing distributor_id into isolate scope, rather than pulling from separate element --- .../orders/directives/customer_search_override.js.coffee | 5 ++++- .../edit/replace_customer_search.html.haml.deface | 4 +--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/admin/orders/directives/customer_search_override.js.coffee b/app/assets/javascripts/admin/orders/directives/customer_search_override.js.coffee index 6f36322d91..08d4ceeb5d 100644 --- a/app/assets/javascripts/admin/orders/directives/customer_search_override.js.coffee +++ b/app/assets/javascripts/admin/orders/directives/customer_search_override.js.coffee @@ -1,5 +1,7 @@ angular.module("admin.orders").directive 'customerSearchOverride', -> restrict: 'C' + scope: + distributorId: '@' link: (scope, element, attr) -> formatCustomerResult = (customer) -> customerTemplate @@ -9,13 +11,14 @@ angular.module("admin.orders").directive 'customerSearchOverride', -> element.select2 placeholder: Spree.translations.choose_a_customer + minimumInputLength: 3 ajax: url: '/admin/search/customers.json' datatype: 'json' data: (term, page) -> { q: term - distributor_id: $('#distributor_id').val() # modified + distributor_id: scope.distributorId # modified } results: (data, page) -> { results: data } diff --git a/app/overrides/spree/admin/orders/customer_details/edit/replace_customer_search.html.haml.deface b/app/overrides/spree/admin/orders/customer_details/edit/replace_customer_search.html.haml.deface index db8cebfb0e..1fb13ef009 100644 --- a/app/overrides/spree/admin/orders/customer_details/edit/replace_customer_search.html.haml.deface +++ b/app/overrides/spree/admin/orders/customer_details/edit/replace_customer_search.html.haml.deface @@ -3,6 +3,4 @@ - content_for :app_wrapper_attrs do = 'ng-app=admin.orders' -= hidden_field_tag :customer_search_override, nil, :class => 'fullwidth title customer-search-override' - -= hidden_field_tag :distributor_id, @order.distributor_id += hidden_field_tag :customer_search_override, nil, distributor_id: @order.distributor_id, :class => 'fullwidth title customer-search-override'