Browse Source

refactor(gui-v2): type correction and avoid unnecessary callback in watch

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/2857/head
Pranav C 2 years ago
parent
commit
35785b78f4
  1. 4
      packages/nc-gui-v2/components/smartsheet-toolbar/FieldsMenu.vue
  2. 9
      packages/nc-gui-v2/composables/useViewColumns.ts
  3. 2
      packages/nc-gui-v2/context/index.ts

4
packages/nc-gui-v2/components/smartsheet-toolbar/FieldsMenu.vue

@ -1,4 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import type { TableType } from 'nocodb-sdk'
import type { ComputedRef } from 'vue'
import { computed, inject } from 'vue' import { computed, inject } from 'vue'
import Draggable from 'vuedraggable' import Draggable from 'vuedraggable'
import { ActiveViewInj, FieldsInj, IsLockedInj, MetaInj, ReloadViewDataHookInj } from '~/context' import { ActiveViewInj, FieldsInj, IsLockedInj, MetaInj, ReloadViewDataHookInj } from '~/context'
@ -38,7 +40,7 @@ const {
hideAll, hideAll,
saveOrUpdate, saveOrUpdate,
sortedFields, sortedFields,
} = useViewColumns(activeView, meta, false, () => reloadDataHook?.trigger()) } = useViewColumns(activeView, meta as ComputedRef<TableType>, false, () => reloadDataHook?.trigger())
watch( watch(
() => activeView?.value?.id, () => activeView?.value?.id,

9
packages/nc-gui-v2/composables/useViewColumns.ts

@ -1,12 +1,12 @@
import { isSystemColumn } from 'nocodb-sdk' import { isSystemColumn } from 'nocodb-sdk'
import type { ColumnType, FormType, GalleryType, GridType, TableType } from 'nocodb-sdk' import type { ColumnType, FormType, GalleryType, GridType, TableType } from 'nocodb-sdk'
import { watch } from 'vue' import { watch } from 'vue'
import type { Ref } from 'vue' import type { ComputedRef, Ref } from 'vue'
import { useNuxtApp } from '#app' import { useNuxtApp } from '#app'
export default function ( export default function (
view: Ref<(GridType | FormType | GalleryType) & { id?: string }> | undefined, view: Ref<(GridType | FormType | GalleryType) & { id?: string }> | undefined,
meta: Ref<TableType> | undefined, meta: ComputedRef<TableType>,
isPublic = false, isPublic = false,
reloadData?: () => void, reloadData?: () => void,
) { ) {
@ -131,10 +131,7 @@ export default function (
}) })
// reload view columns when table meta changes // reload view columns when table meta changes
watch( watch(meta, () => loadViewColumns())
() => meta?.value,
() => loadViewColumns(),
)
return { return {
fields, fields,

2
packages/nc-gui-v2/context/index.ts

@ -5,7 +5,7 @@ import type { useViewData } from '#imports'
import type { TabItem } from '~/composables/useTabs' import type { TabItem } from '~/composables/useTabs'
export const ColumnInj: InjectionKey<ColumnType & { meta: any }> = Symbol('column-injection') export const ColumnInj: InjectionKey<ColumnType & { meta: any }> = Symbol('column-injection')
export const MetaInj: InjectionKey<Ref<TableType>> = Symbol('meta-injection') export const MetaInj: InjectionKey<ComputedRef<TableType>> = Symbol('meta-injection')
export const TabMetaInj: InjectionKey<ComputedRef<TabItem>> = Symbol('tab-meta-injection') export const TabMetaInj: InjectionKey<ComputedRef<TabItem>> = Symbol('tab-meta-injection')
export const PaginationDataInj: InjectionKey<ReturnType<typeof useViewData>['paginationData']> = export const PaginationDataInj: InjectionKey<ReturnType<typeof useViewData>['paginationData']> =
Symbol('pagination-data-injection') Symbol('pagination-data-injection')

Loading…
Cancel
Save