This commit is contained in:
Carl Fuchs 2023-01-25 14:42:05 +01:00
parent 2c6b511a2f
commit 7c83116df1
8 changed files with 32 additions and 9 deletions

View file

@ -22,6 +22,15 @@ export function SymbolForm(props: ISymbolFormProps): JSX.Element {
type='string' type='string'
value={props.symbol.id.toString()} value={props.symbol.id.toString()}
isDisabled={true} /> isDisabled={true} />
<TextInputGroup
id='displayedText'
labelText={Text({ textId: '@SymbolDisplayedText' })}
inputKey='displayedText'
labelClassName=''
inputClassName=''
type='string'
value={props.symbol.displayedText}
onChange={(value) => props.onChange('displayedText', value)} />
<TextInputGroup <TextInputGroup
id='x' id='x'
labelText={Text({ textId: '@SymbolX' })} labelText={Text({ textId: '@SymbolX' })}

View file

@ -16,13 +16,13 @@ export function SymbolsSidebar(props: ISymbolsSidebarProps): JSX.Element {
const divRef = React.useRef<HTMLDivElement>(null); const divRef = React.useRef<HTMLDivElement>(null);
const height = useSize(divRef)[1]; const height = useSize(divRef)[1];
// Render // Render
const containers = [...props.symbols.values()]; const symbols = [...props.symbols.values()];
function Row({ index, style }: { index: number, style: React.CSSProperties }): JSX.Element { function Row({ index, style }: { index: number, style: React.CSSProperties }): JSX.Element {
const container = containers[index]; const symbol = symbols[index];
const key = container.id.toString(); const key = symbol.id;
const text = key; const text = symbol.displayedText;
const selectedClass: string = props.selectedSymbolId !== '' && const selectedClass: string = props.selectedSymbolId !== '' &&
props.selectedSymbolId === container.id props.selectedSymbolId === symbol.id
? 'border-l-4 bg-slate-400/60 hover:bg-slate-400' ? 'border-l-4 bg-slate-400/60 hover:bg-slate-400'
: 'bg-slate-300/60 hover:bg-slate-300'; : 'bg-slate-300/60 hover:bg-slate-300';
@ -45,7 +45,7 @@ export function SymbolsSidebar(props: ISymbolsSidebarProps): JSX.Element {
<div ref={divRef} className='h-1/2 text-gray-800'> <div ref={divRef} className='h-1/2 text-gray-800'>
<List <List
className='List divide-y divide-black' className='List divide-y divide-black'
itemCount={containers.length} itemCount={symbols.length}
itemSize={35} itemSize={35}
height={height} height={height}
width={'100%'} width={'100%'}

View file

@ -10,6 +10,9 @@ export interface IAvailableSymbol {
Image: IImage Image: IImage
/** displayed text */
DisplayedText?: string
X?: number X?: number
Y?: number Y?: number

View file

@ -4,6 +4,9 @@ export interface ISymbolModel {
/** Identifier */ /** Identifier */
id: string id: string
/** Displayed Text */
displayedText: string
/** Type */ /** Type */
type: string type: string

View file

@ -69,6 +69,7 @@
"@StyleFillOpacity": "Fill Opacity", "@StyleFillOpacity": "Fill Opacity",
"@SymbolName": "Name", "@SymbolName": "Name",
"@SymbolDisplayedText": "Displayed text",
"@SymbolX": "x", "@SymbolX": "x",
"@SymbolHeight": "Height", "@SymbolHeight": "Height",
"@SymbolWidth": "Width" "@SymbolWidth": "Width"

View file

@ -69,6 +69,7 @@
"@StyleFillOpacity": "Opacité du remplissage", "@StyleFillOpacity": "Opacité du remplissage",
"@SymbolName": "Nom", "@SymbolName": "Nom",
"@SymbolDisplayedText": "Texte affiché",
"@SymbolX": "x", "@SymbolX": "x",
"@SymbolHeight": "Hauteur", "@SymbolHeight": "Hauteur",
"@SymbolWidth": "Largeur" "@SymbolWidth": "Largeur"

View file

@ -227,6 +227,8 @@ export const DEFAULT_MAINCONTAINER_PROPS: IContainerProperties = {
* @param parent Parent of the container * @param parent Parent of the container
* @param x horizontal offset * @param x horizontal offset
* @param y vertical offset * @param y vertical offset
* @param width
* @param height
* @param containerConfig default config of the container sent by the API * @param containerConfig default config of the container sent by the API
* @returns {IContainerProperties} Default properties of a newly created container * @returns {IContainerProperties} Default properties of a newly created container
*/ */
@ -276,8 +278,10 @@ export function GetDefaultSymbolModel(name: string,
newCounters: Record<string, number>, newCounters: Record<string, number>,
type: string, type: string,
symbolConfig: IAvailableSymbol): ISymbolModel { symbolConfig: IAvailableSymbol): ISymbolModel {
const id = `${name}-${newCounters[type]}`;
return { return {
id: `${name}-${newCounters[type]}`, id,
displayedText: symbolConfig.DisplayedText ?? id,
type: name, type: name,
config: structuredClone(symbolConfig), config: structuredClone(symbolConfig),
x: 0, x: 0,

View file

@ -30,6 +30,7 @@ const requestListener = async (request, response) => {
break; break;
case 'SplitRemplissageParent': case 'SplitRemplissageParent':
json = SplitRemplissage(bodyParsed); json = SplitRemplissage(bodyParsed);
break;
default: default:
break; break;
} }
@ -274,6 +275,7 @@ const GetSVGLayoutConfiguration = () => {
], ],
AvailableSymbols: [ AvailableSymbols: [
{ {
DisplayedText: 'Nom du Symbol',
Width: 32, Width: 32,
Height: 32, Height: 32,
Image: { Image: {
@ -359,7 +361,7 @@ const FillHoleWithChassis = (request) => {
}; };
}; };
const SplitRemplissage = (request) => { const SplitRemplissage = () => {
const lstModels = [ const lstModels = [
{ {
Type: 'Remplissage', Type: 'Remplissage',
@ -380,7 +382,7 @@ const SplitRemplissage = (request) => {
}; };
const Insert = (request) => { const Insert = () => {
const lstModels = [ const lstModels = [
{ {
Type: 'Remplissage', Type: 'Remplissage',