From e124291267550b839f798a1362afd70832d74d91 Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Sat, 27 Aug 2022 12:27:07 +0200 Subject: [PATCH] perspective designer - checking columns --- packages/web/src/designer/ColumnLine.svelte | 42 +++++++++++-------- .../perspectives/PerspectiveDesigner.svelte | 18 ++++++++ 2 files changed, 42 insertions(+), 18 deletions(-) diff --git a/packages/web/src/designer/ColumnLine.svelte b/packages/web/src/designer/ColumnLine.svelte index a722a358..241ac55f 100644 --- a/packages/web/src/designer/ColumnLine.svelte +++ b/packages/web/src/designer/ColumnLine.svelte @@ -100,26 +100,32 @@ > {#if settings?.allowColumnOperations} x.designerId == designerId && x.columnName == column.columnName && x.isOutput - )} + checked={settings?.isColumnChecked + ? settings?.isColumnChecked(designerId, column.columnName) + : !!(designer.columns || []).find( + x => x.designerId == designerId && x.columnName == column.columnName && x.isOutput + )} on:change={e => { - if (e.target.checked) { - onChangeColumn( - { - ...column, - designerId, - }, - col => ({ ...col, isOutput: true }) - ); + if (settings?.setColumnChecked) { + settings?.setColumnChecked(designerId, column.columnName, e.target.checked); } else { - onChangeColumn( - { - ...column, - designerId, - }, - col => ({ ...col, isOutput: false }) - ); + if (e.target.checked) { + onChangeColumn( + { + ...column, + designerId, + }, + col => ({ ...col, isOutput: true }) + ); + } else { + onChangeColumn( + { + ...column, + designerId, + }, + col => ({ ...col, isOutput: false }) + ); + } } }} /> diff --git a/packages/web/src/perspectives/PerspectiveDesigner.svelte b/packages/web/src/perspectives/PerspectiveDesigner.svelte index 6e6ed87b..5e0da8fb 100644 --- a/packages/web/src/perspectives/PerspectiveDesigner.svelte +++ b/packages/web/src/perspectives/PerspectiveDesigner.svelte @@ -90,6 +90,24 @@ return [{ text: 'Remove', onClick: () => onRemoveReference(reference) }]; }, createReferenceText: reference => (reference.isAutoGenerated ? 'FK' : 'Custom'), + isColumnChecked: (designerId, columnName) => { + return config.nodes.find(x => x.designerId == designerId)?.checkedColumns?.includes(columnName); + }, + setColumnChecked: (designerId, columnName, value) => { + onChange(cfg => ({ + ...cfg, + nodes: cfg.nodes.map(node => + node.designerId == designerId + ? { + ...node, + checkedColumns: value + ? [...(node.checkedColumns || []), columnName] + : (node.checkedColumns || []).filter(x => x != columnName), + } + : node + ), + })); + }, }} referenceComponent={QueryDesignerReference} value={createDesignerModel(config, dbInfos)}