diff --git a/SharePointFramework/shared-library/src/components/FilterPanel/Filter/useFilter.tsx b/SharePointFramework/shared-library/src/components/FilterPanel/Filter/useFilter.tsx index 73b1028d7..d301324ee 100644 --- a/SharePointFramework/shared-library/src/components/FilterPanel/Filter/useFilter.tsx +++ b/SharePointFramework/shared-library/src/components/FilterPanel/Filter/useFilter.tsx @@ -39,11 +39,12 @@ export function useFilter(props: IFilterProps) { * Render filter items */ const renderItems = () => { - return state.items.map((props, idx) => ( + return state.items.map((item, idx) => ( onChange(props, checked as boolean)} + {...item} + column={props.column} + onChange={(_event, { checked }) => onChange(item, checked as boolean)} /> )) } diff --git a/SharePointFramework/shared-library/src/components/FilterPanel/FilterItem/FilterItem.tsx b/SharePointFramework/shared-library/src/components/FilterPanel/FilterItem/FilterItem.tsx index 1893ef840..580dd7084 100644 --- a/SharePointFramework/shared-library/src/components/FilterPanel/FilterItem/FilterItem.tsx +++ b/SharePointFramework/shared-library/src/components/FilterPanel/FilterItem/FilterItem.tsx @@ -1,13 +1,15 @@ +import { Checkbox } from '@fluentui/react-components' import React, { FC } from 'react' import styles from './FilterItem.module.scss' import { IFilterItemProps } from './types' -import { Checkbox } from '@fluentui/react-components' +import { useFilterItem } from './useFilterItem' export const FilterItem: FC = (props) => { + const { label } = useFilterItem(props) return ( diff --git a/SharePointFramework/shared-library/src/components/FilterPanel/FilterItem/types.tsx b/SharePointFramework/shared-library/src/components/FilterPanel/FilterItem/types.tsx index 42caff4ab..0e2c917e5 100644 --- a/SharePointFramework/shared-library/src/components/FilterPanel/FilterItem/types.tsx +++ b/SharePointFramework/shared-library/src/components/FilterPanel/FilterItem/types.tsx @@ -1,7 +1,9 @@ +import { IColumn } from '@fluentui/react' import { CheckboxProps } from '@fluentui/react-components' export interface IFilterItemProps extends Pick { name: string value: string selected?: boolean + column?: IColumn } diff --git a/SharePointFramework/shared-library/src/components/FilterPanel/FilterItem/useFilterItem.ts b/SharePointFramework/shared-library/src/components/FilterPanel/FilterItem/useFilterItem.ts new file mode 100644 index 000000000..351756373 --- /dev/null +++ b/SharePointFramework/shared-library/src/components/FilterPanel/FilterItem/useFilterItem.ts @@ -0,0 +1,16 @@ +import strings from 'SharedLibraryStrings' +import _ from 'lodash' +import { IFilterItemProps } from './types' + +export function useFilterItem(props: IFilterItemProps) { + switch (props.column.data.renderAs) { + case 'boolean': { + const valueIfTrue = _.get(props, 'column.data.dataTypeProperties.valueIfTrue', strings.BooleanYes) + const valueIfFalse = _.get(props, 'column.data.dataTypeProperties.valueIfFalse', strings.BooleanNo) + return { label: parseInt(props.value) === 1 ? valueIfTrue : valueIfFalse } + } + default: { + return { label: props.name } + } + } +} \ No newline at end of file diff --git a/SharePointFramework/shared-library/src/loc/mystrings.d.ts b/SharePointFramework/shared-library/src/loc/mystrings.d.ts index 4ae363ada..9f88570d3 100644 --- a/SharePointFramework/shared-library/src/loc/mystrings.d.ts +++ b/SharePointFramework/shared-library/src/loc/mystrings.d.ts @@ -1,5 +1,6 @@ -/* eslint-disable @typescript-eslint/no-empty-interface */ declare interface ISharedLibraryStrings { + BooleanYes: string + BooleanNo: string GtModerationStatus_Choice_Draft: string GtModerationStatus_Choice_Published: string SaveText: string diff --git a/SharePointFramework/shared-library/src/loc/nb-no.js b/SharePointFramework/shared-library/src/loc/nb-no.js index f6b45a49f..82bc532ed 100644 --- a/SharePointFramework/shared-library/src/loc/nb-no.js +++ b/SharePointFramework/shared-library/src/loc/nb-no.js @@ -61,5 +61,7 @@ define([], function () { TriangleLabel: 'Trekant', TypeLabel: 'Type', SyncListAddingField: 'Legger til felt {0} i prosjektegenskaper...', + BooleanYes: 'Ja', + BooleanNo: 'Nei', } })