Fixes #3726 - It should be possible to show attributes which are configured shown false.
This commit is contained in:
parent
5be743aee6
commit
c5659600f3
5 changed files with 57 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<div data-attribute-name="<%= @attribute.name %>" class="<%= @attribute.tag %> form-group<%= " form-group--block" if @attribute.style == 'block' %><%= " #{ @attribute.item_class }" if @attribute.item_class %><%= " is-required" if !@attribute.null %>"<%= " data-width=#{ @attribute.grid_width }" if @attribute.grid_width %>>
|
||||
<div data-attribute-name="<%= @attribute.name %>" class="<%= @attribute.tag %> form-group<%= " form-group--block" if @attribute.style == 'block' %><%= " #{ @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': %>
|
||||
<h2>
|
||||
<% end %>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue