From 9f24d2d40a88c2dc1b69aa7c9e3fc2de98ee464a Mon Sep 17 00:00:00 2001 From: Eric NGUYEN Date: Fri, 16 Sep 2022 15:00:40 +0200 Subject: [PATCH] Implement displayed text --- src/Components/Sidebar/Sidebar.tsx | 2 +- src/Interfaces/IAvailableContainer.ts | 3 +++ src/utils/default.ts | 2 +- test-server/http.js | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Components/Sidebar/Sidebar.tsx b/src/Components/Sidebar/Sidebar.tsx index 3c36de5..cf695de 100644 --- a/src/Components/Sidebar/Sidebar.tsx +++ b/src/Components/Sidebar/Sidebar.tsx @@ -32,7 +32,7 @@ export function Sidebar(props: ISidebarProps): JSX.Element { draggable={true} onDragStart={(event) => HandleDragStart(event)} > - {TruncateString(componentOption.Type, 25)} + {TruncateString(componentOption.DisplayedText ?? componentOption.Type, 25)} ); if (componentOption.Category === null || componentOption.Category === undefined) { rootElements.push(componentButton); diff --git a/src/Interfaces/IAvailableContainer.ts b/src/Interfaces/IAvailableContainer.ts index 027f10c..d61c57f 100644 --- a/src/Interfaces/IAvailableContainer.ts +++ b/src/Interfaces/IAvailableContainer.ts @@ -10,6 +10,9 @@ export interface IAvailableContainer { /** type */ Type: string + /** displayed text */ + DisplayedText?: string + /** category */ Category?: string diff --git a/src/utils/default.ts b/src/utils/default.ts index 7eb4a3b..f71f21d 100644 --- a/src/utils/default.ts +++ b/src/utils/default.ts @@ -160,7 +160,7 @@ export function GetDefaultContainerProps(type: string, type, parentId: parent.properties.id, linkedSymbolId: '', - displayedText: `${type}-${typeCount}`, + displayedText: `${containerConfig.DisplayedText ?? type}-${typeCount}`, x, y, margin: containerConfig.Margin ?? {}, diff --git a/test-server/http.js b/test-server/http.js index 0feb864..a729545 100644 --- a/test-server/http.js +++ b/test-server/http.js @@ -64,6 +64,7 @@ const GetSVGLayoutConfiguration = () => { AvailableContainers: [ { Type: 'Chassis', + DisplayedText: 'Chassis?', MaxWidth: 500, MinWidth: 200, Width: 200,