mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-22 16:55:59 +00:00
diagram ctx menu improved
This commit is contained in:
@@ -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}
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user