From c3971f99fcc4df6cece0f7dee1cf155c4ddbe90c Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Tue, 29 Jul 2025 12:40:37 +0000 Subject: [PATCH] support $res: string in form inputs of arrays --- frontend/src/lib/components/ArgInput.svelte | 48 ++++++++++++++----- .../(root)/(logged)/resources/+page.svelte | 12 ++++- 2 files changed, 47 insertions(+), 13 deletions(-) diff --git a/frontend/src/lib/components/ArgInput.svelte b/frontend/src/lib/components/ArgInput.svelte index 81189d614e..5e197fcab5 100644 --- a/frontend/src/lib/components/ArgInput.svelte +++ b/frontend/src/lib/components/ArgInput.svelte @@ -9,7 +9,7 @@ emptyString, getSchemaFromProperties } from '$lib/utils' - import { DollarSign, Plus, X, Check, Loader2 } from 'lucide-svelte' + import { DollarSign, Plus, X, Check, Loader2, ExternalLink } from 'lucide-svelte' import { createEventDispatcher, onDestroy, onMount, tick, untrack } from 'svelte' import { fade } from 'svelte/transition' import { Button, SecondsInput } from './common' @@ -41,6 +41,7 @@ import MultiSelect from './select/MultiSelect.svelte' import { safeSelectItems } from './select/utils.svelte' import S3ArgInput from './common/fileUpload/S3ArgInput.svelte' + import { base } from '$lib/base' interface Props { label?: string @@ -496,6 +497,29 @@ }) +{#snippet variableInput()} + {#if variableEditor} +
+ {#if value && typeof value == 'string' && value?.startsWith('$var:')} + Linked to variable + {/if} +
+ {/if} +{/snippet} +{#snippet resourceInput()} + {#if variableEditor} +
+ {#if value && typeof value == 'string' && value?.startsWith('$res:')} + Linked to resource {value.slice(5)} + {/if} +
+ {/if} +{/snippet}
{itemsLimit}/{value.length}: Load 50 more... {/if} + {:else if typeof value === 'string'} + {#if value.startsWith('$res:')} + {@render resourceInput()} + {:else} +
+ Invalid string value: "{value}", expected array. Click add item to turn it + into an array. +
+ {/if} {/if} {/key}
@@ -1240,17 +1273,8 @@ {/if} {/if} - {#if variableEditor} -
- {#if value && typeof value == 'string' && value?.startsWith('$var:')} - Linked to variable - {/if} -
- {/if} + {@render variableInput()} + {@render resourceInput()} {/if} {@render actions?.()} diff --git a/frontend/src/routes/(root)/(logged)/resources/+page.svelte b/frontend/src/routes/(root)/(logged)/resources/+page.svelte index 1c0a8172c7..b3f0118584 100644 --- a/frontend/src/routes/(root)/(logged)/resources/+page.svelte +++ b/frontend/src/routes/(root)/(logged)/resources/+page.svelte @@ -417,6 +417,16 @@ } }) + onMount(() => { + let hash = $page.url.hash + if (hash.startsWith('#/resource/')) { + console.log('hash', hash) + let path = hash.slice(11) + resourceEditor?.initEdit(path) + + } + }) + let dbManagerDrawer: DbManagerDrawer | undefined = $state() @@ -788,7 +798,7 @@ resourceEditor?.initEdit?.(path)} >{#if marked}{@html marked}{:else}{path}{/if}