From 5cb02e596160623b218cc272ca23ba855eb7bd37 Mon Sep 17 00:00:00 2001 From: Felix Niklas Date: Mon, 25 Apr 2016 15:59:38 +0200 Subject: [PATCH] userOrgSelector: initially render tokens/name --- .../user_organization_autocompletion.coffee | 36 +++++++++++++++---- .../views/generic/user_search/input.jst.eco | 7 ++-- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/app/lib/app_post/user_organization_autocompletion.coffee b/app/assets/javascripts/app/lib/app_post/user_organization_autocompletion.coffee index d5fa67a58..7ddf9a760 100644 --- a/app/assets/javascripts/app/lib/app_post/user_organization_autocompletion.coffee +++ b/app/assets/javascripts/app/lib/app_post/user_organization_autocompletion.coffee @@ -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()) diff --git a/app/assets/javascripts/app/views/generic/user_search/input.jst.eco b/app/assets/javascripts/app/views/generic/user_search/input.jst.eco index 56a381ac5..1dbc40fe4 100644 --- a/app/assets/javascripts/app/views/generic/user_search/input.jst.eco +++ b/app/assets/javascripts/app/views/generic/user_search/input.jst.eco @@ -1,6 +1,9 @@
- - + + <% if @attribute.multiple: %> + <%- @tokens %> + <% end %> + <%- @Icon('arrow-down', 'dropdown-arrow') %>