Fixes #3088 - Notes on existing ticks are discarded by editing profile settings.
This commit is contained in:
parent
3b18f7feaf
commit
61406365f0
3 changed files with 110 additions and 19 deletions
|
@ -263,6 +263,10 @@ class App.TicketZoom extends App.Controller
|
|||
@positionPageHeaderStart()
|
||||
@autosaveStart()
|
||||
@shortcutNavigationStart()
|
||||
|
||||
if @articleNew
|
||||
@articleNew.show()
|
||||
|
||||
return if !@attributeBar
|
||||
@attributeBar.start()
|
||||
|
||||
|
@ -1056,12 +1060,22 @@ class App.TicketZoom extends App.Controller
|
|||
|
||||
taskUpdate: (area, data) =>
|
||||
@localTaskData[area] = data
|
||||
App.TaskManager.update(@taskKey, { 'state': @localTaskData })
|
||||
|
||||
taskData = { 'state': @localTaskData }
|
||||
if _.isArray(data.attachments)
|
||||
taskData.attachments = data.attachments
|
||||
|
||||
App.TaskManager.update(@taskKey, taskData)
|
||||
|
||||
taskUpdateAll: (data) =>
|
||||
@localTaskData = data
|
||||
@localTaskData.article['form_id'] = @form_id
|
||||
App.TaskManager.update(@taskKey, { 'state': @localTaskData })
|
||||
|
||||
taskData = { 'state': @localTaskData }
|
||||
if _.isArray(data.attachments)
|
||||
taskData.attachments = data.attachments
|
||||
|
||||
App.TaskManager.update(@taskKey, taskData)
|
||||
|
||||
# reset task state
|
||||
taskReset: =>
|
||||
|
|
|
@ -43,14 +43,10 @@ class App.TicketZoomArticleNew extends App.Controller
|
|||
closed: 20
|
||||
|
||||
@dragEventCounter = 0
|
||||
@attachments = []
|
||||
@attachments = @defaults.attachments || []
|
||||
|
||||
@render()
|
||||
|
||||
if _.isArray(@defaults.attachments)
|
||||
for attachment in @defaults.attachments
|
||||
@renderAttachment(attachment)
|
||||
|
||||
# set article type and expand text area
|
||||
@controllerBind('ui::ticket::setArticleType', (data) =>
|
||||
return if data.ticket.id.toString() isnt @ticket_id.toString()
|
||||
|
@ -75,7 +71,7 @@ class App.TicketZoomArticleNew extends App.Controller
|
|||
if data.position is 'end'
|
||||
@placeCaretAtEnd(@textarea.get(0))
|
||||
return
|
||||
|
||||
|
||||
# fixes email validation issue right after new ticket creation
|
||||
@tokanice(data.type.name)
|
||||
)
|
||||
|
@ -92,22 +88,17 @@ class App.TicketZoomArticleNew extends App.Controller
|
|||
@controllerBind('ui::ticket::taskReset', (data) =>
|
||||
@releaseGlobalClickEvents()
|
||||
return if data.ticket_id.toString() isnt @ticket_id.toString()
|
||||
@type = 'note'
|
||||
@defaults = {}
|
||||
@type = 'note'
|
||||
@defaults = {}
|
||||
@attachments = []
|
||||
@render()
|
||||
)
|
||||
|
||||
# set expand of text area only once
|
||||
@controllerBind('ui::ticket::shown', (data) =>
|
||||
return if data.ticket_id.toString() isnt @ticket.id.toString()
|
||||
@tokanice(@type)
|
||||
|
||||
if @defaults.body or @isIE10()
|
||||
@openTextarea(null, true)
|
||||
)
|
||||
|
||||
# rerender, e. g. on language change
|
||||
@controllerBind('ui:rerender', =>
|
||||
@adjustedTextarea = false
|
||||
@defaults = @ui.taskGet('article')
|
||||
@attachments = @defaults.attachments
|
||||
@render()
|
||||
)
|
||||
|
||||
|
@ -117,6 +108,18 @@ class App.TicketZoomArticleNew extends App.Controller
|
|||
@updateSecurityOptions()
|
||||
)
|
||||
|
||||
show: ->
|
||||
@adjustTextarea()
|
||||
|
||||
adjustTextarea: ->
|
||||
return if @adjustedTextarea
|
||||
@adjustedTextarea = true
|
||||
|
||||
@tokanice(@type)
|
||||
|
||||
if @defaults.body or @isIE10()
|
||||
@openTextarea(null, true)
|
||||
|
||||
tokanice: (type = 'email') ->
|
||||
App.Utils.tokanice('.content.active .js-to, .js-cc, js-bcc', type)
|
||||
|
||||
|
@ -285,6 +288,10 @@ class App.TicketZoomArticleNew extends App.Controller
|
|||
if !@subscribeIdTextModule
|
||||
@subscribeIdTextModule = ticket.subscribe(callback)
|
||||
|
||||
if _.isArray(@attachments)
|
||||
for attachment in @attachments
|
||||
@renderAttachment(attachment)
|
||||
|
||||
params: =>
|
||||
params = @formParam( @$('.article-add') )
|
||||
|
||||
|
@ -332,6 +339,7 @@ class App.TicketZoomArticleNew extends App.Controller
|
|||
params.preferences ||= {}
|
||||
params.preferences.security = @paramsSecurity()
|
||||
|
||||
params.attachments = @attachments
|
||||
params
|
||||
|
||||
validate: =>
|
||||
|
|
|
@ -1957,4 +1957,73 @@ RSpec.describe 'Ticket zoom', type: :system do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Notes on existing ticks are discarded by editing profile settings #3088' do
|
||||
let(:ticket) { create(:ticket, group: Group.find_by(name: 'Users')) }
|
||||
|
||||
before do
|
||||
visit "#ticket/zoom/#{ticket.id}"
|
||||
end
|
||||
|
||||
def upload_and_set_text
|
||||
page.find('.js-textarea').send_keys("Hello\nThis\nis\nimportant!\nyo\nhoho\ntest test test test")
|
||||
page.find('input#fileUpload_1', visible: :all).set(Rails.root.join('test/data/mail/mail001.box'))
|
||||
expect(page).to have_text('mail001.box')
|
||||
wait_for_upload_present
|
||||
end
|
||||
|
||||
def wait_for_upload_present
|
||||
wait(5).until { Taskbar.find_by(key: "Ticket-#{ticket.id}").attributes_with_association_ids['attachments'].present? }
|
||||
end
|
||||
|
||||
def wait_for_upload_blank
|
||||
wait(5).until { Taskbar.find_by(key: "Ticket-#{ticket.id}").attributes_with_association_ids['attachments'].blank? }
|
||||
end
|
||||
|
||||
def switch_language_german
|
||||
visit '#profile/language'
|
||||
page.find('.js-input').click
|
||||
page.find('.js-input').set('Deutsch')
|
||||
page.find('.js-input').send_keys(:enter)
|
||||
click_on 'Submit'
|
||||
|
||||
visit "#ticket/zoom/#{ticket.id}"
|
||||
expect(page).to have_text('Dateien wählen')
|
||||
end
|
||||
|
||||
def expect_upload_and_text
|
||||
expect(page).to have_text('mail001.box')
|
||||
expect(page).to have_text("Hello\nThis\nis\nimportant!\nyo\nhoho\ntest test test test")
|
||||
end
|
||||
|
||||
def expect_no_upload_and_text
|
||||
expect(page).to have_no_text('mail001.box')
|
||||
expect(page).to have_no_text("Hello\nThis\nis\nimportant!\nyo\nhoho\ntest test test test")
|
||||
end
|
||||
|
||||
it 'does show up the attachments after a reload of the page' do
|
||||
upload_and_set_text
|
||||
expect_upload_and_text
|
||||
refresh
|
||||
expect_upload_and_text
|
||||
end
|
||||
|
||||
it 'does show up the attachments after updating language (ui:rerender event)' do
|
||||
upload_and_set_text
|
||||
expect_upload_and_text
|
||||
switch_language_german
|
||||
expect_upload_and_text
|
||||
end
|
||||
|
||||
it 'does remove attachments and text on reset' do
|
||||
upload_and_set_text
|
||||
expect_upload_and_text
|
||||
|
||||
page.find('.js-reset').click
|
||||
wait_for_upload_blank
|
||||
expect_no_upload_and_text
|
||||
refresh
|
||||
expect_no_upload_and_text
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue