Add displayed text
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Siklos 2022-08-18 14:37:49 +02:00
parent 1d67702696
commit f569e54ce0
6 changed files with 26 additions and 2 deletions

View file

@ -83,7 +83,9 @@ export const ElementsSidebar: React.FC<IElementsSidebarProps> = (props: IElement
const container = containers[index]; const container = containers[index];
const depth: number = getDepth(container); const depth: number = getDepth(container);
const key = container.properties.id.toString(); const key = container.properties.id.toString();
const text = '|\t'.repeat(depth) + key; const text = container.properties.displayedText === key
? `${'|\t'.repeat(depth)} ${key}`
: `${'|\t'.repeat(depth)} ${container.properties.displayedText} (${key})`;
const selectedClass: string = props.SelectedContainer !== undefined && const selectedClass: string = props.SelectedContainer !== undefined &&
props.SelectedContainer !== null && props.SelectedContainer !== null &&
props.SelectedContainer.properties.id === container.properties.id props.SelectedContainer.properties.id === container.properties.id

View file

@ -52,6 +52,15 @@ const DynamicForm: React.FunctionComponent<IDynamicFormProps> = (props) => {
value={props.properties.parentId?.toString()} value={props.properties.parentId?.toString()}
isDisabled={true} isDisabled={true}
/> />
<InputGroup
labelText='Displayed text'
inputKey='displayedText'
labelClassName=''
inputClassName=''
type='string'
value={props.properties.displayedText?.toString()}
onChange={(event) => props.onChange('displayedText', event.target.value)}
/>
<InputGroup <InputGroup
labelText='x' labelText='x'
inputKey='x' inputKey='x'

View file

@ -52,6 +52,14 @@ const StaticForm: React.FunctionComponent<IStaticFormProps> = (props) => {
defaultValue={props.properties.parentId?.toString()} defaultValue={props.properties.parentId?.toString()}
isDisabled={true} isDisabled={true}
/> />
<InputGroup
labelText='Displayed text'
inputKey='displayedText'
labelClassName=''
inputClassName=''
type='string'
defaultValue={props.properties.displayedText?.toString()}
/>
<InputGroup <InputGroup
labelText='x' labelText='x'
inputKey='x' inputKey='x'

View file

@ -98,7 +98,7 @@ export const Container: React.FC<IContainerProps> = (props: IContainerProps) =>
x={xText} x={xText}
y={yText} y={yText}
> >
{props.model.properties.id} {props.model.properties.displayedText}
</text> </text>
: null } : null }
{ containersElements } { containersElements }

View file

@ -11,6 +11,9 @@ export default interface IProperties {
/** id of the parent container (null when there is no parent) */ /** id of the parent container (null when there is no parent) */
parentId: string | null parentId: string | null
/** Text displayed in the container */
displayedText: string
/** horizontal offset */ /** horizontal offset */
x: number x: number

View file

@ -48,6 +48,7 @@ export const DEFAULT_CONFIG: IConfiguration = {
export const DEFAULT_MAINCONTAINER_PROPS: IProperties = { export const DEFAULT_MAINCONTAINER_PROPS: IProperties = {
id: 'main', id: 'main',
parentId: 'null', parentId: 'null',
displayedText: 'main',
x: 0, x: 0,
y: 0, y: 0,
minWidth: 1, minWidth: 1,
@ -72,6 +73,7 @@ export const GetDefaultContainerProps = (
): IProperties => ({ ): IProperties => ({
id: `${type}-${typeCount}`, id: `${type}-${typeCount}`,
parentId: parent.properties.id, parentId: parent.properties.id,
displayedText: `${type}-${typeCount}`,
x, x,
y, y,
width: containerConfig.Width ?? containerConfig.MinWidth ?? parent.properties.width, width: containerConfig.Width ?? containerConfig.MinWidth ?? parent.properties.width,