diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/form_handler_core_workflow.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/form_handler_core_workflow.coffee index 4fb18c9db..699740da8 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/form_handler_core_workflow.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/form_handler_core_workflow.coffee @@ -32,6 +32,12 @@ class App.FormHandlerCoreWorkflow result.push(screen) return result + # returns if the object and screen is controlled by core workflow + @checkScreen: (checkObject, checkScreen) -> + for object, screens of coreWorkflowScreens + return true if checkObject is object && _.contains(screens, checkScreen) + return false + # returns active Core Workflow requests. it is used to stabilize tests @getRequests: -> return coreWorkflowRequests diff --git a/app/assets/javascripts/app/models/_application_model.coffee b/app/assets/javascripts/app/models/_application_model.coffee index 501630619..e5ff9764b 100644 --- a/app/assets/javascripts/app/models/_application_model.coffee +++ b/app/assets/javascripts/app/models/_application_model.coffee @@ -224,7 +224,7 @@ set new attributes of model (remove already available attributes) attributesNew = {} if screen 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)) + 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] attribute[item] = value attributesNew[ attribute.name ] = attribute diff --git a/app/assets/javascripts/app/views/generic/attribute.jst.eco b/app/assets/javascripts/app/views/generic/attribute.jst.eco index 11288904f..90f051e2c 100644 --- a/app/assets/javascripts/app/views/generic/attribute.jst.eco +++ b/app/assets/javascripts/app/views/generic/attribute.jst.eco @@ -1,4 +1,4 @@ -
<%= " #{ @attribute.item_class }" if @attribute.item_class %><%= " is-required" if !@attribute.null %>"<%= " data-width=#{ @attribute.grid_width }" if @attribute.grid_width %>> +
<%= " #{ @attribute.item_class }" if @attribute.item_class %><%= " is-required" if !@attribute.null %><%= " is-hidden is-removed hide" if @attribute.shown == false %>"<%= " data-width=#{ @attribute.grid_width }" if @attribute.grid_width %>> <% if @attribute.style == 'block': %>

<% end %> diff --git a/app/models/core_workflow/attributes.rb b/app/models/core_workflow/attributes.rb index 5f7f73457..4d5f346d7 100644 --- a/app/models/core_workflow/attributes.rb +++ b/app/models/core_workflow/attributes.rb @@ -77,7 +77,7 @@ class CoreWorkflow::Attributes result[ attribute[:name] ] = if @payload['request_id'] == 'ChecksCoreWorkflow.validate_workflows' 'show' else - screen_value(attribute, 'shown') == false ? 'hide' : 'show' + screen_value(attribute, 'shown') == false ? 'remove' : 'show' end end end diff --git a/spec/system/ticket/create_spec.rb b/spec/system/ticket/create_spec.rb index 69df5b95d..7c44de025 100644 --- a/spec/system/ticket/create_spec.rb +++ b/spec/system/ticket/create_spec.rb @@ -487,4 +487,52 @@ RSpec.describe 'Ticket Create', type: :system do end end end + + describe 'It should be possible to show attributes which are configured shown false #3726', authenticated_as: :authenticate, db_strategy: :reset do + let(:field_name) { SecureRandom.uuid } + let(:field) do + create :object_manager_attribute_text, name: field_name, display: field_name, screens: { + 'create_middle' => { + 'ticket.agent' => { + 'shown' => false, + 'required' => false, + } + } + } + ObjectManager::Attribute.migration_execute + end + + before do + visit 'ticket/create' + 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.is-removed", visible: :hidden) + end + end + end end