Fixed issue #1670 - Reset customer selection in ticket create screen if input field cleared.

This commit is contained in:
Martin Edenhofer 2017-11-24 16:54:56 +01:00
parent 6c707dc5f5
commit ce1135a55c
7 changed files with 297 additions and 28 deletions

View file

@ -1,7 +1,7 @@
class SidebarCustomer extends App.Controller class SidebarCustomer extends App.Controller
sidebarItem: => sidebarItem: =>
return if !@permissionCheck('ticket.agent') return if !@permissionCheck('ticket.agent')
return if !@params.customer_id return if _.isEmpty(@params.customer_id)
{ {
head: 'Customer' head: 'Customer'
name: 'customer' name: 'customer'
@ -18,6 +18,7 @@ class SidebarCustomer extends App.Controller
showCustomer: (el) => showCustomer: (el) =>
@el = el @el = el
return if _.isEmpty(@params.customer_id)
new App.WidgetUser( new App.WidgetUser(
el: @el el: @el
user_id: @params.customer_id user_id: @params.customer_id

View file

@ -18,8 +18,19 @@ class App.TicketCustomer extends App.ControllerModal
onSubmit: (e) => onSubmit: (e) =>
params = @formParam(e.target) params = @formParam(e.target)
@customer_id = params['customer_id'] ticket = App.Ticket.find(@ticket_id)
ticket.customer_id = params['customer_id']
errors = ticket.validate()
if !_.isEmpty(errors)
@log 'error', errors
@formValidate(
form: e.target
errors: errors
)
return
@customer_id = params['customer_id']
callback = => callback = =>
# close modal # close modal

View file

@ -71,7 +71,7 @@ class App.ObjectOrganizationAutocompletion extends App.Controller
@open() @open()
focusInput: => focusInput: =>
@objectSelect.focus() if not @formControl.hasClass 'focus' @objectSelect.focus() if not @formControl.hasClass('focus')
onBlur: => onBlur: =>
selectObject = @objectSelect.val() selectObject = @objectSelect.val()
@ -85,6 +85,9 @@ class App.ObjectOrganizationAutocompletion extends App.Controller
@objectId.val("guess:#{selectObject}") @objectId.val("guess:#{selectObject}")
@formControl.removeClass 'focus' @formControl.removeClass 'focus'
resetObjectSelection: =>
@objectId.val('').trigger('change')
onObjectClick: (e) => onObjectClick: (e) =>
objectId = $(e.currentTarget).data('object-id') objectId = $(e.currentTarget).data('object-id')
@selectObject(objectId) @selectObject(objectId)
@ -103,14 +106,14 @@ class App.ObjectOrganizationAutocompletion extends App.Controller
# Only work with the last one since its the newest one # Only work with the last one since its the newest one
objectId = @objectId.val().split(',').pop() objectId = @objectId.val().split(',').pop()
return if !objectId if objectId && App[@objectSingle].exists(objectId)
return if !App[@objectSingle].exists(objectId)
object = App[@objectSingle].find(objectId) object = App[@objectSingle].find(objectId)
name = object.displayName() name = object.displayName()
if @attribute.multiple if @attribute.multiple
# create token # create token
@createToken name, objectId @createToken(name, objectId)
else else
if object.email if object.email
@ -321,12 +324,16 @@ class App.ObjectOrganizationAutocompletion extends App.Controller
@hideOrganizationMembers() @hideOrganizationMembers()
# hide dropdown # hide dropdown
if !query if _.isEmpty(query)
@emptyResultList() @emptyResultList()
if !@attribute.disableCreateObject if !@attribute.disableCreateObject
@recipientList.append(@buildObjectNew()) @recipientList.append(@buildObjectNew())
# reset object selection
@resetObjectSelection()
return
# show dropdown # show dropdown
if query && ( !@attribute.minLengt || @attribute.minLengt <= query.length ) if query && ( !@attribute.minLengt || @attribute.minLengt <= query.length )
@lazySearch(query) @lazySearch(query)

View file

@ -20,6 +20,7 @@ if [ "$LEVEL" == '1' ]; then
rm test/browser/admin_role_test.rb rm test/browser/admin_role_test.rb
# test/browser/agent_navigation_and_title_test.rb # test/browser/agent_navigation_and_title_test.rb
rm test/browser/agent_ticket_attachment_test.rb rm test/browser/agent_ticket_attachment_test.rb
rm test/browser/agent_ticket_create_reset_customer_selection_test.rb
rm test/browser/agent_ticket_email_reply_keep_body_test.rb rm test/browser/agent_ticket_email_reply_keep_body_test.rb
rm test/browser/agent_ticket_email_signature_test.rb rm test/browser/agent_ticket_email_signature_test.rb
rm test/browser/agent_ticket_link_test.rb rm test/browser/agent_ticket_link_test.rb
@ -78,6 +79,7 @@ elif [ "$LEVEL" == '2' ]; then
rm test/browser/agent_navigation_and_title_test.rb rm test/browser/agent_navigation_and_title_test.rb
rm test/browser/agent_organization_profile_test.rb rm test/browser/agent_organization_profile_test.rb
rm test/browser/agent_ticket_attachment_test.rb rm test/browser/agent_ticket_attachment_test.rb
rm test/browser/agent_ticket_create_reset_customer_selection_test.rb
rm test/browser/agent_ticket_email_reply_keep_body_test.rb rm test/browser/agent_ticket_email_reply_keep_body_test.rb
rm test/browser/agent_ticket_email_signature_test.rb rm test/browser/agent_ticket_email_signature_test.rb
rm test/browser/agent_ticket_link_test.rb rm test/browser/agent_ticket_link_test.rb
@ -136,6 +138,7 @@ elif [ "$LEVEL" == '3' ]; then
rm test/browser/agent_navigation_and_title_test.rb rm test/browser/agent_navigation_and_title_test.rb
rm test/browser/agent_organization_profile_test.rb rm test/browser/agent_organization_profile_test.rb
# test/browser/agent_ticket_attachment_test.rb # test/browser/agent_ticket_attachment_test.rb
# test/browser/agent_ticket_create_reset_customer_selection_test.rb
# test/browser/agent_ticket_email_reply_keep_body_test.rb # test/browser/agent_ticket_email_reply_keep_body_test.rb
# test/browser/agent_ticket_email_signature_test.rb # test/browser/agent_ticket_email_signature_test.rb
# test/browser/agent_ticket_link_test.rb # test/browser/agent_ticket_link_test.rb
@ -194,6 +197,7 @@ elif [ "$LEVEL" == '4' ]; then
rm test/browser/agent_navigation_and_title_test.rb rm test/browser/agent_navigation_and_title_test.rb
rm test/browser/agent_organization_profile_test.rb rm test/browser/agent_organization_profile_test.rb
rm test/browser/agent_ticket_attachment_test.rb rm test/browser/agent_ticket_attachment_test.rb
rm test/browser/agent_ticket_create_reset_customer_selection_test.rb
rm test/browser/agent_ticket_email_reply_keep_body_test.rb rm test/browser/agent_ticket_email_reply_keep_body_test.rb
rm test/browser/agent_ticket_email_signature_test.rb rm test/browser/agent_ticket_email_signature_test.rb
rm test/browser/agent_ticket_link_test.rb rm test/browser/agent_ticket_link_test.rb
@ -251,6 +255,7 @@ elif [ "$LEVEL" == '5' ]; then
rm test/browser/agent_navigation_and_title_test.rb rm test/browser/agent_navigation_and_title_test.rb
# test/browser/agent_organization_profile_test.rb # test/browser/agent_organization_profile_test.rb
rm test/browser/agent_ticket_attachment_test.rb rm test/browser/agent_ticket_attachment_test.rb
rm test/browser/agent_ticket_create_reset_customer_selection_test.rb
rm test/browser/agent_ticket_email_reply_keep_body_test.rb rm test/browser/agent_ticket_email_reply_keep_body_test.rb
rm test/browser/agent_ticket_email_signature_test.rb rm test/browser/agent_ticket_email_signature_test.rb
rm test/browser/agent_ticket_link_test.rb rm test/browser/agent_ticket_link_test.rb
@ -311,6 +316,7 @@ elif [ "$LEVEL" == '6' ]; then
rm test/browser/agent_navigation_and_title_test.rb rm test/browser/agent_navigation_and_title_test.rb
rm test/browser/agent_organization_profile_test.rb rm test/browser/agent_organization_profile_test.rb
rm test/browser/agent_ticket_attachment_test.rb rm test/browser/agent_ticket_attachment_test.rb
rm test/browser/agent_ticket_create_reset_customer_selection_test.rb
rm test/browser/agent_ticket_email_reply_keep_body_test.rb rm test/browser/agent_ticket_email_reply_keep_body_test.rb
rm test/browser/agent_ticket_email_signature_test.rb rm test/browser/agent_ticket_email_signature_test.rb
rm test/browser/agent_ticket_link_test.rb rm test/browser/agent_ticket_link_test.rb

View file

@ -0,0 +1,244 @@
require 'browser_test_helper'
class AgentTicketCreateResetCustomerSelectionTest < TestCase
def test_clear_customer
@browser = browser_instance
login(
username: 'master@example.com',
password: 'test',
url: browser_url,
)
tasks_close_all()
click(css: 'a[href="#new"]')
click(css: 'a[href="#ticket/create"]')
sleep 2
exists(css: '.content.active .newTicket')
exists(css: '.content.active .tabsSidebar .sidebar[data-tab="template"]')
exists(css: '.content.active .tabsSidebar .tabsSidebar-tab.active[data-tab="template"]')
exists_not(css: '.content.active .tabsSidebar .sidebar[data-tab="customer"]')
exists_not(css: '.content.active .tabsSidebar .tabsSidebar-tab[data-tab="customer"]')
click(css: '.content.active .newTicket [name="customer_id_completion"]')
# check if pulldown is open, it's not working stable via selenium
@browser.execute_script( "$('.content.active .newTicket .js-recipientDropdown').addClass('open')" )
set(
css: '.content.active .newTicket input[name="customer_id_completion"]',
value: 'nicole',
)
sleep 2
sendkey(value: :enter)
sleep 1
exists(css: '.content.active .newTicket')
exists(css: '.content.active .tabsSidebar .sidebar[data-tab="template"]')
exists(css: '.content.active .tabsSidebar .tabsSidebar-tab.active[data-tab="template"]')
exists(css: '.content.active .tabsSidebar .sidebar[data-tab="customer"]')
exists(css: '.content.active .tabsSidebar .tabsSidebar-tab[data-tab="customer"]')
set(
css: '.content.active .newTicket input[name="customer_id_completion"]',
value: '',
)
sendkey(value: :backspace)
sleep 1
exists(css: '.content.active .newTicket')
exists(css: '.content.active .tabsSidebar .sidebar[data-tab="template"]')
exists(css: '.content.active .tabsSidebar .tabsSidebar-tab.active[data-tab="template"]')
exists_not(css: '.content.active .tabsSidebar .sidebar[data-tab="customer"]')
exists_not(css: '.content.active .tabsSidebar .tabsSidebar-tab[data-tab="customer"]')
set(
css: '.content.active .newTicket input[name="title"]',
value: 'some title',
)
set(
css: '.content.active .newTicket div[data-name="body"]',
value: 'some body',
)
select(
css: '.content.active .newTicket select[name="group_id"]',
value: 'Users',
)
click(css: '.content.active .newTicket .js-submit')
watch_for(
css: '.content.active .newTicket .user_autocompletion.form-group.has-error',
)
# cleanup
tasks_close_all()
end
def test_clear_customer_use_email
@browser = browser_instance
login(
username: 'master@example.com',
password: 'test',
url: browser_url,
)
tasks_close_all()
click(css: 'a[href="#new"]')
click(css: 'a[href="#ticket/create"]')
sleep 2
exists(css: '.content.active .newTicket')
exists(css: '.content.active .tabsSidebar .sidebar[data-tab="template"]')
exists(css: '.content.active .tabsSidebar .tabsSidebar-tab.active[data-tab="template"]')
exists_not(css: '.content.active .tabsSidebar .sidebar[data-tab="customer"]')
exists_not(css: '.content.active .tabsSidebar .tabsSidebar-tab[data-tab="customer"]')
click(css: '.content.active .newTicket [name="customer_id_completion"]')
# check if pulldown is open, it's not working stable via selenium
@browser.execute_script( "$('.content.active .newTicket .js-recipientDropdown').addClass('open')" )
set(
css: '.content.active .newTicket input[name="customer_id_completion"]',
value: 'nicole',
)
sleep 2
sendkey(value: :enter)
sleep 1
exists(css: '.content.active .newTicket')
exists(css: '.content.active .tabsSidebar .sidebar[data-tab="template"]')
exists(css: '.content.active .tabsSidebar .tabsSidebar-tab.active[data-tab="template"]')
exists(css: '.content.active .tabsSidebar .sidebar[data-tab="customer"]')
exists(css: '.content.active .tabsSidebar .tabsSidebar-tab[data-tab="customer"]')
set(
css: '.content.active .newTicket input[name="customer_id_completion"]',
value: '',
)
sendkey(value: :backspace)
sleep 1
exists(css: '.content.active .newTicket')
exists(css: '.content.active .tabsSidebar .sidebar[data-tab="template"]')
exists(css: '.content.active .tabsSidebar .tabsSidebar-tab.active[data-tab="template"]')
exists_not(css: '.content.active .tabsSidebar .sidebar[data-tab="customer"]')
exists_not(css: '.content.active .tabsSidebar .tabsSidebar-tab[data-tab="customer"]')
set(
css: '.content.active .newTicket input[name="customer_id_completion"]',
value: 'somecustomer_not_existing_right_now@example.com',
)
set(
css: '.content.active .newTicket input[name="title"]',
value: 'some title',
)
set(
css: '.content.active .newTicket div[data-name="body"]',
value: 'some body',
)
select(
css: '.content.active .newTicket select[name="group_id"]',
value: 'Users',
)
click(css: '.content.active .newTicket .js-submit')
watch_for(
css: '.content.active .ticketZoom-header .ticket-number',
value: '\d',
)
click(css: '.content.active .tabsSidebar-tabs .tabsSidebar-tab[data-tab="customer"]')
match(
css: '.content.active .tabsSidebar .sidebar[data-tab="customer"]',
value: 'somecustomer_not_existing_right_now@example.com',
)
click(css: '.content.active .tabsSidebar .sidebar[data-tab="customer"] .js-actions')
click(css: '.content.active .tabsSidebar .sidebar[data-tab="customer"] .js-actions li[data-type="customer-change"]')
watch_for(
css: '.content.active .modal',
)
exists_not(
css: '.content.active .modal .user_autocompletion.form-group.has-error',
)
click(css: '.content.active .modal .js-submit')
watch_for(
css: '.content.active .modal .user_autocompletion.form-group.has-error',
)
set(
css: '.content.active .modal input[name="customer_id_completion"]',
value: 'master',
)
click(css: '.content.active .modal .js-submit')
watch_for(
css: '.content.active .modal .user_autocompletion.form-group.has-error',
)
set(
css: '.content.active .modal input[name="customer_id_completion"]',
value: 'master',
)
sendkey(value: :enter)
sleep 1
set(
css: '.content.active .modal input[name="customer_id_completion"]',
value: '',
)
sendkey(value: :backspace)
sleep 1
click(css: '.content.active .modal .js-submit')
watch_for(
css: '.content.active .modal .user_autocompletion.form-group.has-error',
)
set(
css: '.content.active .modal input[name="customer_id_completion"]',
value: 'master',
)
sendkey(value: :enter)
sleep 1
click(css: '.content.active .modal .js-submit')
#click(css: '.content.active .tabsSidebar-tabs .tabsSidebar-tab[data-tab="customer"]')
watch_for(
css: '.content.active .tabsSidebar .sidebar[data-tab="customer"]',
value: 'master@example.com',
)
# cleanup
tasks_close_all()
end
end

View file

@ -19,17 +19,17 @@ class AgentUserManageTest < TestCase
sleep 1 sleep 1
# create customer # create customer
click( css: 'a[href="#new"]' ) click(css: 'a[href="#new"]')
click( css: 'a[href="#ticket/create"]' ) click(css: 'a[href="#ticket/create"]')
click( css: '.active .newTicket [name="customer_id_completion"]' ) click(css: '.active .newTicket [name="customer_id_completion"]')
# check if pulldown is open, it's not working stable via selenium # check if pulldown is open, it's not working stable via selenium
@browser.execute_script( "$('.active .newTicket .js-recipientDropdown').addClass('open')" ) @browser.execute_script( "$('.active .newTicket .js-recipientDropdown').addClass('open')" )
sleep 1 sleep 1
sendkey( value: :arrow_down ) sendkey(value: :arrow_down)
sleep 0.5 sleep 0.5
click( css: '.active .newTicket .recipientList-entry.js-objectNew' ) click(css: '.active .newTicket .recipientList-entry.js-objectNew')
sleep 1 sleep 1
set( set(
@ -45,7 +45,7 @@ class AgentUserManageTest < TestCase
value: customer_user_email, value: customer_user_email,
) )
click( css: '.modal button.js-submit' ) click(css: '.modal button.js-submit')
sleep 4 sleep 4
# check is used to check selected # check is used to check selected
@ -75,8 +75,8 @@ class AgentUserManageTest < TestCase
# call new ticket screen again # call new ticket screen again
tasks_close_all() tasks_close_all()
click( css: 'a[href="#new"]' ) click(css: 'a[href="#new"]')
click( css: 'a[href="#ticket/create"]' ) click(css: 'a[href="#ticket/create"]')
sleep 2 sleep 2
match( match(
@ -93,7 +93,7 @@ class AgentUserManageTest < TestCase
) )
sleep 3 sleep 3
click( css: '.active .newTicket .recipientList-entry.js-object.is-active' ) click(css: '.active .newTicket .recipientList-entry.js-object.is-active')
sleep 1 sleep 1
# check is used to check selected # check is used to check selected

View file

@ -1261,7 +1261,7 @@ set type of task (closeTab, closeNextInOverview, stayOnTab)
sleep 0.5 sleep 0.5
return true return true
# match pn attribute # match an attribute
else else
text = if params[:attribute] text = if params[:attribute]
element.attribute(params[:attribute]) element.attribute(params[:attribute])