diff --git a/app/[domain]/[lang]/[plan]/(with-layout-elements)/indicators/page.tsx b/app/[domain]/[lang]/[plan]/(with-layout-elements)/indicators/page.tsx
index 499a5b5b7..1de5fd8e8 100644
--- a/app/[domain]/[lang]/[plan]/(with-layout-elements)/indicators/page.tsx
+++ b/app/[domain]/[lang]/[plan]/(with-layout-elements)/indicators/page.tsx
@@ -28,6 +28,7 @@ export default async function ActionsPage({ params }: Props) {
);
}
diff --git a/common/__generated__/graphql.ts b/common/__generated__/graphql.ts
index c490a1995..af54f38cb 100644
--- a/common/__generated__/graphql.ts
+++ b/common/__generated__/graphql.ts
@@ -2581,6 +2581,7 @@ export type IndicatorListPage = PageInterface & {
goLiveAt?: Maybe;
hasUnpublishedChanges: Scalars['Boolean'];
id?: Maybe;
+ includeRelatedPlans?: Maybe;
lastPublishedAt?: Maybe;
latestRevision?: Maybe;
latestRevisionCreatedAt?: Maybe;
@@ -12161,7 +12162,7 @@ export type GetPlanPageIndicatorListQuery = (
{ id?: string | null, slug: string, title: string, lastPublishedAt?: any | null }
& { __typename: 'AccessibilityStatementPage' | 'ActionListPage' | 'CategoryPage' | 'CategoryTypePage' | 'EmptyPage' | 'ImpactGroupPage' | 'Page' | 'PlanRootPage' | 'PrivacyPolicyPage' | 'StaticPage' }
) | (
- { leadContent?: string | null, displayInsights?: boolean | null, id?: string | null, slug: string, title: string, lastPublishedAt?: any | null }
+ { leadContent?: string | null, displayInsights?: boolean | null, includeRelatedPlans?: boolean | null, id?: string | null, slug: string, title: string, lastPublishedAt?: any | null }
& { __typename: 'IndicatorListPage' }
) | null }
& { __typename?: 'Query' }
diff --git a/components/indicators/IndicatorList.tsx b/components/indicators/IndicatorList.tsx
index 0cc992d92..7f37240f0 100644
--- a/components/indicators/IndicatorList.tsx
+++ b/components/indicators/IndicatorList.tsx
@@ -65,11 +65,9 @@ const collectCommonCategories = (indicators) => {
}));
};
-const includeRelatedPlanIndicators = true;
-
const getFilterConfig = (categoryType, indicators, commonCategories) => ({
mainFilters: [
- ...(includeRelatedPlanIndicators
+ ...(commonCategories
? commonCategories.map(({ typeIdentifier, categories, type }) => ({
__typename: 'CategoryTypeFilterBlock',
field: 'category',
@@ -291,6 +289,7 @@ interface Filters {
const filterIndicators = (
indicators,
filters: Filters,
+ includeRelatedPlans: boolean,
categoryIdentifier?: string
) => {
const filterByCategory = (indicator) => {
@@ -336,7 +335,7 @@ const filterIndicators = (
const commonCategoryResult = filterByCommonCategory(indicator);
const searchResult = filterBySearch(indicator);
return (
- (!includeRelatedPlanIndicators ? categoryResult : commonCategoryResult) &&
+ (!includeRelatedPlans ? categoryResult : commonCategoryResult) &&
searchResult
);
});
@@ -352,9 +351,14 @@ const getFirstUsableCategoryType = (categoryTypes, indicators) =>
interface Props {
leadContent: IndicatorListPage['leadContent'];
displayInsights: IndicatorListPage['displayInsights'];
+ includeRelatedPlans: IndicatorListPage['includeRelatedPlans'];
}
-const IndicatorList = ({ leadContent, displayInsights }: Props) => {
+const IndicatorList = ({
+ leadContent,
+ displayInsights,
+ includeRelatedPlans,
+}: Props) => {
const plan = usePlan();
const t = useTranslations();
const searchParams = useSearchParams();
@@ -364,7 +368,7 @@ const IndicatorList = ({ leadContent, displayInsights }: Props) => {
{
variables: {
plan: plan.identifier,
- relatedPlanIndicators: includeRelatedPlanIndicators,
+ relatedPlanIndicators: includeRelatedPlans,
},
}
);
@@ -413,9 +417,7 @@ const IndicatorList = ({ leadContent, displayInsights }: Props) => {
leadContent: generalContent.indicatorListLeadContent,
displayMunicipality,
displayNormalizedValues,
- relatedPlanIndicators: includeRelatedPlanIndicators
- ? relatedPlanIndicators
- : [],
+ relatedPlanIndicators: includeRelatedPlans ? relatedPlanIndicators : [],
};
};
@@ -424,13 +426,13 @@ const IndicatorList = ({ leadContent, displayInsights }: Props) => {
const indicatorListProps = getIndicatorListProps(data);
- const indicators = includeRelatedPlanIndicators
+ const indicators = includeRelatedPlans
? indicatorListProps.relatedPlanIndicators
: indicatorListProps.indicators;
const commonCategories = collectCommonCategories(indicators);
const hierarchy = processCommonIndicatorHierarchy(
- includeRelatedPlanIndicators
+ includeRelatedPlans
? indicatorListProps.relatedPlanIndicators
: data?.planIndicators
);
@@ -445,7 +447,7 @@ const IndicatorList = ({ leadContent, displayInsights }: Props) => {
? getFilterConfig(
categoryType,
indicators,
- includeRelatedPlanIndicators ? commonCategories : []
+ includeRelatedPlans ? commonCategories : []
)
: {};
@@ -462,6 +464,7 @@ const IndicatorList = ({ leadContent, displayInsights }: Props) => {
const filteredIndicators = filterIndicators(
indicators,
filters,
+ includeRelatedPlans,
categoryType?.identifier
);
@@ -490,7 +493,7 @@ const IndicatorList = ({ leadContent, displayInsights }: Props) => {
shouldDisplayCategory={(category: Category) =>
category.type.id === categoryType?.id
}
- includePlanRelatedIndicators={includeRelatedPlanIndicators}
+ includePlanRelatedIndicators={includeRelatedPlans}
commonCategories={commonCategories}
/>
diff --git a/queries/get-indicator-list-page.ts b/queries/get-indicator-list-page.ts
index 4f5baf9e5..62d4b05dd 100644
--- a/queries/get-indicator-list-page.ts
+++ b/queries/get-indicator-list-page.ts
@@ -15,6 +15,7 @@ const GET_INDICATOR_LIST_PAGE = gql`
... on IndicatorListPage {
leadContent
displayInsights
+ includeRelatedPlans
}
lastPublishedAt
}