mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-23 16:16:02 +00:00
drag & drop into/from connection folder
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
export let checkedObjectsStore = null;
|
export let checkedObjectsStore = null;
|
||||||
export let disableContextMenu = false;
|
export let disableContextMenu = false;
|
||||||
export let passProps;
|
export let passProps;
|
||||||
|
export let onDropOnGroup = undefined;
|
||||||
|
|
||||||
let isExpanded = true;
|
let isExpanded = true;
|
||||||
|
|
||||||
@@ -36,7 +37,17 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="group" on:click={() => (isExpanded = !isExpanded)}>
|
<div
|
||||||
|
class="group"
|
||||||
|
on:click={() => (isExpanded = !isExpanded)}
|
||||||
|
on:drop={e => {
|
||||||
|
var data = e.dataTransfer.getData('app_object_drag_data');
|
||||||
|
if (data && onDropOnGroup) {
|
||||||
|
e.stopPropagation();
|
||||||
|
onDropOnGroup(data, group);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
<span class="expand-icon">
|
<span class="expand-icon">
|
||||||
<FontIcon icon={groupIconFunc(isExpanded)} />
|
<FontIcon icon={groupIconFunc(isExpanded)} />
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
export let groupIconFunc = plusExpandIcon;
|
export let groupIconFunc = plusExpandIcon;
|
||||||
export let groupFunc = undefined;
|
export let groupFunc = undefined;
|
||||||
|
export let onDropOnGroup = undefined;
|
||||||
|
|
||||||
$: filtered = !groupFunc
|
$: filtered = !groupFunc
|
||||||
? list.filter(data => {
|
? list.filter(data => {
|
||||||
@@ -83,6 +84,7 @@
|
|||||||
{passProps}
|
{passProps}
|
||||||
{getIsExpanded}
|
{getIsExpanded}
|
||||||
{setIsExpanded}
|
{setIsExpanded}
|
||||||
|
{onDropOnGroup}
|
||||||
/>
|
/>
|
||||||
{/each}
|
{/each}
|
||||||
{:else}
|
{:else}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
import LargeButton from '../buttons/LargeButton.svelte';
|
import LargeButton from '../buttons/LargeButton.svelte';
|
||||||
import { matchingProps } from '../tabs/TableDataTab.svelte';
|
import { matchingProps } from '../tabs/TableDataTab.svelte';
|
||||||
import { plusExpandIcon, chevronExpandIcon } from '../icons/expandIcons';
|
import { plusExpandIcon, chevronExpandIcon } from '../icons/expandIcons';
|
||||||
|
import { safeJsonParse } from 'dbgate-tools';
|
||||||
|
|
||||||
const connections = useConnectionList();
|
const connections = useConnectionList();
|
||||||
const serverStatus = useServerStatus();
|
const serverStatus = useServerStatus();
|
||||||
@@ -41,8 +42,12 @@
|
|||||||
x => !x.unsaved || $openedConnections.includes(x._id) || $openedSingleDatabaseConnections.includes(x._id)
|
x => !x.unsaved || $openedConnections.includes(x._id) || $openedSingleDatabaseConnections.includes(x._id)
|
||||||
);
|
);
|
||||||
|
|
||||||
$: connectionsWithParent = connectionsWithStatusFiltered ? connectionsWithStatusFiltered?.filter((x) => x.parent !== undefined && x.parent !== null && x.parent.length !== 0) : [];
|
$: connectionsWithParent = connectionsWithStatusFiltered
|
||||||
$: connectionsWithoutParent = connectionsWithStatusFiltered ? connectionsWithStatusFiltered?.filter((x) => x.parent === undefined || x.parent === null || x.parent.length === 0) : [];
|
? connectionsWithStatusFiltered?.filter(x => x.parent !== undefined && x.parent !== null && x.parent.length !== 0)
|
||||||
|
: [];
|
||||||
|
$: connectionsWithoutParent = connectionsWithStatusFiltered
|
||||||
|
? connectionsWithStatusFiltered?.filter(x => x.parent === undefined || x.parent === null || x.parent.length === 0)
|
||||||
|
: [];
|
||||||
|
|
||||||
const handleRefreshConnections = () => {
|
const handleRefreshConnections = () => {
|
||||||
for (const conid of $openedConnections) {
|
for (const conid of $openedConnections) {
|
||||||
@@ -50,6 +55,16 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleDropOnGroup = (data, group) => {
|
||||||
|
const json = safeJsonParse(data);
|
||||||
|
if (json?._id) {
|
||||||
|
apiCall('connections/update', {
|
||||||
|
_id: json?._id,
|
||||||
|
values: { parent: group },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const connectionColorFactory = useConnectionColorFactory(3);
|
const connectionColorFactory = useConnectionColorFactory(3);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -65,7 +80,14 @@
|
|||||||
<FontIcon icon="icon refresh" />
|
<FontIcon icon="icon refresh" />
|
||||||
</InlineButton>
|
</InlineButton>
|
||||||
</SearchBoxWrapper>
|
</SearchBoxWrapper>
|
||||||
<WidgetsInnerContainer>
|
<WidgetsInnerContainer
|
||||||
|
on:drop={e => {
|
||||||
|
var data = e.dataTransfer.getData('app_object_drag_data');
|
||||||
|
if (data) {
|
||||||
|
handleDropOnGroup(data, '');
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
<AppObjectList
|
<AppObjectList
|
||||||
list={_.sortBy(connectionsWithParent, connection => (getConnectionLabel(connection) || '').toUpperCase())}
|
list={_.sortBy(connectionsWithParent, connection => (getConnectionLabel(connection) || '').toUpperCase())}
|
||||||
module={connectionAppObject}
|
module={connectionAppObject}
|
||||||
@@ -81,6 +103,7 @@
|
|||||||
groupIconFunc={chevronExpandIcon}
|
groupIconFunc={chevronExpandIcon}
|
||||||
groupFunc={data => data.parent}
|
groupFunc={data => data.parent}
|
||||||
expandIconFunc={plusExpandIcon}
|
expandIconFunc={plusExpandIcon}
|
||||||
|
onDropOnGroup={handleDropOnGroup}
|
||||||
/>
|
/>
|
||||||
{#if connectionsWithParent?.length > 0 && connectionsWithoutParent?.length > 0}
|
{#if connectionsWithParent?.length > 0 && connectionsWithoutParent?.length > 0}
|
||||||
<div class="br" />
|
<div class="br" />
|
||||||
@@ -108,8 +131,6 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</WidgetsInnerContainer>
|
</WidgetsInnerContainer>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.br {
|
.br {
|
||||||
background: var(--theme-bg-2);
|
background: var(--theme-bg-2);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<div><slot /></div>
|
<div on:drop><slot /></div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
div {
|
div {
|
||||||
|
|||||||
Reference in New Issue
Block a user