Fixes #4024 - Tree select value cannot be set to "-" (empty) with Trigger/Scheduler/Core workflow.
This commit is contained in:
parent
772bf3516c
commit
49b73de11a
9 changed files with 112 additions and 6 deletions
|
@ -113,7 +113,7 @@ class App.UiElement.ApplicationSelector
|
|||
config.operator = operator
|
||||
elements["#{groupKey}.#{config.name}"] = config
|
||||
|
||||
if config.tag == 'select'
|
||||
if /^(tree_|multi)?select$/.test(config.tag)
|
||||
config.multiple = true
|
||||
|
||||
if attribute.out_of_office
|
||||
|
|
|
@ -73,7 +73,7 @@ class App.UiElement.core_workflow_perform extends App.UiElement.ApplicationSelec
|
|||
config = _.clone(row)
|
||||
if config.tag is 'boolean'
|
||||
config.tag = 'select'
|
||||
if /^((multi)?select)$/.test(config.tag)
|
||||
if /^(tree_|multi)?select$/.test(config.tag)
|
||||
config.multiple = true
|
||||
config.default = undefined
|
||||
if config.type is 'email' || config.type is 'tel'
|
||||
|
@ -121,14 +121,14 @@ class App.UiElement.core_workflow_perform extends App.UiElement.ApplicationSelec
|
|||
currentOperator = elementRow.find('.js-operator option:selected').attr('value')
|
||||
name = @buildValueName(elementFull, elementRow, groupAndAttribute, elements, meta, attribute)
|
||||
|
||||
if !_.contains(['add_option', 'remove_option', 'set_fixed_to', 'select', 'multiselect', 'execute', 'fill_in', 'fill_in_empty'], currentOperator)
|
||||
if !_.contains(['add_option', 'remove_option', 'set_fixed_to', 'select', 'execute', 'fill_in', 'fill_in_empty'], currentOperator)
|
||||
elementRow.find('.js-value').addClass('hide').html('<input type="hidden" name="' + name + '" value="true" />')
|
||||
return
|
||||
|
||||
super(elementFull, elementRow, groupAndAttribute, elements, meta, attribute)
|
||||
|
||||
@buildValueConfigMultiple: (config, meta) ->
|
||||
if _.contains(['add_option', 'remove_option', 'set_fixed_to', 'select', 'multiselect'], meta.operator)
|
||||
if _.contains(['add_option', 'remove_option', 'set_fixed_to', 'select'], meta.operator)
|
||||
config.multiple = true
|
||||
config.nulloption = true
|
||||
else
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
# coffeelint: disable=camel_case_classes
|
||||
class App.UiElement.multiselect_search extends App.UiElement.ApplicationUiElement
|
||||
@render: (attribute, params) ->
|
||||
|
||||
# set multiple option
|
||||
if attribute.multiple
|
||||
attribute.multiple = 'multiple'
|
||||
else
|
||||
attribute.multiple = ''
|
||||
|
||||
delete attribute.filter
|
||||
|
||||
# build options list based on config
|
||||
@getConfigOptionList(attribute, params)
|
||||
|
||||
# build options list based on relation
|
||||
@getRelationOptionList(attribute, params)
|
||||
|
||||
# add null selection if needed
|
||||
@addNullOption(attribute, params)
|
||||
|
||||
# sort attribute.options
|
||||
@sortOptions(attribute, params)
|
||||
|
||||
# find selected/checked item of list
|
||||
@selectedOptions(attribute, params)
|
||||
|
||||
# disable item of list
|
||||
@disabledOptions(attribute, params)
|
||||
|
||||
# filter attributes
|
||||
@filterOption(attribute, params)
|
||||
|
||||
# return item
|
||||
$( App.view('generic/select')(attribute: attribute) )
|
|
@ -319,6 +319,8 @@ class App.UiElement.ticket_perform_action
|
|||
config['value'] = _.clone(attribute.value[groupAndAttribute]['value'])
|
||||
config.multiple = false
|
||||
config.nulloption = config.null
|
||||
if config.tag is 'multiselect'
|
||||
config.multiple = true
|
||||
if config.tag is 'checkbox'
|
||||
config.tag = 'select'
|
||||
tagSearch = "#{config.tag}_search"
|
||||
|
|
|
@ -6,7 +6,13 @@ class App.UiElement.tree_select_search extends App.UiElement.ApplicationUiElemen
|
|||
attribute = clone(localAttribute)
|
||||
|
||||
# set multiple option
|
||||
if attribute.multiple
|
||||
attribute.multiple = 'multiple'
|
||||
else
|
||||
attribute.multiple = ''
|
||||
|
||||
# add null selection if needed
|
||||
@addNullOption(attribute, params)
|
||||
|
||||
# sort attribute.options
|
||||
@sortOptions(attribute, params)
|
||||
|
|
|
@ -191,6 +191,10 @@ class App.FormHandlerCoreWorkflow
|
|||
return if _.isEmpty(data)
|
||||
|
||||
for field, values of data
|
||||
fieldElement = $("div[data-attribute-name='" + field + "']")
|
||||
if fieldElement.hasClass('tree_select')
|
||||
fieldElement.find(".js-option[data-value='" + data[field] + "']").trigger('click')
|
||||
else
|
||||
form.find('[name="' + field + '"]').val(data[field])
|
||||
coreWorkflowParams[classname][field] = data[field]
|
||||
|
||||
|
|
|
@ -1631,3 +1631,23 @@ QUnit.test("Fixes #3909 - Wrong size for textareas in triggers and core workflow
|
|||
})
|
||||
.finally(done)
|
||||
});
|
||||
|
||||
QUnit.test("Fixes #4024 - Tree select value cannot be set to \"-\" (empty) with Trigger/Scheduler/Core workflow.", assert => {
|
||||
$('#qunit').append('<hr><h1>Fixes #4024 - Tree select value cannot be set to "-" (empty) with Trigger/Scheduler/Core workflow.</h1><form id="form22"></form>')
|
||||
var el = $('#form22')
|
||||
new App.ControllerForm({
|
||||
el: el,
|
||||
model: {
|
||||
configure_attributes: [
|
||||
{ name: '4042_select', display: '4042_select', tag: 'select_search', null: true, nulloption: true, multiple: true, options: { 'a': 'a', 'b': 'b' } },
|
||||
{ name: '4042_multiselect', display: '4042_multiselect', tag: 'multiselect_search', null: true, nulloption: true, multiple: true, options: { 'a': 'a', 'b': 'b' } },
|
||||
{ name: '4042_tree_select', display: '4042_tree_select', tag: 'tree_select_search', null: true, nulloption: true, multiple: true, options: [{ 'value': 'a', 'name': 'a'}, { 'value': 'b', 'name': 'b'}] },
|
||||
],
|
||||
},
|
||||
autofocus: true
|
||||
});
|
||||
|
||||
assert.equal(el.find('select[name="4042_select"] option[value=""]').text(), '-', '4042_select has nulloption')
|
||||
assert.equal(el.find('select[name="4042_multiselect"] option[value=""]').text(), '-', '4042_multiselect has nulloption')
|
||||
assert.equal(el.find('select[name="4042_tree_select"] option[value=""]').text(), '-', '4042_tree_select has nulloption')
|
||||
});
|
||||
|
|
|
@ -203,6 +203,7 @@ QUnit.test("form elements check", assert => {
|
|||
"tag": "tree_select_search",
|
||||
"null": true,
|
||||
"translate": true,
|
||||
"multiple": true,
|
||||
"value": ['aa::aab', 'bb', 'aa::aac::33'],
|
||||
"options": [
|
||||
{
|
||||
|
|
|
@ -908,4 +908,42 @@ RSpec.describe 'Ticket Create', type: :system do
|
|||
expect(page).to have_no_text('Test Other Agent')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Tree select value cannot be set to "-" (empty) with Trigger/Scheduler/Core workflow #4024', authenticated_as: :authenticate, db_strategy: :reset do
|
||||
let(:field_name) { SecureRandom.uuid }
|
||||
let(:field) do
|
||||
create :object_manager_attribute_tree_select, name: field_name, display: field_name, screens: attributes_for(:required_screen)
|
||||
ObjectManager::Attribute.migration_execute
|
||||
end
|
||||
let(:workflow) do
|
||||
create(:core_workflow,
|
||||
object: 'Ticket',
|
||||
condition_selected: { 'ticket.priority_id'=>{ 'operator' => 'is', 'value' => Ticket::Priority.find_by(name: '3 high').id.to_s } },
|
||||
perform: { "ticket.#{field_name}" => { 'operator' => 'select', 'select' => 'Incident' } })
|
||||
end
|
||||
let(:workflow2) do
|
||||
create(:core_workflow,
|
||||
object: 'Ticket',
|
||||
condition_selected: { 'ticket.priority_id'=>{ 'operator' => 'is', 'value' => Ticket::Priority.find_by(name: '2 normal').id.to_s } },
|
||||
perform: { "ticket.#{field_name}" => { 'operator' => 'select', 'select' => '' } })
|
||||
end
|
||||
|
||||
def authenticate
|
||||
field
|
||||
workflow
|
||||
workflow2
|
||||
true
|
||||
end
|
||||
|
||||
before do
|
||||
visit 'ticket/create'
|
||||
end
|
||||
|
||||
it 'does select the field value properly' do
|
||||
page.find('[name=priority_id]').select '3 high'
|
||||
wait.until { page.find("input[name='#{field_name}']", visible: :all).value == 'Incident' }
|
||||
page.find('[name=priority_id]').select '2 normal'
|
||||
wait.until { page.find("input[name='#{field_name}']", visible: :all).value == '' }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue