Fixes #4054 - Searches display all groups and owners on bulk selections.

This commit is contained in:
Rolf Schmidt 2022-06-02 15:13:04 +02:00
parent 3f81df1925
commit 81408f7e87
5 changed files with 73 additions and 7 deletions

View file

@ -205,6 +205,7 @@ class App.Search extends App.Controller
items.slice(startId+1, endId).find('[name="bulk"]').prop('checked', (-> !@checked))
@lastChecked = e.currentTarget
@bulkForm.updateTicketIdsBulkForm(e)
ticket_ids = []
for item in localList

View file

@ -1107,8 +1107,7 @@ class Table extends App.Controller
items.slice(startId+1, endId).find('[name="bulk"]').prop('checked', (-> !@checked))
@lastChecked = e.currentTarget
@updateTicketIdsBulkForm()
@bulkForm.updateTicketIdsBulkForm(e)
callbackIconHeader = (headers) ->
attribute =
@ -1250,11 +1249,6 @@ class Table extends App.Controller
bulkAll.prop('indeterminate', true)
)
updateTicketIdsBulkForm: =>
items = $('.content.active .table-overview .table').find('[name="bulk"]:checked')
ticket_ids = _.map(items, (el) -> $(el).val() )
@bulkForm.el.find('input[name=ticket_ids]').val(ticket_ids.join(',')).trigger('change')
renderCustomerNotTicketExistIfNeeded: (ticketListShow) =>
user = App.User.current()
@stopListening user, 'refresh'

View file

@ -243,3 +243,8 @@ class App.TicketBulkForm extends App.Controller
@render()
@hide()
)
updateTicketIdsBulkForm: (e) ->
items = $(e.target).closest('table').find('input[name="bulk"]:checked')
ticket_ids = _.map(items, (el) -> $(el).val() )
@el.find('input[name=ticket_ids]').val(ticket_ids.join(',')).trigger('change')

View file

@ -9,6 +9,7 @@ class TicketOverviewsController < ApplicationController
# get attributes to update
attributes_to_change = Ticket::ScreenOptions.attributes_to_change(
view: 'ticket_overview',
screen: 'overview_bulk',
current_user: current_user,
)
render json: attributes_to_change

View file

@ -232,4 +232,69 @@ RSpec.describe 'Search', type: :system, authenticated: true, searchindex: true d
end
end
end
describe 'Searches display all groups and owners on bulk selections #4054', authenticated_as: :authenticate do
let(:group1) { create(:group) }
let(:group2) { create(:group) }
let(:agent1) { create(:agent, groups: [group1]) }
let(:agent2) { create(:agent, groups: [group2]) }
let(:agent_all) { create(:agent, groups: [group1, group2]) }
let(:ticket1) { create(:ticket, group: group1, title: '4054 group 1') }
let(:ticket2) { create(:ticket, group: group2, title: '4054 group 2') }
def authenticate
agent1 && agent2 && agent_all
ticket1 && ticket2
agent_all
end
def check_owner_empty
expect(page).to have_select('owner_id', text: '-', visible: :all)
expect(page).to have_no_select('owner_id', text: agent1.fullname, visible: :all)
expect(page).to have_no_select('owner_id', text: agent2.fullname, visible: :all)
end
def click_ticket(ticket)
page.find(".js-tableBody tr.item[data-id='#{ticket.id}'] td.js-checkbox-field").click
end
def check_owner_agent1_shown
expect(page).to have_select('owner_id', text: agent1.fullname)
expect(page).to have_no_select('owner_id', text: agent2.fullname)
end
def check_owner_agent2_shown
expect(page).to have_no_select('owner_id', text: agent1.fullname)
expect(page).to have_select('owner_id', text: agent2.fullname)
end
def check_owner_field
check_owner_empty
click_ticket(ticket1)
check_owner_agent1_shown
click_ticket(ticket1)
click_ticket(ticket2)
check_owner_agent2_shown
end
context 'when search is used' do
before do
visit '#search/4054'
end
it 'does show the correct owner selection for each bulk action' do
check_owner_field
end
end
context 'when ticket overview is used' do
before do
visit '#ticket/view/all_unassigned'
end
it 'does show the correct owner selection for each bulk action' do
check_owner_field
end
end
end
end