diff --git a/src/UI/Studio/EditLayerState.ts b/src/UI/Studio/EditLayerState.ts
index 4abdf49261..b94b3f6114 100644
--- a/src/UI/Studio/EditLayerState.ts
+++ b/src/UI/Studio/EditLayerState.ts
@@ -172,7 +172,8 @@ export abstract class EditJsonState {
}
}
- public getSchema(path: string[]): ConfigMeta[] {
+ public getSchema(path: (string | number)[]): ConfigMeta[] {
+ path = path.filter(p => typeof p === "string")
const schemas = this.schema.filter(
(sch) =>
sch !== undefined &&
diff --git a/src/UI/Studio/SchemaBasedArray.svelte b/src/UI/Studio/SchemaBasedArray.svelte
index 71c249162c..cd14004fe1 100644
--- a/src/UI/Studio/SchemaBasedArray.svelte
+++ b/src/UI/Studio/SchemaBasedArray.svelte
@@ -5,16 +5,16 @@
import { TrashIcon } from "@babeard/svelte-heroicons/mini"
import ShowConversionMessage from "./ShowConversionMessage.svelte"
import Markdown from "../Base/Markdown.svelte"
- import { Utils } from "../../Utils"
- import type { QuestionableTagRenderingConfigJson } from "../../Models/ThemeConfig/Json/QuestionableTagRenderingConfigJson"
+ import type {
+ QuestionableTagRenderingConfigJson,
+ } from "../../Models/ThemeConfig/Json/QuestionableTagRenderingConfigJson"
import CollapsedTagRenderingPreview from "./CollapsedTagRenderingPreview.svelte"
import { Accordion } from "flowbite-svelte"
export let state: EditJsonState
export let path: (string | number)[] = []
- export let schema: ConfigMeta
+ let schema: ConfigMeta = state.getSchema(path)[0]
- schema = Utils.Clone(schema)
let title = schema.path.at(-1)
let singular = title
if (title?.endsWith("s")) {
@@ -37,7 +37,8 @@
.filter((part) => part.path.length - 1 === schema.path.length)
let messages = state.messagesFor(path)
- const currentValue = state.getStoreFor<(string | QuestionableTagRenderingConfigJson)[]>(path)
+ let datapath = path
+ const currentValue = state.getStoreFor<(string | QuestionableTagRenderingConfigJson)[]>(datapath)
if (currentValue.data === undefined) {
currentValue.setData([])
}
@@ -54,18 +55,8 @@
}
}
- function fusePath(i: number, subpartPath: string[]): (string | number)[] {
- const newPath = [...path, i]
- const toAdd = [...subpartPath]
- for (const part of path) {
- if (toAdd[0] === part) {
- toAdd.splice(0, 1)
- } else {
- break
- }
- }
- newPath.push(...toAdd)
- return newPath
+ function fusePath(i: number): (string | number)[] {
+ return [...path, i]
}
function del(i: number) {
@@ -74,7 +65,6 @@
}
-
@@ -85,18 +75,20 @@
{/if}
{#if $currentValue === undefined}
No array defined
- {:else if $currentValue.length === 0}
+ {:else if !Array.isArray($currentValue)}
+ Not an array: {typeof $currentValue} {JSON.stringify(path)} {JSON.stringify($currentValue).slice(0,120)}
+ {:else if $currentValue?.length === 0}
No values are defined
{#if $messages.length > 0}
{#each $messages as message}
{/each}
{/if}
- {:else if subparts.length === 0}
+ {:else if subparts.length === 0}
{#each $currentValue as value, i}