From 307b9dc7444c31090ee6d8c4176cd0febb9f8578 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Fri, 4 Nov 2016 08:42:46 +0100 Subject: [PATCH] Fixed issue#312 - In object manager, blank line in object deleted all values for selections. --- CHANGES.md | 1 + .../_application_controller_form.coffee | 16 ++++---- .../app/controllers/_ui_element/select.coffee | 2 +- public/assets/tests/form.js | 37 ++++++++++++++++--- 4 files changed, 42 insertions(+), 14 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 9fe5181a9..23399c70a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,7 @@ - 2016-10-28 Implemented issue#[317](https://github.com/zammad/zammad/issues/317) - Display origin url from tweet/facebook post in article view. ## Zammad 1.0.1 + - 2016-11-04 Fixed issue#[312](https://github.com/zammad/zammad/issues/312) - In object manager, blank line in object deleted all values for selections. - 2016-11-04 Fixed issue#[286](https://github.com/zammad/zammad/issues/286) - Answers from google mail shows complete quote. - 2016-11-03 Fixed issue#[348](https://github.com/zammad/zammad/issues/348) - IMAP mail fetching stops because of broken spam email (invalid Content-Transfer-Encoding header) - 2016-10-29 Fixed issue#[326](https://github.com/zammad/zammad/issues/326) - Create emails via fetchmail / procmail. diff --git a/app/assets/javascripts/app/controllers/_application_controller_form.coffee b/app/assets/javascripts/app/controllers/_application_controller_form.coffee index 571d3d5c4..bba8696a8 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_form.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_form.coffee @@ -108,7 +108,7 @@ class App.ControllerForm extends App.Controller if @fullForm if !@formClass @formClass = '' - fieldset = $('
').prepend( fieldset ) + fieldset = $('
').prepend( fieldset ) # bind form events if @events @@ -489,21 +489,21 @@ class App.ControllerForm extends App.Controller inputSelectObject = {} for key of param parts = key.split '::' - if parts[0] && parts[1] - if parts[1] && !inputSelectObject[ parts[0] ] + if parts[0] && parts[1] isnt undefined + if parts[1] isnt undefined && !inputSelectObject[ parts[0] ] inputSelectObject[ parts[0] ] = {} - if parts[2] && !inputSelectObject[ parts[0] ][ parts[1] ] + if parts[2] isnt undefined && !inputSelectObject[ parts[0] ][ parts[1] ] inputSelectObject[ parts[0] ][ parts[1] ] = {} - if parts[3] && !inputSelectObject[ parts[0] ][ parts[1] ][ parts[2] ] + if parts[3] isnt undefined && !inputSelectObject[ parts[0] ][ parts[1] ][ parts[2] ] inputSelectObject[ parts[0] ][ parts[1] ][ parts[2] ] = {} - if parts[3] + if parts[3] isnt undefined inputSelectObject[ parts[0] ][ parts[1] ][ parts[2] ][ parts[3] ] = param[ key ] delete param[ key ] - else if parts[2] + else if parts[2] isnt undefined inputSelectObject[ parts[0] ][ parts[1] ][ parts[2] ] = param[ key ] delete param[ key ] - else if parts[1] + else if parts[1] isnt undefined inputSelectObject[ parts[0] ][ parts[1] ] = param[ key ] delete param[ key ] diff --git a/app/assets/javascripts/app/controllers/_ui_element/select.coffee b/app/assets/javascripts/app/controllers/_ui_element/select.coffee index ada6c0b07..da812722e 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/select.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/select.coffee @@ -30,4 +30,4 @@ class App.UiElement.select extends App.UiElement.ApplicationUiElement @filterOption(attribute, params) # return item - $( App.view('generic/select')( attribute: attribute ) ) \ No newline at end of file + $( App.view('generic/select')(attribute: attribute) ) diff --git a/public/assets/tests/form.js b/public/assets/tests/form.js index bd6ec621f..2343a2ccc 100644 --- a/public/assets/tests/form.js +++ b/public/assets/tests/form.js @@ -551,9 +551,9 @@ test("form handler check with and without fieldset", function() { } var formChanges = function(params, attribute, attributes, classname, form, ui) { - console.log('FROM', form) + //console.log('FROM', form) if (params['select1'] === 'b') { - console.log('lala', params) + //console.log('select1 -> b', params) var item = { name: 'select2', display: 'Select2', @@ -566,7 +566,7 @@ test("form handler check with and without fieldset", function() { form.find('[name="select2"]').closest('.form-group').replaceWith(newElement) } if (params['select1'] === 'a') { - console.log('lala', params) + //console.log('select1 -> a', params) var item = { name: 'select2', display: 'Select2', @@ -938,8 +938,35 @@ test("form params check", function() { select3: '', select4: '', } - console.log('params', params) - console.log('test_params', test_params) + //console.log('params', params) + //console.log('test_params', test_params) + deepEqual(params, test_params, 'form param check') + +}); + +test("form params check direct", function() { + + $('#forms').append('

form params check direct

') + var el = $('#form10') + + params = App.ControllerForm.params(el) + test_params = { + a: 'b', + l: { + l: { + l1: 'd', + '': '', + }, + }, + f: { + f: { + f1: 'e', + '': '', + }, + }, + } + //console.log('params', params) + //console.log('test_params', test_params) deepEqual(params, test_params, 'form param check') });