diagram ctx menu improved

This commit is contained in:
Jan Prochazka
2022-01-20 14:43:19 +01:00
parent a0d7ade863
commit 53441d3e62
2 changed files with 36 additions and 21 deletions

View File

@@ -71,6 +71,8 @@
$: tables = value?.tables as any[];
$: references = value?.references as any[];
$: isMultipleTableSelection = tables.filter(x => x.isSelectedTable).length >= 2;
const tableRefs = {};
const referenceRefs = {};
$: domTables = _.pickBy(_.mapValues(tableRefs, (tbl: any) => tbl?.getDomTable()));
@@ -205,14 +207,22 @@
};
const removeTable = table => {
callChange(current => ({
...current,
tables: (current.tables || []).filter(x => x.designerId != table.designerId),
references: (current.references || []).filter(
x => x.sourceId != table.designerId && x.targetId != table.designerId
),
columns: (current.columns || []).filter(x => x.designerId != table.designerId),
}));
if (isMultipleTableSelection && settings?.useDatabaseReferences && settings?.canSelectTables) {
callChange(current => ({
...current,
tables: (current.tables || []).filter(x => !x.isSelectedTable),
}));
updateFromDbInfo();
} else {
callChange(current => ({
...current,
tables: (current.tables || []).filter(x => x.designerId != table.designerId),
references: (current.references || []).filter(
x => x.sourceId != table.designerId && x.targetId != table.designerId
),
columns: (current.columns || []).filter(x => x.designerId != table.designerId),
}));
}
};
const changeReference = ref => {
@@ -753,6 +763,7 @@
{table}
{conid}
{database}
{isMultipleTableSelection}
onChangeTable={changeTable}
onBringToFront={bringToFront}
onSelectTable={selectTable}

View File

@@ -26,6 +26,7 @@
export let onSelectColumn;
export let onChangeColumn;
export let onChangeTableColor;
export let isMultipleTableSelection;
export let onMoveStart;
export let onMove;
@@ -143,20 +144,23 @@
return [
{ text: 'Remove', onClick: () => onRemoveTable({ designerId }) },
{ divider: true },
settings?.allowTableAlias && [
{ text: 'Set table alias', onClick: handleSetTableAlias },
alias && {
text: 'Remove table alias',
onClick: () =>
onChangeTable({
...table,
alias: null,
}),
},
],
settings?.allowAddAllReferences && { text: 'Add references', onClick: () => onAddAllReferences(table) },
settings?.allowTableAlias &&
!isMultipleTableSelection && [
{ text: 'Set table alias', onClick: handleSetTableAlias },
alias && {
text: 'Remove table alias',
onClick: () =>
onChangeTable({
...table,
alias: null,
}),
},
],
settings?.allowAddAllReferences &&
!isMultipleTableSelection && { text: 'Add references', onClick: () => onAddAllReferences(table) },
settings?.allowChangeColor && { text: 'Change color', onClick: () => onChangeTableColor(table) },
settings?.appendTableSystemMenu && [{ divider: true }, createDatabaseObjectMenu({ ...table, conid, database })],
settings?.appendTableSystemMenu &&
!isMultipleTableSelection && [{ divider: true }, createDatabaseObjectMenu({ ...table, conid, database })],
];
}
</script>