Fixes #3981 - Draft Sharing: Draft stays after new ticket creation.
This commit is contained in:
parent
c6d9abd96e
commit
0fcbb11684
6 changed files with 65 additions and 1 deletions
|
@ -181,7 +181,8 @@ class App.TicketCreate extends App.Controller
|
||||||
show: =>
|
show: =>
|
||||||
@navupdate("#ticket/create/id/#{@id}#{@split}", type: 'menu')
|
@navupdate("#ticket/create/id/#{@id}#{@split}", type: 'menu')
|
||||||
@autosaveStart()
|
@autosaveStart()
|
||||||
@controllerBind('ticket_create_rerender', (template) => @renderQueue(template))
|
@controllerBind('ticket_create_rerender', (template) => @renderQueue(template))
|
||||||
|
@controllerBind('ticket_create_shared_draft_saved', @sharedDraftSaved)
|
||||||
@controllerBind('ticket_create_import_draft_attachments', @importDraftAttachments)
|
@controllerBind('ticket_create_import_draft_attachments', @importDraftAttachments)
|
||||||
|
|
||||||
# initially hide sidebar on mobile
|
# initially hide sidebar on mobile
|
||||||
|
@ -192,6 +193,7 @@ class App.TicketCreate extends App.Controller
|
||||||
hide: =>
|
hide: =>
|
||||||
@autosaveStop()
|
@autosaveStop()
|
||||||
@controllerUnbind('ticket_create_rerender', (template) => @renderQueue(template))
|
@controllerUnbind('ticket_create_rerender', (template) => @renderQueue(template))
|
||||||
|
@controllerUnbind('ticket_create_shared_draft_saved')
|
||||||
@controllerUnbind('ticket_create_import_draft_attachments')
|
@controllerUnbind('ticket_create_import_draft_attachments')
|
||||||
|
|
||||||
changed: =>
|
changed: =>
|
||||||
|
@ -305,6 +307,11 @@ class App.TicketCreate extends App.Controller
|
||||||
error: ->
|
error: ->
|
||||||
App.Event.trigger(options.callbackName, { success: false })
|
App.Event.trigger(options.callbackName, { success: false })
|
||||||
|
|
||||||
|
sharedDraftSaved: (options) =>
|
||||||
|
@el
|
||||||
|
.find('.ticket-create input[name=shared_draft_id]')
|
||||||
|
.val(options.shared_draft_id)
|
||||||
|
|
||||||
updateTaskManagerAttachments: (attribute, attachments) =>
|
updateTaskManagerAttachments: (attribute, attachments) =>
|
||||||
taskData = App.TaskManager.get(@taskKey)
|
taskData = App.TaskManager.get(@taskKey)
|
||||||
return if _.isEmpty(taskData)
|
return if _.isEmpty(taskData)
|
||||||
|
|
|
@ -1016,6 +1016,7 @@ class App.TicketZoom extends App.Controller
|
||||||
data: JSON.stringify(params)
|
data: JSON.stringify(params)
|
||||||
success: (data, status, xhr) =>
|
success: (data, status, xhr) =>
|
||||||
App.Collection.loadAssets(data.assets)
|
App.Collection.loadAssets(data.assets)
|
||||||
|
App.Event.trigger 'ui::ticket::shared_draft_saved', { ticket_id: @ticket_id, shared_draft_id: data.shared_draft_id }
|
||||||
@draftFetched()
|
@draftFetched()
|
||||||
error: =>
|
error: =>
|
||||||
@draftFetched()
|
@draftFetched()
|
||||||
|
|
|
@ -80,6 +80,7 @@ class App.TicketZoomArticleNew extends App.Controller
|
||||||
)
|
)
|
||||||
|
|
||||||
@controllerBind('ui::ticket::import_draft_attachments', @importDraftAttachments)
|
@controllerBind('ui::ticket::import_draft_attachments', @importDraftAttachments)
|
||||||
|
@controllerBind('ui::ticket::shared_draft_saved', @sharedDraftSaved)
|
||||||
|
|
||||||
# add article attachment
|
# add article attachment
|
||||||
@controllerBind('ui::ticket::addArticleAttachent', (data) =>
|
@controllerBind('ui::ticket::addArticleAttachent', (data) =>
|
||||||
|
@ -659,6 +660,13 @@ class App.TicketZoomArticleNew extends App.Controller
|
||||||
error: ->
|
error: ->
|
||||||
App.Event.trigger(options.callbackName, { success: false })
|
App.Event.trigger(options.callbackName, { success: false })
|
||||||
|
|
||||||
|
sharedDraftSaved: (options) =>
|
||||||
|
return if @ticket.id != options.ticket_id
|
||||||
|
|
||||||
|
@el
|
||||||
|
.find('input[name=shared_draft_id]')
|
||||||
|
.val(options.shared_draft_id)
|
||||||
|
|
||||||
actions: ->
|
actions: ->
|
||||||
actionConfig = App.Config.get('TicketZoomArticleAction')
|
actionConfig = App.Config.get('TicketZoomArticleAction')
|
||||||
keys = _.keys(actionConfig).sort()
|
keys = _.keys(actionConfig).sort()
|
||||||
|
|
|
@ -66,6 +66,7 @@ class App.WidgetSharedDraft extends App.Controller
|
||||||
|
|
||||||
success: (data, status, xhr) =>
|
success: (data, status, xhr) =>
|
||||||
App.Collection.loadAssets(data.assets)
|
App.Collection.loadAssets(data.assets)
|
||||||
|
App.Event.trigger 'ticket_create_shared_draft_saved', { shared_draft_id: data.shared_draft_id }
|
||||||
@render()
|
@render()
|
||||||
|
|
||||||
highlightError: ->
|
highlightError: ->
|
||||||
|
|
|
@ -31,6 +31,16 @@ RSpec.describe 'Ticket Shared Draft Start', type: :system, authenticated_as: :au
|
||||||
click '.settings.add'
|
click '.settings.add'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
shared_examples 'shared draft ID is present' do
|
||||||
|
it 'sets shared draft ID' do
|
||||||
|
within :active_content do
|
||||||
|
elem = find('.ticket-create input[name=shared_draft_id]', visible: :all)
|
||||||
|
|
||||||
|
expect(Ticket::SharedDraftStart).to be_exist(elem.value)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'sidebar' do
|
context 'sidebar' do
|
||||||
context 'given multiple groups' do
|
context 'given multiple groups' do
|
||||||
let(:another_group) { create(:group, shared_drafts: false) }
|
let(:another_group) { create(:group, shared_drafts: false) }
|
||||||
|
@ -96,6 +106,18 @@ RSpec.describe 'Ticket Shared Draft Start', type: :system, authenticated_as: :au
|
||||||
.by 1
|
.by 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'draft saved' do
|
||||||
|
before do
|
||||||
|
within :draft_sidebar do
|
||||||
|
find('.js-name').fill_in with: 'Draft Name'
|
||||||
|
|
||||||
|
click '.js-create'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
include_examples 'shared draft ID is present'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'update' do
|
context 'update' do
|
||||||
|
@ -207,6 +229,8 @@ RSpec.describe 'Ticket Shared Draft Start', type: :system, authenticated_as: :au
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
include_examples 'shared draft ID is present'
|
||||||
|
|
||||||
it 'applies body' do
|
it 'applies body' do
|
||||||
within :active_content do
|
within :active_content do
|
||||||
expect(page).to have_text draft_body
|
expect(page).to have_text draft_body
|
||||||
|
|
|
@ -32,6 +32,16 @@ RSpec.describe 'Ticket Shared Draft Zoom', type: :system, authenticated_as: :aut
|
||||||
visit "ticket/zoom/#{ticket.id}"
|
visit "ticket/zoom/#{ticket.id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
shared_examples 'shared draft ID is present' do
|
||||||
|
it 'sets shared draft ID' do
|
||||||
|
within :active_content do
|
||||||
|
elem = find('.article-add input[name=shared_draft_id]', visible: :all)
|
||||||
|
|
||||||
|
expect(Ticket::SharedDraftZoom).to be_exist(elem.value)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'buttons' do
|
context 'buttons' do
|
||||||
context 'when drafts disabled for the group' do
|
context 'when drafts disabled for the group' do
|
||||||
let(:group_shared_drafts) { false }
|
let(:group_shared_drafts) { false }
|
||||||
|
@ -169,6 +179,17 @@ RSpec.describe 'Ticket Shared Draft Zoom', type: :system, authenticated_as: :aut
|
||||||
expect(draft.reload.new_article[:body]).to match %r{another reply}
|
expect(draft.reload.new_article[:body]).to match %r{another reply}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'draft saved' do
|
||||||
|
before do
|
||||||
|
find('.articleNewEdit-body').send_keys('Some reply')
|
||||||
|
|
||||||
|
click '.js-openDropdownMacro'
|
||||||
|
click :draft_save_button
|
||||||
|
end
|
||||||
|
|
||||||
|
include_examples 'shared draft ID is present'
|
||||||
|
end
|
||||||
|
|
||||||
context 'draft loaded' do
|
context 'draft loaded' do
|
||||||
before do
|
before do
|
||||||
visit "ticket/zoom/#{ticket_with_draft.id}"
|
visit "ticket/zoom/#{ticket_with_draft.id}"
|
||||||
|
@ -214,6 +235,8 @@ RSpec.describe 'Ticket Shared Draft Zoom', type: :system, authenticated_as: :aut
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
include_examples 'shared draft ID is present'
|
||||||
|
|
||||||
it 'applies new article body' do
|
it 'applies new article body' do
|
||||||
expect(page).to have_text draft_body
|
expect(page).to have_text draft_body
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue