Use display names and allow descriptions to be edited

This commit is contained in:
Andrew Kingston 2024-09-11 13:11:41 +01:00
parent 9f0c160bfa
commit a5520a973c
No known key found for this signature in database
3 changed files with 20 additions and 11 deletions

View File

@ -17,9 +17,10 @@
targetPosition: Position.Left, targetPosition: Position.Left,
type: "role", type: "role",
data: { data: {
label: "New role", displayName: "New role",
description: "Custom role", description: "Custom role",
custom: true, custom: true,
color: "var(--spectrum-global-color-gray-700)",
}, },
position: { x: 0, y: 0 }, position: { x: 0, y: 0 },
}, },

View File

@ -23,7 +23,8 @@
let anchor let anchor
let modal let modal
let tempLabel let tempDisplayName
let tempDescription
let tempColor let tempColor
$: color = data.color || RoleUtils.getRoleColour(id) $: color = data.color || RoleUtils.getRoleColour(id)
@ -37,14 +38,16 @@
} }
const openPopover = () => { const openPopover = () => {
tempLabel = data.label tempDisplayName = data.displayName
tempDescription = data.description
tempColor = color tempColor = color
modal.show() modal.show()
} }
const saveChanges = () => { const saveChanges = () => {
flow.updateNodeData(id, { flow.updateNodeData(id, {
label: tempLabel, displayName: tempDisplayName,
description: tempDescription,
color: tempColor, color: tempColor,
}) })
} }
@ -66,8 +69,8 @@
<div class="color" /> <div class="color" />
<div class="content"> <div class="content">
<div class="title"> <div class="title">
<div class="label"> <div class="name">
{data.label} {data.displayName}
</div> </div>
{#if data.custom} {#if data.custom}
<div class="buttons"> <div class="buttons">
@ -92,14 +95,19 @@
<Modal bind:this={modal}> <Modal bind:this={modal}>
<ModalContent <ModalContent
title={`Edit ${data.label}`} title={`Edit ${data.displayName}`}
confirmText="Save" confirmText="Save"
onConfirm={saveChanges} onConfirm={saveChanges}
> >
<Input <Input
label="Name" label="Name"
value={tempLabel} value={tempDisplayName}
on:change={e => (tempLabel = e.detail)} on:change={e => (tempDisplayName = e.detail)}
/>
<Input
label="Description"
value={tempDescription}
on:change={e => (tempDescription = e.detail)}
/> />
<div> <div>
<FieldLabel label="Color" /> <FieldLabel label="Color" />
@ -160,7 +168,7 @@
.title :global(.spectrum-Icon) { .title :global(.spectrum-Icon) {
color: var(--spectrum-global-color-gray-600); color: var(--spectrum-global-color-gray-600);
} }
.label { .name {
white-space: nowrap; white-space: nowrap;
text-overflow: ellipsis; text-overflow: ellipsis;
overflow: hidden; overflow: hidden;

View File

@ -29,7 +29,7 @@ export const defaultLayout = () => {
targetPosition: Position.Left, targetPosition: Position.Left,
type: "role", type: "role",
data: { data: {
label: role.name, displayName: role.displayName || role.name || "",
description: descriptions[role._id] || "Custom role", description: descriptions[role._id] || "Custom role",
color: role.color, color: role.color,
custom: !role._id.match(/[A-Z]+/), custom: !role._id.match(/[A-Z]+/),