Fixes #2985 - Adding a note during bulk operation only works for one ticket
This commit is contained in:
parent
73f6a98e29
commit
41bba5dda3
2 changed files with 121 additions and 90 deletions
|
@ -1575,33 +1575,7 @@ class BulkForm extends App.Controller
|
||||||
if _.isEmpty(ticket.title)
|
if _.isEmpty(ticket.title)
|
||||||
ticket.title = '-'
|
ticket.title = '-'
|
||||||
|
|
||||||
ticket.save(
|
@saveTicketArticle(ticket, article)
|
||||||
done: (r) =>
|
|
||||||
@bulkCountIndex++
|
|
||||||
|
|
||||||
# reset form after save
|
|
||||||
if article
|
|
||||||
article.save(
|
|
||||||
fail: (r) =>
|
|
||||||
@log 'error', 'update article', r
|
|
||||||
)
|
|
||||||
|
|
||||||
# refresh view after all tickets are proceeded
|
|
||||||
if @bulkCountIndex == @bulkCount
|
|
||||||
@render()
|
|
||||||
@hide()
|
|
||||||
|
|
||||||
# fetch overview data again
|
|
||||||
App.Event.trigger('overview:fetch')
|
|
||||||
|
|
||||||
fail: (r) =>
|
|
||||||
@bulkCountIndex++
|
|
||||||
@log 'error', 'update ticket', r
|
|
||||||
App.Event.trigger 'notify', {
|
|
||||||
type: 'error'
|
|
||||||
msg: App.i18n.translateContent('Can\'t update Ticket %s!', ticket.number)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
@holder.find('.table-overview').find('[name="bulk"]:checked').prop('checked', false)
|
@holder.find('.table-overview').find('[name="bulk"]:checked').prop('checked', false)
|
||||||
App.Event.trigger 'notify', {
|
App.Event.trigger 'notify', {
|
||||||
|
@ -1609,6 +1583,36 @@ class BulkForm extends App.Controller
|
||||||
msg: App.i18n.translateContent('Bulk action executed!')
|
msg: App.i18n.translateContent('Bulk action executed!')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
saveTicketArticle: (ticket, article) =>
|
||||||
|
ticket.save(
|
||||||
|
done: (r) =>
|
||||||
|
@bulkCountIndex++
|
||||||
|
|
||||||
|
# reset form after save
|
||||||
|
if article
|
||||||
|
article.save(
|
||||||
|
fail: (r) =>
|
||||||
|
@log 'error', 'update article', r
|
||||||
|
)
|
||||||
|
|
||||||
|
# refresh view after all tickets are proceeded
|
||||||
|
if @bulkCountIndex == @bulkCount
|
||||||
|
@render()
|
||||||
|
@hide()
|
||||||
|
|
||||||
|
# fetch overview data again
|
||||||
|
App.Event.trigger('overview:fetch')
|
||||||
|
|
||||||
|
fail: (r) =>
|
||||||
|
@bulkCountIndex++
|
||||||
|
@log 'error', 'update ticket', r
|
||||||
|
App.Event.trigger 'notify', {
|
||||||
|
type: 'error'
|
||||||
|
msg: App.i18n.translateContent('Can\'t update Ticket %s!', ticket.number)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class App.OverviewSettings extends App.ControllerModal
|
class App.OverviewSettings extends App.ControllerModal
|
||||||
buttonClose: true
|
buttonClose: true
|
||||||
buttonCancel: true
|
buttonCancel: true
|
||||||
|
|
|
@ -1,88 +1,115 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe 'Ticket views', type: :system do
|
RSpec.describe 'Ticket views', type: :system do
|
||||||
|
context 'macros' do
|
||||||
|
let!(:group1) { create :group }
|
||||||
|
let!(:group2) { create :group }
|
||||||
|
let!(:macro_without_group) { create :macro }
|
||||||
|
let!(:macro_group1) { create :macro, groups: [group1] }
|
||||||
|
let!(:macro_group2) { create :macro, groups: [group2] }
|
||||||
|
|
||||||
let!(:group1) { create :group }
|
it 'supports group-dependent macros' do
|
||||||
let!(:group2) { create :group }
|
|
||||||
let!(:macro_without_group) { create :macro }
|
|
||||||
let!(:macro_group1) { create :macro, groups: [group1] }
|
|
||||||
let!(:macro_group2) { create :macro, groups: [group2] }
|
|
||||||
|
|
||||||
it 'supports group-dependent macros' do
|
ticket1 = create :ticket, group: group1
|
||||||
|
ticket2 = create :ticket, group: group2
|
||||||
|
|
||||||
ticket1 = create :ticket, group: group1
|
# give user access to all groups including those created
|
||||||
ticket2 = create :ticket, group: group2
|
# by using FactoryBot outside of the example
|
||||||
|
group_names_access_map = Group.all.pluck(:name).each_with_object({}) do |group_name, result|
|
||||||
|
result[group_name] = 'full'.freeze
|
||||||
|
end
|
||||||
|
|
||||||
# give user access to all groups including those created
|
current_user do |user|
|
||||||
# by using FactoryBot outside of the example
|
user.group_names_access_map = group_names_access_map
|
||||||
group_names_access_map = Group.all.pluck(:name).each_with_object({}) do |group_name, result|
|
user.save!
|
||||||
result[group_name] = 'full'.freeze
|
end
|
||||||
end
|
|
||||||
|
|
||||||
current_user do |user|
|
|
||||||
user.group_names_access_map = group_names_access_map
|
|
||||||
user.save!
|
|
||||||
end
|
|
||||||
|
|
||||||
# refresh browser to get macro accessable
|
|
||||||
refresh
|
|
||||||
visit '#ticket/view/all_open'
|
|
||||||
|
|
||||||
within(:active_content) do
|
|
||||||
|
|
||||||
ticket = page.find(:table_row, 1).native
|
|
||||||
|
|
||||||
# click and hold first ticket in table
|
|
||||||
click_and_hold(ticket)
|
|
||||||
|
|
||||||
# move ticket to y -ticket.location.y
|
|
||||||
move_mouse_by(0, -ticket.location.y + 5)
|
|
||||||
|
|
||||||
# move a bit to the left to display macro batches
|
|
||||||
move_mouse_by(-250, 0)
|
|
||||||
|
|
||||||
expect(page).to have_selector(:macro_batch, macro_without_group.id, visible: :visible)
|
|
||||||
expect(page).to have_no_selector(:macro_batch, macro_group1.id)
|
|
||||||
expect(page).to have_no_selector(:macro_batch, macro_group2.id)
|
|
||||||
|
|
||||||
release_mouse
|
|
||||||
|
|
||||||
|
# refresh browser to get macro accessable
|
||||||
refresh
|
refresh
|
||||||
|
visit '#ticket/view/all_open'
|
||||||
|
|
||||||
ticket = page.find(:table_row, ticket1.id).native
|
within(:active_content) do
|
||||||
|
|
||||||
# click and hold first ticket in table
|
ticket = page.find(:table_row, 1).native
|
||||||
click_and_hold(ticket)
|
|
||||||
|
|
||||||
# move ticket to y -ticket.location.y
|
# click and hold first ticket in table
|
||||||
move_mouse_by(0, -ticket.location.y + 5)
|
click_and_hold(ticket)
|
||||||
|
|
||||||
# move a bit to the left to display macro batches
|
# move ticket to y -ticket.location.y
|
||||||
move_mouse_by(-250, 0)
|
move_mouse_by(0, -ticket.location.y + 5)
|
||||||
|
|
||||||
expect(page).to have_selector(:macro_batch, macro_without_group.id, visible: :visible)
|
# move a bit to the left to display macro batches
|
||||||
expect(page).to have_selector(:macro_batch, macro_group1.id)
|
move_mouse_by(-250, 0)
|
||||||
expect(page).to have_no_selector(:macro_batch, macro_group2.id)
|
|
||||||
|
|
||||||
release_mouse
|
expect(page).to have_selector(:macro_batch, macro_without_group.id, visible: :visible)
|
||||||
|
expect(page).to have_no_selector(:macro_batch, macro_group1.id)
|
||||||
|
expect(page).to have_no_selector(:macro_batch, macro_group2.id)
|
||||||
|
|
||||||
refresh
|
release_mouse
|
||||||
|
|
||||||
ticket = page.find(:table_row, ticket2.id).native
|
refresh
|
||||||
|
|
||||||
# click and hold first ticket in table
|
ticket = page.find(:table_row, ticket1.id).native
|
||||||
click_and_hold(ticket)
|
|
||||||
|
|
||||||
# move ticket to y -ticket.location.y
|
# click and hold first ticket in table
|
||||||
move_mouse_by(0, -ticket.location.y + 5)
|
click_and_hold(ticket)
|
||||||
|
|
||||||
# move a bit to the left to display macro batches
|
# move ticket to y -ticket.location.y
|
||||||
move_mouse_by(-250, 0)
|
move_mouse_by(0, -ticket.location.y + 5)
|
||||||
|
|
||||||
expect(page).to have_selector(:macro_batch, macro_without_group.id, visible: :visible)
|
# move a bit to the left to display macro batches
|
||||||
expect(page).to have_no_selector(:macro_batch, macro_group1.id)
|
move_mouse_by(-250, 0)
|
||||||
expect(page).to have_selector(:macro_batch, macro_group2.id)
|
|
||||||
|
|
||||||
|
expect(page).to have_selector(:macro_batch, macro_without_group.id, visible: :visible)
|
||||||
|
expect(page).to have_selector(:macro_batch, macro_group1.id)
|
||||||
|
expect(page).to have_no_selector(:macro_batch, macro_group2.id)
|
||||||
|
|
||||||
|
release_mouse
|
||||||
|
|
||||||
|
refresh
|
||||||
|
|
||||||
|
ticket = page.find(:table_row, ticket2.id).native
|
||||||
|
|
||||||
|
# click and hold first ticket in table
|
||||||
|
click_and_hold(ticket)
|
||||||
|
|
||||||
|
# move ticket to y -ticket.location.y
|
||||||
|
move_mouse_by(0, -ticket.location.y + 5)
|
||||||
|
|
||||||
|
# move a bit to the left to display macro batches
|
||||||
|
move_mouse_by(-250, 0)
|
||||||
|
|
||||||
|
expect(page).to have_selector(:macro_batch, macro_without_group.id, visible: :visible)
|
||||||
|
expect(page).to have_no_selector(:macro_batch, macro_group1.id)
|
||||||
|
expect(page).to have_selector(:macro_batch, macro_group2.id)
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'bulk note', authenticated_as: :user do
|
||||||
|
let(:group) { create :group }
|
||||||
|
let(:user) { create :admin, groups: [group] }
|
||||||
|
let!(:ticket1) { create(:ticket, state_name: 'open', owner: user, group: group) }
|
||||||
|
let!(:ticket2) { create(:ticket, state_name: 'open', owner: user, group: group) }
|
||||||
|
let(:note) { Faker::Lorem.sentence }
|
||||||
|
|
||||||
|
it 'adds note to all selected tickets' do
|
||||||
|
visit 'ticket/view/my_assigned'
|
||||||
|
|
||||||
|
within :active_content do
|
||||||
|
all('.js-checkbox-field', count: 2).each(&:click)
|
||||||
|
click '.js-confirm'
|
||||||
|
find('.js-confirm-step textarea').fill_in with: note
|
||||||
|
click '.js-submit'
|
||||||
|
end
|
||||||
|
|
||||||
|
await_empty_ajax_queue
|
||||||
|
|
||||||
|
expect([
|
||||||
|
ticket1.articles.last&.body,
|
||||||
|
ticket2.articles.last&.body
|
||||||
|
]).to be_all note
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue