From e8f19809b7959b447b62823be750a4b68d491a78 Mon Sep 17 00:00:00 2001 From: mertmit Date: Tue, 29 Nov 2022 22:02:44 +0300 Subject: [PATCH] feat: auto-expand bases in TreeView Signed-off-by: mertmit --- .../nc-gui/components/dashboard/TreeView.vue | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/packages/nc-gui/components/dashboard/TreeView.vue b/packages/nc-gui/components/dashboard/TreeView.vue index 02d0446dc4..10a5d9fbff 100644 --- a/packages/nc-gui/components/dashboard/TreeView.vue +++ b/packages/nc-gui/components/dashboard/TreeView.vue @@ -273,10 +273,23 @@ useEventListener(document, 'keydown', async (e: KeyboardEvent) => { } }) -onMounted(() => { - if (bases.value.filter((el) => el.enabled)[0]?.id) - activeKey.value.push(`collapse-${bases.value.filter((el) => el.enabled)[0].id}`) -}) +watch( + activeTable, + (value, oldValue) => { + if (value) { + if (value !== oldValue) { + const fndTable = tables.value.find((el) => el.id === value) + if (fndTable) { + activeKey.value = [`collapse-${fndTable.base_id}`] + } + } + } else { + if (bases.value.filter((el) => el.enabled)[0]?.id) + activeKey.value = [`collapse-${bases.value.filter((el) => el.enabled)[0].id}`] + } + }, + { immediate: true }, +)