Fixed issue #1670 - Reset customer selection in ticket create screen if input field cleared.
This commit is contained in:
parent
6c707dc5f5
commit
ce1135a55c
7 changed files with 297 additions and 28 deletions
|
@ -1,7 +1,7 @@
|
|||
class SidebarCustomer extends App.Controller
|
||||
sidebarItem: =>
|
||||
return if !@permissionCheck('ticket.agent')
|
||||
return if !@params.customer_id
|
||||
return if _.isEmpty(@params.customer_id)
|
||||
{
|
||||
head: 'Customer'
|
||||
name: 'customer'
|
||||
|
@ -18,6 +18,7 @@ class SidebarCustomer extends App.Controller
|
|||
|
||||
showCustomer: (el) =>
|
||||
@el = el
|
||||
return if _.isEmpty(@params.customer_id)
|
||||
new App.WidgetUser(
|
||||
el: @el
|
||||
user_id: @params.customer_id
|
||||
|
|
|
@ -18,8 +18,19 @@ class App.TicketCustomer extends App.ControllerModal
|
|||
onSubmit: (e) =>
|
||||
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 = =>
|
||||
|
||||
# close modal
|
||||
|
|
|
@ -71,7 +71,7 @@ class App.ObjectOrganizationAutocompletion extends App.Controller
|
|||
@open()
|
||||
|
||||
focusInput: =>
|
||||
@objectSelect.focus() if not @formControl.hasClass 'focus'
|
||||
@objectSelect.focus() if not @formControl.hasClass('focus')
|
||||
|
||||
onBlur: =>
|
||||
selectObject = @objectSelect.val()
|
||||
|
@ -85,6 +85,9 @@ class App.ObjectOrganizationAutocompletion extends App.Controller
|
|||
@objectId.val("guess:#{selectObject}")
|
||||
@formControl.removeClass 'focus'
|
||||
|
||||
resetObjectSelection: =>
|
||||
@objectId.val('').trigger('change')
|
||||
|
||||
onObjectClick: (e) =>
|
||||
objectId = $(e.currentTarget).data('object-id')
|
||||
@selectObject(objectId)
|
||||
|
@ -103,14 +106,14 @@ class App.ObjectOrganizationAutocompletion extends App.Controller
|
|||
# Only work with the last one since its the newest one
|
||||
objectId = @objectId.val().split(',').pop()
|
||||
|
||||
return if !objectId
|
||||
return if !App[@objectSingle].exists(objectId)
|
||||
if objectId && App[@objectSingle].exists(objectId)
|
||||
object = App[@objectSingle].find(objectId)
|
||||
name = object.displayName()
|
||||
|
||||
if @attribute.multiple
|
||||
|
||||
# create token
|
||||
@createToken name, objectId
|
||||
@createToken(name, objectId)
|
||||
else
|
||||
if object.email
|
||||
|
||||
|
@ -321,12 +324,16 @@ class App.ObjectOrganizationAutocompletion extends App.Controller
|
|||
@hideOrganizationMembers()
|
||||
|
||||
# hide dropdown
|
||||
if !query
|
||||
if _.isEmpty(query)
|
||||
@emptyResultList()
|
||||
|
||||
if !@attribute.disableCreateObject
|
||||
@recipientList.append(@buildObjectNew())
|
||||
|
||||
# reset object selection
|
||||
@resetObjectSelection()
|
||||
return
|
||||
|
||||
# show dropdown
|
||||
if query && ( !@attribute.minLengt || @attribute.minLengt <= query.length )
|
||||
@lazySearch(query)
|
||||
|
|
|
@ -20,6 +20,7 @@ if [ "$LEVEL" == '1' ]; then
|
|||
rm test/browser/admin_role_test.rb
|
||||
# test/browser/agent_navigation_and_title_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_signature_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_organization_profile_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_signature_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_organization_profile_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_signature_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_organization_profile_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_signature_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
|
||||
# test/browser/agent_organization_profile_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_signature_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_organization_profile_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_signature_test.rb
|
||||
rm test/browser/agent_ticket_link_test.rb
|
||||
|
|
|
@ -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
|
|
@ -1261,7 +1261,7 @@ set type of task (closeTab, closeNextInOverview, stayOnTab)
|
|||
sleep 0.5
|
||||
return true
|
||||
|
||||
# match pn attribute
|
||||
# match an attribute
|
||||
else
|
||||
text = if params[:attribute]
|
||||
element.attribute(params[:attribute])
|
||||
|
|
Loading…
Reference in a new issue