Skip to content

Commit

Permalink
Fix issue with exporting currency and number values in views #1395
Browse files Browse the repository at this point in the history
  • Loading branch information
Remi749 committed Apr 16, 2024
1 parent 3ad91f8 commit 2d65069
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Sjekk ut [release notes](./releasenotes/1.9.0.md) for høydepunkter og mer detal
- 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)
- Rettet et problem hvor eksportering av visninger som inneholdt felttypene 'valuta' og 'nummer' ble vist med masse desimaler [#1395](https://github.com/Puzzlepart/prosjektportalen365/issues/1395)

### Forbedringer

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,19 @@ export function useExcelExport(context: IPortfolioAggregationContext) {
})
})
})
ExcelExportService.export(items, columns)

const filteredItems = items.map((item) => {
const filteredItem = { ...item }
Object.keys(filteredItem).forEach((key) => {
const column = columns.find((c) => c.fieldName === key)
if (column && (column.dataType === 'currency' || column.dataType === 'number')) {
filteredItem[key] = Math.floor(filteredItem[key])
}
})
return filteredItem
})

ExcelExportService.export(filteredItems, columns)
} catch (error) {}
}, [context.state])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,23 @@ export function useExcelExport(context: IPortfolioOverviewContext) {
})
})
})

const filteredItems = items.map((item) => {
const filteredItem = { ...item }
Object.keys(filteredItem).forEach((key) => {
const column = columns.find((c) => c.fieldName === key)
if (column && (column.dataType === 'currency' || column.dataType === 'number')) {
filteredItem[key] = Math.floor(filteredItem[key])
}
})
return filteredItem
})

let fileNamePart: string
if (includeViewNameInExcelExportFilename) {
fileNamePart = currentView?.title.replace(/[^a-z0-9]/gi, '-')
}
ExcelExportService.export(items, columns, fileNamePart)
ExcelExportService.export(filteredItems, columns, fileNamePart)
context.dispatch(EXCEL_EXPORT_SUCCESS())
} catch (error) {
context.dispatch(EXCEL_EXPORT_ERROR(error))
Expand Down

0 comments on commit 2d65069

Please sign in to comment.