Fixes #4090 - Tree Select Trigger changes the conditions on its own

This commit is contained in:
Martin Edenhofer 2022-05-17 16:45:48 +02:00 committed by Rolf Schmidt
parent 5fae57a8ce
commit d095cd6612
29 changed files with 152 additions and 41 deletions

View file

@ -1,6 +1,7 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.active extends App.UiElement.ApplicationUiElement
@render: (attribute, params) ->
@render: (attributeConfig, params) ->
attribute = $.extend(true, {}, attributeConfig)
# set attributes
attribute.null = false

View file

@ -1,6 +1,8 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.auth_provider
@render: (attribute) ->
@render: (attributeConfig) ->
attribute = $.extend(true, {}, attributeConfig)
for key, value of App.Config.get('auth_provider_all')
continue if value.config isnt attribute.provider
attribute.value = "#{App.Config.get('http_type')}://#{App.Config.get('fqdn')}#{value.url}/callback"

View file

@ -1,6 +1,7 @@
# coffeelint: disable=camel_case_classes,no_interpolation_in_single_quotes
class App.UiElement.autocompletion
@render: (attribute, params = {}) ->
@render: (attributeConfig, params = {}) ->
attribute = $.extend(true, {}, attributeConfig)
if params[ attribute.name + '_autocompletion_value_shown' ]
attribute.valueShown = params[ attribute.name + '_autocompletion_value_shown' ]

View file

@ -1,6 +1,7 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.autocompletion_ajax_search extends App.UiElement.autocompletion_ajax
@render: (attributeOrig, params = {}, form) ->
attribute = _.clone(attributeOrig)
@render: (attributeConfig, params = {}, form) ->
attribute = $.extend(true, {}, attributeConfig)
attribute.multiple = true
super(attribute, params = {}, form)

View file

@ -4,8 +4,9 @@ class App.UiElement.basedate
@templateName: ->
throw 'Must override in a subclass'
@render: (attributeOrig) ->
attribute = _.clone(attributeOrig)
@render: (attributeConfig) ->
attribute = $.extend(true, {}, attributeConfig)
attribute.nameRaw = attribute.name
attribute.name = "{#{@templateName()}}#{attribute.name}"

View file

@ -1,6 +1,7 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.boolean extends App.UiElement.ApplicationUiElement
@render: (attribute, params) ->
@render: (attributeConfig, params) ->
attribute = $.extend(true, {}, attributeConfig)
# build options list
if _.isEmpty(attribute.options)

View file

@ -1,8 +1,8 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.business_hours
@render: (attributeOrig) ->
@render: (attributeConfig) ->
attribute = $.extend(true, {}, attributeConfig)
attribute = _.clone(attributeOrig)
attribute.nameRaw = attribute.name
attribute.name = "{business_hours}#{attribute.name}"

View file

@ -1,6 +1,7 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.checkbox extends App.UiElement.ApplicationUiElement
@render: (attribute, params) ->
@render: (attributeConfig, params) ->
attribute = $.extend(true, {}, attributeConfig)
# build options list based on config
@getConfigOptionList( attribute, params )

View file

@ -1,6 +1,7 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.checkboxTicketAttributes extends App.UiElement.ApplicationUiElement
@render: (attribute, params) ->
@render: (attributeConfig, params) ->
attribute = $.extend(true, {}, attributeConfig)
attributeOptionsArray = []
for name, row of App.Ticket.attributesGet()

View file

@ -1,6 +1,7 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.column_select extends App.UiElement.ApplicationUiElement
@render: (attribute, params) ->
@render: (attributeConfig, params) ->
attribute = $.extend(true, {}, attributeConfig)
# set multiple option
attribute.multiple = 'multiple'

View file

@ -1,7 +1,8 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.datetime_search
@render: (attributeOrig) ->
attribute = _.clone(attributeOrig)
@render: (attributeConfig, params) ->
attribute = $.extend(true, {}, attributeConfig)
attribute.disable_feature = true
attribute.null = false
App.UiElement.datetime.render(attribute)

View file

@ -1,6 +1,8 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.integer
@render: (attribute) ->
@render: (attributeConfig) ->
attribute = $.extend(true, {}, attributeConfig)
attribute.type = 'number'
attribute.step = '1'
item = $( App.view('generic/input')(attribute: attribute) )

View file

@ -1,6 +1,7 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.multiselect extends App.UiElement.ApplicationUiElement
@render: (attribute, params, form = {}) ->
@render: (attributeConfig, params, form = {}) ->
attribute = $.extend(true, {}, attributeConfig)
# set multiple option
attribute.multiple = 'multiple'

View file

@ -1,6 +1,7 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.multiselect_search extends App.UiElement.ApplicationUiElement
@render: (attribute, params) ->
@render: (attributeConfig, params) ->
attribute = $.extend(true, {}, attributeConfig)
# set multiple option
if attribute.multiple

View file

@ -2,7 +2,8 @@
class App.UiElement.radio extends App.UiElement.ApplicationUiElement
@template_name: 'radio'
@render: (attribute, params) ->
@render: (attributeConfig, params) ->
attribute = $.extend(true, {}, attributeConfig)
# build options list based on config
@getConfigOptionList(attribute, params)

View file

@ -1,6 +1,8 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.richtext
@render: (attribute, params, form) ->
@render: (attributeConfig, params, form) ->
attribute = $.extend(true, {}, attributeConfig)
if _.isObject(attribute.value)
attribute.attachments = attribute.value.attachments
attribute.value = attribute.value.text

View file

@ -1,6 +1,7 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.searchable_select extends App.UiElement.ApplicationUiElement
@render: (attribute, params) ->
@render: (attributeConfig, params) ->
attribute = $.extend(true, {}, attributeConfig)
# set multiple option
if attribute.multiple

View file

@ -1,6 +1,7 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.select extends App.UiElement.ApplicationUiElement
@render: (attribute, params, form = {}) ->
@render: (attributeConfig, params, form = {}) ->
attribute = $.extend(true, {}, attributeConfig)
# set multiple option
if attribute.multiple

View file

@ -1,6 +1,7 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.selectTicketAttributes extends App.UiElement.ApplicationUiElement
@render: (attribute, params) ->
@render: (attributeConfig, params) ->
attribute = $.extend(true, {}, attributeConfig)
attributeOptionsArray = []
for name, row of App.Ticket.attributesGet()

View file

@ -1,6 +1,7 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.select_search extends App.UiElement.ApplicationUiElement
@render: (attribute, params) ->
@render: (attributeConfig, params) ->
attribute = $.extend(true, {}, attributeConfig)
# set multiple option
if attribute.multiple

View file

@ -1,6 +1,7 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.tag
@render: (attribute) ->
@render: (attributeConfig) ->
attribute = $.extend(true, {}, attributeConfig)
if !attribute.id
attribute.id = 'tag-' + new Date().getTime() + '-' + Math.floor(Math.random() * 999999)
item = $( App.view('generic/input')(attribute: attribute) )

View file

@ -64,7 +64,8 @@ class App.UiElement.ticket_perform_action
item.find('.js-attributeSelector').prepend(selector)
item
@render: (attribute, params = {}) ->
@render: (attributeConfig, params = {}) ->
attribute = $.extend(true, {}, attributeConfig)
[defaults, groups, elements] = @defaults(attribute)

View file

@ -1,6 +1,8 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.time_range
@render: (attribute) ->
@render: (attributeConfig, params) ->
attribute = $.extend(true, {}, attributeConfig)
ranges =
minute: __('Minute(s)')
hour: __('Hour(s)')

View file

@ -1,6 +1,8 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.timer
@render: (attribute) ->
@render: (attributeConfig, params) ->
attribute = $.extend(true, {}, attributeConfig)
days =
Mon: __('Monday')
Tue: __('Tuesday')

View file

@ -1,6 +1,7 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.timezone extends App.UiElement.ApplicationUiElement
@render: (attribute, params) ->
@render: (attributeConfig, params) ->
attribute = $.extend(true, {}, attributeConfig)
attribute.options = []
timezones = App.Config.get('timezones')

View file

@ -1,6 +1,7 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.tree_select extends App.UiElement.ApplicationUiElement
@render: (attribute, params) ->
@render: (attributeConfig, params) ->
attribute = $.extend(true, {}, attributeConfig)
# set multiple option
if attribute.multiple

View file

@ -1,13 +1,10 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.tree_select_search extends App.UiElement.ApplicationUiElement
@render: (attributeConfig, params) ->
attribute = $.extend({}, attributeConfig)
attribute = $.extend(true, {}, attributeConfig)
# set multiple option
if attribute.multiple
attribute.multiple = 'multiple'
else
attribute.multiple = ''
attribute.multiple = 'multiple'
# add null selection if needed
@addNullOption(attribute, params)

View file

@ -50,7 +50,7 @@ class App.SearchableSelect extends Spine.Controller
# create tokens and attribute values
values = []
for dataId in @attribute.value
if App[relation].exists dataId
if App[relation] && App[relation].exists(dataId)
name = App[relation].find(dataId).displayName()
value = dataId
values.push({name: name, value: value})

View file

@ -1,5 +1,5 @@
QUnit.test("form elements check", assert => {
$('#forms').append('<hr><h1>form elements check</h1><form id="form1"></form>')
$('#forms').append('<hr><h1>form elements check 1</h1><form id="form1"></form>')
var el = $('#form1')
new App.ControllerForm({
el: el,
@ -62,7 +62,7 @@ QUnit.test("form elements check", assert => {
}
assert.deepEqual(params, test_params, 'form param check')
$('#forms').append('<hr><h1>form elements check</h1><form id="form2"></form>')
$('#forms').append('<hr><h1>form elements check 2</h1><form id="form2"></form>')
var el = $('#form2')
new App.ControllerForm({
el: el,
@ -127,7 +127,7 @@ QUnit.test("form elements check", assert => {
}
assert.deepEqual(params, test_params, 'form param check')
$('#forms').append('<hr><h1>form elements check</h1><form id="form3"></form>')
$('#forms').append('<hr><h1>form elements check 3</h1><form id="form3"></form>')
var el = $('#form3')
new App.ControllerForm({
el: el,
@ -191,7 +191,7 @@ QUnit.test("form elements check", assert => {
}
assert.deepEqual(params, test_params, 'form param check')
$('#forms').append('<hr><h1>form elements check</h1><form id="form4"></form>')
$('#forms').append('<hr><h1>form elements check 4</h1><form id="form4"></form>')
var el = $('#form4')
new App.ControllerForm({
el: el,
@ -270,10 +270,94 @@ QUnit.test("form elements check", assert => {
});
QUnit.test("ui elements check", assert => {
attribute = {
"name": "tree_select_search",
"display": "tree_select_search",
"tag": "tree_select_search",
"null": true,
"translate": true,
"value": ['bb::bba', 'bb::bbb'],
"multiple": true,
"options": [
{
"value": "aa",
"name": "yes",
"children": [
{
"value": "aa::aaa",
"name": "yes1",
},
{
"value": "aa::aab",
"name": "yes2",
},
]
},
{
"value": "bb",
"name": "bb (comment)",
"children": [
{
"value": "bb::bba",
"name": "yes11",
},
{
"value": "bb::bbb",
"name": "yes22",
},
]
},
],
};
options = [
{
"value": "aa",
"name": "yes",
"children": [
{
"value": "aa::aaa",
"name": "yes1",
},
{
"value": "aa::aab",
"name": "yes2",
},
]
},
{
"value": "bb",
"name": "bb (comment)",
"children": [
{
"value": "bb::bba",
"name": "yes11",
},
{
"value": "bb::bbb",
"name": "yes22",
},
]
}
]
element = App.UiElement.tree_select_search.render(attribute)
assert.deepEqual(attribute.options, options, 'options tree_select_search')
attribute.name = 'tree_select'
attribute.display = 'tree_select'
attribute.tag = 'tree_select'
element = App.UiElement.tree_select.render(attribute)
assert.deepEqual(attribute.options, options, 'options tree_select')
});
QUnit.test("searchable_select submenu and option list check", assert => {
var done = assert.async()
$('#forms').append('<hr><h1>form elements check</h1><form id="form5"></form>')
$('#forms').append('<hr><h1>form elements check 5</h1><form id="form5"></form>')
var el = $('#form5')
new App.ControllerForm({
el: el,