From 80a5d6ed6a857fc91dc7586859263d894528fb6d Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Wed, 10 Apr 2024 16:02:45 +0200 Subject: [PATCH] fix: fix plug connection for apps with array items --- frontend/src/lib/components/apps/editor/appUtils.ts | 11 +++++++++-- .../settingsPanel/ComponentInputTypeEditor.svelte | 2 +- .../apps/editor/settingsPanel/InputsSpecEditor.svelte | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/frontend/src/lib/components/apps/editor/appUtils.ts b/frontend/src/lib/components/apps/editor/appUtils.ts index ae72d338a5..4564c769f9 100644 --- a/frontend/src/lib/components/apps/editor/appUtils.ts +++ b/frontend/src/lib/components/apps/editor/appUtils.ts @@ -371,9 +371,16 @@ export function insertNewGridItem( let parent = findGridItemById(app.grid, app.subgrids, key)?.data let subgrids = parent?.numberOfSubgrids if (subgrids === undefined) { - throw Error(`Invalid subgrid selected, the parent has no subgrids: ${key}, parent: ${JSON.stringify(parent)}`) + throw Error( + `Invalid subgrid selected, the parent has no subgrids: ${key}, parent: ${JSON.stringify( + parent + )}` + ) } - if (focusedGrid?.subGridIndex && (focusedGrid?.subGridIndex < 0 || focusedGrid?.subGridIndex >= subgrids)) { + if ( + focusedGrid?.subGridIndex && + (focusedGrid?.subGridIndex < 0 || focusedGrid?.subGridIndex >= subgrids) + ) { throw Error(`Invalid subgrid selected: ${key}, max subgrids: ${subgrids}`) } // If ever the subgrid is undefined, we want to make sure it is defined diff --git a/frontend/src/lib/components/apps/editor/settingsPanel/ComponentInputTypeEditor.svelte b/frontend/src/lib/components/apps/editor/settingsPanel/ComponentInputTypeEditor.svelte index 51e6868d47..59f9230afe 100644 --- a/frontend/src/lib/components/apps/editor/settingsPanel/ComponentInputTypeEditor.svelte +++ b/frontend/src/lib/components/apps/editor/settingsPanel/ComponentInputTypeEditor.svelte @@ -29,7 +29,7 @@ ...componentInput, type: 'evalv2', expr: expr, - connections: [{ componentId: connection.componentId, id: connection.path.split('.')[0] }] + connections: [{ componentId: connection.componentId, id: connection.path.split('.')[0].split('[')[0] }] } evalV2editor?.setCode(expr) $app = $app diff --git a/frontend/src/lib/components/apps/editor/settingsPanel/InputsSpecEditor.svelte b/frontend/src/lib/components/apps/editor/settingsPanel/InputsSpecEditor.svelte index 6096538b09..a1ba8ff98a 100644 --- a/frontend/src/lib/components/apps/editor/settingsPanel/InputsSpecEditor.svelte +++ b/frontend/src/lib/components/apps/editor/settingsPanel/InputsSpecEditor.svelte @@ -52,7 +52,7 @@ ...componentInput, type: 'evalv2', expr: expr, - connections: [{ componentId: connection.componentId, id: connection.path.split('.')[0] }] + connections: [{ componentId: connection.componentId, id: connection.path.split('.')[0].split('[')[0] }] } evalV2editor?.setCode(expr) $app = $app