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
|
@ -10,7 +10,7 @@ class App.Controller extends Spine.Controller
|
|||
super
|
||||
|
||||
# generate controllerId
|
||||
@controllerId = 'controller-' + new Date().getTime() + '-' + Math.floor( Math.random() * 999999 )
|
||||
@controllerId = 'controller-' + new Date().getTime() + '-' + Math.floor(Math.random() * 999999)
|
||||
|
||||
# apply to release controller on dom remove
|
||||
@el.on('remove', @releaseController)
|
||||
|
@ -84,7 +84,7 @@ class App.Controller extends Spine.Controller
|
|||
|
||||
# add @title methode to set title
|
||||
title: (name, translate = false) ->
|
||||
# $('html head title').html( @Config.get(product_name) + ' - ' + App.i18n.translateInline(name) )
|
||||
# $('html head title').html(@Config.get(product_name) + ' - ' + App.i18n.translateInline(name))
|
||||
title = name
|
||||
if translate
|
||||
title = App.i18n.translatePlain(name)
|
||||
|
@ -92,9 +92,9 @@ class App.Controller extends Spine.Controller
|
|||
|
||||
copyToClipboard: (text) ->
|
||||
if window.clipboardData # IE
|
||||
window.clipboardData.setData( 'Text', text )
|
||||
window.clipboardData.setData('Text', text)
|
||||
else
|
||||
window.prompt( 'Copy to clipboard: Ctrl+C, Enter', text )
|
||||
window.prompt('Copy to clipboard: Ctrl+C, Enter', text)
|
||||
|
||||
# disable all delay's and interval's
|
||||
disconnectClient: ->
|
||||
|
@ -238,11 +238,11 @@ class App.Controller extends Spine.Controller
|
|||
currentVal = item.text()
|
||||
ui.frontendTimeUpdateItem(item, currentVal)
|
||||
)
|
||||
App.Interval.set( update, 61000, 'frontendTimeUpdate', 'ui' )
|
||||
App.Interval.set(update, 61000, 'frontendTimeUpdate', 'ui')
|
||||
|
||||
frontendTimeUpdateItem: (item, currentVal) =>
|
||||
timestamp = item.data('time')
|
||||
time = @humanTime( timestamp, item.hasClass('escalation') )
|
||||
time = @humanTime(timestamp, item.hasClass('escalation'))
|
||||
|
||||
# only do dom updates on changes
|
||||
return if time is currentVal
|
||||
|
|
|
@ -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,51 +413,62 @@ 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
|
||||
currentStoreTicket = @ticket.attributes()
|
||||
delete currentStoreTicket.article
|
||||
currentStore =
|
||||
ticket: currentStoreTicket
|
||||
article:
|
||||
to: ''
|
||||
cc: ''
|
||||
type: 'note'
|
||||
body: ''
|
||||
internal: ''
|
||||
in_reply_to: ''
|
||||
currentParams =
|
||||
ticket: @formParam( @el.find('.edit') )
|
||||
article: @formParam( @el.find('.article-add') )
|
||||
currentParams = @formCurrent()
|
||||
|
||||
# add attachments if exist
|
||||
attachmentCount = @$('.article-add .textBubble .attachments .attachment').length
|
||||
if attachmentCount > 0
|
||||
currentParams.article.attachments = true
|
||||
else
|
||||
delete currentParams.article.attachments
|
||||
# check changed between last autosave
|
||||
sameAsLastSave = _.isEqual(currentParams, @autosaveLast)
|
||||
return if sameAsLastSave
|
||||
@autosaveLast = clone(currentParams)
|
||||
|
||||
#console.log('lll', currentStore)
|
||||
# remove not needed attributes
|
||||
delete currentParams.article.form_id
|
||||
# update changes in ui
|
||||
currentStore = @currentStore()
|
||||
modelDiff = @formDiff(currentParams, currentStore)
|
||||
@markFormDiff(modelDiff)
|
||||
@taskUpdateAll(modelDiff)
|
||||
|
||||
# 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')
|
||||
|
||||
currentStore: =>
|
||||
return if !@ticket
|
||||
currentStoreTicket = @ticket.attributes()
|
||||
delete currentStoreTicket.article
|
||||
currentStore =
|
||||
ticket: currentStoreTicket
|
||||
article:
|
||||
to: ''
|
||||
cc: ''
|
||||
type: 'note'
|
||||
body: ''
|
||||
internal: ''
|
||||
in_reply_to: ''
|
||||
currentStore
|
||||
|
||||
formCurrent: =>
|
||||
currentParams =
|
||||
ticket: @formParam(@el.find('.edit'))
|
||||
article: @formParam(@el.find('.article-add'))
|
||||
|
||||
# add attachments if exist
|
||||
attachmentCount = @$('.article-add .textBubble .attachments .attachment').length
|
||||
if attachmentCount > 0
|
||||
currentParams.article.attachments = true
|
||||
else
|
||||
delete currentParams.article.attachments
|
||||
|
||||
# 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)
|
||||
|
||||
modelDiff
|
||||
|
||||
markFormDiff: (diff = {}) =>
|
||||
ticketForm = @$('.edit')
|
||||
ticketSidebar = @$('.tabsSidebar-tab[data-tab="ticket"]')
|
||||
|
|
|
@ -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)
|
||||
|
@ -109,7 +109,7 @@ class App.OnlineNotificationWidget extends App.Controller
|
|||
id: 'markAllAsRead'
|
||||
type: 'POST'
|
||||
url: @apiPath + '/online_notifications/mark_all_as_read'
|
||||
data: JSON.stringify( '' )
|
||||
data: JSON.stringify('')
|
||||
processData: true
|
||||
)
|
||||
|
||||
|
@ -170,7 +170,7 @@ class App.OnlineNotificationWidget extends App.Controller
|
|||
|
||||
# update title
|
||||
$('.js-notificationsContainer .popover-title').html(
|
||||
App.i18n.translateInline( 'Notifications' ) + " <span class='popover-notificationsCounter'>#{counter}</span>"
|
||||
App.i18n.translateInline('Notifications') + " <span class='popover-notificationsCounter'>#{counter}</span>"
|
||||
)
|
||||
|
||||
# show mark all as read if needed
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -13,7 +13,7 @@ class AgentTicketActionsLevel2Test < TestCase
|
|||
password: 'test',
|
||||
url: browser_url,
|
||||
)
|
||||
tasks_close_all( browser: browser1 )
|
||||
tasks_close_all(browser: browser1)
|
||||
|
||||
browser2 = browser_instance
|
||||
login(
|
||||
|
@ -22,7 +22,7 @@ class AgentTicketActionsLevel2Test < TestCase
|
|||
password: 'test',
|
||||
url: browser_url,
|
||||
)
|
||||
tasks_close_all( browser: browser2 )
|
||||
tasks_close_all(browser: browser2)
|
||||
|
||||
# create ticket
|
||||
ticket1 = ticket_create(
|
||||
|
|
|
@ -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
|
||||
|
@ -11,7 +62,7 @@ class AgentTicketActionsLevel3Test < TestCase
|
|||
password: 'test',
|
||||
url: browser_url,
|
||||
)
|
||||
tasks_close_all( browser: browser1 )
|
||||
tasks_close_all(browser: browser1)
|
||||
|
||||
browser2 = browser_instance
|
||||
login(
|
||||
|
@ -20,7 +71,7 @@ class AgentTicketActionsLevel3Test < TestCase
|
|||
password: 'test',
|
||||
url: browser_url,
|
||||
)
|
||||
tasks_close_all( browser: browser2 )
|
||||
tasks_close_all(browser: browser2)
|
||||
|
||||
# create ticket
|
||||
ticket1 = ticket_create(
|
||||
|
@ -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,
|
||||
|
|
|
@ -13,7 +13,7 @@ class AgentTicketOverviewLevel1Test < TestCase
|
|||
password: 'test',
|
||||
url: browser_url,
|
||||
)
|
||||
tasks_close_all( browser: browser1 )
|
||||
tasks_close_all(browser: browser1)
|
||||
|
||||
browser2 = browser_instance
|
||||
login(
|
||||
|
@ -22,7 +22,7 @@ class AgentTicketOverviewLevel1Test < TestCase
|
|||
password: 'test',
|
||||
url: browser_url,
|
||||
)
|
||||
tasks_close_all( browser: browser2 )
|
||||
tasks_close_all(browser: browser2)
|
||||
|
||||
# create new overview
|
||||
overview_create(
|
||||
|
|
|
@ -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