From a8d0b8c817b7d6381d03b378d68eb3364765ae5e Mon Sep 17 00:00:00 2001 From: Joseph Frazer Date: Thu, 1 Nov 2018 16:51:50 -0400 Subject: [PATCH] [DEV-3866] changes for new checkbox question type The new checkbox question type is setup with an empty validator. When checked, it was not unchecking because it was trying to behave like the "noyes" questions. I updated the logic to not behave like that if there is only one checkbox in a group. --- src/ui/step/GeneralStepUi.js | 19 ++++++++++--------- src/validate/standardBucketValidator.js | 3 ++- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/ui/step/GeneralStepUi.js b/src/ui/step/GeneralStepUi.js index ddc89e2..0622ae6 100644 --- a/src/ui/step/GeneralStepUi.js +++ b/src/ui/step/GeneralStepUi.js @@ -1,7 +1,7 @@ /** * General UI logic for steps * - * Copyright (C) 2015 R-T Specialty, LLC. + * Copyright (C) 2015, 2018 R-T Specialty, LLC. * * This file is part of liza. * @@ -343,20 +343,21 @@ module.exports = Class( 'GeneralStepUi' ) || $element.attr( 'type' ) === 'checkbox' ) { - // if it's not checked, then this isn't the radio we're - // interested in. Sorry! - if ( !( $element.attr( 'checked' ) ) ) + + // 2 in this instance is the yes/no group length. + var group_length = $element.attr( 'data-question-length' ) + ? +$element.attr( 'data-question-length' ) + : 2; + + // if it's not checked and in a group, then this isn't + // the radio we're interested in. Sorry! + if ( !( $element.attr( 'checked' ) ) && group_length !== 1 ) { $element.attr( 'checked', true ); return; } - // 2 in this instance is the yes/no group length. - var group_length = $element.attr( 'data-question-length' ) - ? $element.attr( 'data-question-length' ) - : 2; - index = Math.floor( index / group_length ); } diff --git a/src/validate/standardBucketValidator.js b/src/validate/standardBucketValidator.js index 97d5427..97a8fca 100644 --- a/src/validate/standardBucketValidator.js +++ b/src/validate/standardBucketValidator.js @@ -1,7 +1,7 @@ /** * Standard formatters * - * Copyright (C) 2017 R-T Specialty, LLC. + * Copyright (C) 2017, 2018 R-T Specialty, LLC. * * This file is part of the Liza Data Collection Framework. * @@ -81,6 +81,7 @@ module.exports = function( type_map ) explain: formatter.VoidFormatter, dateTime: formatter.VoidFormatter, waitable: formatter.VoidFormatter, + checkbox: formatter.VoidFormatter, /* TODO:*/ state: formatter.VoidFormatter,