From 728ad21d2fef302e32669b83a42ec88642c944af Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Fri, 26 Aug 2022 19:17:35 +0200 Subject: [PATCH] perspective arrange button --- packages/datalib/src/PerspectiveConfig.ts | 2 +- packages/web/src/designer/Designer.svelte | 1 + .../src/perspectives/PerspectiveDesigner.svelte | 2 +- .../web/src/perspectives/PerspectiveTable.svelte | 4 ++-- packages/web/src/tabs/PerspectiveTab.svelte | 1 + packages/web/src/utility/createActivator.ts | 14 +++++++++++++- 6 files changed, 19 insertions(+), 5 deletions(-) diff --git a/packages/datalib/src/PerspectiveConfig.ts b/packages/datalib/src/PerspectiveConfig.ts index 2196823f..fb4bfc49 100644 --- a/packages/datalib/src/PerspectiveConfig.ts +++ b/packages/datalib/src/PerspectiveConfig.ts @@ -67,7 +67,7 @@ export interface PerspectiveNodeConfig { filters: { [uniqueName: string]: string }; isAutoGenerated?: true | undefined; - position: { + position?: { x: number; y: number; }; diff --git a/packages/web/src/designer/Designer.svelte b/packages/web/src/designer/Designer.svelte index b879050a..ace2da97 100644 --- a/packages/web/src/designer/Designer.svelte +++ b/packages/web/src/designer/Designer.svelte @@ -9,6 +9,7 @@ toolbar: true, isRelatedToTab: true, testEnabled: () => getCurrentEditor()?.canArrange(), + // testEnabled: () => !!getCurrentEditor(), onClick: () => getCurrentEditor().arrange(), }); diff --git a/packages/web/src/perspectives/PerspectiveDesigner.svelte b/packages/web/src/perspectives/PerspectiveDesigner.svelte index 3d15525c..8dc7ffa2 100644 --- a/packages/web/src/perspectives/PerspectiveDesigner.svelte +++ b/packages/web/src/perspectives/PerspectiveDesigner.svelte @@ -67,7 +67,7 @@ useDatabaseReferences: false, allowScrollColumns: true, allowAddAllReferences: false, - canArrange: false, + canArrange: true, canExport: false, canSelectColumns: true, canSelectTables: false, diff --git a/packages/web/src/perspectives/PerspectiveTable.svelte b/packages/web/src/perspectives/PerspectiveTable.svelte index 5e88e6d7..26b20f5d 100644 --- a/packages/web/src/perspectives/PerspectiveTable.svelte +++ b/packages/web/src/perspectives/PerspectiveTable.svelte @@ -40,8 +40,8 @@ import openNewTab from '../utility/openNewTab'; import { getFilterValueExpression } from 'dbgate-filterparser'; - const dbg = debug('dbgate:PerspectivaTable'); - export const activator = createActivator('PerspectiveTable', true); + const dbg = debug('dbgate:PerspectiveTable'); + export const activator = createActivator('PerspectiveTable', true, ['Designer']); export let root: PerspectiveTreeNode; export let loadedCounts; diff --git a/packages/web/src/tabs/PerspectiveTab.svelte b/packages/web/src/tabs/PerspectiveTab.svelte index 171052e6..fb1077e5 100644 --- a/packages/web/src/tabs/PerspectiveTab.svelte +++ b/packages/web/src/tabs/PerspectiveTab.svelte @@ -134,6 +134,7 @@ /> + diff --git a/packages/web/src/utility/createActivator.ts b/packages/web/src/utility/createActivator.ts index cceb282d..a379c953 100644 --- a/packages/web/src/utility/createActivator.ts +++ b/packages/web/src/utility/createActivator.ts @@ -12,7 +12,11 @@ function isParent(parent, child) { return false; } -export default function createActivator(name: string, activateOnTabVisible: boolean) { +export default function createActivator( + name: string, + activateOnTabVisible: boolean = false, + friendActivators: string[] = [] +) { const instance = get_current_component(); const tabVisible: any = getContext('tabVisible'); const tabid = getContext('tabid'); @@ -38,11 +42,19 @@ export default function createActivator(name: string, activateOnTabVisible: bool const activate = () => { const toDelete = []; + + // console.log('ACTIVATE', instance); + for (const key in lastActiveDictionary) { if (isParent(lastActiveDictionary[key], instance)) continue; if (isParent(instance, lastActiveDictionary[key])) continue; + if (friendActivators.includes(key)) continue; + toDelete.push(key); } + + // console.log('toDelete', toDelete); + for (const del of toDelete) { delete lastActiveDictionary[del]; }