Fixed losing article text in tab close (was ignored on changes check).
This commit is contained in:
parent
f4c78b9502
commit
77d4f00957
9 changed files with 178 additions and 64 deletions
|
@ -126,10 +126,11 @@ class App.TicketZoom extends App.Controller
|
|||
|
||||
changed: =>
|
||||
return false if !@ticket
|
||||
formCurrent = @formParam( @el.find('.edit') )
|
||||
ticket = App.Ticket.find(@ticket_id).attributes()
|
||||
modelDiff = App.Utils.formDiff(formCurrent, ticket)
|
||||
currentParams = @formCurrent()
|
||||
currentStore = @currentStore()
|
||||
modelDiff = @formDiff(currentParams, currentStore)
|
||||
return false if !modelDiff || _.isEmpty(modelDiff)
|
||||
return false if _.isEmpty(modelDiff.ticket) && _.isEmpty(modelDiff.article)
|
||||
return true
|
||||
|
||||
release: =>
|
||||
|
@ -412,7 +413,23 @@ class App.TicketZoom extends App.Controller
|
|||
if !@autosaveLast
|
||||
@autosaveLast = @taskGet()
|
||||
update = =>
|
||||
#console.log('AR', @ticket_id, @ticket, @formParam( @el.find('.article-add') ) )
|
||||
return if !@ticket
|
||||
currentParams = @formCurrent()
|
||||
|
||||
# check changed between last autosave
|
||||
sameAsLastSave = _.isEqual(currentParams, @autosaveLast)
|
||||
return if sameAsLastSave
|
||||
@autosaveLast = clone(currentParams)
|
||||
|
||||
# update changes in ui
|
||||
currentStore = @currentStore()
|
||||
modelDiff = @formDiff(currentParams, currentStore)
|
||||
@markFormDiff(modelDiff)
|
||||
@taskUpdateAll(modelDiff)
|
||||
|
||||
@interval(update, 2800, 'autosave')
|
||||
|
||||
currentStore: =>
|
||||
return if !@ticket
|
||||
currentStoreTicket = @ticket.attributes()
|
||||
delete currentStoreTicket.article
|
||||
|
@ -425,6 +442,9 @@ class App.TicketZoom extends App.Controller
|
|||
body: ''
|
||||
internal: ''
|
||||
in_reply_to: ''
|
||||
currentStore
|
||||
|
||||
formCurrent: =>
|
||||
currentParams =
|
||||
ticket: @formParam(@el.find('.edit'))
|
||||
article: @formParam(@el.find('.article-add'))
|
||||
|
@ -436,26 +456,18 @@ class App.TicketZoom extends App.Controller
|
|||
else
|
||||
delete currentParams.article.attachments
|
||||
|
||||
#console.log('lll', currentStore)
|
||||
# remove not needed attributes
|
||||
delete currentParams.article.form_id
|
||||
currentParams
|
||||
|
||||
formDiff: (currentParams, currentStore) ->
|
||||
|
||||
# get diff of model
|
||||
modelDiff =
|
||||
ticket: App.Utils.formDiff(currentParams.ticket, currentStore.ticket)
|
||||
article: App.Utils.formDiff(currentParams.article, currentStore.article)
|
||||
#console.log('modelDiff', modelDiff)
|
||||
|
||||
# get diff of last save
|
||||
changedBetweenLastSave = _.isEqual(currentParams, @autosaveLast)
|
||||
if !changedBetweenLastSave
|
||||
#console.log('model DIFF ', modelDiff)
|
||||
|
||||
@autosaveLast = clone(currentParams)
|
||||
@markFormDiff(modelDiff)
|
||||
|
||||
@taskUpdateAll(modelDiff)
|
||||
@interval(update, 2800, 'autosave')
|
||||
modelDiff
|
||||
|
||||
markFormDiff: (diff = {}) =>
|
||||
ticketForm = @$('.edit')
|
||||
|
|
|
@ -98,10 +98,10 @@ class App.OnlineNotificationWidget extends App.Controller
|
|||
|
||||
counterUpdate: (count) =>
|
||||
if !count
|
||||
@el.find('.js-counter').text('')
|
||||
@$('.js-counter').text('')
|
||||
return
|
||||
|
||||
@el.find('.js-counter').text(count)
|
||||
@$('.js-counter').text(count)
|
||||
|
||||
markAllAsRead: =>
|
||||
@counterUpdate(0)
|
||||
|
|
|
@ -53,7 +53,7 @@ class AgentTicketActionLevel0Test < TestCase
|
|||
css: '.active div[data-name=body]',
|
||||
value: 'some content' + random,
|
||||
)
|
||||
tasks_close_all( discard_changes: true )
|
||||
tasks_close_all()
|
||||
|
||||
# test with two browser windows
|
||||
random = 'text_II_module_test_' + rand(99_999_999).to_s
|
||||
|
|
|
@ -2,6 +2,57 @@
|
|||
require 'browser_test_helper'
|
||||
|
||||
class AgentTicketActionsLevel3Test < TestCase
|
||||
def test_check_changes
|
||||
@browser = browser_instance
|
||||
login(
|
||||
username: 'agent1@example.com',
|
||||
password: 'test',
|
||||
url: browser_url,
|
||||
)
|
||||
tasks_close_all()
|
||||
|
||||
# confirm on create
|
||||
ticket_create(
|
||||
data: {
|
||||
customer: 'nico',
|
||||
group: 'Users',
|
||||
title: 'some changes',
|
||||
body: 'some body 123äöü - changes',
|
||||
},
|
||||
do_not_submit: true,
|
||||
)
|
||||
close_task(
|
||||
data: {
|
||||
title: 'some changes',
|
||||
},
|
||||
discard_changes: true,
|
||||
)
|
||||
sleep 1
|
||||
|
||||
# confirm on zoom
|
||||
ticket1 = ticket_create(
|
||||
data: {
|
||||
customer: 'nico',
|
||||
group: 'Users',
|
||||
title: 'some changes',
|
||||
body: 'some body 123äöü - changes',
|
||||
},
|
||||
)
|
||||
ticket_update(
|
||||
data: {
|
||||
body: 'some note',
|
||||
},
|
||||
do_not_submit: true,
|
||||
)
|
||||
close_task(
|
||||
data: {
|
||||
title: 'some changes',
|
||||
},
|
||||
discard_changes: true,
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
def test_work_with_two_browser_on_same_ticket_edit
|
||||
|
||||
browser1 = browser_instance
|
||||
|
@ -52,6 +103,13 @@ class AgentTicketActionsLevel3Test < TestCase
|
|||
},
|
||||
do_not_submit: true,
|
||||
)
|
||||
sleep 6
|
||||
watch_for(
|
||||
browser: browser1,
|
||||
css: '.content.active .js-reset',
|
||||
value: '(Discard your unsaved changes.|Verwerfen der)',
|
||||
no_quote: true,
|
||||
)
|
||||
|
||||
# update ticket in instance 2
|
||||
ticket_update(
|
||||
|
@ -61,6 +119,13 @@ class AgentTicketActionsLevel3Test < TestCase
|
|||
},
|
||||
do_not_submit: true,
|
||||
)
|
||||
sleep 6
|
||||
watch_for(
|
||||
browser: browser2,
|
||||
css: '.content.active .js-reset',
|
||||
value: '(Discard your unsaved changes.|Verwerfen der)',
|
||||
no_quote: true,
|
||||
)
|
||||
|
||||
click(
|
||||
browser: browser2,
|
||||
|
|
|
@ -73,7 +73,7 @@ class AgentUserManageTest < TestCase
|
|||
sleep 4
|
||||
|
||||
# call new ticket screen again
|
||||
tasks_close_all( discard_changes: 1 )
|
||||
tasks_close_all()
|
||||
|
||||
click( css: 'a[href="#new"]' )
|
||||
click( css: 'a[href="#ticket/create"]' )
|
||||
|
|
|
@ -933,7 +933,7 @@ class TestCase < Test::Unit::TestCase
|
|||
|
||||
=end
|
||||
|
||||
def open_task(params = {}, _fallback = false)
|
||||
def open_task(params = {})
|
||||
switch_window_focus(params)
|
||||
log('open_task', params)
|
||||
|
||||
|
@ -949,6 +949,44 @@ class TestCase < Test::Unit::TestCase
|
|||
true
|
||||
end
|
||||
|
||||
=begin
|
||||
|
||||
close_task(
|
||||
browser: browser1,
|
||||
data: {
|
||||
title: 'some title',
|
||||
},
|
||||
discard_changes: true,
|
||||
)
|
||||
|
||||
=end
|
||||
|
||||
def close_task(params = {})
|
||||
switch_window_focus(params)
|
||||
log('close_task', params)
|
||||
|
||||
instance = params[:browser] || @browser
|
||||
data = params[:data]
|
||||
|
||||
element = instance.find_elements(partial_link_text: data[:title])[0]
|
||||
if !element
|
||||
screenshot(browser: instance, comment: 'close_task_failed')
|
||||
fail "no task with title '#{data[:title]}' found"
|
||||
end
|
||||
|
||||
instance.mouse.move_to(element)
|
||||
sleep 0.1
|
||||
instance.execute_script("$('.navigation .tasks .task:contains(\"#{data[:title]}\") .js-close').click()")
|
||||
|
||||
# accept task close warning
|
||||
if params[:discard_changes]
|
||||
sleep 1
|
||||
instance.find_elements(css: '.modal button.js-submit')[0].click
|
||||
end
|
||||
|
||||
true
|
||||
end
|
||||
|
||||
=begin
|
||||
|
||||
file_upload(
|
||||
|
@ -1122,7 +1160,6 @@ wait untill text in selector disabppears
|
|||
|
||||
tasks_close_all(
|
||||
browser: browser1,
|
||||
discard_changes: true,
|
||||
)
|
||||
|
||||
=end
|
||||
|
@ -1144,8 +1181,8 @@ wait untill text in selector disabppears
|
|||
click_element.click
|
||||
|
||||
# accept task close warning
|
||||
if params[:discard_changes]
|
||||
sleep 1
|
||||
if instance.find_elements(css: '.modal button.js-submit')[0]
|
||||
sleep 0.5
|
||||
instance.find_elements(css: '.modal button.js-submit')[0].click
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue