From b904f0811b28dea72f9fc3d5f260942d3a846493 Mon Sep 17 00:00:00 2001 From: Remi Blom-Ohlsen Date: Wed, 17 Apr 2024 19:06:42 +0200 Subject: [PATCH] Add PercentageColumn [skip-install] --- .../List/ItemColumn/PercentageColumn/index.tsx | 13 +++++++++++++ .../src/components/List/ItemColumn/registry.ts | 8 ++------ .../shared-library/src/types/ColumnDataType.ts | 1 + Templates/Portfolio/Objects/Lists/Datakilder.xml | 6 +++--- 4 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 SharePointFramework/PortfolioWebParts/src/components/List/ItemColumn/PercentageColumn/index.tsx diff --git a/SharePointFramework/PortfolioWebParts/src/components/List/ItemColumn/PercentageColumn/index.tsx b/SharePointFramework/PortfolioWebParts/src/components/List/ItemColumn/PercentageColumn/index.tsx new file mode 100644 index 000000000..a7e3dd66e --- /dev/null +++ b/SharePointFramework/PortfolioWebParts/src/components/List/ItemColumn/PercentageColumn/index.tsx @@ -0,0 +1,13 @@ +import strings from 'PortfolioWebPartsStrings' +import { tryParsePercentage } from 'pp365-shared-library' +import React from 'react' +import { ColumnRenderComponent } from '../types' + +export const PercentageColumn: ColumnRenderComponent = (props) => ( + {tryParsePercentage(props.columnValue, true, 0)} +) + +PercentageColumn.key = 'percentage' +PercentageColumn.id = 'Percentage' +PercentageColumn.displayName = strings.ColumnRenderOptionPercentage +PercentageColumn.iconName = 'CalculatorPercentage' diff --git a/SharePointFramework/PortfolioWebParts/src/components/List/ItemColumn/registry.ts b/SharePointFramework/PortfolioWebParts/src/components/List/ItemColumn/registry.ts index de0a3ed98..28baaa84b 100644 --- a/SharePointFramework/PortfolioWebParts/src/components/List/ItemColumn/registry.ts +++ b/SharePointFramework/PortfolioWebParts/src/components/List/ItemColumn/registry.ts @@ -6,6 +6,7 @@ import { GetDataTypeProperties, IColumnDataTypeFieldOption } from './ColumnDataT import { BooleanColumn } from './BooleanColumn' import { CurrencyColumn } from './CurrencyColumn' import { NumberColumn } from './NumberColumn' +import { PercentageColumn } from './PercentageColumn' import { DateColumn } from './DateColumn' import { DialogColumn } from './DialogColumn' import { FileNameColumn } from './FileNameColumn' @@ -234,6 +235,7 @@ export function useColumnRenderComponentRegistry() { FileNameColumn, CurrencyColumn, NumberColumn, + PercentageColumn, ListColumn, DialogColumn, TagsColumn, @@ -254,11 +256,5 @@ export function useColumnRenderComponentRegistry() { strings.ColumnRenderOptionNote, 'EditStyle' ) - ColumnRenderComponentRegistry.registerColumnRenderOption( - 'percentage', - 'Percentage', - strings.ColumnRenderOptionPercentage, - 'CalculatorPercentage' - ) }, []) } diff --git a/SharePointFramework/shared-library/src/types/ColumnDataType.ts b/SharePointFramework/shared-library/src/types/ColumnDataType.ts index 1abbd4b0d..d90dbf99b 100644 --- a/SharePointFramework/shared-library/src/types/ColumnDataType.ts +++ b/SharePointFramework/shared-library/src/types/ColumnDataType.ts @@ -3,6 +3,7 @@ export type ColumnDataType = | 'date' | 'currency' | 'number' + | 'percentage' | 'tags' | 'boolean' | 'url' diff --git a/Templates/Portfolio/Objects/Lists/Datakilder.xml b/Templates/Portfolio/Objects/Lists/Datakilder.xml index 224017ccb..13108e25f 100644 --- a/Templates/Portfolio/Objects/Lists/Datakilder.xml +++ b/Templates/Portfolio/Objects/Lists/Datakilder.xml @@ -197,10 +197,10 @@ fbe4dcc8-ed4c-4c0a-ad52-4247ca90f9b3 Alle ressursallokeringer for underområder - (ContentTypeId:0x010004EAFF7AFCC94C2680042E6881264120* OR ContentTypeId:0x010029F45E75BA9CE340A83EFFB2927E11F4*) DepartmentId:{{sitecollectionid}} + ContentTypeId:0x010004EAFF7AFCC94C2680042E6881264120* DepartmentId:{{sitecollectionid}} Ressursallokering - 57,58,59,60,61,62,63,64,65 - 57,58,62,64 + 57,58,59,60,61,62,63 + 57,58,62 SizeLegacy Overordnet/Program