From 2809203f60d77d2386f7ec6dab735ae2033bae7b Mon Sep 17 00:00:00 2001 From: Maurits Lourens Date: Thu, 29 Jul 2021 11:22:45 +0200 Subject: [PATCH] Collapse and expand database connections --- .../DatasourceNavigator.svelte | 20 ++++++++++++++++++- .../src/components/common/NavItem.svelte | 10 +++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/packages/builder/src/components/backend/DatasourceNavigator/DatasourceNavigator.svelte b/packages/builder/src/components/backend/DatasourceNavigator/DatasourceNavigator.svelte index 42ea30dbb0..84c737eb67 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/DatasourceNavigator.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/DatasourceNavigator.svelte @@ -9,7 +9,10 @@ import TableNavigator from "components/backend/TableNavigator/TableNavigator.svelte" import ICONS from "./icons" + let openDataSources = [] + function selectDatasource(datasource) { + toggleNode(datasource) datasources.select(datasource._id) $goto(`./datasource/${datasource._id}`) } @@ -19,6 +22,15 @@ $goto(`./datasource/${query.datasourceId}/${query._id}`) } + function toggleNode(datasource) { + const isOpen = openDataSources.includes(datasource._id) + if (isOpen) { + openDataSources = openDataSources.filter(id => datasource._id !== id) + } else { + openDataSources = [...openDataSources, datasource._id] + } + } + onMount(() => { datasources.fetch() queries.fetch() @@ -31,8 +43,11 @@ 0} text={datasource.name} + opened={openDataSources.includes(datasource._id)} selected={$datasources.selected === datasource._id} + withArrow={true} on:click={() => selectDatasource(datasource)} + on:iconClick={() => toggleNode(datasource)} >
- + {#if openDataSources.includes(datasource._id)} + + {/if} {#each $queries.list.filter(query => query.datasourceId === datasource._id) as query} onClickQuery(query)} > diff --git a/packages/builder/src/components/common/NavItem.svelte b/packages/builder/src/components/common/NavItem.svelte index 977369299d..ec7994be84 100644 --- a/packages/builder/src/components/common/NavItem.svelte +++ b/packages/builder/src/components/common/NavItem.svelte @@ -1,5 +1,6 @@
{#if withArrow} -
+
{/if}