diff --git a/app/assets/javascripts/app/controllers/agent_ticket_create.coffee b/app/assets/javascripts/app/controllers/agent_ticket_create.coffee index 93bd6f11e..f14fd7b55 100644 --- a/app/assets/javascripts/app/controllers/agent_ticket_create.coffee +++ b/app/assets/javascripts/app/controllers/agent_ticket_create.coffee @@ -33,6 +33,7 @@ class App.TicketCreate extends App.Controller @bind('ui:rerender', => return if !@authenticateCheck() @renderQueue() + @tokanice() ) # listen to rerender sidebars @@ -55,6 +56,7 @@ class App.TicketCreate extends App.Controller changeFormType: (e) => type = $(e.currentTarget).data('type') @setFormTypeInUi(type) + @tokanice() setFormTypeInUi: (type) => @@ -347,6 +349,11 @@ class App.TicketCreate extends App.Controller # update taskbar with new meta data App.TaskManager.touch(@taskKey) + @tokanice() + + tokanice: -> + App.Utils.tokaniceEmails('.content.active input[name=cc]') + localUserInfo: (e) => return if !@sidebarWidget params = App.ControllerForm.params($(e.target).closest('form')) diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee index 2688e2efa..a8138a5d3 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee @@ -103,22 +103,7 @@ class App.TicketZoomArticleNew extends App.Controller ) tokanice: -> - source = "#{App.Config.get('api_path')}/users/search" - a = -> - $('.content.active .js-to, .js-cc, js-bcc').tokenfield( - createTokensOnBlur: true - autocomplete: { - source: source - minLength: 2 - }, - ).on('tokenfield:createtoken', (e) -> - if !e.attrs.value.match(/@/) || e.attrs.value.match(/\s/) - e.preventDefault() - return false - e.attrs.label = e.attrs.value - true - ) - App.Delay.set(a, 500, undefined, 'tags') + App.Utils.tokaniceEmails('.content.active .js-to, .js-cc, js-bcc') setPossibleArticleTypes: => @articleTypes = [] diff --git a/app/assets/javascripts/app/lib/app_post/utils.coffee b/app/assets/javascripts/app/lib/app_post/utils.coffee index 25fb9a27f..8fc83ec1f 100644 --- a/app/assets/javascripts/app/lib/app_post/utils.coffee +++ b/app/assets/javascripts/app/lib/app_post/utils.coffee @@ -1060,3 +1060,23 @@ class App.Utils articleNew.cc = addAddresses(article.cc, articleNew.cc) articleNew + + # apply email token field with autocompletion + @tokaniceEmails: (selector) -> + source = "#{App.Config.get('api_path')}/users/search" + a = -> + $(selector).tokenfield( + createTokensOnBlur: true + autocomplete: { + source: source + minLength: 2 + }, + ).on('tokenfield:createtoken', (e) -> + if !e.attrs.value.match(/@/) || e.attrs.value.match(/\s/) + e.preventDefault() + return false + e.attrs.label = e.attrs.value + true + ) + App.Delay.set(a, 500, undefined, 'tags') + diff --git a/script/build/test_slice_tests.sh b/script/build/test_slice_tests.sh index f49030955..5dcfd5e55 100755 --- a/script/build/test_slice_tests.sh +++ b/script/build/test_slice_tests.sh @@ -23,6 +23,7 @@ if [ "$LEVEL" == '1' ]; then # test/browser/agent_organization_profile_test.rb rm test/browser/agent_ticket_attachment_test.rb rm test/browser/agent_ticket_auto_assignment_test.rb + rm test/browser/agent_ticket_create_cc_tokenizer_test.rb rm test/browser/agent_ticket_create_reset_customer_selection_test.rb rm test/browser/agent_ticket_create_template_test.rb rm test/browser/agent_ticket_email_reply_keep_body_test.rb @@ -89,6 +90,7 @@ elif [ "$LEVEL" == '2' ]; then rm test/browser/agent_organization_profile_test.rb rm test/browser/agent_ticket_attachment_test.rb rm test/browser/agent_ticket_auto_assignment_test.rb + rm test/browser/agent_ticket_create_cc_tokenizer_test.rb rm test/browser/agent_ticket_create_reset_customer_selection_test.rb rm test/browser/agent_ticket_create_template_test.rb rm test/browser/agent_ticket_email_reply_keep_body_test.rb @@ -155,6 +157,7 @@ elif [ "$LEVEL" == '3' ]; then rm test/browser/agent_organization_profile_test.rb # test/browser/agent_ticket_attachment_test.rb # test/browser/agent_ticket_auto_assignment_test.rb + #rm test/browser/agent_ticket_create_cc_tokenizer_test.rb # test/browser/agent_ticket_create_reset_customer_selection_test.rb # test/browser/agent_ticket_create_template_test.rb # test/browser/agent_ticket_email_reply_keep_body_test.rb @@ -221,6 +224,7 @@ elif [ "$LEVEL" == '4' ]; then rm test/browser/agent_organization_profile_test.rb rm test/browser/agent_ticket_attachment_test.rb rm test/browser/agent_ticket_auto_assignment_test.rb + rm test/browser/agent_ticket_create_cc_tokenizer_test.rb rm test/browser/agent_ticket_create_reset_customer_selection_test.rb rm test/browser/agent_ticket_create_template_test.rb rm test/browser/agent_ticket_email_reply_keep_body_test.rb @@ -286,6 +290,7 @@ elif [ "$LEVEL" == '5' ]; then rm test/browser/agent_organization_profile_test.rb rm test/browser/agent_ticket_attachment_test.rb rm test/browser/agent_ticket_auto_assignment_test.rb + rm test/browser/agent_ticket_create_cc_tokenizer_test.rb rm test/browser/agent_ticket_create_reset_customer_selection_test.rb rm test/browser/agent_ticket_create_template_test.rb rm test/browser/agent_ticket_email_reply_keep_body_test.rb @@ -354,6 +359,7 @@ elif [ "$LEVEL" == '6' ]; then rm test/browser/agent_organization_profile_test.rb rm test/browser/agent_ticket_attachment_test.rb rm test/browser/agent_ticket_auto_assignment_test.rb + rm test/browser/agent_ticket_create_cc_tokenizer_test.rb rm test/browser/agent_ticket_create_reset_customer_selection_test.rb rm test/browser/agent_ticket_create_template_test.rb rm test/browser/agent_ticket_email_reply_keep_body_test.rb diff --git a/test/browser/agent_ticket_create_cc_tokenizer_test.rb b/test/browser/agent_ticket_create_cc_tokenizer_test.rb new file mode 100644 index 000000000..9d2800c2f --- /dev/null +++ b/test/browser/agent_ticket_create_cc_tokenizer_test.rb @@ -0,0 +1,34 @@ +require 'browser_test_helper' + +# Regression test for UI bugfix +# https://github.com/zammad/zammad/issues/1990 +# +# Ensure that CC field when creating a new ticket is autocompleting user emails + +class AgentTicketCreateResetCustomerSelectionTest < TestCase + def test_tokenizer + @browser = browser_instance + + login( + username: 'agent1@example.com', + password: 'test', + url: browser_url, + ) + tasks_close_all() + + click( + css: 'a[href="#ticket/create"]' + ) + + @browser.find_element(:css, 'li[data-type=email-out]').click + + elem = @browser.find_element(:name, 'cc') + elem.send_keys 'test@example.com' + elem.send_keys :enter + + exists( + css: '.token-label', + value: 'test@example.com' + ) + end +end