From 16814c1061ccfc853ca058215df8b0c4c82a9480 Mon Sep 17 00:00:00 2001 From: Chisom Chima <87203527+Chisomchima@users.noreply.github.com> Date: Tue, 12 Nov 2024 07:09:42 +0100 Subject: [PATCH] feat: add indicators list view (#432) * feat: add indicators list view * feat: add filters to the list * chore: remove default filters * chore: lint error check --- i18n/en.pot | 51 ++++--------------- .../sectionList/filters/DynamicFilters.tsx | 3 ++ .../filterSelectors/IndicatorFilter.tsx | 24 +++++++++ .../filters/filterSelectors/index.ts | 1 + src/lib/sectionList/filters/filterConfig.tsx | 2 + .../listViews/sectionListViewsConfig.ts | 8 +++ src/pages/indicators/List.tsx | 4 ++ .../form/OrganisationUnitFormFields.tsx | 2 - 8 files changed, 51 insertions(+), 44 deletions(-) create mode 100644 src/components/sectionList/filters/filterSelectors/IndicatorFilter.tsx create mode 100644 src/pages/indicators/List.tsx diff --git a/i18n/en.pot b/i18n/en.pot index baf333f8..b05cae63 100644 --- a/i18n/en.pot +++ b/i18n/en.pot @@ -312,6 +312,9 @@ msgstr "Data set" msgid "Search by name, code or ID" msgstr "Search by name, code or ID" +msgid "Indicator Type" +msgstr "Indicator Type" + msgid "Public access" msgstr "Public access" @@ -961,48 +964,6 @@ msgstr "Filter selected categories" msgid "At least one category is required" msgstr "At least one category is required" -msgid "Set up the basic information for this category option group set." -msgstr "Set up the basic information for this category option group set." - -msgid "Explain the purpose of this category option group set." -msgstr "Explain the purpose of this category option group set." - -msgid "" -"Choose how this category option group set will be used to capture and " -"analyze" -msgstr "" -"Choose how this category option group set will be used to capture and " -"analyze" - -msgid "" -"Category option group set will be available to the analytics as another " -"dimension" -msgstr "" -"Category option group set will be available to the analytics as another " -"dimension" - -msgid "Category option Groups" -msgstr "Category option Groups" - -msgid "" -"Choose the category option groups to include in this category option group " -"set." -msgstr "" -"Choose the category option groups to include in this category option group " -"set." - -msgid "Available category option groups" -msgstr "Available category option groups" - -msgid "Selected category option groups" -msgstr "Selected category option groups" - -msgid "Filter available category option groups" -msgstr "Filter available category option groups" - -msgid "Filter selected category option groups" -msgstr "Filter selected category option groups" - msgid "Set up the basic information for this category option group." msgstr "Set up the basic information for this category option group." @@ -1239,6 +1200,12 @@ msgstr "Set up the organisation unit location." msgid "Reference assignment" msgstr "Reference assignment" +msgid "Longitude" +msgstr "Longitude" + +msgid "Reference assignment" +msgstr "Reference assignment" + msgid "Assign the organisation unit to related objects." msgstr "Assign the organisation unit to related objects." diff --git a/src/components/sectionList/filters/DynamicFilters.tsx b/src/components/sectionList/filters/DynamicFilters.tsx index 6f4ef7b6..e74d4f51 100644 --- a/src/components/sectionList/filters/DynamicFilters.tsx +++ b/src/components/sectionList/filters/DynamicFilters.tsx @@ -8,6 +8,7 @@ import { CategoryOptionGroupFilter, DataDimensionTypeFilter, DataSetFilter, + IndicatorFilter, DomainTypeSelectionFilter, IgnoreApprovalFilter, PublicAccessFilter, @@ -19,6 +20,7 @@ type FilterKeyToComponentMap = Partial> const filterKeyToComponentMap: FilterKeyToComponentMap = { category: Categoryfilter, + indicatorType: IndicatorFilter, categoryOption: CategoryOptionFilter, categoryCombo: CategoryComboFilter, categoryOptionGroup: CategoryOptionGroupFilter, @@ -33,6 +35,7 @@ const filterKeyToComponentMap: FilterKeyToComponentMap = { export const DynamicFilters = () => { const filterKeys = useFilterKeys() + return ( <> {filterKeys.map((filterKey) => { diff --git a/src/components/sectionList/filters/filterSelectors/IndicatorFilter.tsx b/src/components/sectionList/filters/filterSelectors/IndicatorFilter.tsx new file mode 100644 index 00000000..0c678ac2 --- /dev/null +++ b/src/components/sectionList/filters/filterSelectors/IndicatorFilter.tsx @@ -0,0 +1,24 @@ +import i18n from '@dhis2/d2-i18n' +import React from 'react' +import { useSectionListFilter } from '../../../../lib' +import { createFilterDataQuery } from './createFilterDataQuery' +import { ModelFilterSelect } from './ModelFilter' + +const query = createFilterDataQuery('indicatorTypes') + +export const IndicatorFilter = () => { + const [filter, setFilter] = useSectionListFilter('indicatorType') + + const selected = filter?.[0] + + return ( + + setFilter(selected ? [selected] : undefined) + } + /> + ) +} diff --git a/src/components/sectionList/filters/filterSelectors/index.ts b/src/components/sectionList/filters/filterSelectors/index.ts index 6c0cd7e9..7cf11768 100644 --- a/src/components/sectionList/filters/filterSelectors/index.ts +++ b/src/components/sectionList/filters/filterSelectors/index.ts @@ -8,3 +8,4 @@ export * from './CategoryFilter' export * from './CategoryOptionGroupFilter' export * from './BooleanFilters' export * from './CategoryOptionFilter' +export * from './IndicatorFilter' diff --git a/src/lib/sectionList/filters/filterConfig.tsx b/src/lib/sectionList/filters/filterConfig.tsx index 18b174be..975aaea1 100644 --- a/src/lib/sectionList/filters/filterConfig.tsx +++ b/src/lib/sectionList/filters/filterConfig.tsx @@ -25,6 +25,7 @@ export const filterParamsSchema = z valueType: z.array(z.nativeEnum(DataElement.valueType)), dataDimensionType: z.nativeEnum(Category.dataDimensionType), ignoreApproval: z.boolean(), + indicatorType: zodArrayIds, }) .partial() @@ -43,6 +44,7 @@ export const filterQueryParamType = { publicAccess: CustomDelimitedArrayParam, dataDimensionType: StringParam, ignoreApproval: BooleanParam, + indicatorType: CustomDelimitedArrayParam, } as const satisfies QueryParamsConfigMap export const validFilterKeys = Object.keys(filterQueryParamType) diff --git a/src/lib/sectionList/listViews/sectionListViewsConfig.ts b/src/lib/sectionList/listViews/sectionListViewsConfig.ts index 076618df..6c78bf72 100644 --- a/src/lib/sectionList/listViews/sectionListViewsConfig.ts +++ b/src/lib/sectionList/listViews/sectionListViewsConfig.ts @@ -126,6 +126,14 @@ export const modelListViewsConfig = { default: ['dataDimensionType', 'categoryCombo'], }, }, + indicator: { + columns: { + default: ['name', DESCRIPTORS.publicAccess, 'lastUpdated'], + }, + filters: { + default: ['indicatorType'], + }, + }, categoryOptionGroupSet: { columns: { default: [ diff --git a/src/pages/indicators/List.tsx b/src/pages/indicators/List.tsx new file mode 100644 index 00000000..b310e1bd --- /dev/null +++ b/src/pages/indicators/List.tsx @@ -0,0 +1,4 @@ +import React from 'react' +import { DefaultSectionList } from '../DefaultSectionList' + +export const Component = () => diff --git a/src/pages/organisationUnits/form/OrganisationUnitFormFields.tsx b/src/pages/organisationUnits/form/OrganisationUnitFormFields.tsx index 49e6a074..c5f73b7d 100644 --- a/src/pages/organisationUnits/form/OrganisationUnitFormFields.tsx +++ b/src/pages/organisationUnits/form/OrganisationUnitFormFields.tsx @@ -9,8 +9,6 @@ import { StandardFormSection, StandardFormSectionDescription, StandardFormSectionTitle, -} from '../../../components' -import { DefaultIdentifiableFields, DescriptionField, } from '../../../components'