Fixes #3713 - Core workflows breaks groups selection for customer panel

This commit is contained in:
Rolf Schmidt 2021-08-30 15:26:24 +02:00 committed by Thorsten Eckel
parent 4a9f448de7
commit 080ccc4a66
3 changed files with 46 additions and 12 deletions

View file

@ -33,12 +33,6 @@ class CustomerTicketCreate extends App.ControllerAppContent
defaults = template['options'] || {}
handlers = @Config.get('TicketCreateFormHandler')
groupFilter = App.Config.get('customer_ticket_create_group_ids')
if groupFilter
if !_.isArray(groupFilter)
groupFilter = [groupFilter]
@formMeta.filter.group_id = groupFilter
@html App.view('customer_ticket_create')(
head: 'New Ticket'
form_id: @form_id

View file

@ -13,18 +13,36 @@ class CoreWorkflow::Attributes::Group < CoreWorkflow::Attributes::Base
end
end
def customer_ticket_create_group_ids
Setting.get('customer_ticket_create_group_ids')
end
def groups
@groups ||= if @attributes.user.permissions?('ticket.agent')
if @attributes.payload['screen'] == 'create_middle'
@attributes.user.groups_access(%w[create])
else
@attributes.user.groups_access(%w[create change])
end
groups_agent
elsif @attributes.user.permissions?('ticket.customer') && @attributes.payload['screen'] == 'create_middle' && customer_ticket_create_group_ids.present?
groups_customer
else
Group.where(active: true)
groups_default
end
end
def groups_agent
if @attributes.payload['screen'] == 'create_middle'
@attributes.user.groups_access(%w[create])
else
@attributes.user.groups_access(%w[create change])
end
end
def groups_customer
Group.where(id: customer_ticket_create_group_ids, active: true)
end
def groups_default
Group.where(active: true)
end
def assets(group)
return if @attributes.assets[Group.to_app_model] && @attributes.assets[Group.to_app_model][group.id]

View file

@ -237,6 +237,28 @@ RSpec.describe CoreWorkflow, type: :model do
end
end
describe '.perform - Default - Customer setting customer_ticket_create_group_ids' do
let(:action_user) { create(:customer) }
let!(:group1) { create(:group) }
let!(:group2) { create(:group) }
let!(:group3) { create(:group) }
it 'does show group 1' do
expect(result[:restrict_values]['group_id']).to include(group1.id.to_s)
end
context 'with customer_ticket_create_group_ids set' do
before do
Setting.set('customer_ticket_create_group_ids', [group2.id.to_s, group3.id.to_s])
end
it 'does not show group 1' do
expect(result[:restrict_values]['group_id']).not_to include(group1.id.to_s)
end
end
end
describe '.perform - Custom - Pending Time' do
it 'does not show pending time for non pending state' do
expect(result[:visibility]['pending_time']).to eq('remove')