mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
24 lines
709 B
CoffeeScript
24 lines
709 B
CoffeeScript
angular.module("admin.users").directive "userSelect", ->
|
|
scope:
|
|
user: '&userSelect'
|
|
model: '=ngModel'
|
|
link: (scope,element,attrs) ->
|
|
setTimeout ->
|
|
element.select2
|
|
multiple: false
|
|
initSelection: (element, callback) ->
|
|
callback {id: scope.user().id, email: scope.user().email}
|
|
ajax:
|
|
url: '/admin/search/known_users'
|
|
datatype: 'json'
|
|
data:(term, page) ->
|
|
{ q: term }
|
|
results: (data, page) ->
|
|
{ results: data }
|
|
formatResult: (user) ->
|
|
user.email
|
|
formatSelection: (user) ->
|
|
scope.$apply ->
|
|
scope.model = user if scope.model?
|
|
user.email
|