From a69feda6bfe2a5e6afabc4ce368619b6af965664 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81d=C3=A1m=20Kov=C3=A1cs?= <43071496+adam-kov@users.noreply.github.com> Date: Sun, 2 Apr 2023 15:46:24 +0200 Subject: [PATCH] feat(frontend): Add ID renaming popup (#1344) * feat(frontend): Add id renaming popup * fix(frontend): State reset * actually do it --------- Co-authored-by: Ruben Fiszel --- .../src/lib/components/DisplayResult.svelte | 12 +- .../components/inputs/AppTextInput.svelte | 15 ++- .../editor/component/ComponentWrapper.svelte | 5 + .../contextPanel/components/IdEditor.svelte | 95 +++++++++++++++ .../components/OutputHeader.svelte | 115 +++++++++++++++--- .../lib/components/common/popup/Popup.svelte | 10 +- frontend/src/lib/components/flows/idUtils.ts | 2 +- 7 files changed, 218 insertions(+), 36 deletions(-) create mode 100644 frontend/src/lib/components/apps/editor/contextPanel/components/IdEditor.svelte diff --git a/frontend/src/lib/components/DisplayResult.svelte b/frontend/src/lib/components/DisplayResult.svelte index d1d87bd78a..e672f00d49 100644 --- a/frontend/src/lib/components/DisplayResult.svelte +++ b/frontend/src/lib/components/DisplayResult.svelte @@ -99,19 +99,17 @@
as JSON 
{/if}{#if typeof result == 'object' && Object.keys(result).length > 0}
The result keys are: {truncate(Object.keys(result).join(', '), 50)} -
+
{/if}{#if !forceJson && resultKind == 'table-col'}
{#each Object.keys(result) as col}
-
+
{col}
{#if Array.isArray(result[col])} @@ -125,7 +123,7 @@ {/each}
{:else if !forceJson && resultKind == 'table-row'}
diff --git a/frontend/src/lib/components/apps/components/inputs/AppTextInput.svelte b/frontend/src/lib/components/apps/components/inputs/AppTextInput.svelte index a1bc9d59ee..c8708598ec 100644 --- a/frontend/src/lib/components/apps/components/inputs/AppTextInput.svelte +++ b/frontend/src/lib/components/apps/components/inputs/AppTextInput.svelte @@ -19,7 +19,8 @@ | 'textareainputcomponent' = 'textinputcomponent' export let render: boolean - const { app, worldStore, selectedComponent } = getContext('AppViewerContext') + const { app, worldStore, selectedComponent, connectingInput } = + getContext('AppViewerContext') let placeholder: string | undefined = undefined let defaultValue: string | undefined = undefined @@ -50,7 +51,8 @@ css?.input?.class ?? '' )} style="resize:none; {css?.input?.style ?? ''}" - on:pointerdown|stopPropagation={(e) => selectId(e, id, selectedComponent, $app)} + on:pointerdown|stopPropagation={(e) => + !$connectingInput.opened && selectId(e, id, selectedComponent, $app)} bind:value {placeholder} /> @@ -63,7 +65,8 @@ css?.input?.class ?? '' )} style={css?.input?.style ?? ''} - on:pointerdown|stopPropagation={(e) => selectId(e, id, selectedComponent, $app)} + on:pointerdown|stopPropagation={(e) => + !$connectingInput.opened && selectId(e, id, selectedComponent, $app)} type="password" bind:value {placeholder} @@ -75,7 +78,8 @@ css?.input?.class ?? '' )} style={css?.input?.style ?? ''} - on:pointerdown|stopPropagation={(e) => selectId(e, id, selectedComponent, $app)} + on:pointerdown|stopPropagation={(e) => + !$connectingInput.opened && selectId(e, id, selectedComponent, $app)} type="text" bind:value {placeholder} @@ -87,7 +91,8 @@ css?.input?.class ?? '' )} style={css?.input?.style ?? ''} - on:pointerdown|stopPropagation={(e) => selectId(e, id, selectedComponent, $app)} + on:pointerdown|stopPropagation={(e) => + !$connectingInput.opened && selectId(e, id, selectedComponent, $app)} type="email" bind:value {placeholder} diff --git a/frontend/src/lib/components/apps/editor/component/ComponentWrapper.svelte b/frontend/src/lib/components/apps/editor/component/ComponentWrapper.svelte index a79da8ca21..bc535c00a5 100644 --- a/frontend/src/lib/components/apps/editor/component/ComponentWrapper.svelte +++ b/frontend/src/lib/components/apps/editor/component/ComponentWrapper.svelte @@ -59,6 +59,11 @@ e.stopPropagation() } }} + on:focus={(e) => { + if ($connectingInput.opened) { + e.stopPropagation() + } + }} on:pointerdown={onPointerDown} on:click|capture={(event) => preventInteraction(event, type === 'tabscomponent')} on:drag|capture={preventInteraction} diff --git a/frontend/src/lib/components/apps/editor/contextPanel/components/IdEditor.svelte b/frontend/src/lib/components/apps/editor/contextPanel/components/IdEditor.svelte new file mode 100644 index 0000000000..da2d76262e --- /dev/null +++ b/frontend/src/lib/components/apps/editor/contextPanel/components/IdEditor.svelte @@ -0,0 +1,95 @@ + + + + (value = id)} +> + + diff --git a/frontend/src/lib/components/apps/editor/contextPanel/components/OutputHeader.svelte b/frontend/src/lib/components/apps/editor/contextPanel/components/OutputHeader.svelte index c39e46d03b..6001c20c01 100644 --- a/frontend/src/lib/components/apps/editor/contextPanel/components/OutputHeader.svelte +++ b/frontend/src/lib/components/apps/editor/contextPanel/components/OutputHeader.svelte @@ -1,9 +1,11 @@
{ + on:mouseenter|stopPropagation={() => { if (id !== $hoverStore) { $hoverStore = id } }} - on:mouseout|stopPropagation={() => { + on:mouseleave|stopPropagation={() => { if ($hoverStore !== undefined) { $hoverStore = undefined } @@ -74,26 +140,35 @@ $manuallyOpened[id] = $manuallyOpened[id] != undefined ? !$manuallyOpened[id] : true }} > -
- {#if selectable && !$selectedComponent?.includes(id)} -
- +
+ {id}
+ {#if selectable && !$selectedComponent?.includes(id)} +
+ +
+ {/if} + + {#if selectable && ($selectedComponent?.includes(id) || $hoverStore === id)} + ($selectedComponent = [id])} + on:change={({ detail }) => renameId(detail)} + /> {/if} - +
{name} {#if !open} diff --git a/frontend/src/lib/components/common/popup/Popup.svelte b/frontend/src/lib/components/common/popup/Popup.svelte index 37d2950b29..06ac01950d 100644 --- a/frontend/src/lib/components/common/popup/Popup.svelte +++ b/frontend/src/lib/components/common/popup/Popup.svelte @@ -1,7 +1,7 @@