Fixes #3739 - Core Workflow: Show hidden attributes on group selection (ticket edit).

This commit is contained in:
Rolf Schmidt 2021-09-15 10:00:44 +01:00
parent 03a831b53b
commit 1a3ecd91f4
4 changed files with 57 additions and 5 deletions

View file

@ -92,7 +92,7 @@ class App.ControllerForm extends App.Controller
if @model.attributesGet if @model.attributesGet
attributesClean = @model.attributesGet(@screen) attributesClean = @model.attributesGet(@screen)
else else
attributesClean = App.Model.attributesGet(@screen, @model.configure_attributes) attributesClean = App.Model.attributesGet(@screen, @model.configure_attributes, undefined, @model.className)
for attributeName, attribute of attributesClean for attributeName, attribute of attributesClean

View file

@ -38,7 +38,7 @@ class Edit extends App.ControllerObserver
else else
@controllerFormSidebarTicket = new App.ControllerForm( @controllerFormSidebarTicket = new App.ControllerForm(
elReplace: @el elReplace: @el
model: { configure_attributes: @formMeta.configure_attributes || App.Ticket.configure_attributes } model: { className: 'Ticket', configure_attributes: @formMeta.configure_attributes || App.Ticket.configure_attributes }
screen: 'edit' screen: 'edit'
handlersConfig: handlers handlersConfig: handlers
filter: @formMeta.filter filter: @formMeta.filter

View file

@ -211,9 +211,12 @@ set new attributes of model (remove already available attributes)
### ###
@attributesGet: (screen = undefined, attributes = false, noDefaultAttributes = false) -> @attributesGet: (screen = undefined, attributes = false, noDefaultAttributes = false, className = undefined) ->
if !className
className = @.className
if !attributes if !attributes
attributes = clone(App[@.className].configure_attributes, true) attributes = clone(App[className].configure_attributes, true)
else else
attributes = clone(attributes, true) attributes = clone(attributes, true)
@ -224,7 +227,7 @@ set new attributes of model (remove already available attributes)
attributesNew = {} attributesNew = {}
if screen if screen
for attribute in attributes for attribute in attributes
if attribute && attribute.screen && attribute.screen[screen] && (!_.isEmpty(attribute.screen[screen]) && (attribute.screen[screen].shown is true || attribute.screen[screen].shown is undefined || App.FormHandlerCoreWorkflow.checkScreen(@.className, screen))) if attribute && attribute.screen && attribute.screen[screen] && (!_.isEmpty(attribute.screen[screen]) && (attribute.screen[screen].shown is true || attribute.screen[screen].shown is undefined || App.FormHandlerCoreWorkflow.checkScreen(className, screen)))
for item, value of attribute.screen[screen] for item, value of attribute.screen[screen]
attribute[item] = value attribute[item] = value
attributesNew[ attribute.name ] = attribute attributesNew[ attribute.name ] = attribute

View file

@ -1908,4 +1908,53 @@ RSpec.describe 'Ticket zoom', type: :system do
end end
end end
end end
describe 'Core Workflow: Show hidden attributes on group selection (ticket edit) #3739', authenticated_as: :authenticate do
let!(:ticket) { create(:ticket, group: Group.find_by(name: 'Users')) }
let(:field_name) { SecureRandom.uuid }
let(:field) do
create :object_manager_attribute_text, name: field_name, display: field_name, screens: {
'edit' => {
'ticket.agent' => {
'shown' => false,
'required' => false,
}
}
}
ObjectManager::Attribute.migration_execute
end
before do
visit "#ticket/zoom/#{ticket.id}"
end
context 'when field visible' do
let(:workflow) do
create(:core_workflow,
object: 'Ticket',
perform: { "ticket.#{field_name}" => { 'operator' => 'show', 'show' => 'true' } })
end
def authenticate
field
workflow
true
end
it 'does show up the field' do
expect(page).to have_css("div[data-attribute-name='#{field_name}']")
end
end
context 'when field hidden' do
def authenticate
field
true
end
it 'does not show the field' do
expect(page).to have_css("div[data-attribute-name='#{field_name}'].is-hidden", visible: :hidden)
end
end
end
end end