From 62d35d2a0e8d81be1a581d1e69ce34c6cf3dd058 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 25 Apr 2016 23:06:39 +0200 Subject: [PATCH] Fixed search result, used _.debounce in correct way. --- .../app/controllers/_ui_element/user_autocompletion.coffee | 4 ++-- .../controllers/_ui_element/user_autocompletion_search.coffee | 4 ++-- .../app/lib/app_post/user_organization_autocompletion.coffee | 4 +++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_ui_element/user_autocompletion.coffee b/app/assets/javascripts/app/controllers/_ui_element/user_autocompletion.coffee index 1c88294d2..02bbcdb07 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/user_autocompletion.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/user_autocompletion.coffee @@ -1,4 +1,4 @@ # coffeelint: disable=camel_case_classes class App.UiElement.user_autocompletion - @render: (attribute) -> - new App.UserOrganizationAutocompletion(attribute: attribute).element() + @render: (attribute, params = {}) -> + new App.UserOrganizationAutocompletion(attribute: attribute, params: params).element() diff --git a/app/assets/javascripts/app/controllers/_ui_element/user_autocompletion_search.coffee b/app/assets/javascripts/app/controllers/_ui_element/user_autocompletion_search.coffee index c6c2bc4db..b8d47b42f 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/user_autocompletion_search.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/user_autocompletion_search.coffee @@ -1,6 +1,6 @@ # coffeelint: disable=camel_case_classes class App.UiElement.user_autocompletion_search - @render: (attributeOrig) -> + @render: (attributeOrig, params = {}) -> attribute = _.clone(attributeOrig) attribute.disableCreateUser = true - new App.UserOrganizationAutocompletion(attribute: attribute).element() + new App.UserOrganizationAutocompletion(attribute: attribute, params: params).element() 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 a96b611b2..b542fc746 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 @@ -23,7 +23,7 @@ class App.UserOrganizationAutocompletion extends App.Controller constructor: (params) -> super - @lazySearch = _.debounce(@searchUser, 200, true) + @lazySearch = _.debounce(@searchUser, 200) @key = Math.floor( Math.random() * 999999 ).toString() @@ -260,6 +260,8 @@ class App.UserOrganizationAutocompletion extends App.Controller name = user.displayName() if user.email name += " <#{user.email}>" + else if @params && @params["#{@attribute.name}_completion"] + name = @params["#{@attribute.name}_completion"] else @log 'userId doesn\'t exist', value