userOrgSelector: initially render tokens/name
This commit is contained in:
parent
e0324b7e35
commit
5cb02e5961
2 changed files with 35 additions and 8 deletions
|
@ -32,12 +32,8 @@ class App.UserOrganizationAutocompletion extends App.Controller
|
|||
@build()
|
||||
|
||||
# set current value
|
||||
if @attribute.value
|
||||
if @attribute.multiple and typeof value is 'object'
|
||||
for value in @attribute.value
|
||||
@selectUser value, false
|
||||
else
|
||||
@selectUser @attribute.value, false
|
||||
if @attribute.value and @callback
|
||||
@callback(@attribute.value)
|
||||
|
||||
element: =>
|
||||
@el
|
||||
|
@ -232,9 +228,37 @@ class App.UserOrganizationAutocompletion extends App.Controller
|
|||
App.view('generic/user_search/new_user')()
|
||||
|
||||
build: =>
|
||||
if @attribute.multiple
|
||||
if typeof @attribute.value is not 'object'
|
||||
@attribute.value = [@attribute.value]
|
||||
|
||||
value = @attribute.value.join ','
|
||||
tokens = ''
|
||||
name = ''
|
||||
for userId in @attribute.value
|
||||
if App.User.exists userId
|
||||
tokens += App.view('generic/token')(
|
||||
name: App.User.find(userId).displayName()
|
||||
value: userId
|
||||
)
|
||||
else
|
||||
@log 'userId doesn\'t exist', userId
|
||||
else
|
||||
value = @attribute.value
|
||||
tokens = ''
|
||||
if value
|
||||
if App.User.exists value
|
||||
name = App.User.find(value).displayName()
|
||||
else
|
||||
@log 'userId doesn\'t exist', value
|
||||
|
||||
@html App.view('generic/user_search/input')(
|
||||
attribute: @attribute
|
||||
value: value
|
||||
tokens: tokens
|
||||
name: name
|
||||
)
|
||||
|
||||
if !@attribute.disableCreateUser
|
||||
@recipientList.append(@buildUserNew())
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
<div class="tokenfield form-control u-positionOrigin">
|
||||
<input class="js-userId" type="hidden" name="<%- @attribute.name %>" tabindex="-1">
|
||||
<input name="<%- @attribute.name %>_completion" class="user-select token-input js-userSelect" autocapitalize="off" placeholder="<%- @attribute.placeholder %>" autocomplete="off" role="textbox" aria-autocomplete="list" aria-haspopup="true">
|
||||
<input class="js-userId" type="hidden" value="<%= @value %>" name="<%- @attribute.name %>" tabindex="-1">
|
||||
<% if @attribute.multiple: %>
|
||||
<%- @tokens %>
|
||||
<% end %>
|
||||
<input name="<%- @attribute.name %>_completion" class="user-select token-input js-userSelect" autocapitalize="off" placeholder="<%- @attribute.placeholder %>" autocomplete="off" role="textbox" aria-autocomplete="list" value="<%= @name %>" aria-haspopup="true">
|
||||
<%- @Icon('arrow-down', 'dropdown-arrow') %>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in a new issue