From 6a2b978193cae74540c4f3a4f9c1d242c933af35 Mon Sep 17 00:00:00 2001 From: Lilia Sviridova Date: Tue, 7 Jan 2025 11:30:38 +0200 Subject: [PATCH] Adjust filter Label text on indicators page --- common/i18n.ts | 13 +++++++++---- components/actions/ActionListFilters.tsx | 18 +++++++++++++----- components/indicators/IndicatorList.tsx | 1 + locales/de/common.json | 2 +- locales/en/common.json | 2 +- 5 files changed, 25 insertions(+), 11 deletions(-) diff --git a/common/i18n.ts b/common/i18n.ts index 8f76ebcf9..b41328109 100644 --- a/common/i18n.ts +++ b/common/i18n.ts @@ -4,10 +4,15 @@ import { SiteGeneralContentActionTerm, } from './__generated__/graphql'; -export function getActionTermContext(plan: { - generalContent?: { actionTerm: SiteGeneralContentActionTerm }; -}) { - const actionTerm = plan.generalContent?.actionTerm; +export function getActionTermContext( + plan: { + generalContent?: { actionTerm: SiteGeneralContentActionTerm }; + }, + actionTerm?: string +) { + if (!actionTerm) { + actionTerm = plan.generalContent?.actionTerm; + } return actionTerm === 'ACTION' ? { context: undefined } : { context: actionTerm }; diff --git a/components/actions/ActionListFilters.tsx b/components/actions/ActionListFilters.tsx index 9e9a2ad69..cc30a4a63 100644 --- a/components/actions/ActionListFilters.tsx +++ b/components/actions/ActionListFilters.tsx @@ -811,9 +811,9 @@ class ActionNameFilter implements ActionListFilter { hasActionIdentifiers: boolean; ref: Ref; - constructor(plan: PlanContextType) { + constructor(plan: PlanContextType, actionTerm?: string) { this.hasActionIdentifiers = plan.features.hasActionIdentifiers; - this.actionTermContext = getActionTermContext(plan); + this.actionTermContext = getActionTermContext(plan, actionTerm); this.ref = createRef(); } @@ -1067,11 +1067,19 @@ type ConstructFiltersOpts = { orgs: ActionListOrganization[]; primaryOrgs: ActionListPrimaryOrg[]; filterByCommonCategory: boolean; + actionTerm?: string; }; ActionListFilters.constructFilters = (opts: ConstructFiltersOpts) => { - const { mainConfig, plan, t, orgs, primaryOrgs, filterByCommonCategory } = - opts; + const { + mainConfig, + plan, + t, + orgs, + primaryOrgs, + filterByCommonCategory, + actionTerm, + } = opts; const { primaryFilters, mainFilters, advancedFilters } = mainConfig; function makeSection( @@ -1219,7 +1227,7 @@ ActionListFilters.constructFilters = (opts: ConstructFiltersOpts) => { }; filters.push(new GenericSelectFilter(opts)); } - filters.push(new ActionNameFilter(plan)); + filters.push(new ActionNameFilter(plan, actionTerm)); } const ret: ActionListFilterSection = { diff --git a/components/indicators/IndicatorList.tsx b/components/indicators/IndicatorList.tsx index 04a0537ca..c9174b0de 100644 --- a/components/indicators/IndicatorList.tsx +++ b/components/indicators/IndicatorList.tsx @@ -480,6 +480,7 @@ const IndicatorList = ({ plan, filterByCommonCategory: false, t, + actionTerm: 'INDICATOR', }); const filteredIndicators = filterIndicators( diff --git a/locales/de/common.json b/locales/de/common.json index fc87baf52..b5b2bcc78 100644 --- a/locales/de/common.json +++ b/locales/de/common.json @@ -46,7 +46,7 @@ "filter-primary-organization": "{context, select, DIVISION {Leitende Abteilung} other {Primäre Organisation}}", "filter-result-actions": "{context, select, STRATEGY {Strategien} CASE_STUDY {Fallstudien} other {Maßnahmen}}", "filter-schedule": "Zeitplan", - "filter-text": "{context, select, CASE_STUDY {Fallstudien durchsuchen} STRATEGY {Strategien durchsuchen} other {Maßnahmen durchsuchen}}", + "filter-text": "{context, select, CASE_STUDY {Fallstudien durchsuchen} STRATEGY {Strategien durchsuchen} INDICATOR {Indikatoren durchsuchen} other {Maßnahmen durchsuchen}}", "filter-text-default": "Nach Schlüsselwort suchen", "front-page": "Titelseite", "give-feedback": "Feedback geben", diff --git a/locales/en/common.json b/locales/en/common.json index 136d4cf34..6e188ebcc 100644 --- a/locales/en/common.json +++ b/locales/en/common.json @@ -49,7 +49,7 @@ "filter-result-actions": "{context, select, CASE_STUDY {case studies} STRATEGY {strategies} other {actions}}", "filter-schedule": "Schedule", "filter-status": "Status", - "filter-text": "{context, select, STRATEGY {Search strategies} CASE_STUDY {Search case studies} other {Search actions}}", + "filter-text": "{context, select, STRATEGY {Search strategies} CASE_STUDY {Search case studies} INDICATOR {Search indicators} other {Search actions}}", "filter-text-default": "Search by keyword", "front-page": "Front Page", "give-feedback": "Give feedback",