Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

fix(nc-gui): view data reload issue after view config copy

Ramesh Manef99517b0a149
diff --git a/packages/nc-gui/components/smartsheet/toolbar/ColumnFilterMenu.vue b/packages/nc-gui/components/smartsheet/toolbar/ColumnFilterMenu.vue
index 568f2ace51..7a25fb404d 100644
--- a/packages/nc-gui/components/smartsheet/toolbar/ColumnFilterMenu.vue
+++ b/packages/nc-gui/components/smartsheet/toolbar/ColumnFilterMenu.vue
@@ -1,5 +1,5 @@
<script setup lang="ts">
-import { CURRENT_USER_TOKEN, type ColumnType, type FilterType } from 'nocodb-sdk'
+import { CURRENT_USER_TOKEN, ViewSettingOverrideOptions, type ColumnType, type FilterType } from 'nocodb-sdk'
import type ColumnFilter from './ColumnFilter.vue'
const isLocked = inject(IsLockedInj, ref(false))
@@ -66,16 +66,19 @@ useMenuCloseOnEsc(open)
const draftFilter = ref({})
const queryFilterOpen = ref(false)
-eventBus.on(async (event, column: ColumnType) => {
- if (event === SmartsheetStoreEvents.FILTER_RELOAD && activeView?.value?.id) {
+eventBus.on(async (event, payload) => {
+ if (validateViewConfigOverrideEvent(event, ViewSettingOverrideOptions.FILTER_CONDITION, payload) && activeView?.value?.id) {
await loadFilters({
hookId: undefined,
isWebhook: false,
loadAllFilters: true,
})
+
filtersLength.value = nonDeletedFilters.value.length || 0
}
+ const column = payload?.column as ColumnType | undefined
+
if (!column) return
if (event === SmartsheetStoreEvents.FILTER_ADD) {
diff --git a/packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue b/packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue
index af119fad09..beb0ac37fa 100644
--- a/packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue
+++ b/packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue
@@ -63,9 +63,13 @@ const viewStore = useViewsStore()
const { updateViewMeta } = viewStore
-eventBus.on((event) => {
+eventBus.on(async (event, payload) => {
if (event === SmartsheetStoreEvents.FIELD_RELOAD) {
- loadViewColumns()
+ try {
+ await loadViewColumns()
+ } finally {
+ payload?.callback?.()
+ }
} else if (event === SmartsheetStoreEvents.MAPPED_BY_COLUMN_CHANGE) {
loadViewColumns()
}
diff --git a/packages/nc-gui/components/smartsheet/toolbar/SortListMenu.vue b/packages/nc-gui/components/smartsheet/toolbar/SortListMenu.vue
index 6bcddeb877..c9e8ed00e5 100644
--- a/packages/nc-gui/components/smartsheet/toolbar/SortListMenu.vue
+++ b/packages/nc-gui/components/smartsheet/toolbar/SortListMenu.vue
@@ -1,5 +1,5 @@
<script setup lang="ts">
-import { type ColumnType, type LinkToAnotherRecordType, UITypesName } from 'nocodb-sdk'
+import { type ColumnType, type LinkToAnotherRecordType, UITypesName, ViewSettingOverrideOptions } from 'nocodb-sdk'
import { PlanLimitTypes, RelationTypes, UITypes, isLinksOrLTAR, isSystemColumn } from 'nocodb-sdk'
import rfdc from 'rfdc'
import { getColumnUidtByID as sortGetColumnUidtByID } from '~/utils/sortUtils'
@@ -31,8 +31,11 @@ const isToolbarIconMode = inject(
computed(() => false),
)
-eventBus.on((event) => {
- if (event === SmartsheetStoreEvents.SORT_RELOAD) {
+eventBus.on((event, payload) => {
+ if (
+ event === SmartsheetStoreEvents.SORT_RELOAD ||
+ validateViewConfigOverrideEvent(event, ViewSettingOverrideOptions.SORT, payload)
+ ) {
loadSorts()
}
})
diff --git a/packages/nc-gui/lib/enums.ts b/packages/nc-gui/lib/enums.ts
index cbab8f0774..9e703ecff1 100644
--- a/packages/nc-gui/lib/enums.ts
+++ b/packages/nc-gui/lib/enums.ts
@@ -80,9 +80,9 @@ export enum SmartsheetStoreEvents {
CELL_SELECTED = 'cell-selected',
FIELD_UPDATE = 'field-update',
ROW_COLOR_UPDATE = 'row-color-update',
- ROW_COLOR_RELOAD = 'row-color-reload',
TRIGGER_RE_RENDER = 'trigger-re-render',
ON_ROW_COLOUR_INFO_UPDATE = 'on-row-colour-info-update',
+ COPIED_VIEW_CONFIG = 'copied-view-config',
}
export enum SmartsheetScriptActions {
diff --git a/packages/nc-gui/utils/viewUtils.ts b/packages/nc-gui/utils/viewUtils.ts
index d3433bba77..a1dd5b7e16 100644
--- a/packages/nc-gui/utils/viewUtils.ts
+++ b/packages/nc-gui/utils/viewUtils.ts
@@ -1,4 +1,4 @@
-import { type RowColoringInfo, ViewTypes } from 'nocodb-sdk'
+import { type RowColoringInfo, ViewSettingOverrideOptions, ViewTypes } from 'nocodb-sdk'
import { iconMap } from './iconUtils'
import type { Language } from '~/lib/types'
import UsersIcon from '~icons/nc-icons/users'
@@ -79,3 +79,20 @@ export const getDefaultViewMetas = (viewType: ViewTypes) => {
}
return {}
}
+
+export const validateViewConfigOverrideEvent = (
+ event: SmartsheetStoreEvents | string,
+ optionToValidate: ViewSettingOverrideOptions,
+ params?: { viewId: string; copiedOptions: ViewSettingOverrideOptions[] },
+) => {
+ if (
+ event !== SmartsheetStoreEvents.COPIED_VIEW_CONFIG ||
+ !optionToValidate ||
+ !ncIsObject(params) ||
+ !ncIsArray(params?.copiedOptions)
+ ) {
+ return false
+ }
+
+ return params.copiedOptions.includes(optionToValidate)
+}