mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Initialise user autocomplete element using data from element itself rather than AJAX request
This commit is contained in:
@@ -4,8 +4,7 @@ angular.module("admin.users").directive "ofnUserAutocomplete", ($http) ->
|
||||
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
|
||||
callback { id: element.val(), email: attrs.email }
|
||||
ajax:
|
||||
url: Spree.routes.user_search
|
||||
datatype: 'json'
|
||||
|
||||
@@ -27,7 +27,8 @@
|
||||
.with-tip{'data-powertip' => "The primary user responsible for this enterprise."}
|
||||
%a What's this?
|
||||
.eight.columns
|
||||
= f.hidden_field :owner_id, class: "select2 fullwidth", 'ofn-user-autocomplete' => true
|
||||
- owner_email = @enterprise.andand.owner.andand.email || ""
|
||||
= f.hidden_field :owner_id, class: "select2 fullwidth", 'ofn-user-autocomplete' => true, email: owner_email
|
||||
|
||||
.row
|
||||
.three.columns.alpha
|
||||
|
||||
Reference in New Issue
Block a user