From 75f00231dc83d1db27eb3fb992c46b29f2a2c689 Mon Sep 17 00:00:00 2001 From: Chloe Renaud Date: Thu, 8 Jan 2026 17:19:39 +0100 Subject: [PATCH] feat(legacy): handle gender source variable for pairwise magic variables --- .env | 2 ++ src/constants/dictionary/pairing.ts | 16 +++++------ .../response-format-pairing.jsx | 24 +++++++++++++--- .../response-format-pairing.jsx | 11 ++++++-- .../pairing/response-format-pairing.jsx | 28 +++++++++---------- 5 files changed, 52 insertions(+), 29 deletions(-) diff --git a/.env b/.env index 2610ed9aa..759811a1a 100644 --- a/.env +++ b/.env @@ -15,6 +15,8 @@ VITE_DEFAULT_USER_NAME= VITE_DEFAULT_USER_STAMP= # FEATURE FLAGS + +# if enabled, will allow to display a recap in pairwise question form VITE_ENABLE_PAIRING_RECAP= VITE_LOG_LEVEL=DEBUG \ No newline at end of file diff --git a/src/constants/dictionary/pairing.ts b/src/constants/dictionary/pairing.ts index 94f8ef71f..fa233e90e 100644 --- a/src/constants/dictionary/pairing.ts +++ b/src/constants/dictionary/pairing.ts @@ -7,19 +7,19 @@ export const pairingDictionary: Dictionary = { en: 'Household members pairing', }, pairingSourceVariable: { - fr: 'Variable source', - en: 'Source variable', + fr: 'Variable source du nom', + en: 'Name source variable', + }, + pairingGenderVariable: { + fr: 'Variable source du sexe', + en: 'Gender source variable', }, pairingDisplayRecap: { fr: 'Afficher le récapitulatif des habitants du logement', en: 'Display inhabitants summary', }, - pairingRecapGender: { - fr: 'Variable sexe source', - en: 'Gender source variable', - }, - pairingRecapAge: { - fr: 'Variable Âge source', + pairingAgeVariable: { + fr: "Variable source de l'âge", en: 'Age source variable', }, selectGenderVariable: { diff --git a/src/model/formToState/component-new-edit/response-format-pairing.jsx b/src/model/formToState/component-new-edit/response-format-pairing.jsx index 3ba06de81..68e79b171 100644 --- a/src/model/formToState/component-new-edit/response-format-pairing.jsx +++ b/src/model/formToState/component-new-edit/response-format-pairing.jsx @@ -10,14 +10,20 @@ import { const { DROPDOWN } = DATATYPE_VIS_HINT; export const defaultState = { - scope: '', visHint: DROPDOWN, + sourceVariableReferences: { + name: '', + gender: '', + age: '', + }, // [DEFAULT_CODES_LIST_SELECTOR_PATH]: cloneDeep(CodesListDefaultState), }; export const defaultForm = { - scope: '', visHint: DROPDOWN, + nameSourceVariable: '', + genderSourceVariable: '', + ageSourceVariable: '', // [DEFAULT_CODES_LIST_SELECTOR_PATH]: cloneDeep(CodesListDefaultForm), }; @@ -26,6 +32,9 @@ export function formToState(form, transformers) { id, visHint, scope, + nameSourceVariable, + genderSourceVariable, + ageSourceVariable, [DEFAULT_CODES_LIST_SELECTOR_PATH]: codesListForm, } = form; @@ -35,18 +44,25 @@ export function formToState(form, transformers) { scope, [DEFAULT_CODES_LIST_SELECTOR_PATH]: transformers.codesList.formToStateComponent(codesListForm), + sourceVariableReferences: { + name: nameSourceVariable, + gender: genderSourceVariable, + age: ageSourceVariable, + }, }; } export function stateToForm(currentState, transformers) { - const { id, visHint, scope } = currentState; + const { id, visHint, sourceVariableReferences } = currentState; return { id, visHint, - scope, [DEFAULT_CODES_LIST_SELECTOR_PATH]: transformers.codesList.stateComponentToForm(), + nameSourceVariable: sourceVariableReferences.name, + genderSourceVariable: sourceVariableReferences.gender, + ageSourceVariable: sourceVariableReferences.age, }; } diff --git a/src/model/transformations/response-format-pairing.jsx b/src/model/transformations/response-format-pairing.jsx index e966c4ae6..1de0bdd30 100644 --- a/src/model/transformations/response-format-pairing.jsx +++ b/src/model/transformations/response-format-pairing.jsx @@ -10,13 +10,20 @@ export function remoteToState(remote) { id, }, ], - scope, + sourceVariableReferences, + scope, // deprecated } = remote; + const { name, gender, age } = sourceVariableReferences ?? {}; + return { [DEFAULT_CODES_LIST_SELECTOR_PATH]: CodeList.remoteToState(CodeListReference), id, - scope, visHint, + sourceVariableReferences: { + name: name || scope, + gender, + age, + }, }; } diff --git a/src/widgets/component-new-edit/components/response-format/pairing/response-format-pairing.jsx b/src/widgets/component-new-edit/components/response-format/pairing/response-format-pairing.jsx index 42f2dd860..f8dc48451 100644 --- a/src/widgets/component-new-edit/components/response-format/pairing/response-format-pairing.jsx +++ b/src/widgets/component-new-edit/components/response-format/pairing/response-format-pairing.jsx @@ -101,7 +101,7 @@ function ResponseFormatPairing({ return ( {pairingSourceVariable} + + + {Dictionary.selectGenderVariable} + + {pairingSourceVariable} + {enableRecap ? ( <>
@@ -127,21 +137,9 @@ function ResponseFormatPairing({
- - {Dictionary.selectGenderVariable} - - {pairingSourceVariable} - -