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

+
+ +
+