Added fix for #2117 by disabling the create/update button during file uploading

This commit is contained in:
Billy Zhou 2018-07-10 22:07:11 +08:00
parent f2ff8ee532
commit 166e1e04f1
4 changed files with 93 additions and 0 deletions

View file

@ -73,12 +73,19 @@ class App.UiElement.richtext
@attachmentPlaceholder.addClass('hide') @attachmentPlaceholder.addClass('hide')
@attachmentUpload.removeClass('hide') @attachmentUpload.removeClass('hide')
@cancelContainer.removeClass('hide') @cancelContainer.removeClass('hide')
# Disable the create ticket button during uploading
$('.main .newTicket .page-content .js-submit')
.text(App.i18n.translateInline('Uploading'))
.addClass('is-disabled')
App.Log.debug 'UiElement.richtext', 'upload start' App.Log.debug 'UiElement.richtext', 'upload start'
onAborted: => onAborted: =>
@attachmentPlaceholder.removeClass('hide') @attachmentPlaceholder.removeClass('hide')
@attachmentUpload.addClass('hide') @attachmentUpload.addClass('hide')
item.find('input').val('') item.find('input').val('')
$('.main .newTicket .page-content .js-submit')
.text(App.i18n.translateInline('Create'))
.removeClass('is-disabled')
# Called after received response from the server # Called after received response from the server
onCompleted: (response) => onCompleted: (response) =>
@ -93,6 +100,9 @@ class App.UiElement.richtext
renderFile(response.data) renderFile(response.data)
item.find('input').val('') item.find('input').val('')
$('.main .newTicket .page-content .js-submit')
.text(App.i18n.translateInline('Create'))
.removeClass('is-disabled')
App.Log.debug 'UiElement.richtext', 'upload complete', response.data App.Log.debug 'UiElement.richtext', 'upload complete', response.data

View file

@ -188,11 +188,18 @@ class App.TicketZoomArticleNew extends App.Controller
@attachmentPlaceholder.addClass('hide') @attachmentPlaceholder.addClass('hide')
@attachmentUpload.removeClass('hide') @attachmentUpload.removeClass('hide')
@cancelContainer.removeClass('hide') @cancelContainer.removeClass('hide')
# Disable the update ticket button during uploading
$('.active .attributeBar .js-submit')
.text(App.i18n.translateInline('Uploading'))
.addClass('is-disabled')
onAborted: => onAborted: =>
@attachmentPlaceholder.removeClass('hide') @attachmentPlaceholder.removeClass('hide')
@attachmentUpload.addClass('hide') @attachmentUpload.addClass('hide')
@$('.article-attachment input').val('') @$('.article-attachment input').val('')
$('.active .attributeBar .js-submit')
.text(App.i18n.translateInline('Update'))
.removeClass('is-disabled')
# Called after received response from the server # Called after received response from the server
onCompleted: (response) => onCompleted: (response) =>
@ -209,6 +216,9 @@ class App.TicketZoomArticleNew extends App.Controller
@renderAttachment(response.data) @renderAttachment(response.data)
@$('.article-attachment input').val('') @$('.article-attachment input').val('')
$('.active .attributeBar .js-submit')
.text(App.i18n.translateInline('Update'))
.removeClass('is-disabled')
# Called during upload progress, first parameter # Called during upload progress, first parameter
# is decimal value from 0 to 100. # is decimal value from 0 to 100.

View file

@ -302,4 +302,76 @@ class AgentTicketAttachmentTest < TestCase
# some form reset checks # some form reset checks
end end
def test_upload_blocks_ticket_updates
# since selenium webdriver with firefox is not able to upload files, skip here
# https://github.com/w3c/webdriver/issues/1230
return if browser == 'firefox'
@browser = browser_instance
login(
username: 'agent1@example.com',
password: 'test',
url: browser_url,
)
tasks_close_all()
ticket1 = ticket_create(
data: {
customer: 'Nico',
group: 'Users',
title: 'Ticket 1',
body: 'some body',
},
do_not_submit: true,
)
# First test the attachment uploading for new tickets
file_upload(
css: '.content.active .attachmentPlaceholder-inputHolder input',
files: [Rails.root.join('test', 'data', 'upload', 'upload2.jpg')],
no_sleep: true,
)
match(
css: '.js-submit.is-disabled',
value: 'Uploading',
)
watch_for_disappear(
css: '.js-submit.is-disabled',
value: 'Uploading',
)
match(
css: '.js-submit',
value: 'Create',
)
click(
css: '.active .js-submit',
)
sleep 2
# Next test the attachment uploading for new articles
ticket_update(
data: {
body: 'added attachment',
},
do_not_submit: true,
)
file_upload(
css: '.content.active .attachmentPlaceholder-inputHolder input',
files: [Rails.root.join('test', 'data', 'upload', 'upload2.jpg')],
no_sleep: true,
)
match(
css: '.js-submit.is-disabled',
value: 'Uploading',
)
watch_for_disappear(
css: '.js-submit.is-disabled',
value: 'Uploading',
)
match(
css: '.js-submit',
value: 'Update',
)
end
end end

View file

@ -1317,6 +1317,7 @@ set type of task (closeTab, closeNextInOverview, stayOnTab)
params[:files].each do |file| params[:files].each do |file|
instance.find_elements(css: params[:css])[0].send_keys(Rails.root.join(file)) instance.find_elements(css: params[:css])[0].send_keys(Rails.root.join(file))
end end
return if params[:no_sleep]
sleep 2 * params[:files].count sleep 2 * params[:files].count
end end