diff --git a/app/assets/javascripts/app/controllers/_ui_element/_application_selector.coffee b/app/assets/javascripts/app/controllers/_ui_element/_application_selector.coffee index e0b6d95e6..7e12a836c 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/_application_selector.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/_application_selector.coffee @@ -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 diff --git a/app/assets/javascripts/app/controllers/_ui_element/core_workflow_perform.coffee b/app/assets/javascripts/app/controllers/_ui_element/core_workflow_perform.coffee index 53c048aeb..c22917f07 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/core_workflow_perform.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/core_workflow_perform.coffee @@ -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('') 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 diff --git a/app/assets/javascripts/app/controllers/_ui_element/multiselect_search.coffee b/app/assets/javascripts/app/controllers/_ui_element/multiselect_search.coffee new file mode 100644 index 000000000..02aefad66 --- /dev/null +++ b/app/assets/javascripts/app/controllers/_ui_element/multiselect_search.coffee @@ -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) ) diff --git a/app/assets/javascripts/app/controllers/_ui_element/ticket_perform_action.coffee b/app/assets/javascripts/app/controllers/_ui_element/ticket_perform_action.coffee index 93f185047..1b8cfb7fc 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/ticket_perform_action.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/ticket_perform_action.coffee @@ -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" diff --git a/app/assets/javascripts/app/controllers/_ui_element/tree_select_search.coffee b/app/assets/javascripts/app/controllers/_ui_element/tree_select_search.coffee index 7022ad61d..ff35e0274 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/tree_select_search.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/tree_select_search.coffee @@ -6,7 +6,13 @@ class App.UiElement.tree_select_search extends App.UiElement.ApplicationUiElemen attribute = clone(localAttribute) # set multiple option - attribute.multiple = 'multiple' + if attribute.multiple + attribute.multiple = 'multiple' + else + attribute.multiple = '' + + # add null selection if needed + @addNullOption(attribute, params) # sort attribute.options @sortOptions(attribute, params) 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 6dbcbb007..ca3b83302 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 @@ -191,7 +191,11 @@ class App.FormHandlerCoreWorkflow return if _.isEmpty(data) for field, values of data - form.find('[name="' + field + '"]').val(data[field]) + 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] # fill in data in input fields diff --git a/public/assets/tests/qunit/form.js b/public/assets/tests/qunit/form.js index a84d83478..03821c2d3 100644 --- a/public/assets/tests/qunit/form.js +++ b/public/assets/tests/qunit/form.js @@ -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('