From 894afeeb421988448cd4abe608f620441a975b5b Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Fri, 16 Feb 2018 10:35:50 +0100 Subject: [PATCH] WIP. --- .../app/controllers/_application_controller_form.coffee | 8 ++++---- public/assets/tests/form.js | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_application_controller_form.coffee b/app/assets/javascripts/app/controllers/_application_controller_form.coffee index 828c8784d..7f7cc5991 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_form.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_form.coffee @@ -460,16 +460,16 @@ class App.ControllerForm extends App.Controller checked = $(@).attr('checked') name = $(@).attr('name') if name && !checked && (!(name of param) || param[name] is '') - if uncheckParam[name] is '' - uncheckParam[name] = [] + if !(name of uncheckParam) + uncheckParam[name] = undefined else - uncheckParam[name] = '' + uncheckParam[name] = [] ) lookupForm.find('input[type=radio]').each( (index) -> checked = $(@).attr('checked') name = $(@).attr('name') if name && !checked && !(name of param) - uncheckParam[name] = '' + uncheckParam[name] = undefined ) for key, value of uncheckParam if !(key of param) diff --git a/public/assets/tests/form.js b/public/assets/tests/form.js index 6f3fc49f8..46d22e110 100644 --- a/public/assets/tests/form.js +++ b/public/assets/tests/form.js @@ -143,9 +143,9 @@ test("form params check", function() { active1: true, active2: false, checkbox1: [], - checkbox2: '', + checkbox2: undefined, checkbox3: 'd', - radiobox1: '', + radiobox1: undefined, radiobox2: 'a', } new App.ControllerForm({ @@ -291,10 +291,10 @@ test("form params check", function() { active1: true, active2: false, checkbox1: [], - checkbox2: '', + checkbox2: undefined, checkbox3: 'd', checkbox4: [], - radiobox1: '', + radiobox1: undefined, radiobox2: 'a', } deepEqual(params, test_params, 'form param check')