Browse Source

Merge pull request #3977 from nocodb/fix/3971-active-table-delete

Fix:  Table delete - active table deletion
pull/3978/head
Raju Udava 2 years ago committed by GitHub
parent
commit
62a89d7ccd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      packages/nc-gui/components/smartsheet/toolbar/ColumnFilterMenu.vue
  2. 11
      packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue
  3. 4
      packages/nc-gui/components/smartsheet/toolbar/SortListMenu.vue
  4. 5
      packages/nc-gui/composables/useGridViewColumnWidth.ts
  5. 18
      packages/nc-gui/composables/useViewColumns.ts
  6. 2
      packages/nc-gui/composables/useViewFilters.ts

10
packages/nc-gui/components/smartsheet/toolbar/ColumnFilterMenu.vue

@ -41,10 +41,12 @@ const { filters, loadFilters } = useViewFilters(
const filtersLength = ref(0)
watch(
() => activeView?.value,
async () => {
await loadFilters()
filtersLength.value = filters.value.length || 0
() => activeView?.value?.id,
async (viewId) => {
if (viewId) {
await loadFilters()
filtersLength.value = filters.value.length || 0
}
},
{ immediate: true },
)

11
packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue

@ -39,7 +39,6 @@ const {
showSystemFields,
sortedAndFilteredFields,
fields,
loadViewColumns,
filteredFieldList,
filterQuery,
showAll,
@ -48,16 +47,6 @@ const {
metaColumnById,
} = useViewColumns(activeView, meta, () => reloadDataHook.trigger())
watch(
() => activeView.value?.id,
async (newVal, oldVal) => {
if (newVal !== oldVal && meta.value) {
await loadViewColumns()
}
},
{ immediate: true },
)
watch(
sortedAndFilteredFields,
(v) => {

4
packages/nc-gui/components/smartsheet/toolbar/SortListMenu.vue

@ -32,8 +32,8 @@ const columnByID = computed(() =>
watch(
() => view.value?.id,
() => {
loadSorts()
(viewId) => {
if (viewId) loadSorts()
},
{ immediate: true },
)

5
packages/nc-gui/composables/useGridViewColumnWidth.ts

@ -50,8 +50,9 @@ export function useGridViewColumnWidth(view: Ref<GridType | undefined>) {
loadCss()
}
/** when columns changes(create/delete) reload grid columns */
watch(columns, loadGridViewColumns)
/** when columns changes(create/delete) reload grid columns
* or when view changes reload columns width */
watch([() => columns.value?.length, () => view?.value?.id], loadGridViewColumns)
const updateWidth = async (id: string, width: string) => {
if (gridViewCols?.value?.[id]) {

18
packages/nc-gui/composables/useViewColumns.ts

@ -205,12 +205,18 @@ export function useViewColumns(
?.map((field: Field) => metaColumnById?.value?.[field.fk_column_id!]) || []) as ColumnType[]
})
// reload view columns when table meta changes
watch(meta, async (newVal, oldVal) => {
if (newVal !== oldVal && meta.value) {
await loadViewColumns()
}
})
// reload view columns when active view changes
// or when columns count changes(delete/add)
watch(
[() => view?.value?.id, () => meta.value?.columns?.length],
async ([newViewId]) => {
// reload only if view belongs to current table
if (newViewId && view.value?.fk_model_id === meta.value?.id) {
await loadViewColumns()
}
},
{ immediate: true },
)
return {
fields,

2
packages/nc-gui/composables/useViewFilters.ts

@ -218,7 +218,7 @@ export function useViewFilters(
return metas?.value?.[view?.value?.fk_model_id as string]?.columns?.length || 0
},
async (nextColsLength, oldColsLength) => {
if (nextColsLength < oldColsLength) await loadFilters()
if (nextColsLength && nextColsLength < oldColsLength) await loadFilters()
},
)

Loading…
Cancel
Save