From 7e298cce9f44d85c246ce858ecddf5474ce8e939 Mon Sep 17 00:00:00 2001 From: Muhammed Mustafa Date: Thu, 25 Aug 2022 15:15:40 +0530 Subject: [PATCH 1/5] fix/Forced meta loading when tab changes --- packages/nc-gui-v2/components/tabs/Smartsheet.vue | 14 +------------- .../[projectType]/[projectId]/index/index.vue | 9 +++++++++ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/packages/nc-gui-v2/components/tabs/Smartsheet.vue b/packages/nc-gui-v2/components/tabs/Smartsheet.vue index ca045fc415..06b8314a9d 100644 --- a/packages/nc-gui-v2/components/tabs/Smartsheet.vue +++ b/packages/nc-gui-v2/components/tabs/Smartsheet.vue @@ -10,7 +10,6 @@ import { MetaInj, OpenNewRecordFormHookInj, ReloadViewDataHookInj, - TabMetaInj, computed, inject, provide, @@ -18,12 +17,11 @@ import { useMetas, useProvideSmartsheetStore, watch, - watchEffect, } from '#imports' import type { TabItem } from '~/composables' -const { getMeta, metas } = useMetas() +const { metas } = useMetas() const activeView = ref() @@ -35,13 +33,8 @@ const tabMeta = inject( TabMetaInj, computed(() => ({} as TabItem)), ) - const meta = computed(() => metas.value?.[tabMeta?.value?.id as string]) -watchEffect(async () => { - await getMeta(tabMeta?.value?.id as string) -}) - const reloadEventHook = createEventHook() const openNewRecordFormHook = createEventHook() @@ -52,7 +45,6 @@ provideSidebar({ storageKey: 'nc-right-sidebar' }) // todo: move to store provide(MetaInj, meta) -provide(TabMetaInj, tabMeta) provide(ActiveViewInj, activeView) provide(IsLockedInj, isLocked) provide(ReloadViewDataHookInj, reloadEventHook) @@ -62,10 +54,6 @@ provide(IsFormInj, isForm) const treeViewIsLockedInj = inject('TreeViewIsLockedInj', ref(false)) -watch(tabMeta, async (newTabMeta, oldTabMeta) => { - if (newTabMeta !== oldTabMeta && newTabMeta?.id) await getMeta(newTabMeta.id) -}) - watch(isLocked, (nextValue) => (treeViewIsLockedInj.value = nextValue), { immediate: true }) diff --git a/packages/nc-gui-v2/pages/[projectType]/[projectId]/index/index.vue b/packages/nc-gui-v2/pages/[projectType]/[projectId]/index/index.vue index 8471d52a37..68df7a0e3e 100644 --- a/packages/nc-gui-v2/pages/[projectType]/[projectId]/index/index.vue +++ b/packages/nc-gui-v2/pages/[projectType]/[projectId]/index/index.vue @@ -7,11 +7,20 @@ import MdiView from '~icons/mdi/eye-circle-outline' import MdiAccountGroup from '~icons/mdi/account-group' const { tabs, activeTabIndex, activeTab, closeTab } = useTabs() +const { getMeta } = useMetas() const { isLoading } = useGlobal() provide(TabMetaInj, activeTab) +watch( + () => activeTab?.value?.id, + async () => { + await getMeta(activeTab?.value?.id as string, true) + }, + { immediate: true }, +) + const icon = (tab: TabItem) => { switch (tab.type) { case TabType.TABLE: From 096ea7289b8b519a47dc83e43701d89d1b12e017 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Fri, 26 Aug 2022 01:19:32 +0530 Subject: [PATCH 2/5] fix: avoid multiple meta api request Signed-off-by: Pranav C --- .../pages/[projectType]/[projectId]/index/index.vue | 9 +-------- .../index/index/[type]/[title]/[[viewTitle]].vue | 9 +++++---- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/packages/nc-gui-v2/pages/[projectType]/[projectId]/index/index.vue b/packages/nc-gui-v2/pages/[projectType]/[projectId]/index/index.vue index 68df7a0e3e..8df091dd61 100644 --- a/packages/nc-gui-v2/pages/[projectType]/[projectId]/index/index.vue +++ b/packages/nc-gui-v2/pages/[projectType]/[projectId]/index/index.vue @@ -7,19 +7,11 @@ import MdiView from '~icons/mdi/eye-circle-outline' import MdiAccountGroup from '~icons/mdi/account-group' const { tabs, activeTabIndex, activeTab, closeTab } = useTabs() -const { getMeta } = useMetas() const { isLoading } = useGlobal() provide(TabMetaInj, activeTab) -watch( - () => activeTab?.value?.id, - async () => { - await getMeta(activeTab?.value?.id as string, true) - }, - { immediate: true }, -) const icon = (tab: TabItem) => { switch (tab.type) { @@ -101,6 +93,7 @@ function onEdit(targetKey: number, action: 'add' | 'remove' | string) { .ant-tabs-nav-add { @apply !hidden; } + .ant-tabs-nav-more { @apply text-white; } diff --git a/packages/nc-gui-v2/pages/[projectType]/[projectId]/index/index/[type]/[title]/[[viewTitle]].vue b/packages/nc-gui-v2/pages/[projectType]/[projectId]/index/index/[type]/[title]/[[viewTitle]].vue index ec671406ea..d5f4f4375b 100644 --- a/packages/nc-gui-v2/pages/[projectType]/[projectId]/index/index/[type]/[title]/[[viewTitle]].vue +++ b/packages/nc-gui-v2/pages/[projectType]/[projectId]/index/index/[type]/[title]/[[viewTitle]].vue @@ -1,7 +1,8 @@ -