mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-29 02:56:01 +00:00
designer: move group of tables
This commit is contained in:
@@ -503,6 +503,45 @@
|
|||||||
updateFromDbInfo();
|
updateFromDbInfo();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function forEachSelected(op: Function) {
|
||||||
|
for (const tbl of _.values(tableRefs)) {
|
||||||
|
const table = tbl as any;
|
||||||
|
if (!table.isSelected()) continue;
|
||||||
|
op(table);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const tableMoveStart = () => {
|
||||||
|
forEachSelected(t => t.moveStart());
|
||||||
|
};
|
||||||
|
const tableMove = (x, y) => {
|
||||||
|
forEachSelected(t => t.move(x, y));
|
||||||
|
tick().then(recomputeReferencePositions);
|
||||||
|
};
|
||||||
|
const tableMoveEnd = () => {
|
||||||
|
const moves = {};
|
||||||
|
forEachSelected(t => {
|
||||||
|
moves[t.getDesignerId()] = t.moveEnd();
|
||||||
|
});
|
||||||
|
callChange(current => {
|
||||||
|
return {
|
||||||
|
...current,
|
||||||
|
tables: (current?.tables || []).map(table => {
|
||||||
|
const position = moves[table.designerId];
|
||||||
|
return position
|
||||||
|
? {
|
||||||
|
...table,
|
||||||
|
left: position.left,
|
||||||
|
top: position.top,
|
||||||
|
}
|
||||||
|
: table;
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
tick().then(recomputeReferencePositions);
|
||||||
|
};
|
||||||
|
|
||||||
function recomputeReferencePositions() {
|
function recomputeReferencePositions() {
|
||||||
for (const ref of Object.values(referenceRefs) as any[]) {
|
for (const ref of Object.values(referenceRefs) as any[]) {
|
||||||
if (ref) ref.recomputePosition();
|
if (ref) ref.recomputePosition();
|
||||||
@@ -650,6 +689,9 @@
|
|||||||
onBringToFront={bringToFront}
|
onBringToFront={bringToFront}
|
||||||
onSelectTable={selectTable}
|
onSelectTable={selectTable}
|
||||||
onRemoveTable={removeTable}
|
onRemoveTable={removeTable}
|
||||||
|
onMoveStart={tableMoveStart}
|
||||||
|
onMove={tableMove}
|
||||||
|
onMoveEnd={tableMoveEnd}
|
||||||
{domCanvas}
|
{domCanvas}
|
||||||
designer={value}
|
designer={value}
|
||||||
{sourceDragColumn$}
|
{sourceDragColumn$}
|
||||||
|
|||||||
@@ -20,6 +20,10 @@
|
|||||||
export let onSelectColumn;
|
export let onSelectColumn;
|
||||||
export let onChangeColumn;
|
export let onChangeColumn;
|
||||||
|
|
||||||
|
export let onMoveStart;
|
||||||
|
export let onMove;
|
||||||
|
export let onMoveEnd;
|
||||||
|
|
||||||
// export let sourceDragColumn;
|
// export let sourceDragColumn;
|
||||||
// export let setSourceDragColumn;
|
// export let setSourceDragColumn;
|
||||||
// export let targetDragColumn;
|
// export let targetDragColumn;
|
||||||
@@ -48,22 +52,56 @@
|
|||||||
$: left = table?.left;
|
$: left = table?.left;
|
||||||
$: top = table?.top;
|
$: top = table?.top;
|
||||||
|
|
||||||
function handleMoveStart() {
|
export function isSelected() {
|
||||||
|
return table?.isSelectedTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getDesignerId() {
|
||||||
|
return designerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function moveStart() {
|
||||||
movingPosition = { left, top };
|
movingPosition = { left, top };
|
||||||
}
|
}
|
||||||
function handleMove(x, y) {
|
|
||||||
|
export function move(x, y) {
|
||||||
movingPosition.left += x;
|
movingPosition.left += x;
|
||||||
movingPosition.top += y;
|
movingPosition.top += y;
|
||||||
tick().then(onMoveReferences);
|
}
|
||||||
|
|
||||||
|
export function moveEnd() {
|
||||||
|
const res = movingPosition;
|
||||||
|
movingPosition = null;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleMoveStart() {
|
||||||
|
if (settings?.canSelectTables) {
|
||||||
|
onMoveStart();
|
||||||
|
} else {
|
||||||
|
moveStart();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function handleMove(x, y) {
|
||||||
|
if (settings?.canSelectTables) {
|
||||||
|
onMove(x, y);
|
||||||
|
} else {
|
||||||
|
move(x, y);
|
||||||
|
tick().then(onMoveReferences);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function handleMoveEnd() {
|
function handleMoveEnd() {
|
||||||
onChangeTable({
|
if (settings?.canSelectTables) {
|
||||||
...table,
|
onMoveEnd();
|
||||||
left: movingPosition.left,
|
} else {
|
||||||
top: movingPosition.top,
|
const position = moveEnd();
|
||||||
});
|
onChangeTable({
|
||||||
movingPosition = null;
|
...table,
|
||||||
tick().then(onMoveReferences);
|
left: position.left,
|
||||||
|
top: position.top,
|
||||||
|
});
|
||||||
|
tick().then(onMoveReferences);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getDomTable() {
|
export function getDomTable() {
|
||||||
@@ -157,10 +195,10 @@
|
|||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
{#if table?.isSelectedTable}
|
{#if table?.isSelectedTable}
|
||||||
<div class='selection-marker lt' />
|
<div class="selection-marker lt" />
|
||||||
<div class='selection-marker rt' />
|
<div class="selection-marker rt" />
|
||||||
<div class='selection-marker lb' />
|
<div class="selection-marker lb" />
|
||||||
<div class='selection-marker rb' />
|
<div class="selection-marker rb" />
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user