mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 06:06:01 +00:00
drag & drop - change order in pinned dbs #227
This commit is contained in:
@@ -76,6 +76,10 @@
|
||||
on:dragstart={e => {
|
||||
e.dataTransfer.setData('app_object_drag_data', JSON.stringify(data));
|
||||
}}
|
||||
on:dragstart
|
||||
on:dragenter
|
||||
on:dragend
|
||||
on:drop
|
||||
>
|
||||
{#if checkedObjectsStore}
|
||||
<CheckboxField
|
||||
|
||||
@@ -330,6 +330,10 @@
|
||||
isBold={_.get($currentDatabase, 'connection._id') == _.get(data.connection, '_id') &&
|
||||
_.get($currentDatabase, 'name') == data.name}
|
||||
on:click={() => ($currentDatabase = data)}
|
||||
on:dragstart
|
||||
on:dragenter
|
||||
on:dragend
|
||||
on:drop
|
||||
on:middleclick={() => {
|
||||
createMenu()
|
||||
.find(x => x.isNewQuery)
|
||||
|
||||
@@ -8,14 +8,43 @@
|
||||
}
|
||||
return data.connection._id;
|
||||
};
|
||||
|
||||
function dragExchange(dragged, data, pinned, setPinned, compare) {
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import _ from 'lodash';
|
||||
import { draggedPinnedObject, pinnedDatabases } from '../stores';
|
||||
|
||||
export let data;
|
||||
</script>
|
||||
|
||||
{#if data.objectTypeField}
|
||||
<DatabaseObjectAppObject {...$$props} />
|
||||
<DatabaseObjectAppObject {...$$props}
|
||||
/>
|
||||
{:else}
|
||||
<DatabaseAppObject {...$$props} />
|
||||
<DatabaseAppObject
|
||||
{...$$props}
|
||||
on:dragstart={() => {
|
||||
$draggedPinnedObject = data;
|
||||
}}
|
||||
on:dragenter={e => {
|
||||
const dragged = $draggedPinnedObject;
|
||||
if (dragged?.connection?._id != data?.connection?._id || dragged?.name != data?.name) {
|
||||
const dbs = $pinnedDatabases;
|
||||
const i1 = _.findIndex(dbs, x => x?.name == dragged?.name && x?.connection?._id == dragged?.connection?._id);
|
||||
const i2 = _.findIndex(dbs, x => x?.name == data?.name && x?.connection?._id == data?.connection?._id);
|
||||
const newDbs = [...dbs];
|
||||
const tmp = newDbs[i1];
|
||||
newDbs[i1] = newDbs[i2];
|
||||
newDbs[i2] = tmp;
|
||||
$pinnedDatabases = newDbs;
|
||||
}
|
||||
}}
|
||||
on:dragend={() => {
|
||||
$draggedPinnedObject = null;
|
||||
}}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user