Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boolean felttyper vises feil og filtreres ikke korrekt #1579 #1598

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ Sjekk ut [release notes](./releasenotes/1.10.0.md) for høydepunkter og mer deta
- Forbedret feilhåndtering for redigeringspanel for statusrapport [#1578](https://github.com/Puzzlepart/prosjektportalen365/issues/1578)
- Forbedret feilhåndtering for provisjonering av Planner-oppgaver [#1593](https://github.com/Puzzlepart/prosjektportalen365/issues/1593)

### Feilrettinger
- Boolean felttyper vises nå riktig, og filtreres korrekt [#1579](https://github.com/Puzzlepart/prosjektportalen365/issues/1579)

## 1.10.1 - TBA

### Forbedringer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) => (
<FilterItem
key={idx}
{...props}
onChange={(_event, { checked }) => onChange(props, checked as boolean)}
{...item}
column={props.column}
onChange={(_event, { checked }) => onChange(item, checked as boolean)}
/>
))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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<IFilterItemProps> = (props) => {
const { label } = useFilterItem(props)
return (
<Checkbox
className={styles.filterItem}
label={props.name}
label={label}
checked={props.selected}
onChange={props.onChange}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { IColumn } from '@fluentui/react'
import { CheckboxProps } from '@fluentui/react-components'

export interface IFilterItemProps extends Pick<CheckboxProps, 'onChange'> {
name: string
value: string
selected?: boolean
column?: IColumn
}
Original file line number Diff line number Diff line change
@@ -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 }
}
}
}
3 changes: 2 additions & 1 deletion SharePointFramework/shared-library/src/loc/mystrings.d.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions SharePointFramework/shared-library/src/loc/nb-no.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,7 @@ define([], function () {
TriangleLabel: 'Trekant',
TypeLabel: 'Type',
SyncListAddingField: 'Legger til felt {0} i prosjektegenskaper...',
BooleanYes: 'Ja',
BooleanNo: 'Nei',
}
})
Loading