From 8907a573b4690d89482732ae7999641befa93885 Mon Sep 17 00:00:00 2001 From: BulotF Date: Thu, 19 Sep 2024 11:53:35 +0200 Subject: [PATCH 1/3] Allow checks (Occurrence / Whole) for roundabouts --- src/constants/dictionary.jsx | 8 +++++++ src/model/transformations/control.jsx | 5 ++-- .../components/controls.jsx | 24 +++++++++++++++++-- .../components/sequence-new-edit.jsx | 10 ++++++++ 4 files changed, 43 insertions(+), 4 deletions(-) diff --git a/src/constants/dictionary.jsx b/src/constants/dictionary.jsx index b5d26fbbc..6f1230a34 100644 --- a/src/constants/dictionary.jsx +++ b/src/constants/dictionary.jsx @@ -787,6 +787,14 @@ const dictionary = { en: 'Array', fr: 'Tableau', }, + ROUNDABOUT: { + en: 'Roundabout', + fr: 'Rond-point', + }, + OCCURRENCE: { + en: 'Occurrence', + fr: 'Occurrence', + }, responseFormatSimple: { fr: 'RĂ©ponse simple', en: 'Simple response', diff --git a/src/model/transformations/control.jsx b/src/model/transformations/control.jsx index e218e8120..affb12a6f 100644 --- a/src/model/transformations/control.jsx +++ b/src/model/transformations/control.jsx @@ -23,7 +23,8 @@ export function remoteToState(remote = []) { criticity, during_collect, post_collect, - scope: scope === 'line' ? 'LINE' : 'DYNAMIC_ARRAY', + scope: + scope === 'line' || scope === 'occurrence' ? 'OCCURRENCE' : 'WHOLE', }, }; }, {}); @@ -50,7 +51,7 @@ export function stateToRemote(state) { criticity, during_collect, post_collect, - scope: scope === 'LINE' && 'line', + scope: scope === 'OCCURRENCE' && 'occurrence', }; }); } diff --git a/src/widgets/component-new-edit/components/controls.jsx b/src/widgets/component-new-edit/components/controls.jsx index 2d21a3dd2..67a789985 100644 --- a/src/widgets/component-new-edit/components/controls.jsx +++ b/src/widgets/component-new-edit/components/controls.jsx @@ -32,6 +32,7 @@ const Controls = ({ errors, addErrors, isDynamicArray, + isRoundabout, }) => { const [disableValidation, setDisableValidation] = useState(false); return ( @@ -91,14 +92,30 @@ const Controls = ({ label={Dictionary.control_scope} required={isDynamicArray} > - + {Dictionary.DYNAMIC_ARRAY} - + {Dictionary.LINE} )} + {isRoundabout && ( + + + {Dictionary.ROUNDABOUT} + + + {Dictionary.OCCURRENCE} + + + )} {/* { state, `${TABS_PATHS.RESPONSE_FORMAT}.${QUESTION_TYPE_ENUM.TABLE}.${DIMENSION_TYPE.PRIMARY}.type`, ) === DIMENSION_FORMATS.LIST, + isRoundabout: selector(state, `locked`) !== undefined, }; }; @@ -136,12 +154,14 @@ Controls.propTypes = { errors: PropTypes.array, addErrors: PropTypes.func.isRequired, isDynamicArray: PropTypes.bool, + isRoundabout: PropTypes.bool, }; Controls.defaultProps = { formName: DEFAULT_FORM_NAME, selectorPath: TABS_PATHS.CONTROLS, errors: [], isDynamicArray: false, + isRoundabout: false, }; export default connect(mapStateToProps)(Controls); diff --git a/src/widgets/component-new-edit/components/sequence-new-edit.jsx b/src/widgets/component-new-edit/components/sequence-new-edit.jsx index 7c99c5ca9..e736f12b0 100644 --- a/src/widgets/component-new-edit/components/sequence-new-edit.jsx +++ b/src/widgets/component-new-edit/components/sequence-new-edit.jsx @@ -85,6 +85,16 @@ export const SequenceNewEdit = ({ addErrors={addSubformValidationErrors} /> + + + )} {componentType !== ROUNDABOUT && ( From 3e8ffbefbf4de029378ee1998c5dbd7ff4676d53 Mon Sep 17 00:00:00 2001 From: BulotF Date: Thu, 19 Sep 2024 12:07:43 +0200 Subject: [PATCH 2/3] fix test --- src/model/transformations/control.spec.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/model/transformations/control.spec.jsx b/src/model/transformations/control.spec.jsx index 2d734638e..5aa5e51b3 100644 --- a/src/model/transformations/control.spec.jsx +++ b/src/model/transformations/control.spec.jsx @@ -21,7 +21,7 @@ describe('control tramsformation', () => { criticity: 'criticity 2', during_collect: 'during_collect 2', post_collect: 'post_collect 2', - scope: 'line', + scope: 'occurrence', }, ]; const state = { @@ -33,7 +33,7 @@ describe('control tramsformation', () => { criticity: 'criticity 1', during_collect: 'during_collect 1', post_collect: 'post_collect 1', - scope: 'DYNAMIC_ARRAY', + scope: 'WHOLE', }, 2: { id: '2', @@ -43,7 +43,7 @@ describe('control tramsformation', () => { criticity: 'criticity 2', during_collect: 'during_collect 2', post_collect: 'post_collect 2', - scope: 'LINE', + scope: 'OCCURRENCE', }, }; describe('remoteToState', () => { From 66bfeb5eeff9299809f893273485b08d5811ba58 Mon Sep 17 00:00:00 2001 From: BulotF Date: Thu, 26 Sep 2024 17:54:31 +0200 Subject: [PATCH 3/3] fix : required = isRoundabout for roundabout component --- .../component-new-edit/components/controls.jsx | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/widgets/component-new-edit/components/controls.jsx b/src/widgets/component-new-edit/components/controls.jsx index 67a789985..d47337bfc 100644 --- a/src/widgets/component-new-edit/components/controls.jsx +++ b/src/widgets/component-new-edit/components/controls.jsx @@ -106,7 +106,7 @@ const Controls = ({ id="control_scope" component={Select} label={Dictionary.control_scope} - required={isDynamicArray} + required={isRoundabout} > {Dictionary.ROUNDABOUT} @@ -116,18 +116,6 @@ const Controls = ({ )} - {/* */} - {/* */} );