mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Adding user autocomplete directive to speed up specification of owner for enterprises
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
angular.module("admin.users").directive "ofnUserAutocomplete", ($http) ->
|
||||
link: (scope,element,attrs) ->
|
||||
setTimeout ->
|
||||
element.select2
|
||||
multiple: false
|
||||
initSelection: (element, callback) ->
|
||||
$http.get( Spree.url(Spree.routes.user_search, { ids: element.val() }) ).success (data) ->
|
||||
callback(data[0]) if data.length > 0
|
||||
ajax:
|
||||
url: Spree.routes.user_search
|
||||
datatype: 'json'
|
||||
data:(term, page) ->
|
||||
{ q: term }
|
||||
results: (data, page) ->
|
||||
{ results: data }
|
||||
formatResult: (user) ->
|
||||
user.email
|
||||
formatSelection: (user) ->
|
||||
user.email
|
||||
1
app/assets/javascripts/admin/users/users.js.coffee
Normal file
1
app/assets/javascripts/admin/users/users.js.coffee
Normal file
@@ -0,0 +1 @@
|
||||
angular.module("admin.users", [])
|
||||
Reference in New Issue
Block a user