Prevent submitting attachments without article body.

This commit is contained in:
Martin Edenhofer 2015-10-23 13:45:20 +02:00
parent ce937627d8
commit 453e201912
3 changed files with 53 additions and 7 deletions

View file

@ -547,6 +547,15 @@ class App.TicketZoom extends App.Controller
# validate article # validate article
articleParams = @formParam( @$('.article-add') ) articleParams = @formParam( @$('.article-add') )
console.log 'submit article', articleParams console.log 'submit article', articleParams
# check if attachment exists but no body
attachmentCount = @$('.article-add .textBubble .attachments .attachment').length
if !articleParams['body'] && attachmentCount > 0
if !confirm( App.i18n.translateContent('Please fill also some text in!') )
@formEnable(e)
@autosaveStart()
return
if articleParams['body'] if articleParams['body']
articleParams.from = @Session.get().displayName() articleParams.from = @Session.get().displayName()
articleParams.ticket_id = ticket.id articleParams.ticket_id = ticket.id
@ -590,8 +599,7 @@ class App.TicketZoom extends App.Controller
# check attachment # check attachment
if articleParams['body'] if articleParams['body']
if App.Utils.checkAttachmentReference( articleParams['body'] ) if App.Utils.checkAttachmentReference( articleParams['body'] ) && attachmentCount < 1
if @$('.article-add .textBubble .attachments .attachment').length < 1
if !confirm( App.i18n.translateContent('You use attachment in text but no attachment is attached. Do you want to continue?') ) if !confirm( App.i18n.translateContent('You use attachment in text but no attachment is attached. Do you want to continue?') )
@formEnable(e) @formEnable(e)
@autosaveStart() @autosaveStart()

View file

@ -107,6 +107,44 @@ class AgentTicketActionLevel6Test < TestCase
value: 'test 6 - ticket 1-1', value: 'test 6 - ticket 1-1',
) )
# add attachment without body
@browser.execute_script( "App.TestHelper.attachmentUploadFake('.active .article-add .textBubble .attachments')" )
# submit form
click(
css: '.active .js-submit',
)
sleep 2
# check warning
alert = @browser.switch_to.alert
alert.dismiss()
ticket_update(
data: {
body: 'now submit should work',
},
do_not_submit: true,
)
# submit form
click(
css: '.active .js-submit',
)
sleep 2
# discard changes should gone away
watch_for_disappear(
css: '.content.active .js-reset',
value: '(Discard your unsaved changes.|Verwerfen der)',
no_quote: true,
)
ticket_verify(
data: {
body: '',
},
)
# #
# ticket customer change checks # ticket customer change checks
# #

View file

@ -1076,7 +1076,7 @@ wait untill text in selector disabppears
element.clear element.clear
# workaround, sometimes focus is not triggered # workaround, sometimes focus is not triggered
element.send_keys( data[:customer] ) element.send_keys( data[:customer] + '*' )
sleep 3.5 sleep 3.5
# check if pulldown is open, it's not working stable via selenium # check if pulldown is open, it's not working stable via selenium