Skip to content

Commit 61d0d56

Browse files
authored
Merge pull request #2240 from citizenos/fix/demographics-prefix
Fix: Update demographic values
2 parents da34053 + 4966827 commit 61d0d56

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

src/app/ideation/components/add-idea/add-idea.component.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -423,30 +423,33 @@ export class AddIdeaComponent {
423423

424424
return Object.keys(this.ideation.demographicsConfig).reduce(
425425
(acc: Idea['demographics'], curr: string) => {
426-
if (curr === 'residence') {
427-
const prefix = this.translate.instant(
428-
'COMPONENTS.ADD_IDEA.RESIDENCE_VALUE_PREFIX'
429-
);
426+
/**
427+
* Prefix used to define open field value in the database
428+
* for easier filtering.
429+
* @see https://github.com/citizenos/citizenos-fe/issues/2081
430+
*/
431+
const prefix = "other: ";
430432

433+
if (curr === 'residence') {
431434
return {
432435
...acc,
433-
residence: this.isCountryEstonia
434-
? this.filtersData.residence.selectedValue
435-
: prefix + this.ideation.demographicsConfig?.[curr].value,
436+
residence:
437+
this.ideation.demographicsConfig?.[curr].value ?
438+
prefix + this.ideation.demographicsConfig?.[curr].value :
439+
this.filtersData.residence.selectedValue,
436440
};
437441
}
438-
if (curr === 'gender') {
439-
const prefix = this.translate.instant(
440-
'COMPONENTS.ADD_IDEA.GENDER_VALUE_PREFIX'
441-
);
442442

443+
if (curr === 'gender') {
443444
return {
444445
...acc,
445446
gender:
446-
prefix + this.ideation.demographicsConfig?.[curr].value ||
447-
this.filtersData.gender.selectedValue,
447+
this.ideation.demographicsConfig?.[curr].value ?
448+
prefix + this.ideation.demographicsConfig?.[curr].value :
449+
this.filtersData.gender.selectedValue,
448450
};
449451
}
452+
450453
return {
451454
...acc,
452455
[curr]: this.ideation.demographicsConfig?.[curr].value || '',

0 commit comments

Comments
 (0)