diff --git a/app/assets/javascripts/app/controllers/search.coffee b/app/assets/javascripts/app/controllers/search.coffee index 1ec5781c4..515daa8d4 100644 --- a/app/assets/javascripts/app/controllers/search.coffee +++ b/app/assets/javascripts/app/controllers/search.coffee @@ -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 diff --git a/app/assets/javascripts/app/controllers/ticket_overview.coffee b/app/assets/javascripts/app/controllers/ticket_overview.coffee index e222558c0..e7d27f12b 100644 --- a/app/assets/javascripts/app/controllers/ticket_overview.coffee +++ b/app/assets/javascripts/app/controllers/ticket_overview.coffee @@ -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' diff --git a/app/assets/javascripts/app/controllers/widget/ticket_bulk_form.coffee b/app/assets/javascripts/app/controllers/widget/ticket_bulk_form.coffee index dd2c92734..f436a845f 100644 --- a/app/assets/javascripts/app/controllers/widget/ticket_bulk_form.coffee +++ b/app/assets/javascripts/app/controllers/widget/ticket_bulk_form.coffee @@ -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') diff --git a/app/controllers/ticket_overviews_controller.rb b/app/controllers/ticket_overviews_controller.rb index ebf027114..1e4290073 100644 --- a/app/controllers/ticket_overviews_controller.rb +++ b/app/controllers/ticket_overviews_controller.rb @@ -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 diff --git a/spec/system/search_spec.rb b/spec/system/search_spec.rb index beb95fece..e4b086aeb 100644 --- a/spec/system/search_spec.rb +++ b/spec/system/search_spec.rb @@ -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