mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-17 00:07:24 +00:00
Refactoring customer_search_override directive
Passing distributor_id into isolate scope, rather than pulling from separate element
This commit is contained in:
@@ -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 }
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user