From 2fe417d7ac46b6d114e2d7118a1cd03af5fd23fa Mon Sep 17 00:00:00 2001 From: Rajesh Sharma Date: Mon, 12 Jul 2021 13:04:37 +0545 Subject: [PATCH 1/6] make roster group entries collapsible --- src/RosterGroupComponent.coffee | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/RosterGroupComponent.coffee b/src/RosterGroupComponent.coffee index e720d932..92a6f992 100644 --- a/src/RosterGroupComponent.coffee +++ b/src/RosterGroupComponent.coffee @@ -5,7 +5,7 @@ R = React.createElement formUtils = require './formUtils' TextExprsComponent = require './TextExprsComponent' - +cx = require 'classnames' # TODO Add focus() # Rosters are repeated information, such as asking questions about household members N times. @@ -23,6 +23,13 @@ module.exports = class RosterGroupComponent extends React.Component responseRow: PropTypes.object # ResponseRow object (for roster entry if in roster) schema: PropTypes.object.isRequired # Schema to use, including form + constructor: (props) -> + super(props) + + @state = { + collapsedEntries: [] # the indices that are collapsed + } + # Gets the id that the answer is stored under getAnswerId: -> # Prefer rosterId if specified, otherwise use id. @@ -67,6 +74,9 @@ module.exports = class RosterGroupComponent extends React.Component isChildVisible: (index, id) => return @props.isVisible("#{@getAnswerId()}.#{index}.#{id}") + handleToggle: (index) => + @setState(collapsedEntries: _.xor(@state.collapsedEntries, [index])) + renderName: -> R 'h4', key: "prompt", formUtils.localizeString(@props.rosterGroup.name, @context.locale) @@ -82,12 +92,24 @@ module.exports = class RosterGroupComponent extends React.Component renderEntry: (entry, index) -> # To avoid circularity ItemListComponent = require './ItemListComponent' + isCollapsed = @state.collapsedEntries.includes(index) + + bodyStyle = { + height: if isCollapsed then 0 else 'auto', + transition: 'height 0.25s ease-in' + padding: if isCollapsed then 0 else 15, + overflow: 'hidden' + } R 'div', key: index, className: "panel panel-default", - R 'div', key: "header", className: "panel-heading", style: { fontWeight: "bold" }, + R 'div', key: "header", className: "panel-heading", style: { fontWeight: "bold", position: "relative" }, "#{index + 1}. " @renderEntryTitle(entry, index) - R 'div', key: "body", className: "panel-body", + + R 'button', className: 'btn btn-link', style: {position: 'absolute', right: 0, top: 5}, onClick: @handleToggle.bind(null, index), + R 'span', className: cx('glyphicon', {'glyphicon-chevron-up': !isCollapsed, 'glyphicon-chevron-down': isCollapsed}) + + R 'div', key: "body", className: "panel-body", style: bodyStyle, if @props.rosterGroup.allowRemove R 'button', type: "button", style: { float: "right" }, className: "btn btn-sm btn-link", onClick: @handleRemove.bind(null, index), R 'span', className: "glyphicon glyphicon-remove" From 3840274dc154bcd8a2f7772ca92273bc7c9b537d Mon Sep 17 00:00:00 2001 From: Rajesh Sharma Date: Mon, 12 Jul 2021 13:05:02 +0545 Subject: [PATCH 2/6] build --- lib/AdminRegionDisplayComponent.js | 6 +-- lib/AdminRegionSelectComponent.js | 2 +- lib/DateTimePickerComponent.js | 2 +- lib/EntityDisplayComponent.js | 6 +-- lib/EntitySchemaBuilder.js | 4 +- lib/FormComponent.js | 2 +- lib/FormSchemaBuilder.js | 4 +- lib/GroupComponent.js | 2 +- lib/ImageDisplayComponent.js | 2 +- lib/ImageEditorComponent.js | 2 +- lib/ImagePopupComponent.js | 6 +-- lib/ImageThumbnailComponent.js | 2 +- lib/ImageUploaderModalComponent.js | 2 +- lib/ImagelistEditorComponent.js | 2 +- lib/InstructionsComponent.js | 2 +- lib/ItemListComponent.js | 2 +- lib/MatrixColumnCellComponent.js | 2 +- lib/QuestionComponent.js | 2 +- lib/ResponseAnswersComponent.js | 6 +-- lib/ResponseArchivesComponent.js | 2 +- lib/ResponseDataValidator.js | 4 +- lib/ResponseDisplayComponent.js | 2 +- lib/ResponseViewEditComponent.js | 2 +- lib/RosterGroupComponent.js | 53 +++++++++++++++++---- lib/RosterMatrixComponent.js | 2 +- lib/RotationAwareImageComponent.js | 6 +-- lib/SectionsComponent.js | 2 +- lib/TextExprsComponent.js | 2 +- lib/TimerComponent.js | 2 +- lib/answers/AdminRegionAnswerComponent.js | 2 +- lib/answers/AquagenxCBTAnswerComponent.js | 2 +- lib/answers/AquagenxCBTDisplayComponent.js | 2 +- lib/answers/AquagenxCBTPopupComponent.js | 2 +- lib/answers/BarcodeAnswerComponent.js | 2 +- lib/answers/CheckAnswerComponent.js | 2 +- lib/answers/DateAnswerComponent.js | 2 +- lib/answers/DropdownAnswerComponent.js | 2 +- lib/answers/EntityAnswerComponent.js | 2 +- lib/answers/ImageAnswerComponent.js | 2 +- lib/answers/ImagesAnswerComponent.js | 2 +- lib/answers/LikertAnswerComponent.js | 2 +- lib/answers/LocationAnswerComponent.js | 2 +- lib/answers/MatrixAnswerComponent.js | 2 +- lib/answers/MulticheckAnswerComponent.js | 2 +- lib/answers/NumberAnswerComponent.js | 2 +- lib/answers/RadioAnswerComponent.js | 2 +- lib/answers/SiteAnswerComponent.js | 2 +- lib/answers/SiteColumnAnswerComponent.js | 2 +- lib/answers/StopwatchAnswerComponent.js | 2 +- lib/answers/TextAnswerComponent.js | 2 +- lib/answers/TextListAnswerComponent.js | 2 +- lib/answers/UnitsAnswerComponent.js | 2 +- lib/checkbox.png | Bin 0 -> 677 bytes lib/demo.js | 2 +- lib/radio.png | Bin 0 -> 1233 bytes 55 files changed, 110 insertions(+), 73 deletions(-) create mode 100644 lib/checkbox.png create mode 100644 lib/radio.png diff --git a/lib/AdminRegionDisplayComponent.js b/lib/AdminRegionDisplayComponent.js index 9aa9bcdd..cca072c2 100644 --- a/lib/AdminRegionDisplayComponent.js +++ b/lib/AdminRegionDisplayComponent.js @@ -14,7 +14,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var AdminRegionDisplayComponent, AsyncLoadComponent, PropTypes, R, React, _; @@ -37,8 +37,8 @@ module.exports = AdminRegionDisplayComponent = function () { (0, _createClass2["default"])(AdminRegionDisplayComponent, [{ key: "isLoadNeeded", - // Override to determine if a load is needed. Not called on mounting - value: function isLoadNeeded(newProps, oldProps) { + value: // Override to determine if a load is needed. Not called on mounting + function isLoadNeeded(newProps, oldProps) { return newProps.value !== oldProps.value; } // Call callback with state changes diff --git a/lib/AdminRegionSelectComponent.js b/lib/AdminRegionSelectComponent.js index 356bfb03..91d1fbcf 100644 --- a/lib/AdminRegionSelectComponent.js +++ b/lib/AdminRegionSelectComponent.js @@ -18,7 +18,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var AdminRegionSelectComponent, AsyncLoadComponent, diff --git a/lib/DateTimePickerComponent.js b/lib/DateTimePickerComponent.js index f91d0476..ef97fa0b 100644 --- a/lib/DateTimePickerComponent.js +++ b/lib/DateTimePickerComponent.js @@ -16,7 +16,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var $, DateTimePickerComponent, diff --git a/lib/EntityDisplayComponent.js b/lib/EntityDisplayComponent.js index 9cf6adbf..cfa1c2ad 100644 --- a/lib/EntityDisplayComponent.js +++ b/lib/EntityDisplayComponent.js @@ -14,7 +14,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var AsyncLoadComponent, EntityDisplayComponent, PropTypes, R, React; PropTypes = require('prop-types'); @@ -35,8 +35,8 @@ module.exports = EntityDisplayComponent = function () { (0, _createClass2["default"])(EntityDisplayComponent, [{ key: "isLoadNeeded", - // Override to determine if a load is needed. Not called on mounting - value: function isLoadNeeded(newProps, oldProps) { + value: // Override to determine if a load is needed. Not called on mounting + function isLoadNeeded(newProps, oldProps) { return newProps.entityType !== oldProps.entityType || newProps.entityId !== oldProps.entityId || newProps.entityCode !== oldProps.entityCode; } // Call callback with state changes diff --git a/lib/EntitySchemaBuilder.js b/lib/EntitySchemaBuilder.js index f58698f3..f01fd009 100644 --- a/lib/EntitySchemaBuilder.js +++ b/lib/EntitySchemaBuilder.js @@ -18,12 +18,12 @@ module.exports = EntitySchemaBuilder = /*#__PURE__*/function () { (0, _createClass2["default"])(EntitySchemaBuilder, [{ key: "addEntities", - // Pass in: + value: // Pass in: // entityTypes: list of entity types objects // propFilter: optional filter function that takes a property and returns true to include, false to exclude // regionTypes: optional region types to add to schema // Returns updated schema - value: function addEntities(schema, entityTypes, propFilter, regionTypes) { + function addEntities(schema, entityTypes, propFilter, regionTypes) { var contents, entityType, i, j, labelColumn, len, len1, linksSection, ref, reverseJoins, rjTable, rjs, table, tableId; // Keep list of reverse join columns (one to many) to add later. table and column reverseJoins = []; // For each entity type, finding reverse joins diff --git a/lib/FormComponent.js b/lib/FormComponent.js index 23734eab..a71639a9 100644 --- a/lib/FormComponent.js +++ b/lib/FormComponent.js @@ -20,7 +20,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var DefaultValueApplier, FormComponent, diff --git a/lib/FormSchemaBuilder.js b/lib/FormSchemaBuilder.js index 906aed11..cd931bc2 100644 --- a/lib/FormSchemaBuilder.js +++ b/lib/FormSchemaBuilder.js @@ -25,8 +25,8 @@ module.exports = FormSchemaBuilder = /*#__PURE__*/function () { (0, _createClass2["default"])(FormSchemaBuilder, [{ key: "addForm", - // indicators is at least all indicators referenced in indicator calculations. Can be empty and indicator calculations will be omitted - value: function addForm(schema, form, cloneFormsDeprecated) { + value: // indicators is at least all indicators referenced in indicator calculations. Can be empty and indicator calculations will be omitted + function addForm(schema, form, cloneFormsDeprecated) { var isAdmin = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true; var indicators = arguments.length > 4 ? arguments[4] : undefined; var conditionsExprCompiler, contents, deploymentValues, jsonql, metadata, reverseJoins; diff --git a/lib/GroupComponent.js b/lib/GroupComponent.js index 64def59e..e2b450c8 100644 --- a/lib/GroupComponent.js +++ b/lib/GroupComponent.js @@ -14,7 +14,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var GroupComponent, PropTypes, R, React, _, formUtils; diff --git a/lib/ImageDisplayComponent.js b/lib/ImageDisplayComponent.js index 5ecfb470..69f466d0 100644 --- a/lib/ImageDisplayComponent.js +++ b/lib/ImageDisplayComponent.js @@ -16,7 +16,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var ImageDisplayComponent, ImagePopupComponent, diff --git a/lib/ImageEditorComponent.js b/lib/ImageEditorComponent.js index a075a863..9b740fc9 100644 --- a/lib/ImageEditorComponent.js +++ b/lib/ImageEditorComponent.js @@ -14,7 +14,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var ImageAnswerComponent, ImageEditorComponent, PropTypes, R, React; PropTypes = require('prop-types'); diff --git a/lib/ImagePopupComponent.js b/lib/ImagePopupComponent.js index f3e02362..243d78bd 100644 --- a/lib/ImagePopupComponent.js +++ b/lib/ImagePopupComponent.js @@ -14,7 +14,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var AsyncLoadComponent, ImagePopupComponent, ModalPopupComponent, PropTypes, R, React, RotationAwareImageComponent; PropTypes = require('prop-types'); @@ -37,8 +37,8 @@ module.exports = ImagePopupComponent = function () { (0, _createClass2["default"])(ImagePopupComponent, [{ key: "isLoadNeeded", - // Override to determine if a load is needed. Not called on mounting - value: function isLoadNeeded(newProps, oldProps) { + value: // Override to determine if a load is needed. Not called on mounting + function isLoadNeeded(newProps, oldProps) { return newProps.id !== oldProps.id; } // Call callback with state changes diff --git a/lib/ImageThumbnailComponent.js b/lib/ImageThumbnailComponent.js index 70b206fa..4800db4d 100644 --- a/lib/ImageThumbnailComponent.js +++ b/lib/ImageThumbnailComponent.js @@ -16,7 +16,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var AsyncLoadComponent, ImageThumbnailComponent, diff --git a/lib/ImageUploaderModalComponent.js b/lib/ImageUploaderModalComponent.js index e1c00415..123be3af 100644 --- a/lib/ImageUploaderModalComponent.js +++ b/lib/ImageUploaderModalComponent.js @@ -16,7 +16,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var ImageUploaderModalComponent, ModalPopupComponent, diff --git a/lib/ImagelistEditorComponent.js b/lib/ImagelistEditorComponent.js index 4eff1723..93e0dcc8 100644 --- a/lib/ImagelistEditorComponent.js +++ b/lib/ImagelistEditorComponent.js @@ -14,7 +14,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var ImagelistEditorComponent, ImagesAnswerComponent, PropTypes, R, React; PropTypes = require('prop-types'); diff --git a/lib/InstructionsComponent.js b/lib/InstructionsComponent.js index c844112e..b134be89 100644 --- a/lib/InstructionsComponent.js +++ b/lib/InstructionsComponent.js @@ -14,7 +14,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var InstructionsComponent, PropTypes, R, React, TextExprsComponent, _, formUtils; diff --git a/lib/ItemListComponent.js b/lib/ItemListComponent.js index 454bc85e..0a72235d 100644 --- a/lib/ItemListComponent.js +++ b/lib/ItemListComponent.js @@ -20,7 +20,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var ItemListComponent, PropTypes, diff --git a/lib/MatrixColumnCellComponent.js b/lib/MatrixColumnCellComponent.js index d8ca3a98..f68c2ba1 100644 --- a/lib/MatrixColumnCellComponent.js +++ b/lib/MatrixColumnCellComponent.js @@ -16,7 +16,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var DateAnswerComponent, MatrixColumnCellComponent, diff --git a/lib/QuestionComponent.js b/lib/QuestionComponent.js index 3783df4f..9e63075d 100644 --- a/lib/QuestionComponent.js +++ b/lib/QuestionComponent.js @@ -20,7 +20,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var AdminRegionAnswerComponent, AnswerValidator, diff --git a/lib/ResponseAnswersComponent.js b/lib/ResponseAnswersComponent.js index f0568933..038638ad 100644 --- a/lib/ResponseAnswersComponent.js +++ b/lib/ResponseAnswersComponent.js @@ -14,7 +14,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var AdminRegionDisplayComponent, AquagenxCBTDisplayComponent, AsyncLoadComponent, CalculationsDisplayComponent, CascadingListDisplayComponent, CascadingRefDisplayComponent, EntityDisplayComponent, ImageDisplayComponent, PropTypes, R, React, ResponseAnswersComponent, ResponseRow, TextExprsComponent, VisibilityCalculator, _, ezlocalize, formUtils, moment, ui; @@ -51,8 +51,8 @@ module.exports = ResponseAnswersComponent = function () { (0, _createClass2["default"])(ResponseAnswersComponent, [{ key: "isLoadNeeded", - // Check if form design or data are different - value: function isLoadNeeded(newProps, oldProps) { + value: // Check if form design or data are different + function isLoadNeeded(newProps, oldProps) { return !_.isEqual(newProps.formDesign, oldProps.formDesign) || !_.isEqual(newProps.data, oldProps.data); } // Call callback with state changes diff --git a/lib/ResponseArchivesComponent.js b/lib/ResponseArchivesComponent.js index 0a4af851..6a1282e8 100644 --- a/lib/ResponseArchivesComponent.js +++ b/lib/ResponseArchivesComponent.js @@ -16,7 +16,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var PropTypes, R, diff --git a/lib/ResponseDataValidator.js b/lib/ResponseDataValidator.js index e61ba6f6..412be3f0 100644 --- a/lib/ResponseDataValidator.js +++ b/lib/ResponseDataValidator.js @@ -22,7 +22,7 @@ module.exports = ResponseDataValidator = /*#__PURE__*/function () { (0, _createClass2["default"])(ResponseDataValidator, [{ key: "validate", - // It returns null if everything is fine + value: // It returns null if everything is fine // It makes sure required questions are properly answered // It checks custom validations // It returns the id of the question that caused the error, the error and a message which is includes the error and question @@ -31,7 +31,7 @@ module.exports = ResponseDataValidator = /*#__PURE__*/function () { // RosterMatrix -> matrixId.index.columnId // RosterGroup -> rosterGroupId.index.questionId // QuestionMatrix -> matrixId.itemId.columnId - value: function validate(formDesign, visibilityStructure, data, schema, responseRow) { + function validate(formDesign, visibilityStructure, data, schema, responseRow) { return this.validateParentItem(formDesign, visibilityStructure, data, schema, responseRow, ""); } // Validates an parent row // keyPrefix: the part before the row id in the visibility structure. For rosters diff --git a/lib/ResponseDisplayComponent.js b/lib/ResponseDisplayComponent.js index 9b3408e6..c2c40238 100644 --- a/lib/ResponseDisplayComponent.js +++ b/lib/ResponseDisplayComponent.js @@ -16,7 +16,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var $, ModalPopupComponent, diff --git a/lib/ResponseViewEditComponent.js b/lib/ResponseViewEditComponent.js index 94d1279f..84827b3d 100644 --- a/lib/ResponseViewEditComponent.js +++ b/lib/ResponseViewEditComponent.js @@ -16,7 +16,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var FormComponent, PropTypes, diff --git a/lib/RosterGroupComponent.js b/lib/RosterGroupComponent.js index 0567d715..98227b97 100644 --- a/lib/RosterGroupComponent.js +++ b/lib/RosterGroupComponent.js @@ -20,7 +20,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var PropTypes, R, @@ -28,6 +28,7 @@ var PropTypes, RosterGroupComponent, TextExprsComponent, _, + cx, formUtils, boundMethodCheck = function boundMethodCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { @@ -40,7 +41,8 @@ _ = require('lodash'); React = require('react'); R = React.createElement; formUtils = require('./formUtils'); -TextExprsComponent = require('./TextExprsComponent'); // TODO Add focus() +TextExprsComponent = require('./TextExprsComponent'); +cx = require('classnames'); // TODO Add focus() // Rosters are repeated information, such as asking questions about household members N times. // A roster group is a group of questions that is asked once for each roster entry @@ -50,11 +52,11 @@ module.exports = RosterGroupComponent = function () { var _super = _createSuper(RosterGroupComponent); - function RosterGroupComponent() { + function RosterGroupComponent(props) { var _this; (0, _classCallCheck2["default"])(this, RosterGroupComponent); - _this = _super.apply(this, arguments); // Propagate an answer change to the onDataChange + _this = _super.call(this, props); // Propagate an answer change to the onDataChange _this.handleAnswerChange = _this.handleAnswerChange.bind((0, _assertThisInitialized2["default"])(_this)); // Handles a change in data of a specific entry of the roster @@ -62,6 +64,11 @@ module.exports = RosterGroupComponent = function () { _this.handleAdd = _this.handleAdd.bind((0, _assertThisInitialized2["default"])(_this)); _this.handleRemove = _this.handleRemove.bind((0, _assertThisInitialized2["default"])(_this)); _this.isChildVisible = _this.isChildVisible.bind((0, _assertThisInitialized2["default"])(_this)); + _this.handleToggle = _this.handleToggle.bind((0, _assertThisInitialized2["default"])(_this)); + _this.state = { + collapsedEntries: [] // the indices that are collapsed + + }; return _this; } // Gets the id that the answer is stored under @@ -178,6 +185,14 @@ module.exports = RosterGroupComponent = function () { boundMethodCheck(this, RosterGroupComponent); return this.props.isVisible("".concat(this.getAnswerId(), ".").concat(index, ".").concat(id)); } + }, { + key: "handleToggle", + value: function handleToggle(index) { + boundMethodCheck(this, RosterGroupComponent); + return this.setState({ + collapsedEntries: _.xor(this.state.collapsedEntries, [index]) + }); + } }, { key: "renderName", value: function renderName() { @@ -201,9 +216,16 @@ module.exports = RosterGroupComponent = function () { value: function renderEntry(entry, index) { var _this2 = this; - var ItemListComponent; // To avoid circularity + var ItemListComponent, bodyStyle, isCollapsed; // To avoid circularity ItemListComponent = require('./ItemListComponent'); + isCollapsed = this.state.collapsedEntries.includes(index); + bodyStyle = { + height: isCollapsed ? 0 : 'auto', + transition: 'height 0.25s ease-in', + padding: isCollapsed ? 0 : 15, + overflow: 'hidden' + }; return R('div', { key: index, className: "panel panel-default" @@ -211,11 +233,26 @@ module.exports = RosterGroupComponent = function () { key: "header", className: "panel-heading", style: { - fontWeight: "bold" + fontWeight: "bold", + position: "relative" } - }, "".concat(index + 1, ". "), this.renderEntryTitle(entry, index)), R('div', { + }, "".concat(index + 1, ". "), this.renderEntryTitle(entry, index), R('button', { + className: 'btn btn-link', + style: { + position: 'absolute', + right: 0, + top: 5 + }, + onClick: this.handleToggle.bind(null, index) + }, R('span', { + className: cx('glyphicon', { + 'glyphicon-chevron-up': !isCollapsed, + 'glyphicon-chevron-down': isCollapsed + }) + }))), R('div', { key: "body", - className: "panel-body" + className: "panel-body", + style: bodyStyle }, this.props.rosterGroup.allowRemove ? R('button', { type: "button", style: { diff --git a/lib/RosterMatrixComponent.js b/lib/RosterMatrixComponent.js index 61ffe1f6..aaedca2d 100644 --- a/lib/RosterMatrixComponent.js +++ b/lib/RosterMatrixComponent.js @@ -16,7 +16,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var MatrixColumnCellComponent, PropTypes, diff --git a/lib/RotationAwareImageComponent.js b/lib/RotationAwareImageComponent.js index d6e79243..5e7d4344 100644 --- a/lib/RotationAwareImageComponent.js +++ b/lib/RotationAwareImageComponent.js @@ -14,7 +14,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var AsyncLoadComponent, PropTypes, R, React, RotationAwareImageComponent, classNames; PropTypes = require('prop-types'); @@ -36,8 +36,8 @@ module.exports = RotationAwareImageComponent = function () { (0, _createClass2["default"])(RotationAwareImageComponent, [{ key: "isLoadNeeded", - // Override to determine if a load is needed. Not called on mounting - value: function isLoadNeeded(newProps, oldProps) { + value: // Override to determine if a load is needed. Not called on mounting + function isLoadNeeded(newProps, oldProps) { return newProps.image.id !== oldProps.image.id || newProps.thumbnail !== oldProps.thumbnail; } // Call callback with state changes diff --git a/lib/SectionsComponent.js b/lib/SectionsComponent.js index e28ca48b..99e59553 100644 --- a/lib/SectionsComponent.js +++ b/lib/SectionsComponent.js @@ -20,7 +20,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var ItemListComponent, PropTypes, diff --git a/lib/TextExprsComponent.js b/lib/TextExprsComponent.js index 296a482c..ec2df7fb 100644 --- a/lib/TextExprsComponent.js +++ b/lib/TextExprsComponent.js @@ -14,7 +14,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var ExprUtils, Markdown, PromiseExprEvaluator, PropTypes, R, React, TextExprsComponent, _, async, d3Format, formUtils; diff --git a/lib/TimerComponent.js b/lib/TimerComponent.js index 98f30dea..933c5d76 100644 --- a/lib/TimerComponent.js +++ b/lib/TimerComponent.js @@ -18,7 +18,7 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var PropTypes, R, diff --git a/lib/answers/AdminRegionAnswerComponent.js b/lib/answers/AdminRegionAnswerComponent.js index 89babeb3..15ef8f32 100644 --- a/lib/answers/AdminRegionAnswerComponent.js +++ b/lib/answers/AdminRegionAnswerComponent.js @@ -16,7 +16,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var AdminRegionAnswerComponent, AdminRegionSelectComponent, diff --git a/lib/answers/AquagenxCBTAnswerComponent.js b/lib/answers/AquagenxCBTAnswerComponent.js index 92e731aa..6e112ecf 100644 --- a/lib/answers/AquagenxCBTAnswerComponent.js +++ b/lib/answers/AquagenxCBTAnswerComponent.js @@ -16,7 +16,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var AquagenxCBTAnswerComponent, AquagenxCBTDisplayComponent, diff --git a/lib/answers/AquagenxCBTDisplayComponent.js b/lib/answers/AquagenxCBTDisplayComponent.js index 9e4b3dd6..0646ad8a 100644 --- a/lib/answers/AquagenxCBTDisplayComponent.js +++ b/lib/answers/AquagenxCBTDisplayComponent.js @@ -16,7 +16,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var AquagenxCBTDisplayComponent, AquagenxCBTDisplaySVGString, diff --git a/lib/answers/AquagenxCBTPopupComponent.js b/lib/answers/AquagenxCBTPopupComponent.js index 0529737d..81e759b2 100644 --- a/lib/answers/AquagenxCBTPopupComponent.js +++ b/lib/answers/AquagenxCBTPopupComponent.js @@ -16,7 +16,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var $, AquagenxCBTPopupComponent, diff --git a/lib/answers/BarcodeAnswerComponent.js b/lib/answers/BarcodeAnswerComponent.js index 6ab05211..478adbd7 100644 --- a/lib/answers/BarcodeAnswerComponent.js +++ b/lib/answers/BarcodeAnswerComponent.js @@ -16,7 +16,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var BarcodeAnswerComponent, PropTypes, diff --git a/lib/answers/CheckAnswerComponent.js b/lib/answers/CheckAnswerComponent.js index 444fa477..a222562e 100644 --- a/lib/answers/CheckAnswerComponent.js +++ b/lib/answers/CheckAnswerComponent.js @@ -16,7 +16,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var CheckAnswerComponent, PropTypes, diff --git a/lib/answers/DateAnswerComponent.js b/lib/answers/DateAnswerComponent.js index 6d3cf071..6d59bd9e 100644 --- a/lib/answers/DateAnswerComponent.js +++ b/lib/answers/DateAnswerComponent.js @@ -16,7 +16,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var DateAnswerComponent, DateTimePickerComponent, diff --git a/lib/answers/DropdownAnswerComponent.js b/lib/answers/DropdownAnswerComponent.js index 02bc588b..b9f4d1d2 100644 --- a/lib/answers/DropdownAnswerComponent.js +++ b/lib/answers/DropdownAnswerComponent.js @@ -16,7 +16,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var DropdownAnswerComponent, PropTypes, diff --git a/lib/answers/EntityAnswerComponent.js b/lib/answers/EntityAnswerComponent.js index 53236452..ecfd85c3 100644 --- a/lib/answers/EntityAnswerComponent.js +++ b/lib/answers/EntityAnswerComponent.js @@ -16,7 +16,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var AsyncLoadComponent, EntityAnswerComponent, diff --git a/lib/answers/ImageAnswerComponent.js b/lib/answers/ImageAnswerComponent.js index 0d568bee..5bfcbe7c 100644 --- a/lib/answers/ImageAnswerComponent.js +++ b/lib/answers/ImageAnswerComponent.js @@ -16,7 +16,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var ImageAnswerComponent, ImagePopupComponent, diff --git a/lib/answers/ImagesAnswerComponent.js b/lib/answers/ImagesAnswerComponent.js index 19b05c99..165423e9 100644 --- a/lib/answers/ImagesAnswerComponent.js +++ b/lib/answers/ImagesAnswerComponent.js @@ -16,7 +16,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var ImagePopupComponent, ImagesAnswerComponent, diff --git a/lib/answers/LikertAnswerComponent.js b/lib/answers/LikertAnswerComponent.js index 9eee8db1..1ffe5151 100644 --- a/lib/answers/LikertAnswerComponent.js +++ b/lib/answers/LikertAnswerComponent.js @@ -18,7 +18,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var LikertAnswerComponent, PropTypes, diff --git a/lib/answers/LocationAnswerComponent.js b/lib/answers/LocationAnswerComponent.js index 91e85315..7a87ddae 100644 --- a/lib/answers/LocationAnswerComponent.js +++ b/lib/answers/LocationAnswerComponent.js @@ -16,7 +16,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var LocationAnswerComponent, LocationEditorComponent, diff --git a/lib/answers/MatrixAnswerComponent.js b/lib/answers/MatrixAnswerComponent.js index 48e667bf..ef9fcf60 100644 --- a/lib/answers/MatrixAnswerComponent.js +++ b/lib/answers/MatrixAnswerComponent.js @@ -16,7 +16,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var MatrixAnswerComponent, MatrixColumnCellComponent, diff --git a/lib/answers/MulticheckAnswerComponent.js b/lib/answers/MulticheckAnswerComponent.js index eafb442b..568483cb 100644 --- a/lib/answers/MulticheckAnswerComponent.js +++ b/lib/answers/MulticheckAnswerComponent.js @@ -16,7 +16,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var MulticheckAnswerComponent, PropTypes, diff --git a/lib/answers/NumberAnswerComponent.js b/lib/answers/NumberAnswerComponent.js index 5465da6e..51e6ee2c 100644 --- a/lib/answers/NumberAnswerComponent.js +++ b/lib/answers/NumberAnswerComponent.js @@ -14,7 +14,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var NumberAnswerComponent, PropTypes, R, React, _, ui; diff --git a/lib/answers/RadioAnswerComponent.js b/lib/answers/RadioAnswerComponent.js index 24d1a3e3..bd42333a 100644 --- a/lib/answers/RadioAnswerComponent.js +++ b/lib/answers/RadioAnswerComponent.js @@ -16,7 +16,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var PropTypes, R, diff --git a/lib/answers/SiteAnswerComponent.js b/lib/answers/SiteAnswerComponent.js index ab218c40..ee8bb993 100644 --- a/lib/answers/SiteAnswerComponent.js +++ b/lib/answers/SiteAnswerComponent.js @@ -16,7 +16,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var EntityDisplayComponent, PropTypes, diff --git a/lib/answers/SiteColumnAnswerComponent.js b/lib/answers/SiteColumnAnswerComponent.js index c775c1c3..e27526fd 100644 --- a/lib/answers/SiteColumnAnswerComponent.js +++ b/lib/answers/SiteColumnAnswerComponent.js @@ -16,7 +16,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var EntityDisplayComponent, PropTypes, diff --git a/lib/answers/StopwatchAnswerComponent.js b/lib/answers/StopwatchAnswerComponent.js index 8e62ea39..188d5311 100644 --- a/lib/answers/StopwatchAnswerComponent.js +++ b/lib/answers/StopwatchAnswerComponent.js @@ -18,7 +18,7 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var PropTypes, R, diff --git a/lib/answers/TextAnswerComponent.js b/lib/answers/TextAnswerComponent.js index 22271e10..5129eb6e 100644 --- a/lib/answers/TextAnswerComponent.js +++ b/lib/answers/TextAnswerComponent.js @@ -16,7 +16,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var PropTypes, R, diff --git a/lib/answers/TextListAnswerComponent.js b/lib/answers/TextListAnswerComponent.js index 0e9aba1d..7b887c09 100644 --- a/lib/answers/TextListAnswerComponent.js +++ b/lib/answers/TextListAnswerComponent.js @@ -16,7 +16,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var PropTypes, R, diff --git a/lib/answers/UnitsAnswerComponent.js b/lib/answers/UnitsAnswerComponent.js index 6e0647dd..e7c66dec 100644 --- a/lib/answers/UnitsAnswerComponent.js +++ b/lib/answers/UnitsAnswerComponent.js @@ -16,7 +16,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var PropTypes, R, diff --git a/lib/checkbox.png b/lib/checkbox.png new file mode 100644 index 0000000000000000000000000000000000000000..521b897592cb985387fc14866a24c45c81fa6822 GIT binary patch literal 677 zcmV;W0$TlvP)NC4?00006VoOIv0RI60 z0RN!9r;`8x010qNS#tmY3ljhU3ljkVnw%H_000McNliru-vkl^2R5RSfQbMA02y>e zSad^gZEa<4bO1wgWnpw>WFU8GbZ8()Nlj2!fese{00Iq3L_t(&-tF2wXcJ)^$MNrT zdGlgS3`DCjD(a%4U3?h?*D4ed*NB3h928mz#laE~6}Kul6$jBp#4gpLqC-IkA=Fh0 zX+a1{L@lAoHJ6y&or|WVX%hp%#s3G6lR9@8Ut_Je5m{!LhG{U+_(t-|1ptOm#kp~I5W8xil)~c= zZayNXwzfVR)1aJPM1pM0Bu{KdBeUQ^s|EbBgdtaQKpj#9$z0pt>)S1F}Zo|a|Kbqk4(wCMg-G254J$e+p{;d~#VX46LS8tnb zUDw;Dq{6Ybkk%ltA75Z6sp*$Y-ha?mI5Rg-I%nbwgu3sez`y|_@zczF%5ru57R6!_ zfaPp~hqE8??}}l$eBFaAmk&J{CVXg+g|BrIV=0!i1@1nX#R)}mJbG`Z-{aJ&8LQOF zMH*%qJrctm+TC&EZu%yot~_WvA_RZ0M_qZkp0$pTEB+>+@2CG4pTDbXzK+^$00000 LNkvXXu0mjf>`)}~ literal 0 HcmV?d00001 diff --git a/lib/demo.js b/lib/demo.js index 50ea6ae4..d73b7ac2 100644 --- a/lib/demo.js +++ b/lib/demo.js @@ -16,7 +16,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var CustomTablesetSchemaBuilder, DemoComponent, diff --git a/lib/radio.png b/lib/radio.png new file mode 100644 index 0000000000000000000000000000000000000000..72688d3807840e0d4ae36bfc8c952be9415390d4 GIT binary patch literal 1233 zcmV;?1TOoDP)NC4?00006VoOIv0RI60 z0RN!9r;`8x010qNS#tmY3ljhU3ljkVnw%H_000McNliru-vkl^4mNXBJHP+{02y>e zSad^gZEa<4bO1wgWnpw>WFU8GbZ8()Nlj2!fese{00cQnL_t(&-tC%AXdG1>z<=+} z?3gBfPtZ~p)P`?$;#Jb);Q zj>K_XU0q!rYc`uB0J&UlzE~{INGT_EU7uRtNA%u=VYm-CJ2y9XkVh~&Iyw!UR7%Zm z5c$4;#C6@t<>h6AO)xMp5ZJa|HBED>D+9D3WeFO2*5PWseC>^R;g5`bGh6@qsZlQR4SF}d_F(cS@|3Gquwng48v*^ zMPoq_i~tyhF|X_Tj8bZ{SCEmBk&%&+k&%&+k&%&+k&%&+k&%&+k&%&+k@0^ZfQ`RE zC%%3Kv+xcL_ay|+0g&(~dHYxVwXZn$)=v)--9N%GabYjUz!_=_2Os(Q^6)gl@`s#z z``Sj)#D%>i`j7Z4g>HvNytRbRTJF--?Ub0@Wo{q3brUL?F;0*QKsl@vi zfQk`Q)|;3{T0%c)Qj2oj3uO9^<$%9Zpfq#_I4n4R@pU5aTavgddCHcQa}h?X!TzUr z0`S}4iv(JpT2tpAw|%0+azIGXtv7T`XPngrw2w3FG-ArRm_yI*VxI%Mhx#PFvIDz^P_dt;Ftl9yn!VO8BT<_LMNS0iWNZEYyo&f$s6{$+^;TLV%KrTid;R&fKf%j$eEkqi~G4 v^&&~Mr=8XxNbNeo+9f_8{{_%G5`g~zRm!*TT53TU00000NkvXXu0mjfW6nM^ literal 0 HcmV?d00001 From f6447622ea032fa156581a322944ebb77140ae2b Mon Sep 17 00:00:00 2001 From: Rajesh Sharma Date: Fri, 16 Jul 2021 12:42:31 +0545 Subject: [PATCH 3/6] dont coalesce value to 0 --- lib/answers/ValidationCompiler.js | 7 ++++- src/answers/ValidationCompiler.coffee | 5 +++- test/ResponseDataValidatorTests.coffee | 2 +- test/answers/AnswerValidatorTests.coffee | 37 ++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 3 deletions(-) diff --git a/lib/answers/ValidationCompiler.js b/lib/answers/ValidationCompiler.js index 13704cf2..380e0b1b 100644 --- a/lib/answers/ValidationCompiler.js +++ b/lib/answers/ValidationCompiler.js @@ -86,7 +86,12 @@ module.exports = ValidationCompiler = /*#__PURE__*/function () { case "range": return function (answer) { var value; - value = answer != null && answer.value != null ? answer.value : 0; // For units question, get quantity + value = answer != null ? answer.value : null; + + if (value === null || value === void 0) { + return null; + } // For units question, get quantity + if (value.quantity != null) { value = value.quantity; diff --git a/src/answers/ValidationCompiler.coffee b/src/answers/ValidationCompiler.coffee index f1ca5485..9a618891 100644 --- a/src/answers/ValidationCompiler.coffee +++ b/src/answers/ValidationCompiler.coffee @@ -42,7 +42,10 @@ module.exports = class ValidationCompiler return @compileValidationMessage(val) when "range" return (answer) => - value = if answer? and answer.value? then answer.value else 0 + value = if answer? then answer.value else null + + if value == null or value == undefined + return null # For units question, get quantity if value.quantity? value = value.quantity diff --git a/test/ResponseDataValidatorTests.coffee b/test/ResponseDataValidatorTests.coffee index 137540cf..68eca4a1 100644 --- a/test/ResponseDataValidatorTests.coffee +++ b/test/ResponseDataValidatorTests.coffee @@ -320,7 +320,7 @@ describe "ResponseDataValidator", -> "_base": "en" } }] } - { _id: "b", _type: "NumberColumnQuestion", text: { en: "Age" }, decimal: false } + { _id: "b", _type: "NumberColumnQuestion", text: { en: "Age" }, decimal: false, validations: [ { message: { en: "Wrong" }, op: "range", rhs: { literal: { max: 100, min: 10 }}}] } { _id: "c", _type: "CheckColumnQuestion", text: { en: "Present" } } { _id: "d", _type: "DropdownColumnQuestion", text: { en: "Gender" }, choices: [{ label: { en: "Male"}, id: "male" }, { label: { en: "Female"}, id: "female" }] } { _id: "e", _type: "UnitsColumnQuestion", text: { en: "Unit" }, units: [{ label: { en: "CM"}, id: "cm" }, { label: { en: "INCH"}, id: "inch" }] } diff --git a/test/answers/AnswerValidatorTests.coffee b/test/answers/AnswerValidatorTests.coffee index d789ba71..20713823 100644 --- a/test/answers/AnswerValidatorTests.coffee +++ b/test/answers/AnswerValidatorTests.coffee @@ -412,6 +412,43 @@ describe 'AnswerValidator', -> assert.equal result, null describe "validateMatrixQuestion", -> + it "allows non-valid blank answer if not required", -> + question = { + "_id": "q1", + "_type": "MatrixQuestion", + "columns": [ + { "_id": "c1", "_type": "TextColumnQuestion", "required": false}, + { + "_id": "c2", + "_type": "NumberColumnQuestion", + "decimal": false, + "required": false, + "validations": [ {"message": { "undefined": "Wrong" }, "op": "range", "rhs": { "literal": { "max": "10", "min": "0"}}}] + }, + { + "_id": "c3", + "_type": "NumberColumnQuestion", + "decimal": false, + "required": false, + "validations": [ { "message": { "undefined": "Wrong" }, "op": "range", "rhs": { "literal": { "max": "100", "min": "10" }}}] + } + ], + "items": [ { "id": "ts39QF6" }, { "id": "dWY5r5E" }], + "required": true, + } + + answer = { + value: { + "ts39QF6": { + "c1": {value: "as"} + "c2": {value: null} + "c3": {value: null} + } + } + } + result = await @answerValidator.validate(question, answer) + assert.equal result, null + it "passes if ok", -> question = { _type: "MatrixQuestion" From a48e69bf33b4f94e680b72844bc435917704bdfb Mon Sep 17 00:00:00 2001 From: Rajesh Sharma Date: Thu, 29 Jul 2021 16:00:15 +0545 Subject: [PATCH 4/6] show matrix error message --- lib/MatrixColumnCellComponent.js | 8 +++++++- lib/answers/MatrixAnswerComponent.js | 1 + src/MatrixColumnCellComponent.coffee | 3 +++ src/answers/MatrixAnswerComponent.coffee | 1 + 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/MatrixColumnCellComponent.js b/lib/MatrixColumnCellComponent.js index f68c2ba1..4b0cfd50 100644 --- a/lib/MatrixColumnCellComponent.js +++ b/lib/MatrixColumnCellComponent.js @@ -221,7 +221,11 @@ module.exports = MatrixColumnCellComponent = function () { return R('td', { className: className - }, elem); + }, elem, this.props.invalid && this.props.invalidMessage !== null ? R('small', { + style: { + color: '#C43B1D' + } + }, this.props.invalidMessage) : void 0); } }]); return MatrixColumnCellComponent; @@ -241,6 +245,8 @@ module.exports = MatrixColumnCellComponent = function () { // Called with new answer of cell invalid: PropTypes.bool, // True if invalid + invalidMessage: PropTypes.string, + // Validation message schema: PropTypes.object.isRequired // Schema to use, including form }; diff --git a/lib/answers/MatrixAnswerComponent.js b/lib/answers/MatrixAnswerComponent.js index ef9fcf60..b2796db9 100644 --- a/lib/answers/MatrixAnswerComponent.js +++ b/lib/answers/MatrixAnswerComponent.js @@ -172,6 +172,7 @@ module.exports = MatrixAnswerComponent = function () { answer: cellAnswer, onAnswerChange: this.handleCellChange.bind(null, item, column), invalid: invalid != null, + invalidMessage: invalid || null, schema: this.props.schema }); } diff --git a/src/MatrixColumnCellComponent.coffee b/src/MatrixColumnCellComponent.coffee index 2d8cdae1..7ad563ba 100644 --- a/src/MatrixColumnCellComponent.coffee +++ b/src/MatrixColumnCellComponent.coffee @@ -20,6 +20,7 @@ module.exports = class MatrixColumnCellComponent extends React.Component answer: PropTypes.object # Answer of the cell onAnswerChange: PropTypes.func.isRequired # Called with new answer of cell invalid: PropTypes.bool # True if invalid + invalidMessage: PropTypes.string # Validation message schema: PropTypes.object.isRequired # Schema to use, including form @contextTypes: @@ -102,3 +103,5 @@ module.exports = class MatrixColumnCellComponent extends React.Component return R 'td', className: className, elem + if @props.invalid and @props.invalidMessage != null + R 'small', style: {color: '#C43B1D'}, @props.invalidMessage diff --git a/src/answers/MatrixAnswerComponent.coffee b/src/answers/MatrixAnswerComponent.coffee index bee1d6a3..f4beaca6 100644 --- a/src/answers/MatrixAnswerComponent.coffee +++ b/src/answers/MatrixAnswerComponent.coffee @@ -138,6 +138,7 @@ module.exports = class MatrixAnswerComponent extends React.Component answer: cellAnswer onAnswerChange: @handleCellChange.bind(null, item, column) invalid: invalid? + invalidMessage: invalid or null schema: @props.schema renderItem: (item, index) -> From a588a3d38d8af564ae4d1341b8ac3c0a57c0fdf2 Mon Sep 17 00:00:00 2001 From: Clayton Grassick Date: Mon, 16 Aug 2021 15:13:02 -0500 Subject: [PATCH 5/6] Prevent stack overflow https://github.com/mWater/mwater-portal/issues/1312 --- lib/VisibilityCalculator.js | 6 ++++-- src/VisibilityCalculator.coffee | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/VisibilityCalculator.js b/lib/VisibilityCalculator.js index 92621a36..936284e1 100644 --- a/lib/VisibilityCalculator.js +++ b/lib/VisibilityCalculator.js @@ -69,8 +69,10 @@ module.exports = VisibilityCalculator = /*#__PURE__*/function () { } return async.each(item.contents, function (subitem, cb) { - return _this.processItem(subitem, isVisible === false, data, responseRow, visibilityStructure, prefix, function () { - return _.defer(cb); + return _.defer(function () { + return _this.processItem(subitem, isVisible === false, data, responseRow, visibilityStructure, prefix, function () { + return _.defer(cb); + }); }); }, callback); }; // Always visible if no condition has been set diff --git a/src/VisibilityCalculator.coffee b/src/VisibilityCalculator.coffee index ab140098..3dc830b7 100644 --- a/src/VisibilityCalculator.coffee +++ b/src/VisibilityCalculator.coffee @@ -48,10 +48,11 @@ module.exports = class VisibilityCalculator visibilityStructure[prefix + item._id] = isVisible async.each item.contents, (subitem, cb) => - @processItem(subitem, isVisible == false, data, responseRow, visibilityStructure, prefix, -> _.defer(cb)) + _.defer(() => + @processItem(subitem, isVisible == false, data, responseRow, visibilityStructure, prefix, -> _.defer(cb)) + ) , callback - # Always visible if no condition has been set if forceToInvisible isVisible = false From ba6f9a7d8cf87c1a126c8b8cf14a5cf5ecf07baf Mon Sep 17 00:00:00 2001 From: Clayton Grassick Date: Tue, 17 Aug 2021 14:25:26 -0500 Subject: [PATCH 6/6] Optimize response row --- lib/ResponseRow.d.ts | 3 +++ lib/ResponseRow.js | 6 +++++- src/ResponseRow.ts | 11 ++++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/ResponseRow.d.ts b/lib/ResponseRow.d.ts index 0a448d59..4dbf410d 100644 --- a/lib/ResponseRow.d.ts +++ b/lib/ResponseRow.d.ts @@ -1,3 +1,4 @@ +import { VisibilityStructure } from './VisibilityCalculator'; import EntityRow from './EntityRow'; import { PromiseExprEvaluatorRow, Schema, Row } from 'mwater-expressions'; import { ResponseData } from './response'; @@ -30,6 +31,8 @@ export default class ResponseRow implements PromiseExprEvaluatorRow { submittedOn?: string; /** Optional code */ code?: string; + /** Cached visibility structure, needed when visible is queried */ + visibilityStructure?: VisibilityStructure; constructor(options: { /** data of entire response */ responseData: ResponseData; diff --git a/lib/ResponseRow.js b/lib/ResponseRow.js index 3f63193a..e7115f25 100644 --- a/lib/ResponseRow.js +++ b/lib/ResponseRow.js @@ -108,6 +108,9 @@ class ResponseRow { } // Visible if (parts.length === 3 && parts[2] === "visible") { + if (this.visibilityStructure) { + return this.visibilityStructure[parts[1]]; + } const visibilityCalculator = new VisibilityCalculator_1.default(this.formDesign, this.schema); const visibilityStructure = yield new Promise((resolve, reject) => { visibilityCalculator.createVisibilityStructure(this.responseData, this, (error, visibilityStructure) => { @@ -119,7 +122,8 @@ class ResponseRow { } }); }); - return visibilityStructure[parts[1]]; + this.visibilityStructure = visibilityStructure; + return this.visibilityStructure[parts[1]]; } // Simple values if (parts.length === 3 && parts[2] === "value") { diff --git a/src/ResponseRow.ts b/src/ResponseRow.ts index 74ebb0cd..d01769d2 100644 --- a/src/ResponseRow.ts +++ b/src/ResponseRow.ts @@ -49,6 +49,9 @@ export default class ResponseRow implements PromiseExprEvaluatorRow { /** Optional code */ code?: string + /** Cached visibility structure, needed when visible is queried */ + visibilityStructure?: VisibilityStructure + // Create a response row from a response data object. // Options: // responseData: data of entire response @@ -184,6 +187,10 @@ export default class ResponseRow implements PromiseExprEvaluatorRow { // Visible if (parts.length === 3 && parts[2] === "visible") { + if (this.visibilityStructure) { + return this.visibilityStructure[parts[1]] + } + const visibilityCalculator = new VisibilityCalculator(this.formDesign, this.schema) const visibilityStructure = await new Promise((resolve, reject) => { visibilityCalculator.createVisibilityStructure(this.responseData, this, (error, visibilityStructure) => { @@ -195,7 +202,9 @@ export default class ResponseRow implements PromiseExprEvaluatorRow { } }) }) - return visibilityStructure[parts[1]] + this.visibilityStructure = visibilityStructure + + return this.visibilityStructure[parts[1]] } // Simple values