diff --git a/CHANGELOG.md b/CHANGELOG.md index b3a6e47a4..68b0e561e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ Sjekk ut [release notes](./releasenotes/1.9.0.md) for høydepunkter og mer detal - Rettet et problem hvor noen Idémodul listekommandoer ikke ble vist dersom andre Idé-lister var definert i `Idékonfigurasjon` [#1430](https://github.com/Puzzlepart/prosjektportalen365/issues/1430) - Rettet et problem hvor avviklede termer ble vist i nedtrekksmenyer for taksonomi felter [#1499](https://github.com/Puzzlepart/prosjektportalen365/issues/1499) - Rettet et problem hvor antall linjer angitt for et 'multi-linje' felt ikke ble reflektert i det nye redigeringspanelet [#1500](https://github.com/Puzzlepart/prosjektportalen365/issues/1500) +- Rettet et problem hvor valuta ikke ble riktig sortert på porteføljeoversikt og andre aggregerte oversikter [#1369](https://github.com/Puzzlepart/prosjektportalen365/issues/1369) ### Forbedringer diff --git a/SharePointFramework/PortfolioWebParts/src/components/PortfolioAggregation/reducer/createPortfolioAggregationReducer.ts b/SharePointFramework/PortfolioWebParts/src/components/PortfolioAggregation/reducer/createPortfolioAggregationReducer.ts index d9509054a..aed0abda0 100644 --- a/SharePointFramework/PortfolioWebParts/src/components/PortfolioAggregation/reducer/createPortfolioAggregationReducer.ts +++ b/SharePointFramework/PortfolioWebParts/src/components/PortfolioAggregation/reducer/createPortfolioAggregationReducer.ts @@ -222,9 +222,23 @@ export const createPortfolioAggregationReducer = ( state.groupBy = null state.groups = null } - state.items = sortArray([...state.items], [payload.column.fieldName], { - reverse: !isSortedDescending - }) + if (payload.column.dataType === 'currency') { + state.items = state.items.sort((a, b) => { + const aValue = parseFloat(a[payload.column.fieldName]?.replace(/[^0-9.-]+/g, '')) || null + const bValue = parseFloat(b[payload.column.fieldName]?.replace(/[^0-9.-]+/g, '')) || null + if (aValue === bValue) + return 0 + if (aValue === null) + return isSortedDescending ? 1 : -1 + if (bValue === null) + return isSortedDescending ? -1 : 1 + return isSortedDescending ? aValue - bValue : aValue - bValue + }) + } else { + state.items = sortArray([...state.items], [payload.column.fieldName], { + reverse: !isSortedDescending + }) + } state.columns = [...state.columns].map((col) => { col.isSorted = col.key === payload.column.key col.isSortedDescending = col.isSorted ? isSortedDescending : false diff --git a/SharePointFramework/PortfolioWebParts/src/components/PortfolioOverview/reducer/index.ts b/SharePointFramework/PortfolioWebParts/src/components/PortfolioOverview/reducer/index.ts index b2382cad0..013386428 100644 --- a/SharePointFramework/PortfolioWebParts/src/components/PortfolioOverview/reducer/index.ts +++ b/SharePointFramework/PortfolioWebParts/src/components/PortfolioOverview/reducer/index.ts @@ -137,9 +137,23 @@ const $createReducer = (params: IPortfolioOverviewReducerParams) => return isSortedDescending ? $a - $b : $b - $a }) } else { - state.items = sortArray(state.items, [payload.column.fieldName], { - reverse: !isSortedDescending - }) + if (payload.column.dataType === 'currency') { + state.items = state.items.sort((a, b) => { + const aValue = parseFloat(a[payload.column.fieldName]?.replace(/[^0-9.-]+/g, '')) || null + const bValue = parseFloat(b[payload.column.fieldName]?.replace(/[^0-9.-]+/g, '')) || null + if (aValue === bValue) + return 0 + if (aValue === null) + return isSortedDescending ? 1 : -1 + if (bValue === null) + return isSortedDescending ? -1 : 1 + return isSortedDescending ? aValue - bValue : aValue - bValue + }) + } else { + state.items = sortArray(state.items, [payload.column.fieldName], { + reverse: !isSortedDescending + }) + } } state.sortBy = _.pick(payload, ['column', 'customSort']) state.columns = state.columns.map((col) => {