Fixes #3943 - Title column is missing if ticket number is disabled in overview options.

This commit is contained in:
Florian Liebe 2022-06-07 09:01:53 +02:00
parent 81408f7e87
commit ab37cfe972
2 changed files with 43 additions and 3 deletions

View file

@ -959,7 +959,7 @@ class Table extends App.Controller
ticketListShow.push App.Ticket.find(ticket.id)
@overview = App.Overview.find(overview.id)
@table.update(
overviewAttributes: @overview.view.s
overviewAttributes: @convertOverviewAttributesToArray(@overview.view.s)
objects: ticketListShow
groupBy: @overview.group_by
groupDirection: @overview.group_direction
@ -977,7 +977,6 @@ class Table extends App.Controller
return if !overview && !tickets
@view_mode = App.LocalStorage.get("mode:#{@view}", @Session.get('id')) || 's'
console.log 'notice', 'view:', @view, @view_mode
App.WebSocket.send(event:'ticket_overview_select', data: { view: @view })
@ -1177,7 +1176,7 @@ class Table extends App.Controller
tableArguments =
tableId: "ticket_overview_#{@overview.id}"
overview: @overview.view.s
overview: @convertOverviewAttributesToArray(@overview.view.s)
el: @$('.table-overview')
model: App.Ticket
objects: ticketListShow
@ -1249,6 +1248,15 @@ class Table extends App.Controller
bulkAll.prop('indeterminate', true)
)
convertOverviewAttributesToArray: (overviewAttributes) ->
# Ensure that the given attributes for the overview is an array,
# otherwise some data might not be displayed.
# For more details, see https://github.com/zammad/zammad/issues/3943.
if !Array.isArray(overviewAttributes)
overviewAttributes = [overviewAttributes]
overviewAttributes
renderCustomerNotTicketExistIfNeeded: (ticketListShow) =>
user = App.User.current()
@stopListening user, 'refresh'

View file

@ -324,4 +324,36 @@ RSpec.describe 'Overview', type: :system do
end
end
end
context 'when only one attribute is visible', authenticated_as: :user do
let(:user) { create(:agent, groups: [group]) }
let(:group) { create(:group, name: 'aaa') }
let(:ticket) { create(:ticket, group: group, customer: user) }
let(:view) { { 's' => %w[title] } }
let(:condition) do
{
'ticket.customer_id' => {
operator: 'is',
value: user.id
}
}
end
let(:overview) { create(:overview, condition: condition, view: view) }
let(:overview_table_head_selector) { 'div.table-overview table.table thead' }
let(:expected_header_text) { 'TITLE' }
before do
ticket
visit "ticket/view/#{overview.link}"
end
it 'shows only the title column' do
within :active_content, overview_table_head_selector do
expect(page).to have_css('th.js-tableHead[data-column-key="title"]', text: expected_header_text)
end
end
end
end