From d61ce14e02c2cd4c5cc2beddf7a87ec67aa72cce Mon Sep 17 00:00:00 2001 From: Chisomchima Date: Fri, 8 Nov 2024 12:20:54 +0100 Subject: [PATCH] feat: data set list view --- .../sectionList/filters/DynamicFilters.tsx | 2 ++ .../filterSelectors/FormTypeFilter.tsx | 24 +++++++++++++++++++ .../filters/filterSelectors/index.ts | 1 + src/lib/sectionList/filters/filterConfig.tsx | 2 ++ .../listViews/sectionListViewsConfig.ts | 14 +++++++++++ .../form/OrganisationUnitFormFields.tsx | 2 -- 6 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 src/components/sectionList/filters/filterSelectors/FormTypeFilter.tsx diff --git a/src/components/sectionList/filters/DynamicFilters.tsx b/src/components/sectionList/filters/DynamicFilters.tsx index 6f4ef7b6..03a59191 100644 --- a/src/components/sectionList/filters/DynamicFilters.tsx +++ b/src/components/sectionList/filters/DynamicFilters.tsx @@ -12,6 +12,7 @@ import { IgnoreApprovalFilter, PublicAccessFilter, ValueTypeSelectionFilter, + FormTypeFilter, } from './filterSelectors' import { useFilterKeys } from './useFilterKeys' @@ -19,6 +20,7 @@ type FilterKeyToComponentMap = Partial> const filterKeyToComponentMap: FilterKeyToComponentMap = { category: Categoryfilter, + formType: FormTypeFilter, categoryOption: CategoryOptionFilter, categoryCombo: CategoryComboFilter, categoryOptionGroup: CategoryOptionGroupFilter, diff --git a/src/components/sectionList/filters/filterSelectors/FormTypeFilter.tsx b/src/components/sectionList/filters/filterSelectors/FormTypeFilter.tsx new file mode 100644 index 00000000..692412b4 --- /dev/null +++ b/src/components/sectionList/filters/filterSelectors/FormTypeFilter.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('formTypes') + +export const FormTypeFilter = () => { + const [filter, setFilter] = useSectionListFilter('formType') + + 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..f3516f8a 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 './FormTypeFilter' diff --git a/src/lib/sectionList/filters/filterConfig.tsx b/src/lib/sectionList/filters/filterConfig.tsx index 18b174be..1646e9ae 100644 --- a/src/lib/sectionList/filters/filterConfig.tsx +++ b/src/lib/sectionList/filters/filterConfig.tsx @@ -15,6 +15,7 @@ export const filterParamsSchema = z aggregationType: z.array(z.nativeEnum(DataElement.aggregationType)), categoryCombo: zodArrayIds, category: zodArrayIds, + formType: zodArrayIds, categoryOption: zodArrayIds, categoryOptionGroup: zodArrayIds, dataSet: zodArrayIds, @@ -37,6 +38,7 @@ export const filterQueryParamType = { valueType: CustomDelimitedArrayParam, dataSet: CustomDelimitedArrayParam, category: CustomDelimitedArrayParam, + formType: CustomDelimitedArrayParam, categoryOption: CustomDelimitedArrayParam, categoryCombo: CustomDelimitedArrayParam, categoryOptionGroup: CustomDelimitedArrayParam, diff --git a/src/lib/sectionList/listViews/sectionListViewsConfig.ts b/src/lib/sectionList/listViews/sectionListViewsConfig.ts index 076618df..b9cb0ec5 100644 --- a/src/lib/sectionList/listViews/sectionListViewsConfig.ts +++ b/src/lib/sectionList/listViews/sectionListViewsConfig.ts @@ -98,6 +98,20 @@ export const modelListViewsConfig = { default: ['domainType', 'valueType', 'dataSet', 'categoryCombo'], }, }, + dataSet: { + columns: { + default: [ + 'name', + { label: i18n.t('Form type'), path: 'formType' }, + { label: i18n.t('Period type'), path: 'periodType' }, + 'lastUpdated', + DESCRIPTORS.publicAccess, + ], + }, + filters: { + default: ['formType'], + }, + }, organisationUnit: { columns: { available: [], 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'