Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 8 additions & 8 deletions src/constants/dictionary/pairing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Comment on lines +10 to +11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's more first name (as the business analysts confirmed)

},
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: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
};

Expand All @@ -26,6 +32,9 @@ export function formToState(form, transformers) {
id,
visHint,
scope,
nameSourceVariable,
genderSourceVariable,
ageSourceVariable,
[DEFAULT_CODES_LIST_SELECTOR_PATH]: codesListForm,
} = form;

Expand All @@ -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,
};
}

Expand Down
11 changes: 9 additions & 2 deletions src/model/transformations/response-format-pairing.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function ResponseFormatPairing({
return (
<FormSection name={PAIRING} className="response-format__single">
<Field
name="scope"
name="nameSourceVariable"
component={Select}
label={Dictionary.pairingSourceVariable}
required
Expand All @@ -111,6 +111,16 @@ function ResponseFormatPairing({
</GenericOption>
{pairingSourceVariable}
</Field>
<Field
name="genderSourceVariable"
component={Select}
label={Dictionary.pairingGenderVariable}
>
<GenericOption key="" value="">
{Dictionary.selectGenderVariable}
</GenericOption>
{pairingSourceVariable}
</Field>
{enableRecap ? (
<>
<div className="ctrl-checkbox">
Expand All @@ -127,21 +137,9 @@ function ResponseFormatPairing({
</div>
</div>
<Field
name="recapGenderVariable"
component={Select}
label={Dictionary.pairingRecapGender}
disabled={!displayRecap}
required
>
<GenericOption key="" value="">
{Dictionary.selectGenderVariable}
</GenericOption>
{pairingSourceVariable}
</Field>
<Field
name="recapAgeVariable"
name="ageSourceVariable"
component={Select}
label={Dictionary.pairingRecapAge}
label={Dictionary.pairingAgeVariable}
disabled={!displayRecap}
required
>
Expand Down
Loading