From ed9a5711a13523701a0e3ed35ee3fe8062ae343a Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Sun, 28 May 2023 22:04:51 +0200 Subject: [PATCH] fix apps assign for array --- .../display/table/AppAggridTable.svelte | 81 ++++++++++--------- frontend/src/lib/components/apps/rx.ts | 6 +- 2 files changed, 50 insertions(+), 37 deletions(-) diff --git a/frontend/src/lib/components/apps/components/display/table/AppAggridTable.svelte b/frontend/src/lib/components/apps/components/display/table/AppAggridTable.svelte index 15309fbc7a..1fc6d8db6f 100644 --- a/frontend/src/lib/components/apps/components/display/table/AppAggridTable.svelte +++ b/frontend/src/lib/components/apps/components/display/table/AppAggridTable.svelte @@ -95,45 +95,54 @@ {#if Array.isArray(result) && result.every(isObject)} -
+ {#if Array.isArray(resolvedConfig.columnDefs) && resolvedConfig.columnDefs.every(isObject)}
{ - $selectedComponent = [id] - }} - style:height="{clientHeight}px" - style:width="{clientWidth}px" - class="ag-theme-alpine" + class="border border-gray-300 shadow-sm divide-y divide-gray-300 flex flex-col h-full" + bind:clientHeight + bind:clientWidth > - {#key resolvedConfig?.pagination} - { - outputs?.page.set(event.api.paginationGetCurrentPage()) - }} - rowSelection="single" - suppressRowDeselection={true} - onSelectionChanged={(e) => { - const row = e.api.getSelectedNodes()?.[0]?.rowIndex - if (row != undefined) { - toggleRow(row) - } - }} - onGridReady={(e) => { - outputs?.ready.set(true) - $componentControl[id] = { agGrid: { api: e.api, columnApi: e.columnApi } } - }} - /> - {/key} +
{ + $selectedComponent = [id] + }} + style:height="{clientHeight}px" + style:width="{clientWidth}px" + class="ag-theme-alpine" + > + {#key resolvedConfig?.pagination} + { + outputs?.page.set(event.api.paginationGetCurrentPage()) + }} + rowSelection="single" + suppressRowDeselection={true} + onSelectionChanged={(e) => { + const row = e.api.getSelectedNodes()?.[0]?.rowIndex + if (row != undefined) { + toggleRow(row) + } + }} + onGridReady={(e) => { + outputs?.ready.set(true) + $componentControl[id] = { agGrid: { api: e.api, columnApi: e.columnApi } } + }} + /> + {/key} +
-
+ {:else if result != undefined} + + The columnDefs should be an array of objects, received: +
+				{JSON.stringify(resolvedConfig.columnDefs)}
+			
+
+ {/if} {:else if result != undefined} The result should be an array of objects, received: diff --git a/frontend/src/lib/components/apps/rx.ts b/frontend/src/lib/components/apps/rx.ts index 139d3e9400..d8751723ea 100644 --- a/frontend/src/lib/components/apps/rx.ts +++ b/frontend/src/lib/components/apps/rx.ts @@ -169,7 +169,11 @@ export function settableOutput(state: Writable, previousValue: T): Ou state.update((x) => x + 1) if (typeof x === 'object') { - value = Object.assign({}, x) + if (Array.isArray(x)) { + value = [...x] as any + } else { + value = Object.assign({}, x) + } } else { value = x }