diff --git a/app/assets/javascripts/app/controllers/_ui_element/active.coffee b/app/assets/javascripts/app/controllers/_ui_element/active.coffee index 698449bd0..3609c179b 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/active.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/active.coffee @@ -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 diff --git a/app/assets/javascripts/app/controllers/_ui_element/auth_provider.coffee b/app/assets/javascripts/app/controllers/_ui_element/auth_provider.coffee index 07900dedd..ad190b670 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/auth_provider.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/auth_provider.coffee @@ -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" diff --git a/app/assets/javascripts/app/controllers/_ui_element/autocompletion.coffee b/app/assets/javascripts/app/controllers/_ui_element/autocompletion.coffee index da49e3eaa..676146fa0 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/autocompletion.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/autocompletion.coffee @@ -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' ] diff --git a/app/assets/javascripts/app/controllers/_ui_element/autocompletion_ajax_search.coffee b/app/assets/javascripts/app/controllers/_ui_element/autocompletion_ajax_search.coffee index cd588e9b7..3207cddd5 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/autocompletion_ajax_search.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/autocompletion_ajax_search.coffee @@ -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) diff --git a/app/assets/javascripts/app/controllers/_ui_element/basedate.coffee b/app/assets/javascripts/app/controllers/_ui_element/basedate.coffee index 9abbd84cd..abfcfb448 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/basedate.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/basedate.coffee @@ -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}" diff --git a/app/assets/javascripts/app/controllers/_ui_element/boolean.coffee b/app/assets/javascripts/app/controllers/_ui_element/boolean.coffee index fa84c7b38..c0e143a45 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/boolean.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/boolean.coffee @@ -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) diff --git a/app/assets/javascripts/app/controllers/_ui_element/business_hours.coffee b/app/assets/javascripts/app/controllers/_ui_element/business_hours.coffee index c83d9a9b0..054b0525a 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/business_hours.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/business_hours.coffee @@ -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}" diff --git a/app/assets/javascripts/app/controllers/_ui_element/checkbox.coffee b/app/assets/javascripts/app/controllers/_ui_element/checkbox.coffee index 099f37e1b..87bba235e 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/checkbox.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/checkbox.coffee @@ -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 ) diff --git a/app/assets/javascripts/app/controllers/_ui_element/checkboxTicketAttributes.coffee b/app/assets/javascripts/app/controllers/_ui_element/checkboxTicketAttributes.coffee index 865018749..7b14f4230 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/checkboxTicketAttributes.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/checkboxTicketAttributes.coffee @@ -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() diff --git a/app/assets/javascripts/app/controllers/_ui_element/column_select.coffee b/app/assets/javascripts/app/controllers/_ui_element/column_select.coffee index 6741b3946..1fa9f8304 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/column_select.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/column_select.coffee @@ -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' diff --git a/app/assets/javascripts/app/controllers/_ui_element/datetime_search.coffee b/app/assets/javascripts/app/controllers/_ui_element/datetime_search.coffee index 825488467..fce97d504 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/datetime_search.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/datetime_search.coffee @@ -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) diff --git a/app/assets/javascripts/app/controllers/_ui_element/integer.coffee b/app/assets/javascripts/app/controllers/_ui_element/integer.coffee index a155c5512..eed83158f 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/integer.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/integer.coffee @@ -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) ) diff --git a/app/assets/javascripts/app/controllers/_ui_element/multiselect.coffee b/app/assets/javascripts/app/controllers/_ui_element/multiselect.coffee index f8be70484..6510c03ff 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/multiselect.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/multiselect.coffee @@ -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' diff --git a/app/assets/javascripts/app/controllers/_ui_element/multiselect_search.coffee b/app/assets/javascripts/app/controllers/_ui_element/multiselect_search.coffee index 02aefad66..194e2162f 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/multiselect_search.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/multiselect_search.coffee @@ -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 diff --git a/app/assets/javascripts/app/controllers/_ui_element/radio.coffee b/app/assets/javascripts/app/controllers/_ui_element/radio.coffee index 337d6764e..c3071975e 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/radio.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/radio.coffee @@ -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) diff --git a/app/assets/javascripts/app/controllers/_ui_element/richtext.coffee b/app/assets/javascripts/app/controllers/_ui_element/richtext.coffee index aafeb949c..ced9ba920 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/richtext.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/richtext.coffee @@ -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 diff --git a/app/assets/javascripts/app/controllers/_ui_element/searchable_select.coffee b/app/assets/javascripts/app/controllers/_ui_element/searchable_select.coffee index d2b8f3664..4dbe18398 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/searchable_select.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/searchable_select.coffee @@ -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 diff --git a/app/assets/javascripts/app/controllers/_ui_element/select.coffee b/app/assets/javascripts/app/controllers/_ui_element/select.coffee index d50dafd9a..bd7bc77a6 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/select.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/select.coffee @@ -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 diff --git a/app/assets/javascripts/app/controllers/_ui_element/selectTicketAttributes.coffee b/app/assets/javascripts/app/controllers/_ui_element/selectTicketAttributes.coffee index 3a2276746..4ea2b06fe 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/selectTicketAttributes.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/selectTicketAttributes.coffee @@ -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() diff --git a/app/assets/javascripts/app/controllers/_ui_element/select_search.coffee b/app/assets/javascripts/app/controllers/_ui_element/select_search.coffee index ba5a324db..c3decb0ef 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/select_search.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/select_search.coffee @@ -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 diff --git a/app/assets/javascripts/app/controllers/_ui_element/tag.coffee b/app/assets/javascripts/app/controllers/_ui_element/tag.coffee index 905c518f2..20b7fb851 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/tag.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/tag.coffee @@ -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) ) 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 118452cf7..9c2d4da33 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 @@ -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) diff --git a/app/assets/javascripts/app/controllers/_ui_element/time_range.coffee b/app/assets/javascripts/app/controllers/_ui_element/time_range.coffee index e831fab05..230be4f5c 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/time_range.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/time_range.coffee @@ -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)') diff --git a/app/assets/javascripts/app/controllers/_ui_element/timer.coffee b/app/assets/javascripts/app/controllers/_ui_element/timer.coffee index cc6a4a7e6..bc0c513ba 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/timer.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/timer.coffee @@ -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') diff --git a/app/assets/javascripts/app/controllers/_ui_element/timezone.coffee b/app/assets/javascripts/app/controllers/_ui_element/timezone.coffee index 919219cde..0ce26f130 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/timezone.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/timezone.coffee @@ -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') diff --git a/app/assets/javascripts/app/controllers/_ui_element/tree_select.coffee b/app/assets/javascripts/app/controllers/_ui_element/tree_select.coffee index 1c5a23d23..8745bb6f8 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/tree_select.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/tree_select.coffee @@ -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 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 1210e107a..9879a2d6b 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 @@ -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) diff --git a/app/assets/javascripts/app/lib/app_post/searchable_select.coffee b/app/assets/javascripts/app/lib/app_post/searchable_select.coffee index cadc0af17..6077db761 100644 --- a/app/assets/javascripts/app/lib/app_post/searchable_select.coffee +++ b/app/assets/javascripts/app/lib/app_post/searchable_select.coffee @@ -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}) diff --git a/public/assets/tests/qunit/form_tree_select.js b/public/assets/tests/qunit/form_tree_select.js index 441c12ef5..76966281c 100644 --- a/public/assets/tests/qunit/form_tree_select.js +++ b/public/assets/tests/qunit/form_tree_select.js @@ -1,5 +1,5 @@ QUnit.test("form elements check", assert => { - $('#forms').append('