diff --git a/app/assets/javascripts/app/controllers/_ui_element/_application_ui_element.coffee b/app/assets/javascripts/app/controllers/_ui_element/_application_ui_element.coffee index 546d3e29b..674324397 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/_application_ui_element.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/_application_ui_element.coffee @@ -119,7 +119,7 @@ class App.UiElement.ApplicationUiElement list.push record # check if current value need to be added - if params[ attribute.name ] + if params[ attribute.name ] && !attribute.rejectNonExistentValues hit = false for value in list if value['id'].toString() is params[ attribute.name ].toString() diff --git a/app/assets/javascripts/app/controllers/_ui_element/select.coffee b/app/assets/javascripts/app/controllers/_ui_element/select.coffee index e8dbdf1b3..b72158e59 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/select.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/select.coffee @@ -1,6 +1,6 @@ # coffeelint: disable=camel_case_classes class App.UiElement.select extends App.UiElement.ApplicationUiElement - @render: (attribute, params) -> + @render: (attribute, params, form = {}) -> # set multiple option if attribute.multiple @@ -8,6 +8,9 @@ class App.UiElement.select extends App.UiElement.ApplicationUiElement else attribute.multiple = '' + if form.rejectNonExistentValues + attribute.rejectNonExistentValues = true + # add deleted historical options if required @addDeletedOptions(attribute, params) @@ -39,6 +42,7 @@ class App.UiElement.select extends App.UiElement.ApplicationUiElement # 2. If attribute.value is not among current and historical options, then add the value itself as an option @addDeletedOptions: (attribute) -> return if !_.isEmpty(attribute.relation) # do not apply for attributes with relation, relations will fill options automatically + return if attribute.rejectNonExistentValues value = attribute.value return if !value return if _.isArray(value) diff --git a/app/assets/javascripts/app/controllers/agent_ticket_create.coffee b/app/assets/javascripts/app/controllers/agent_ticket_create.coffee index f6257e467..9245d82b1 100644 --- a/app/assets/javascripts/app/controllers/agent_ticket_create.coffee +++ b/app/assets/javascripts/app/controllers/agent_ticket_create.coffee @@ -324,11 +324,12 @@ class App.TicketCreate extends App.Controller events: 'change [name=customer_id]': @localUserInfo handlersConfig: handlers - filter: @formMeta.filter - formMeta: @formMeta - params: params - noFieldset: true - taskKey: @taskKey + filter: @formMeta.filter + formMeta: @formMeta + params: params + noFieldset: true + taskKey: @taskKey + rejectNonExistentValues: true ) new App.ControllerForm( el: @$('.ticket-form-bottom') diff --git a/app/assets/javascripts/app/controllers/customer_ticket_create.coffee b/app/assets/javascripts/app/controllers/customer_ticket_create.coffee index fb917fdb9..fba6fb8ea 100644 --- a/app/assets/javascripts/app/controllers/customer_ticket_create.coffee +++ b/app/assets/javascripts/app/controllers/customer_ticket_create.coffee @@ -69,15 +69,16 @@ class Index extends App.ControllerContent handlersConfig: handlers ) new App.ControllerForm( - el: @el.find('.ticket-form-middle') - form_id: @form_id - model: App.Ticket - screen: 'create_middle' - filter: @formMeta.filter - formMeta: @formMeta - params: defaults - noFieldset: true - handlersConfig: handlers + el: @el.find('.ticket-form-middle') + form_id: @form_id + model: App.Ticket + screen: 'create_middle' + filter: @formMeta.filter + formMeta: @formMeta + params: defaults + noFieldset: true + handlersConfig: handlers + rejectNonExistentValues: true ) if !_.isEmpty(App.Ticket.attributesGet('create_bottom', false, true)) new App.ControllerForm( diff --git a/public/assets/tests/form.js b/public/assets/tests/form.js index 43c5c50b0..11c818f9a 100644 --- a/public/assets/tests/form.js +++ b/public/assets/tests/form.js @@ -1339,6 +1339,70 @@ test("object manager form 3", function() { }); +test("check if select value is not existing but is shown", function() { + + $('#forms').append('