mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
memoize connection folder expand state #425
This commit is contained in:
parent
d5e240a701
commit
13fd7a0aad
@ -18,8 +18,9 @@
|
|||||||
export let passProps;
|
export let passProps;
|
||||||
export let onDropOnGroup = undefined;
|
export let onDropOnGroup = undefined;
|
||||||
export let groupContextMenu = null;
|
export let groupContextMenu = null;
|
||||||
|
export let collapsedGroupNames;
|
||||||
|
|
||||||
let isExpanded = true;
|
$: isExpanded = !$collapsedGroupNames.includes(group);
|
||||||
|
|
||||||
$: filtered = items.filter(x => x.isMatched);
|
$: filtered = items.filter(x => x.isMatched);
|
||||||
$: countText = filtered.length < items.length ? `${filtered.length}/${items.length}` : `${items.length}`;
|
$: countText = filtered.length < items.length ? `${filtered.length}/${items.length}` : `${items.length}`;
|
||||||
@ -49,7 +50,11 @@
|
|||||||
|
|
||||||
<div
|
<div
|
||||||
class="group"
|
class="group"
|
||||||
on:click={() => (isExpanded = !isExpanded)}
|
on:click={() =>
|
||||||
|
collapsedGroupNames.update(names => {
|
||||||
|
if (names.includes(group)) return names.filter(x => x != group);
|
||||||
|
return [...names, group];
|
||||||
|
})}
|
||||||
on:drop={handleDrop}
|
on:drop={handleDrop}
|
||||||
use:contextMenu={() => groupContextMenu(group)}
|
use:contextMenu={() => groupContextMenu(group)}
|
||||||
>
|
>
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
import { plusExpandIcon } from '../icons/expandIcons';
|
import { plusExpandIcon } from '../icons/expandIcons';
|
||||||
|
|
||||||
import AppObjectListItem from './AppObjectListItem.svelte';
|
import AppObjectListItem from './AppObjectListItem.svelte';
|
||||||
|
import { writable } from 'svelte/store';
|
||||||
|
|
||||||
export let list;
|
export let list;
|
||||||
export let module;
|
export let module;
|
||||||
@ -26,6 +27,8 @@
|
|||||||
export let onDropOnGroup = undefined;
|
export let onDropOnGroup = undefined;
|
||||||
export let emptyGroupNames = [];
|
export let emptyGroupNames = [];
|
||||||
|
|
||||||
|
export let collapsedGroupNames = writable([]);
|
||||||
|
|
||||||
$: filtered = !groupFunc
|
$: filtered = !groupFunc
|
||||||
? list.filter(data => {
|
? list.filter(data => {
|
||||||
const matcher = module.createMatcher && module.createMatcher(data);
|
const matcher = module.createMatcher && module.createMatcher(data);
|
||||||
@ -100,6 +103,7 @@
|
|||||||
{setIsExpanded}
|
{setIsExpanded}
|
||||||
{onDropOnGroup}
|
{onDropOnGroup}
|
||||||
{groupContextMenu}
|
{groupContextMenu}
|
||||||
|
{collapsedGroupNames}
|
||||||
/>
|
/>
|
||||||
{/each}
|
{/each}
|
||||||
{:else}
|
{:else}
|
||||||
|
@ -57,6 +57,7 @@ export const visibleSelectedWidget = derived(
|
|||||||
([$selectedWidget, $visibleWidgetSideBar]) => ($visibleWidgetSideBar ? $selectedWidget : null)
|
([$selectedWidget, $visibleWidgetSideBar]) => ($visibleWidgetSideBar ? $selectedWidget : null)
|
||||||
);
|
);
|
||||||
export const emptyConnectionGroupNames = writableWithStorage([], 'emptyConnectionGroupNames');
|
export const emptyConnectionGroupNames = writableWithStorage([], 'emptyConnectionGroupNames');
|
||||||
|
export const collapsedConnectionGroupNames = writableWithStorage([], 'collapsedConnectionGroupNames');
|
||||||
export const openedConnections = writable([]);
|
export const openedConnections = writable([]);
|
||||||
export const openedSingleDatabaseConnections = writable([]);
|
export const openedSingleDatabaseConnections = writable([]);
|
||||||
export const expandedConnections = writable([]);
|
export const expandedConnections = writable([]);
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
openedSingleDatabaseConnections,
|
openedSingleDatabaseConnections,
|
||||||
openedTabs,
|
openedTabs,
|
||||||
emptyConnectionGroupNames,
|
emptyConnectionGroupNames,
|
||||||
|
collapsedConnectionGroupNames,
|
||||||
} from '../stores';
|
} from '../stores';
|
||||||
import runCommand from '../commands/runCommand';
|
import runCommand from '../commands/runCommand';
|
||||||
import getConnectionLabel from '../utility/getConnectionLabel';
|
import getConnectionLabel from '../utility/getConnectionLabel';
|
||||||
@ -149,6 +150,7 @@
|
|||||||
emptyGroupNames={$emptyConnectionGroupNames}
|
emptyGroupNames={$emptyConnectionGroupNames}
|
||||||
sortGroups
|
sortGroups
|
||||||
groupContextMenu={createGroupContextMenu}
|
groupContextMenu={createGroupContextMenu}
|
||||||
|
collapsedGroupNames={collapsedConnectionGroupNames}
|
||||||
/>
|
/>
|
||||||
{#if (connectionsWithParent?.length > 0 && connectionsWithoutParent?.length > 0) || ($emptyConnectionGroupNames.length > 0 && connectionsWithoutParent?.length > 0)}
|
{#if (connectionsWithParent?.length > 0 && connectionsWithoutParent?.length > 0) || ($emptyConnectionGroupNames.length > 0 && connectionsWithoutParent?.length > 0)}
|
||||||
<div class="br" />
|
<div class="br" />
|
||||||
|
Loading…
Reference in New Issue
Block a user