fix: restrict furthermore when the summary is transformed into a path

This commit is contained in:
Ruben Fiszel
2023-08-10 09:28:50 +02:00
parent 20807b85bb
commit 2de4192cac
3 changed files with 14 additions and 2 deletions
+8
View File
@@ -39,6 +39,7 @@
export let disabled = false
export let checkInitialPathExistence = false
export let autofocus = true
export let dirty = false
export let kind: PathKind
let inputP: HTMLInputElement | undefined = undefined
@@ -69,6 +70,7 @@
}
function handleKeyUp(event: KeyboardEvent) {
setDirty()
const key = event.key
if (key === 'Enter') {
@@ -250,6 +252,10 @@
meta.owner = newFolderName
}
}
function setDirty() {
!dirty && (dirty = true)
}
</script>
<Drawer bind:this={newFolder}>
@@ -296,6 +302,7 @@
class="mt-0.5"
bind:selected={meta.ownerKind}
on:selected={(e) => {
setDirty()
const kind = e.detail
if (meta) {
if (kind === 'folder') {
@@ -338,6 +345,7 @@
bind:value={meta.owner}
placeholder={$userStore?.username ?? ''}
disabled={disabled || !($superadmin || ($userStore?.is_admin ?? false))}
on:keydown={setDirty}
/>
</label>
{:else if meta.ownerKind === 'folder'}
@@ -264,6 +264,7 @@
}
let path: Path | undefined = undefined
let dirtyPath = false
</script>
<svelte:window on:keydown={onKeyDown} />
@@ -279,7 +280,7 @@
bind:value={script.summary}
placeholder="Short summary to be displayed when listed"
on:keyup={() => {
if (initialPath == '' && script.summary?.length > 0) {
if (initialPath == '' && script.summary?.length > 0 && !dirtyPath) {
path?.setName(
script.summary
.toLowerCase()
@@ -295,6 +296,7 @@
bind:this={path}
bind:error={pathError}
bind:path={script.path}
bind:dirty={dirtyPath}
{initialPath}
autofocus={false}
namePlaceholder="script"
@@ -40,6 +40,7 @@
}
let path: Path | undefined = undefined
let dirtyPath = false
</script>
<div class="h-full overflow-hidden">
@@ -65,7 +66,7 @@
placeholder="Short summary to be displayed when listed"
id="flow-summary"
on:keyup={() => {
if (initialPath == '' && $flowStore.summary?.length > 0) {
if (initialPath == '' && $flowStore.summary?.length > 0 && !dirtyPath) {
path?.setName(
$flowStore.summary
.toLowerCase()
@@ -82,6 +83,7 @@
<Path
autofocus={false}
bind:this={path}
bind:dirty={dirtyPath}
bind:path={$flowStore.path}
{initialPath}
namePlaceholder="flow"