Fixes #3333 - Tree select has no multi select on ticket selector for overview, triggers,...
This commit is contained in:
parent
415486361d
commit
f3fb482992
2 changed files with 119 additions and 0 deletions
|
@ -0,0 +1,43 @@
|
|||
# coffeelint: disable=camel_case_classes
|
||||
class App.UiElement.tree_select_search extends App.UiElement.ApplicationUiElement
|
||||
@render: (attribute, params) ->
|
||||
|
||||
# set multiple option
|
||||
attribute.multiple = 'multiple'
|
||||
|
||||
# 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) )
|
||||
|
||||
@sortOptions: (attribute, params) ->
|
||||
|
||||
options = []
|
||||
|
||||
@getSub(options, attribute.options, params)
|
||||
|
||||
attribute.options = options
|
||||
|
||||
@getSub: (options, localRow, params) ->
|
||||
for row in localRow
|
||||
length = row.value.split('::').length
|
||||
prefix = ''
|
||||
if length > 1
|
||||
for count in [2..length]
|
||||
prefix += '> '
|
||||
row.name = "#{prefix}#{row.name}"
|
||||
|
||||
options.push row
|
||||
|
||||
if row.children
|
||||
@getSub(options, row.children, params)
|
|
@ -191,4 +191,80 @@ test("form elements check", function() {
|
|||
}
|
||||
deepEqual(params, test_params, 'form param check')
|
||||
|
||||
$('#forms').append('<hr><h1>form elements check</h1><form id="form4"></form>')
|
||||
var el = $('#form4')
|
||||
new App.ControllerForm({
|
||||
el: el,
|
||||
model: {
|
||||
"configure_attributes": [
|
||||
{
|
||||
"name": "tree_select_search",
|
||||
"display": "tree_select_search",
|
||||
"tag": "tree_select_search",
|
||||
"null": true,
|
||||
"translate": true,
|
||||
"value": ['aa::aab', 'bb', 'aa::aac::33'],
|
||||
"options": [
|
||||
{
|
||||
"value": "aa",
|
||||
"name": "yes",
|
||||
"children": [
|
||||
{
|
||||
"value": "aa::aaa",
|
||||
"name": "yes1",
|
||||
},
|
||||
{
|
||||
"value": "aa::aab",
|
||||
"name": "yes2",
|
||||
},
|
||||
{
|
||||
"value": "aa::aac",
|
||||
"name": "yes3",
|
||||
"children": [
|
||||
{
|
||||
"value": "aa::aaa::11",
|
||||
"name": "11",
|
||||
},
|
||||
{
|
||||
"value": "aa::aa1::22",
|
||||
"name": "22",
|
||||
},
|
||||
{
|
||||
"value": "aa::aac::33",
|
||||
"name": "33",
|
||||
},
|
||||
]
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"value": "bb",
|
||||
"name": "bb (comment)",
|
||||
"children": [
|
||||
{
|
||||
"value": "bb::bba",
|
||||
"name": "yes11",
|
||||
},
|
||||
{
|
||||
"value": "bb::bbb",
|
||||
"name": "yes22",
|
||||
},
|
||||
{
|
||||
"value": "bb::bbc",
|
||||
"name": "yes33",
|
||||
},
|
||||
]
|
||||
},
|
||||
],
|
||||
}
|
||||
]
|
||||
},
|
||||
autofocus: true
|
||||
});
|
||||
var params = App.ControllerForm.params(el)
|
||||
var test_params = {
|
||||
tree_select_search: ['aa::aab', 'aa::aac::33', 'bb'],
|
||||
}
|
||||
deepEqual(params, test_params, 'form param check')
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue