Skip to content

Commit

Permalink
feat: data set list view
Browse files Browse the repository at this point in the history
  • Loading branch information
Chisomchima committed Nov 8, 2024
1 parent 9d306d5 commit d61ce14
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/components/sectionList/filters/DynamicFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ import {
IgnoreApprovalFilter,
PublicAccessFilter,
ValueTypeSelectionFilter,
FormTypeFilter,
} from './filterSelectors'
import { useFilterKeys } from './useFilterKeys'

type FilterKeyToComponentMap = Partial<Record<ConfigurableFilterKey, React.FC>>

const filterKeyToComponentMap: FilterKeyToComponentMap = {
category: Categoryfilter,
formType: FormTypeFilter,
categoryOption: CategoryOptionFilter,
categoryCombo: CategoryComboFilter,
categoryOptionGroup: CategoryOptionGroupFilter,
Expand Down
Original file line number Diff line number Diff line change
@@ -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 (
<ModelFilterSelect
placeholder={i18n.t('Form Type')}
query={query}
selected={selected}
onChange={({ selected }) =>
setFilter(selected ? [selected] : undefined)
}
/>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export * from './CategoryFilter'
export * from './CategoryOptionGroupFilter'
export * from './BooleanFilters'
export * from './CategoryOptionFilter'
export * from './FormTypeFilter'
2 changes: 2 additions & 0 deletions src/lib/sectionList/filters/filterConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -37,6 +38,7 @@ export const filterQueryParamType = {
valueType: CustomDelimitedArrayParam,
dataSet: CustomDelimitedArrayParam,
category: CustomDelimitedArrayParam,
formType: CustomDelimitedArrayParam,
categoryOption: CustomDelimitedArrayParam,
categoryCombo: CustomDelimitedArrayParam,
categoryOptionGroup: CustomDelimitedArrayParam,
Expand Down
14 changes: 14 additions & 0 deletions src/lib/sectionList/listViews/sectionListViewsConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import {
StandardFormSection,
StandardFormSectionDescription,
StandardFormSectionTitle,
} from '../../../components'
import {
DefaultIdentifiableFields,
DescriptionField,
} from '../../../components'
Expand Down

0 comments on commit d61ce14

Please sign in to comment.