Skip to content

Commit

Permalink
feat: add indicators list view (#432)
Browse files Browse the repository at this point in the history
* feat: add indicators list view

* feat: add filters to the list

* chore: remove default filters

* chore: lint error check
  • Loading branch information
Chisomchima authored Nov 12, 2024
1 parent e2dc678 commit 16814c1
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 44 deletions.
51 changes: 9 additions & 42 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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."

Expand Down Expand Up @@ -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."

Expand Down
3 changes: 3 additions & 0 deletions src/components/sectionList/filters/DynamicFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
CategoryOptionGroupFilter,
DataDimensionTypeFilter,
DataSetFilter,
IndicatorFilter,
DomainTypeSelectionFilter,
IgnoreApprovalFilter,
PublicAccessFilter,
Expand All @@ -19,6 +20,7 @@ type FilterKeyToComponentMap = Partial<Record<ConfigurableFilterKey, React.FC>>

const filterKeyToComponentMap: FilterKeyToComponentMap = {
category: Categoryfilter,
indicatorType: IndicatorFilter,
categoryOption: CategoryOptionFilter,
categoryCombo: CategoryComboFilter,
categoryOptionGroup: CategoryOptionGroupFilter,
Expand All @@ -33,6 +35,7 @@ const filterKeyToComponentMap: FilterKeyToComponentMap = {

export const DynamicFilters = () => {
const filterKeys = useFilterKeys()

return (
<>
{filterKeys.map((filterKey) => {
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('indicatorTypes')

export const IndicatorFilter = () => {
const [filter, setFilter] = useSectionListFilter('indicatorType')

const selected = filter?.[0]

return (
<ModelFilterSelect
placeholder={i18n.t('Indicator 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 './IndicatorFilter'
2 changes: 2 additions & 0 deletions src/lib/sectionList/filters/filterConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions src/lib/sectionList/listViews/sectionListViewsConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@ export const modelListViewsConfig = {
default: ['dataDimensionType', 'categoryCombo'],
},
},
indicator: {
columns: {
default: ['name', DESCRIPTORS.publicAccess, 'lastUpdated'],
},
filters: {
default: ['indicatorType'],
},
},
categoryOptionGroupSet: {
columns: {
default: [
Expand Down
4 changes: 4 additions & 0 deletions src/pages/indicators/List.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import React from 'react'
import { DefaultSectionList } from '../DefaultSectionList'

export const Component = () => <DefaultSectionList />
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 16814c1

Please sign in to comment.