perspective arrange button

This commit is contained in:
Jan Prochazka 2022-08-26 19:17:35 +02:00
parent d2f18bc048
commit 728ad21d2f
6 changed files with 19 additions and 5 deletions

View File

@ -67,7 +67,7 @@ export interface PerspectiveNodeConfig {
filters: { [uniqueName: string]: string };
isAutoGenerated?: true | undefined;
position: {
position?: {
x: number;
y: number;
};

View File

@ -9,6 +9,7 @@
toolbar: true,
isRelatedToTab: true,
testEnabled: () => getCurrentEditor()?.canArrange(),
// testEnabled: () => !!getCurrentEditor(),
onClick: () => getCurrentEditor().arrange(),
});

View File

@ -67,7 +67,7 @@
useDatabaseReferences: false,
allowScrollColumns: true,
allowAddAllReferences: false,
canArrange: false,
canArrange: true,
canExport: false,
canSelectColumns: true,
canSelectTables: false,

View File

@ -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;

View File

@ -134,6 +134,7 @@
/>
<svelte:fragment slot="toolstrip">
<ToolStripCommandButton command="designer.arrange" />
<ToolStripCommandButton command="perspective.refresh" />
<ToolStripCommandButton command="perspective.customJoin" />
<ToolStripSaveButton idPrefix="perspective" />

View File

@ -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];
}