mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
tasb reordering
This commit is contained in:
parent
10e2d3c632
commit
0d7accc990
@ -269,8 +269,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function dragDropTab(draggingTab, targetTab) {
|
function dragDropTabs(draggingTabs, targetTabs) {
|
||||||
if (draggingTab.tabid == targetTab.tabid) return;
|
if (draggingTabs.find(x => targetTabs.find(y => x.tabid == y.tabid))) return;
|
||||||
|
|
||||||
// if (getTabDbKey(draggingTab) != getTabDbKey(targetTab)) {
|
// if (getTabDbKey(draggingTab) != getTabDbKey(targetTab)) {
|
||||||
// // dragDropDbKey(getTabDbKey(draggingTab), getTabDbKey(targetTab));
|
// // dragDropDbKey(getTabDbKey(draggingTab), getTabDbKey(targetTab));
|
||||||
@ -279,19 +279,25 @@
|
|||||||
|
|
||||||
// const dbKey = getTabDbKey(draggingTab);
|
// const dbKey = getTabDbKey(draggingTab);
|
||||||
const items = sortTabs($openedTabs.filter(x => x.closedTime == null));
|
const items = sortTabs($openedTabs.filter(x => x.closedTime == null));
|
||||||
const dstIndex = _.findIndex(items, x => x.tabid == targetTab.tabid);
|
const dstIndexes = targetTabs.map(targetTab => _.findIndex(items, x => x.tabid == targetTab.tabid));
|
||||||
const srcIndex = _.findIndex(items, x => x.tabid == draggingTab.tabid);
|
const dstIndexFirst = _.min(dstIndexes) as number;
|
||||||
if (srcIndex < 0 || dstIndex < 0) {
|
const dstIndexLast = _.max(dstIndexes) as number;
|
||||||
|
const srcIndex = _.findIndex(items, x => x.tabid == draggingTabs[0].tabid);
|
||||||
|
if (srcIndex < 0 || dstIndexFirst < 0 || dstIndexLast < 0) {
|
||||||
console.warn('Drag tab index not found');
|
console.warn('Drag tab index not found');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const newItems =
|
const newItems =
|
||||||
dstIndex < srcIndex
|
dstIndexFirst < srcIndex
|
||||||
? [...items.slice(0, dstIndex), draggingTab, ...items.slice(dstIndex).filter(x => x.tabid != draggingTab.tabid)]
|
? [
|
||||||
|
...items.slice(0, dstIndexFirst),
|
||||||
|
...draggingTabs,
|
||||||
|
...items.slice(dstIndexFirst).filter(x => !draggingTabs.find(y => y.tabid == x.tabid)),
|
||||||
|
]
|
||||||
: [
|
: [
|
||||||
...items.slice(0, dstIndex + 1).filter(x => x.tabid != draggingTab.tabid),
|
...items.slice(0, dstIndexLast + 1).filter(x => !draggingTabs.find(y => y.tabid == x.tabid)),
|
||||||
draggingTab,
|
...draggingTabs,
|
||||||
...items.slice(dstIndex + 1),
|
...items.slice(dstIndexLast + 1),
|
||||||
];
|
];
|
||||||
|
|
||||||
openedTabs.update(tabs =>
|
openedTabs.update(tabs =>
|
||||||
@ -364,7 +370,7 @@
|
|||||||
draggingDbGroupTarget = tabGroup;
|
draggingDbGroupTarget = tabGroup;
|
||||||
}}
|
}}
|
||||||
on:drop={e => {
|
on:drop={e => {
|
||||||
// dragDropDbKey(draggingDbKey, dbKey);
|
dragDropTabs(draggingDbGroup.tabs, tabGroup.tabs);
|
||||||
}}
|
}}
|
||||||
on:dragend={e => {
|
on:dragend={e => {
|
||||||
draggingDbGroup = null;
|
draggingDbGroup = null;
|
||||||
@ -388,7 +394,7 @@
|
|||||||
<div
|
<div
|
||||||
id={`file-tab-item-${tab.tabid}`}
|
id={`file-tab-item-${tab.tabid}`}
|
||||||
class="file-tab-item"
|
class="file-tab-item"
|
||||||
class:selected={draggingTab ? tab.tabid == draggingTabTarget?.tabid : tab.selected}
|
class:selected={draggingTab || draggingDbGroup ? tab.tabid == draggingTabTarget?.tabid : tab.selected}
|
||||||
on:click={e => handleTabClick(e, tab.tabid)}
|
on:click={e => handleTabClick(e, tab.tabid)}
|
||||||
on:mouseup={e => handleMouseUp(e, tab.tabid)}
|
on:mouseup={e => handleMouseUp(e, tab.tabid)}
|
||||||
use:contextMenu={getContextMenu(tab)}
|
use:contextMenu={getContextMenu(tab)}
|
||||||
@ -402,7 +408,12 @@
|
|||||||
draggingTabTarget = tab;
|
draggingTabTarget = tab;
|
||||||
}}
|
}}
|
||||||
on:drop={e => {
|
on:drop={e => {
|
||||||
dragDropTab(draggingTab, tab);
|
if (draggingTab) {
|
||||||
|
dragDropTabs([draggingTab], [tab]);
|
||||||
|
}
|
||||||
|
if (draggingDbGroup) {
|
||||||
|
dragDropTabs(draggingDbGroup.tabs, [tab]);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
on:dragend={e => {
|
on:dragend={e => {
|
||||||
draggingTab = null;
|
draggingTab = null;
|
||||||
|
Loading…
Reference in New Issue
Block a user