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

View File

@ -13,6 +13,7 @@
import Designer from '../designer/Designer.svelte';
import QueryDesignerReference from '../designer/QueryDesignerReference.svelte';
import { currentDatabase } from '../stores';
import { getPerspectiveNodeMenu } from './perspectiveMenu';
export let config: PerspectiveConfig;
@ -100,6 +101,12 @@
const newNode = createPerspectiveNodeConfig(table);
newNode.designerId = table.designerId;
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;
res.nodes.push(newNode);
}
@ -248,6 +255,15 @@
const child = node?.childNodes?.find(x => x.columnName == columnName);
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}
value={createDesignerModel(config, dbInfos)}

View File

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