perspective - fixed work with specific DB

This commit is contained in:
Jan Prochazka 2022-09-01 15:50:03 +02:00
parent e8452704eb
commit 91e1c83a91
3 changed files with 24 additions and 1 deletions

View File

@ -65,6 +65,8 @@
$: left = table?.left; $: left = table?.left;
$: top = table?.top; $: top = table?.top;
$: mainIcon = settings?.getMainTableIcon ? settings?.getMainTableIcon(designerId) : null; $: mainIcon = settings?.getMainTableIcon ? settings?.getMainTableIcon(designerId) : null;
$: specificDb = settings?.tableSpecificDb ? settings?.tableSpecificDb(designerId) : null;
export function isSelected() { export function isSelected() {
return table?.isSelectedTable; return table?.isSelectedTable;
} }
@ -254,6 +256,10 @@
{/if} {/if}
{alias || pureName} {alias || pureName}
{#if specificDb}
<FontIcon icon="icon database" title={specificDb.database} />
{/if}
</div> </div>
{#if settings?.showTableCloseButton} {#if settings?.showTableCloseButton}
<div class="close" on:click={() => onRemoveTable(table)}> <div class="close" on:click={() => onRemoveTable(table)}>

View File

@ -13,6 +13,7 @@
import Designer from '../designer/Designer.svelte'; import Designer from '../designer/Designer.svelte';
import QueryDesignerReference from '../designer/QueryDesignerReference.svelte'; import QueryDesignerReference from '../designer/QueryDesignerReference.svelte';
import { currentDatabase } from '../stores';
import { getPerspectiveNodeMenu } from './perspectiveMenu'; import { getPerspectiveNodeMenu } from './perspectiveMenu';
export let config: PerspectiveConfig; export let config: PerspectiveConfig;
@ -100,6 +101,12 @@
const newNode = createPerspectiveNodeConfig(table); const newNode = createPerspectiveNodeConfig(table);
newNode.designerId = table.designerId; newNode.designerId = table.designerId;
newNode.position = { x: table.left, y: table.top }; newNode.position = { x: table.left, y: table.top };
if ($currentDatabase?.name != database) {
newNode.database = $currentDatabase?.name;
}
if ($currentDatabase?.connection?._id != conid) {
newNode.conid = $currentDatabase?.connection?._id;
}
isArranged = false; isArranged = false;
res.nodes.push(newNode); res.nodes.push(newNode);
} }
@ -248,6 +255,15 @@
const child = node?.childNodes?.find(x => x.columnName == columnName); const child = node?.childNodes?.find(x => x.columnName == columnName);
child?.toggleCheckedNode(true); child?.toggleCheckedNode(true);
}, },
tableSpecificDb: designerId => {
const node = config.nodes.find(x => x.designerId == designerId);
if (node?.conid || node?.database) {
return {
conid: node.conid,
database: node.database,
};
}
},
}} }}
referenceComponent={QueryDesignerReference} referenceComponent={QueryDesignerReference}
value={createDesignerModel(config, dbInfos)} value={createDesignerModel(config, dbInfos)}

View File

@ -125,10 +125,11 @@
let perspectiveDatabases = extractPerspectiveDatabases({ conid, database }, config); let perspectiveDatabases = extractPerspectiveDatabases({ conid, database }, config);
$: { $: {
const newDatabases = extractPerspectiveDatabases({ conid, database }, config); const newDatabases = extractPerspectiveDatabases({ conid, database }, config);
if (stableStringify(newDatabases) != stableStringify(newDatabases)) { if (stableStringify(newDatabases) != stableStringify(perspectiveDatabases)) {
perspectiveDatabases = newDatabases; perspectiveDatabases = newDatabases;
} }
} }
$: dbInfos = useMultipleDatabaseInfo(perspectiveDatabases); $: dbInfos = useMultipleDatabaseInfo(perspectiveDatabases);
$: rootObject = config?.nodes?.find(x => x.designerId == config?.rootDesignerId); $: rootObject = config?.nodes?.find(x => x.designerId == config?.rootDesignerId);
$: tableInfo = useTableInfo({ conid, database, ...rootObject }); $: tableInfo = useTableInfo({ conid, database, ...rootObject });