From 1a6c8ce0f3c5a25647b2465a830954904ef4345a Mon Sep 17 00:00:00 2001 From: Rolf Schmidt Date: Mon, 29 May 2017 13:49:17 +0200 Subject: [PATCH] Fixed issue #944 - Remove all Users from Overview does not work. --- .../_application_controller_form.coffee | 7 +++-- app/assets/javascripts/application.js | 28 ++++++++++++++----- public/assets/tests/form_column_select.js | 1 + 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_application_controller_form.coffee b/app/assets/javascripts/app/controllers/_application_controller_form.coffee index 8115dcd24..499602a72 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_form.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_form.coffee @@ -426,8 +426,11 @@ class App.ControllerForm extends App.Controller delete param[item.name] continue - # collect all params, push it to an array if already exists - value = item.value.trim() + # collect all params, push it to an array item.value already exists + value = item.value + if item.value + value = item.value.trim() + if item.type is 'boolean' if value is '' value = undefined diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index dffd7ba39..7b907799e 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -246,13 +246,27 @@ jQuery.fn.extend( { var val = $elem.val(); var type = $elem.data('field-type'); - return val == null ? - null : - jQuery.isArray( val ) ? - jQuery.map( val, function( val ) { - return { name: elem.name, value: val.replace( rCRLF, "\r\n" ), type: type }; - } ) : - { name: elem.name, value: val.replace( rCRLF, "\r\n" ), type: type }; + var result; + if ( val == null ) { + + // be sure that also null values are transfered + // https://github.com/zammad/zammad/issues/944 + if ( $elem.prop('multiple') ) { + result = { name: elem.name, value: null, type: type }; + } + else { + result = null + } + } + else if ( jQuery.isArray( val ) ) { + result = jQuery.map( val, function( val ) { + return { name: elem.name, value: val.replace( rCRLF, "\r\n" ), type: type }; + } ); + } + else { + result = { name: elem.name, value: val.replace( rCRLF, "\r\n" ), type: type }; + } + return result; } ).get(); } } ); diff --git a/public/assets/tests/form_column_select.js b/public/assets/tests/form_column_select.js index 9670678ae..a81645e3e 100644 --- a/public/assets/tests/form_column_select.js +++ b/public/assets/tests/form_column_select.js @@ -28,6 +28,7 @@ test( "column_select check", function(assert) { var params = App.ControllerForm.params(el) var test_params = { + column_select1: null, column_select2: ['aaa', 'bbb'], column_select3: ['1', '2'], }