Follow up 7de423517e
- Fixes #3710 - Unable to close tickets in certran cases if core workflow is used.
This commit is contained in:
parent
871d9609e1
commit
fa4577d463
3 changed files with 38 additions and 6 deletions
|
@ -189,11 +189,11 @@ class App.FormHandlerCoreWorkflow
|
|||
ui.hide(field, form, true)
|
||||
|
||||
# changes the mandatory flag of form elements
|
||||
@changeMandatory: (form, ui, data) ->
|
||||
return if _.isEmpty(data)
|
||||
@changeMandatory: (form, ui, visibility, mandatory) ->
|
||||
return if _.isEmpty(visibility)
|
||||
|
||||
for field, state of data
|
||||
if state
|
||||
for field, state of visibility
|
||||
if state && !_.contains(['hide', 'remove'], mandatory[field])
|
||||
ui.mandantory(field, form)
|
||||
else
|
||||
ui.optional(field, form)
|
||||
|
@ -218,7 +218,7 @@ class App.FormHandlerCoreWorkflow
|
|||
App.FormHandlerCoreWorkflow.select(classname, form, ui, attributes, params, data.select)
|
||||
App.FormHandlerCoreWorkflow.fillIn(classname, form, ui, attributes, params, data.fill_in)
|
||||
App.FormHandlerCoreWorkflow.changeVisibility(form, ui, data.visibility)
|
||||
App.FormHandlerCoreWorkflow.changeMandatory(form, ui, data.mandatory)
|
||||
App.FormHandlerCoreWorkflow.changeMandatory(form, ui, data.mandatory, data.visibility)
|
||||
App.FormHandlerCoreWorkflow.executeEval(form, ui, data.eval)
|
||||
App.FormHandlerCoreWorkflow.runCallbacks(ui)
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ module ChecksCoreWorkflow
|
|||
|
||||
def check_mandatory(perform_result)
|
||||
perform_result[:mandatory].each_key do |key|
|
||||
next if perform_result[:visibility][key] != 'show'
|
||||
next if %w[hide remove].include?(perform_result[:visibility][key])
|
||||
next if !perform_result[:mandatory][key]
|
||||
next if self[key].present?
|
||||
|
||||
|
|
|
@ -512,4 +512,36 @@ RSpec.shared_examples 'core workflow' do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Unable to close tickets in certran cases if core workflow is used #3710', authenticated_as: :authenticate, db_strategy: :reset do
|
||||
def authenticate
|
||||
create(:object_manager_attribute_text, object_name: object_name, name: field_name, display: field_name, screens: screens)
|
||||
ObjectManager::Attribute.migration_execute
|
||||
true
|
||||
end
|
||||
|
||||
before do
|
||||
create(:core_workflow,
|
||||
object: object_name,
|
||||
perform: {
|
||||
"#{object_name.downcase}.#{field_name}": {
|
||||
operator: 'set_mandatory',
|
||||
set_mandatory: 'true'
|
||||
},
|
||||
})
|
||||
create(:core_workflow,
|
||||
object: object_name,
|
||||
perform: {
|
||||
"#{object_name.downcase}.#{field_name}": {
|
||||
operator: 'hide',
|
||||
hide: 'true'
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
it 'does not display hidden fields as mandatory' do
|
||||
before_it.call
|
||||
expect(page.find("input[name='#{field_name}']", visible: :hidden, wait: 10)[:required]).not_to eq('true')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue