From fcdd02dca63df37d6d85b464ef46ba106ebd8ac5 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Wed, 26 Jul 2023 01:29:22 +0200 Subject: [PATCH] generate slug from summary on creation --- frontend/src/lib/components/Path.svelte | 7 +++ .../src/lib/components/ScriptBuilder.svelte | 33 ++++++++---- .../apps/editor/AppEditorHeader.svelte | 53 +++++++++++-------- .../components/apps/editor/GridEditor.svelte | 2 +- .../flows/content/FlowSettings.svelte | 53 +++++++++++++------ frontend/tailwind.config.cjs | 3 ++ 6 files changed, 104 insertions(+), 47 deletions(-) diff --git a/frontend/src/lib/components/Path.svelte b/frontend/src/lib/components/Path.svelte index 6b94790c75..acd937dd8d 100644 --- a/frontend/src/lib/components/Path.svelte +++ b/frontend/src/lib/components/Path.svelte @@ -76,6 +76,13 @@ } } + export function setName(x: string) { + if (meta) { + meta.name = x + onMetaChange() + } + } + export async function reset() { if (path == '' || path == 'u//') { if ($lastMetaUsed == undefined || $lastMetaUsed.owner != $userStore?.username) { diff --git a/frontend/src/lib/components/ScriptBuilder.svelte b/frontend/src/lib/components/ScriptBuilder.svelte index 18c211c39e..ab49dba7b3 100644 --- a/frontend/src/lib/components/ScriptBuilder.svelte +++ b/frontend/src/lib/components/ScriptBuilder.svelte @@ -257,6 +257,19 @@ break } } + + let path: Path | undefined = undefined + $: { + if (initialPath == '' && script.summary?.length > 0) { + path?.setName( + script.summary + .toLowerCase() + .replace(/[^a-z0-9_]/g, '_') + .replace(/-+/g, '_') + .replace(/^-|-$/g, '') + ) + } + } @@ -264,21 +277,23 @@ {#if !$userStore?.operator} (metadataOpen = false)}> -

Path

- -

Summary

+

Summary

+

Path

+ +

Language

{#if lockedLanguage} diff --git a/frontend/src/lib/components/apps/editor/AppEditorHeader.svelte b/frontend/src/lib/components/apps/editor/AppEditorHeader.svelte index d2e5c32dbd..659a951e5a 100644 --- a/frontend/src/lib/components/apps/editor/AppEditorHeader.svelte +++ b/frontend/src/lib/components/apps/editor/AppEditorHeader.svelte @@ -386,6 +386,19 @@ } lock = false } + + let path: Path | undefined = undefined + $: { + if (appPath == '' && $summary?.length > 0) { + path?.setName( + $summary + .toLowerCase() + .replace(/[^a-z0-9_]/g, '_') + .replace(/-+/g, '_') + .replace(/^-|-$/g, '') + ) + } + } @@ -400,16 +413,6 @@ Choose a path to save the initial draft of the app. -
- -
-

Summary

+
+ +
+