Fixes #4004 - Overviews are not shown if group_by is used with a tree select attribute.

This commit is contained in:
Bola Ahmed Buari 2022-03-09 14:56:23 +01:00 committed by Dominik Klein
parent f052c2a33f
commit 86683b341e
2 changed files with 99 additions and 1 deletions

View file

@ -97,7 +97,8 @@ class App extends Spine.Controller
if !_.isEmpty(attributeConfig.options) if !_.isEmpty(attributeConfig.options)
if Array.isArray(attributeConfig.options) if Array.isArray(attributeConfig.options)
option = _.find(attributeConfig.options, (option) -> option.value == resultLocal) option = _.find(attributeConfig.options, (option) -> option.value == resultLocal)
resultLocal = option.name if option && option.name
resultLocal = option.name
else if attributeConfig.options[resultLocal] else if attributeConfig.options[resultLocal]
resultLocal = attributeConfig.options[resultLocal] resultLocal = attributeConfig.options[resultLocal]

View file

@ -149,6 +149,103 @@ RSpec.describe 'Overview', type: :system do
end end
end end
end end
context 'when grouping by tree_selects', authenticated_as: :authenticate, db_strategy: :reset do
def authenticate
create(:object_manager_attribute_tree_select, name: 'tree_select_field', display: 'Tree Select Field', data_option: data_option)
ObjectManager::Attribute.migration_execute
user
end
let(:data_option) do
{
'options' => [
{
'name' => 'a',
'value' => 'a',
'children' => [
{
'name' => '1',
'value' => 'a::1',
}
]
},
{
'name' => 'b',
'value' => 'b',
'children' => [
{
'name' => '1',
'value' => 'b::1',
},
{
'name' => '2',
'value' => 'b::2',
}
]
},
{
'name' => 'c',
'value' => 'c',
'children' => [
{
'name' => '1',
'value' => 'c::1',
},
{
'name' => '2',
'value' => 'c::2',
},
{
'name' => '3',
'value' => 'c::3',
},
]
},
],
'default' => '',
'null' => true,
'relation' => '',
'maxlength' => 255,
'nulloption' => true,
}
end
let(:ticket1) { create(:ticket, group: group_a, priority_id: 1, customer: user, tree_select_field: 'a::1') }
let(:ticket2) { create(:ticket, group: group_c, priority_id: 2, customer: user, tree_select_field: 'b::2') }
let(:ticket3) { create(:ticket, group: group_b, priority_id: 3, customer: user, tree_select_field: 'c::3') }
let(:group_key) { 'tree_select_field' }
context 'when group direction is default' do
let(:group_direction) { nil }
it 'sorts groups a::1 > b::2 > c::3' do
within :active_content do
expect(all('.table-overview table b').map(&:text)).to eq %w[a::1 b::2 c::3]
end
end
end
context 'when group direction is ASC' do
let(:group_direction) { 'ASC' }
it 'sorts groups a::1 > b::2 > c::3' do
within :active_content do
expect(all('.table-overview table b').map(&:text)).to eq %w[a::1 b::2 c::3]
end
end
end
context 'when group direction is DESC' do
let(:group_direction) { 'DESC' }
it 'sorts groups c::3 > b::2 > a::1' do
within :active_content do
expect(all('.table-overview table b').map(&:text)).to eq %w[c::3 b::2 a::1]
end
end
end
end
end end
context 'when multiselect is choosen as column', authenticated_as: :authenticate, db_strategy: :reset do context 'when multiselect is choosen as column', authenticated_as: :authenticate, db_strategy: :reset do