diff --git a/package.json b/package.json index c5bb570..580b8db 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@indec/form-builder", - "version": "1.7.0", + "version": "1.7.1", "description": "Form builder", "main": "index.js", "private": false, diff --git a/src/components/FormBuilder/FormBuilder.stories.js b/src/components/FormBuilder/FormBuilder.stories.js index 9f9b983..a41cadd 100644 --- a/src/components/FormBuilder/FormBuilder.stories.js +++ b/src/components/FormBuilder/FormBuilder.stories.js @@ -125,6 +125,106 @@ const sections = [ id: 3, userVarName: 'S1P3', subQuestions: [] + }, + { + id: 4, + label: 'Select an option', + name: 'S1P4', + number: '4', + type: 4, + options: [ + { + id: 1, + name: 'S1P1O1', + subOptions: [ + { + id: 1 + } + ], + label: 'Yes', + value: '1', + needSpecification: true + }, + { + id: 2, + needSpecification: true, + label: 'No', + value: '2' + } + ], + multiple: false, + favorite: false, + validations: [ + { + id: 1, + type: 'required', + params: [ + { + id: 1, + message: 'Must select an option' + } + ], + messageType: 'error' + } + ], + subQuestions: [ + { + id: 1, + optionId: 1, + type: '1', + label: 'Add specification', + name: 'S1P1SQ1', + validations: [ + { + id: 1, + type: 'required', + params: [ + { + id: 1, + message: 'Must add a specification for option 1' + } + ], + messageType: 'error' + }, + { + id: 2, + type: 'min', + params: [ + { + id: 1, + value: 2, + message: 'Should have at least 2 characters' + } + ], + messageType: 'warning' + } + ], + userVarName: 'S1P1E1' + }, + { + id: 2, + optionId: 2, + type: '1', + label: 'Add specification', + name: 'S1P1SQ2', + validations: [ + { + id: 1, + type: 'required', + params: [ + { + id: 1, + message: 'Must add a specification for option 2' + } + ], + messageType: 'error' + } + ], + userVarName: 'S1P1E2' + } + ], + metadata: {}, + userVarName: 'S1P4' } ], multiple: true, diff --git a/src/components/QuestionBuilder/Wrapper.js b/src/components/QuestionBuilder/Wrapper.js index 330e720..0d793af 100644 --- a/src/components/QuestionBuilder/Wrapper.js +++ b/src/components/QuestionBuilder/Wrapper.js @@ -12,7 +12,7 @@ import subQuestionPropTypes from '@/utils/propTypes/subQuestion'; import valuesPropTypes from '@/utils/propTypes/values'; function Wrapper({ - isMultiple, name, values, subQuestions, options, readOnlyMode, ...props + isMultiple, name, values, subQuestions, options, readOnlyMode, warnings, ...props }) { let Component; if (isMultiple) { @@ -21,7 +21,13 @@ function Wrapper({ name={name} render={helpers => values.answer.map((answer, index) => ( - + {values.answer.length === index + 1 && (