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) const filtersLength = ref(0)
watch( watch(
() => activeView?.value, () => activeView?.value?.id,
async () => { async (viewId) => {
await loadFilters() if (viewId) {
filtersLength.value = filters.value.length || 0 await loadFilters()
filtersLength.value = filters.value.length || 0
}
}, },
{ immediate: true }, { immediate: true },
) )

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

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

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

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

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

@ -50,8 +50,9 @@ export function useGridViewColumnWidth(view: Ref<GridType | undefined>) {
loadCss() loadCss()
} }
/** when columns changes(create/delete) reload grid columns */ /** when columns changes(create/delete) reload grid columns
watch(columns, loadGridViewColumns) * or when view changes reload columns width */
watch([() => columns.value?.length, () => view?.value?.id], loadGridViewColumns)
const updateWidth = async (id: string, width: string) => { const updateWidth = async (id: string, width: string) => {
if (gridViewCols?.value?.[id]) { 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[] ?.map((field: Field) => metaColumnById?.value?.[field.fk_column_id!]) || []) as ColumnType[]
}) })
// reload view columns when table meta changes // reload view columns when active view changes
watch(meta, async (newVal, oldVal) => { // or when columns count changes(delete/add)
if (newVal !== oldVal && meta.value) { watch(
await loadViewColumns() [() => 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 { return {
fields, 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 return metas?.value?.[view?.value?.fk_model_id as string]?.columns?.length || 0
}, },
async (nextColsLength, oldColsLength) => { async (nextColsLength, oldColsLength) => {
if (nextColsLength < oldColsLength) await loadFilters() if (nextColsLength && nextColsLength < oldColsLength) await loadFilters()
}, },
) )

Loading…
Cancel
Save