Skip to content

Commit

Permalink
fix(categoryOptionCombo): add ignoreApproval to list, update viewConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
Birkbjo committed Oct 18, 2024
1 parent 9f81016 commit 75327d4
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/components/sectionList/filters/DynamicFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import { ConfigurableFilterKey } from './../../../lib'
import {
AggregationTypeFilter,
CategoryComboFilter,
Categoryfilter,
CategoryOptionGroupFilter,
DataDimensionTypeFilter,
DataSetFilter,
DomainTypeSelectionFilter,
ValueTypeSelectionFilter,
IgnoreApprovalFilter,

Check failure on line 11 in src/components/sectionList/filters/DynamicFilters.tsx

View workflow job for this annotation

GitHub Actions / build

Module '"./filterSelectors"' has no exported member 'IgnoreApprovalFilter'.
PublicAccessFilter,
DataDimensionTypeFilter,
Categoryfilter,
CategoryOptionGroupFilter,
ValueTypeSelectionFilter,
} from './filterSelectors'
import { useFilterKeys } from './useFilterKeys'

Expand All @@ -25,6 +26,7 @@ const filterKeyToComponentMap: FilterKeyToComponentMap = {
aggregationType: AggregationTypeFilter,
publicAccess: PublicAccessFilter,
dataDimensionType: DataDimensionTypeFilter,
ignoreApproval: IgnoreApprovalFilter,
}

export const DynamicFilters = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export * from './ConstantSelectionFilter'
export * from './PublicAccessFilter'
export * from './CategoryFilter'
export * from './CategoryOptionGroupFilter'
export * from './BooleanFilters'

Check failure on line 9 in src/components/sectionList/filters/filterSelectors/index.ts

View workflow job for this annotation

GitHub Actions / lint

Unable to resolve path to module './BooleanFilters'

Check failure on line 9 in src/components/sectionList/filters/filterSelectors/index.ts

View workflow job for this annotation

GitHub Actions / build

Cannot find module './BooleanFilters' or its corresponding type declarations.
12 changes: 11 additions & 1 deletion src/lib/sectionList/filters/filterConfig.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { StringParam } from 'use-query-params'
import { StringParam, BooleanParam } from 'use-query-params'
import { z } from 'zod'
import { Category, DataElement } from '../../../types/generated'
import { IDENTIFIABLE_FILTER_KEY } from '../../constants'
import { isValidUid, parseAccessString } from '../../models'
import { CustomDelimitedArrayParam } from './customParams'
import { KeysOfValue } from '../../../types/utility'

Check failure on line 7 in src/lib/sectionList/filters/filterConfig.tsx

View workflow job for this annotation

GitHub Actions / lint

`../../../types/utility` import should occur before import of `../../constants`

const zodArrayIds = z.array(z.string().refine((val) => isValidUid(val)))

Expand All @@ -22,6 +23,7 @@ export const filterParamsSchema = z
),
valueType: z.array(z.nativeEnum(DataElement.valueType)),
dataDimensionType: z.nativeEnum(Category.dataDimensionType),
ignoreApproval: z.boolean(),
})
.partial()

Expand All @@ -38,6 +40,7 @@ export const filterQueryParamType = {
categoryOptionGroup: CustomDelimitedArrayParam,
publicAccess: CustomDelimitedArrayParam,
dataDimensionType: StringParam,
ignoreApproval: BooleanParam,
} as const satisfies QueryParamsConfigMap

export const validFilterKeys = Object.keys(filterQueryParamType)
Expand All @@ -47,6 +50,8 @@ export type ParsedFilterParams = z.infer<typeof filterParamsSchema>
type MapZodTypeToQueryParamConfig<TZodResultType> =
TZodResultType extends string
? typeof StringParam
: TZodResultType extends boolean
? typeof BooleanParam
: typeof CustomDelimitedArrayParam

/* Type is just used to verify that the ParamType-config matches the zod schema
Expand All @@ -64,4 +69,9 @@ export type ConfigurableFilterKey = Exclude<
typeof IDENTIFIABLE_FILTER_KEY
>

export type BooleanFilterKey = KeysOfValue<
ParsedFilterParams,
boolean | undefined
>

export type FilterKeys = FilterKey[]
13 changes: 13 additions & 0 deletions src/lib/sectionList/listViews/sectionListViewsConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,19 @@ export const modelListViewsConfig = {
},
filters: {
default: ['dataDimensionType', 'category'],
available: ['ignoreApproval'],
},
},
categoryOptionCombo: {
columns: {
default: ['name', 'code', 'lastUpdated'],
overrideDefaultAvailable: true,
available: ['categoryCombo', 'ignoreApproval'],
},
filters: {
default: ['categoryCombo'],
available: ['ignoreApproval'],
overrideDefaultAvailable: true,
},
},
} satisfies SectionListViewConfig<SectionName>
4 changes: 4 additions & 0 deletions src/types/utility.ts
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
export type * from './generated/utility'

export type KeysOfValue<T, TCondition> = keyof {
[K in keyof T as T[K] extends TCondition ? K : never]: K
}

0 comments on commit 75327d4

Please sign in to comment.