From 53c9f7b1fc369a407347cc6ba8629ff00c339319 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 13 Jun 2024 14:26:28 +0000 Subject: [PATCH 01/27] chore: update sdk path --- packages/nc-gui/package.json | 2 +- packages/nocodb/package.json | 2 +- pnpm-lock.yaml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/nc-gui/package.json b/packages/nc-gui/package.json index 4d97488dab..61a2bf879d 100644 --- a/packages/nc-gui/package.json +++ b/packages/nc-gui/package.json @@ -76,7 +76,7 @@ "marked": "^4.3.0", "monaco-editor": "^0.45.0", "monaco-sql-languages": "^0.11.0", - "nocodb-sdk": "0.250.1", + "nocodb-sdk": "workspace:^", "papaparse": "^5.4.1", "parse-github-url": "^1.0.2", "pinia": "^2.1.7", diff --git a/packages/nocodb/package.json b/packages/nocodb/package.json index c2b2cb22dc..e21d016125 100644 --- a/packages/nocodb/package.json +++ b/packages/nocodb/package.json @@ -137,7 +137,7 @@ "ncp": "^2.0.0", "nestjs-kafka": "^1.0.6", "nestjs-throttler-storage-redis": "^0.4.4", - "nocodb-sdk": "0.250.1", + "nocodb-sdk": "workspace:^", "nodemailer": "^6.9.13", "object-hash": "^3.0.0", "object-sizeof": "^2.6.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 22a83f89be..13d523e041 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -158,7 +158,7 @@ importers: specifier: ^0.11.0 version: 0.11.0 nocodb-sdk: - specifier: 0.250.1 + specifier: workspace:^ version: link:../nocodb-sdk papaparse: specifier: ^5.4.1 @@ -727,7 +727,7 @@ importers: specifier: ^0.4.4 version: 0.4.4(@nestjs/common@10.3.8)(@nestjs/core@10.3.8)(@nestjs/throttler@5.1.2)(ioredis@5.4.1)(reflect-metadata@0.2.1) nocodb-sdk: - specifier: 0.250.1 + specifier: workspace:^ version: link:../nocodb-sdk nodemailer: specifier: ^6.9.13 From 470246477cf79b5eac3668bb80a674c0decc4c44 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Thu, 13 Jun 2024 19:41:26 +0000 Subject: [PATCH 02/27] fix: add source_id filter when getting table list --- packages/nocodb/src/models/Model.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/nocodb/src/models/Model.ts b/packages/nocodb/src/models/Model.ts index 4f0bdcb817..03ac425610 100644 --- a/packages/nocodb/src/models/Model.ts +++ b/packages/nocodb/src/models/Model.ts @@ -236,6 +236,12 @@ export default class Model implements TableType { ]); let { list: modelList } = cachedList; const { isNoneList } = cachedList; + + let condition; + if(source_id){ + condition = { source_id } + } + if (!isNoneList && !modelList.length) { modelList = await ncMeta.metaList2( context.workspace_id, @@ -245,6 +251,7 @@ export default class Model implements TableType { orderBy: { order: 'asc', }, + condition, }, ); From f5f4e8c388c2742e0f95752477b8b151d12733ed Mon Sep 17 00:00:00 2001 From: Mert E Date: Fri, 14 Jun 2024 00:01:14 +0300 Subject: [PATCH 03/27] fix: missing conditionV2 (#8736) Signed-off-by: mertmit --- packages/nocodb/src/db/BaseModelSqlv2.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/nocodb/src/db/BaseModelSqlv2.ts b/packages/nocodb/src/db/BaseModelSqlv2.ts index 71fa4f5ef9..8499751890 100644 --- a/packages/nocodb/src/db/BaseModelSqlv2.ts +++ b/packages/nocodb/src/db/BaseModelSqlv2.ts @@ -7184,7 +7184,7 @@ class BaseModelSqlv2 { ); } - async getCustomConditionsAndApply(_params: { + async getCustomConditionsAndApply(params: { view?: View; column: Column; qb?; @@ -7193,7 +7193,8 @@ class BaseModelSqlv2 { rowId; columns?: Column[]; }): Promise { - return; + const { filters, qb } = params; + await conditionV2(this, filters, qb); } } From 91dfbee0a5acde33424ae5377ddb87210caf1b55 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Thu, 13 Jun 2024 21:05:59 +0000 Subject: [PATCH 04/27] fix: support FK column update(system field) and linting --- packages/nocodb/src/db/BaseModelSqlv2.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/nocodb/src/db/BaseModelSqlv2.ts b/packages/nocodb/src/db/BaseModelSqlv2.ts index 8499751890..67511ab211 100644 --- a/packages/nocodb/src/db/BaseModelSqlv2.ts +++ b/packages/nocodb/src/db/BaseModelSqlv2.ts @@ -3850,7 +3850,6 @@ class BaseModelSqlv2 { let preInsertOps: (() => Promise)[] = []; let aiPkCol: Column; let agPkCol: Column; - if (!raw) { const columns = await this.model.getColumns(this.context); @@ -3873,7 +3872,11 @@ class BaseModelSqlv2 { ); } - if (col.system && !allowSystemColumn) { + if ( + col.system && + !allowSystemColumn && + col.uidt !== UITypes.ForeignKey + ) { NcError.badRequest( `Column "${col.title}" is system column and cannot be updated`, ); @@ -4950,7 +4953,7 @@ class BaseModelSqlv2 { ); } - if (column.system) { + if (column.system && column.uidt !== UITypes.ForeignKey) { NcError.badRequest( `Column "${column.title}" is system column and cannot be updated`, ); From c467598895893aeba06dadf1f2a560173dc7203d Mon Sep 17 00:00:00 2001 From: Pranav C Date: Thu, 13 Jun 2024 21:05:59 +0000 Subject: [PATCH 05/27] refactor: review suggestions --- packages/nocodb/src/models/Model.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/packages/nocodb/src/models/Model.ts b/packages/nocodb/src/models/Model.ts index 03ac425610..40a3248635 100644 --- a/packages/nocodb/src/models/Model.ts +++ b/packages/nocodb/src/models/Model.ts @@ -237,11 +237,6 @@ export default class Model implements TableType { let { list: modelList } = cachedList; const { isNoneList } = cachedList; - let condition; - if(source_id){ - condition = { source_id } - } - if (!isNoneList && !modelList.length) { modelList = await ncMeta.metaList2( context.workspace_id, @@ -251,7 +246,7 @@ export default class Model implements TableType { orderBy: { order: 'asc', }, - condition, + ...(source_id ? { condition: { source_id } } : {}), }, ); From edc7c44d9f25cd347c175269f7d9bdb6f341c802 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Thu, 13 Jun 2024 21:26:32 +0000 Subject: [PATCH 06/27] fix: use custom cached debounce function to use individual debounce function for each filter --- .../nc-gui/composables/useDebounceFnCached.ts | 45 +++++++++++++++++++ packages/nc-gui/composables/useViewFilters.ts | 33 ++++++++------ 2 files changed, 65 insertions(+), 13 deletions(-) create mode 100644 packages/nc-gui/composables/useDebounceFnCached.ts diff --git a/packages/nc-gui/composables/useDebounceFnCached.ts b/packages/nc-gui/composables/useDebounceFnCached.ts new file mode 100644 index 0000000000..31b101fa23 --- /dev/null +++ b/packages/nc-gui/composables/useDebounceFnCached.ts @@ -0,0 +1,45 @@ +import type { DebounceFilterOptions, MaybeRefOrGetter } from '@vueuse/core' + +type FunctionArgs = (...args: any[]) => any + +// Cache to store debounced functions based on a unique key +const debounceCache = new Map() + +// Default function to generate a cache key +function defaultGetCacheKey(): string { + return 'default' +} + +/** + * Creates a cached debounced version of the given function. + * + * @param fn - The function to debounce. + * @param ms - The debounce delay in milliseconds. Default is 500ms. + * @param getCacheKey - Function to generate a unique cache key based on the arguments. + * @param options - Additional options for debouncing. + * + * @returns A debounced version of the input function with caching. + */ +export function useCachedDebouncedFunction( + fn: T, + ms: MaybeRefOrGetter = 500, + getCacheKey: (...args: Parameters) => string | number = defaultGetCacheKey, + options: DebounceFilterOptions = {}, +): (...args: Parameters) => ReturnType { + return function (...args: Parameters): ReturnType { + // Generate a unique key for the given arguments + const key = getCacheKey(args) + + // If the debounced function for the given key is not in the cache, create and cache it + if (!debounceCache.has(key)) { + const debouncedFn = useDebounceFn(fn, ms, options) + debounceCache.set(key, debouncedFn) + } + + // Retrieve the cached debounced function + const debouncedFn = debounceCache.get(key) + + // Call and return the result of the debounced function + return debouncedFn!(...args) + } +} diff --git a/packages/nc-gui/composables/useViewFilters.ts b/packages/nc-gui/composables/useViewFilters.ts index dca8d9b391..681bb12bad 100644 --- a/packages/nc-gui/composables/useViewFilters.ts +++ b/packages/nc-gui/composables/useViewFilters.ts @@ -338,7 +338,9 @@ export function useViewFilters( } } - const saveOrUpdate = async (filter: Filter, i: number, force = false, undo = false, skipDataReload = false) => { + const saveOrUpdateDebounced = useCachedDebouncedFunction(saveOrUpdate, 500, (_filter: Filter, i: number) => i) + + async function saveOrUpdate(filter: Filter, i: number, force = false, undo = false, skipDataReload = false) { // if already in progress the debounced function which will call this function again with 500ms delay until it's not saving if (savingStatus[i]) { return saveOrUpdateDebounced(filter, i, force, undo, skipDataReload) @@ -386,7 +388,7 @@ export function useViewFilters( filters.value = [...filters.value] } else if (!autoApply?.value && !force) { filter.status = filter.id ? 'update' : 'create' - } else if (filters.value[i]?.id && filter.status !== 'create') { + } else if (filters.value[i]?.id && filters.value[i]?.status !== 'create') { await $api.dbTableFilter.update(filters.value[i].id!, { ...filter, fk_parent_id: parentId.value, @@ -399,15 +401,23 @@ export function useViewFilters( }) } else { if (linkColId?.value) { - filters.value[i] = await $api.dbTableLinkFilter.create(linkColId.value, { - ...filter, - fk_parent_id: parentId, - }) + // set value with current value of filter since user can change value while saving + filters.value[i] = { + ...((await $api.dbTableLinkFilter.create(linkColId.value, { + ...filter, + fk_parent_id: parentId, + })) || {}), + value: (filters.value[i] || filter).value, + } } else { - filters.value[i] = await $api.dbTableFilter.create(view.value.id!, { - ...filter, - fk_parent_id: parentId.value, - }) + // set value with current value of filter since user can change value while saving + filters.value[i] = { + ...((await $api.dbTableFilter.create(view.value.id!, { + ...filter, + fk_parent_id: parentId.value, + })) || {}), + value: (filters.value[i] || filter).value, + } } if (!isLink && !isWebhook) allFilters.value.push(filters.value[+i]) } @@ -496,9 +506,6 @@ export function useViewFilters( if (!isLink && !isWebhook) allFilters.value = allFilters.value.filter((f) => f.id !== filter.id) } } - - const saveOrUpdateDebounced = useDebounceFn(saveOrUpdate, 500) - const addFilter = async (undo = false, draftFilter: Partial = {}) => { filters.value.push(draftFilter?.fk_column_id ? { ...placeholderFilter(), ...draftFilter } : placeholderFilter()) if (!undo) { From a2b81dc73c1423889e918e6600cc75762d035799 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Thu, 13 Jun 2024 21:26:32 +0000 Subject: [PATCH 07/27] fix: keep any local state value of filter after sync --- packages/nc-gui/composables/useViewFilters.ts | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/packages/nc-gui/composables/useViewFilters.ts b/packages/nc-gui/composables/useViewFilters.ts index 681bb12bad..b22f42b26d 100644 --- a/packages/nc-gui/composables/useViewFilters.ts +++ b/packages/nc-gui/composables/useViewFilters.ts @@ -401,22 +401,26 @@ export function useViewFilters( }) } else { if (linkColId?.value) { - // set value with current value of filter since user can change value while saving + const savedFilter = await $api.dbTableLinkFilter.create(linkColId.value, { + ...filter, + fk_parent_id: parentId, + }) + // override any local changes with saved filter since user can change value while saving filters.value[i] = { - ...((await $api.dbTableLinkFilter.create(linkColId.value, { - ...filter, - fk_parent_id: parentId, - })) || {}), - value: (filters.value[i] || filter).value, + ...(savedFilter || {}), + ...filters.value[i], + status: undefined, } } else { - // set value with current value of filter since user can change value while saving + const savedFilter = await $api.dbTableFilter.create(view.value.id!, { + ...filter, + fk_parent_id: parentId.value, + }) + // override any local changes with saved filter since user can change value while saving filters.value[i] = { - ...((await $api.dbTableFilter.create(view.value.id!, { - ...filter, - fk_parent_id: parentId.value, - })) || {}), - value: (filters.value[i] || filter).value, + ...(savedFilter || {}), + ...filters.value[i], + status: undefined, } } if (!isLink && !isWebhook) allFilters.value.push(filters.value[+i]) From 8dbda1cb99a94d6308033752677a1e1f5d3b8a0e Mon Sep 17 00:00:00 2001 From: Pranav C Date: Thu, 13 Jun 2024 21:26:33 +0000 Subject: [PATCH 08/27] fix: move cache reference within clossure since each instance should have its own cache --- packages/nc-gui/composables/useDebounceFnCached.ts | 6 +++--- packages/nc-gui/composables/useViewFilters.ts | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/nc-gui/composables/useDebounceFnCached.ts b/packages/nc-gui/composables/useDebounceFnCached.ts index 31b101fa23..d01c1aab5e 100644 --- a/packages/nc-gui/composables/useDebounceFnCached.ts +++ b/packages/nc-gui/composables/useDebounceFnCached.ts @@ -2,9 +2,6 @@ import type { DebounceFilterOptions, MaybeRefOrGetter } from '@vueuse/core' type FunctionArgs = (...args: any[]) => any -// Cache to store debounced functions based on a unique key -const debounceCache = new Map() - // Default function to generate a cache key function defaultGetCacheKey(): string { return 'default' @@ -26,6 +23,9 @@ export function useCachedDebouncedFunction( getCacheKey: (...args: Parameters) => string | number = defaultGetCacheKey, options: DebounceFilterOptions = {}, ): (...args: Parameters) => ReturnType { + // Cache to store debounced functions based on a unique key + const debounceCache = new Map() + return function (...args: Parameters): ReturnType { // Generate a unique key for the given arguments const key = getCacheKey(args) diff --git a/packages/nc-gui/composables/useViewFilters.ts b/packages/nc-gui/composables/useViewFilters.ts index b22f42b26d..ecd59224a2 100644 --- a/packages/nc-gui/composables/useViewFilters.ts +++ b/packages/nc-gui/composables/useViewFilters.ts @@ -381,7 +381,6 @@ export function useViewFilters( } } } - try { if (nestedMode.value) { filters.value[i] = { ...filter } @@ -407,19 +406,22 @@ export function useViewFilters( }) // override any local changes with saved filter since user can change value while saving filters.value[i] = { - ...(savedFilter || {}), ...filters.value[i], + fk_parent_id: parentId, + id: savedFilter.id, status: undefined, } } else { + console.log(parentId.value) const savedFilter = await $api.dbTableFilter.create(view.value.id!, { ...filter, fk_parent_id: parentId.value, }) // override any local changes with saved filter since user can change value while saving filters.value[i] = { - ...(savedFilter || {}), ...filters.value[i], + fk_parent_id: parentId, + id: savedFilter.id, status: undefined, } } From 78614619778a68602aaf7f660cdfb8dd03d15177 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Thu, 13 Jun 2024 21:26:33 +0000 Subject: [PATCH 09/27] fix: coderabbit suggestion and passing args correctly --- packages/nc-gui/composables/useDebounceFnCached.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/nc-gui/composables/useDebounceFnCached.ts b/packages/nc-gui/composables/useDebounceFnCached.ts index d01c1aab5e..20137331bf 100644 --- a/packages/nc-gui/composables/useDebounceFnCached.ts +++ b/packages/nc-gui/composables/useDebounceFnCached.ts @@ -26,9 +26,9 @@ export function useCachedDebouncedFunction( // Cache to store debounced functions based on a unique key const debounceCache = new Map() - return function (...args: Parameters): ReturnType { + return (...args: Parameters): ReturnType => { // Generate a unique key for the given arguments - const key = getCacheKey(args) + const key = getCacheKey(...args) // If the debounced function for the given key is not in the cache, create and cache it if (!debounceCache.has(key)) { From 9c3dfe9ea24f700f648d27d749110980f2ec79b6 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Thu, 13 Jun 2024 21:26:33 +0000 Subject: [PATCH 10/27] refactor: review suggestions --- packages/nc-gui/composables/useViewFilters.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/nc-gui/composables/useViewFilters.ts b/packages/nc-gui/composables/useViewFilters.ts index ecd59224a2..51e905bd01 100644 --- a/packages/nc-gui/composables/useViewFilters.ts +++ b/packages/nc-gui/composables/useViewFilters.ts @@ -404,7 +404,8 @@ export function useViewFilters( ...filter, fk_parent_id: parentId, }) - // override any local changes with saved filter since user can change value while saving + // extract id from saved filter and update the filter object + // avoiding whole object update to prevent overwriting of current filter object changes filters.value[i] = { ...filters.value[i], fk_parent_id: parentId, @@ -417,7 +418,8 @@ export function useViewFilters( ...filter, fk_parent_id: parentId.value, }) - // override any local changes with saved filter since user can change value while saving + // extract id from saved filter and update the filter object + // avoiding whole object update to prevent overwriting of current filter object changes filters.value[i] = { ...filters.value[i], fk_parent_id: parentId, From c9d5ab2c09d5eb84d52adb9f5dd825a9e2740160 Mon Sep 17 00:00:00 2001 From: Mert E Date: Fri, 14 Jun 2024 08:46:17 +0300 Subject: [PATCH 11/27] fix: avoid extra encode (#8739) --- packages/nc-gui/composables/useAttachment.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/nc-gui/composables/useAttachment.ts b/packages/nc-gui/composables/useAttachment.ts index dddded1da2..0b6dd5f51c 100644 --- a/packages/nc-gui/composables/useAttachment.ts +++ b/packages/nc-gui/composables/useAttachment.ts @@ -5,9 +5,9 @@ const useAttachment = () => { const res: string[] = [] if (item?.data) res.push(item.data) if (item?.file) res.push(window.URL.createObjectURL(item.file)) - if (item?.signedPath) res.push(encodeURI(`${appInfo.value.ncSiteUrl}/${item.signedPath}`)) - if (item?.signedUrl) res.push(encodeURI(item.signedUrl)) - if (item?.path) res.push(encodeURI(`${appInfo.value.ncSiteUrl}/${item.path}`)) + if (item?.signedPath) res.push(`${appInfo.value.ncSiteUrl}/${encodeURI(item.signedPath)}`) + if (item?.signedUrl) res.push(item.signedUrl) + if (item?.path) res.push(`${appInfo.value.ncSiteUrl}/${encodeURI(item.path)}`) if (item?.url) res.push(item.url) return res } From f49bf52abf5ef37337a8bc1f52454fde187b2627 Mon Sep 17 00:00:00 2001 From: Ramesh Mane <101566080+rameshmane7218@users.noreply.github.com> Date: Fri, 14 Jun 2024 11:43:26 +0530 Subject: [PATCH 12/27] Nc fix/resolve console warnings (#8715) * fix(nc-gui): some ts warnings * fix(nc-gui): columnFilter file warnings * fix(nc-gui): fix ts errors * fix(nc-gui): pr review changes * fix(nc-gui): update NcCheckbox change event * fix(nc-gui): pr review changes --- packages/nc-gui/components/dlg/ViewCreate.vue | 4 ++-- packages/nc-gui/components/nc/Checkbox.vue | 4 ++-- packages/nc-gui/components/shared-view/AskPassword.vue | 8 +------- packages/nc-gui/components/smartsheet/Form.vue | 4 ++-- packages/nc-gui/components/smartsheet/Kanban.vue | 1 - .../components/smartsheet/expanded-form/Comments.vue | 2 +- .../nc-gui/components/smartsheet/toolbar/ColumnFilter.vue | 4 ++-- 7 files changed, 10 insertions(+), 17 deletions(-) diff --git a/packages/nc-gui/components/dlg/ViewCreate.vue b/packages/nc-gui/components/dlg/ViewCreate.vue index 9b22e0173f..0faaf29d65 100644 --- a/packages/nc-gui/components/dlg/ViewCreate.vue +++ b/packages/nc-gui/components/dlg/ViewCreate.vue @@ -13,7 +13,7 @@ interface Props { groupingFieldColumnId?: string geoDataFieldColumnId?: string tableId: string - calendarRange: Array<{ + calendarRange?: Array<{ fk_from_column_id: string fk_to_column_id: string | null // for ee only }> @@ -36,7 +36,7 @@ interface Form { // for calendar view only calendar_range: Array<{ fk_from_column_id: string - fk_to_column_id: string | undefined // for ee only + fk_to_column_id: string | null // for ee only }> } diff --git a/packages/nc-gui/components/nc/Checkbox.vue b/packages/nc-gui/components/nc/Checkbox.vue index f3c650da85..865437e457 100644 --- a/packages/nc-gui/components/nc/Checkbox.vue +++ b/packages/nc-gui/components/nc/Checkbox.vue @@ -1,6 +1,6 @@ diff --git a/packages/nc-gui/components/shared-view/AskPassword.vue b/packages/nc-gui/components/shared-view/AskPassword.vue index dd5efc9a9d..1cce0c76a1 100644 --- a/packages/nc-gui/components/shared-view/AskPassword.vue +++ b/packages/nc-gui/components/shared-view/AskPassword.vue @@ -44,13 +44,6 @@ const focus: VNodeRef = (el: typeof InputPassword) => { return el && el?.focus?.() } -watch( - () => formState.value.password, - () => { - passwordError.value = null - }, -) - const bgImageName = computed(() => { switch (props.viewType) { case ViewTypes.GRID: @@ -97,6 +90,7 @@ const bgImageName = computed(() => { class="!rounded-lg !text-small" hide-details :placeholder="$t('msg.enterPassword')" + @input="passwordError = null" />
{{ passwordError }}
diff --git a/packages/nc-gui/components/smartsheet/Form.vue b/packages/nc-gui/components/smartsheet/Form.vue index 4a634dc796..16c00d6191 100644 --- a/packages/nc-gui/components/smartsheet/Form.vue +++ b/packages/nc-gui/components/smartsheet/Form.vue @@ -969,7 +969,7 @@ useEventListener( :bordered="false" :data-testid="NcForm.heading" :data-title="NcForm.heading" - @update:value="updateView" + @input="updateView" @focus="activeRow = NcForm.heading" @blur="activeRow = ''" /> @@ -1280,7 +1280,7 @@ useEventListener( :placeholder="$t('msg.info.formInput')" @focus="onFocusActiveFieldLabel" @keydown.enter.prevent - @update:value="updateFieldTitle" + @input="updateFieldTitle($event.target.value)" @change="updateColMeta(activeField)" /> diff --git a/packages/nc-gui/components/smartsheet/Kanban.vue b/packages/nc-gui/components/smartsheet/Kanban.vue index 5f888edebb..ec8d80adea 100644 --- a/packages/nc-gui/components/smartsheet/Kanban.vue +++ b/packages/nc-gui/components/smartsheet/Kanban.vue @@ -113,7 +113,6 @@ const kanbanContainerRef = ref() const selectedStackTitle = ref('') reloadViewDataHook?.on(async () => { - console.log('load') await loadKanbanMeta() await loadKanbanData() }) diff --git a/packages/nc-gui/components/smartsheet/expanded-form/Comments.vue b/packages/nc-gui/components/smartsheet/expanded-form/Comments.vue index 8d57469c86..aca4c7b6f2 100644 --- a/packages/nc-gui/components/smartsheet/expanded-form/Comments.vue +++ b/packages/nc-gui/components/smartsheet/expanded-form/Comments.vue @@ -3,7 +3,7 @@ import { type CommentType, ProjectRoles } from 'nocodb-sdk' const props = defineProps<{ loading: boolean - primaryKey: string + primaryKey: string | null }>() const { diff --git a/packages/nc-gui/components/smartsheet/toolbar/ColumnFilter.vue b/packages/nc-gui/components/smartsheet/toolbar/ColumnFilter.vue index 985ad6080a..d3942396a3 100644 --- a/packages/nc-gui/components/smartsheet/toolbar/ColumnFilter.vue +++ b/packages/nc-gui/components/smartsheet/toolbar/ColumnFilter.vue @@ -878,7 +878,7 @@ const changeToDynamic = async (filter, i) => { 'mt-1 mb-2': filters.length, }" > - +
@@ -904,7 +904,7 @@ const changeToDynamic = async (filter, i) => { 'mt-1 mb-2': filters.length, }" > - +
From 70b31392cdf113277e91ec3e143f192ab2fa5119 Mon Sep 17 00:00:00 2001 From: Raju Udava <86527202+dstala@users.noreply.github.com> Date: Fri, 14 Jun 2024 12:48:03 +0530 Subject: [PATCH 13/27] test: fix mfe toggle (trial) (#8740) * test: fix mfe toggle (trial) Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * test: retain timeout wait after save Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> --------- Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> --- tests/playwright/pages/Dashboard/Details/FieldsPage.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/playwright/pages/Dashboard/Details/FieldsPage.ts b/tests/playwright/pages/Dashboard/Details/FieldsPage.ts index a2a9a64cde..286122cc21 100644 --- a/tests/playwright/pages/Dashboard/Details/FieldsPage.ts +++ b/tests/playwright/pages/Dashboard/Details/FieldsPage.ts @@ -272,6 +272,9 @@ export class FieldsPage extends BasePage { } async saveChanges() { + // allow the changes triggered earlier (toggle visibility, etc) to settle + await this.rootPage.waitForTimeout(1000); + await this.waitForResponse({ uiAction: async () => await this.saveChangesButton.click(), requestUrlPathToMatch: 'api/v1/db/meta/tables/', From aa7b9a156fa52efe7c68d47aef41b88a8ed46321 Mon Sep 17 00:00:00 2001 From: Mert E Date: Fri, 14 Jun 2024 11:30:13 +0300 Subject: [PATCH 14/27] fix: delete org user (#8742) Signed-off-by: mertmit --- packages/nocodb/src/meta/meta.service.ts | 29 ------------------- packages/nocodb/src/models/BaseUser.ts | 15 ++++------ packages/nocodb/src/models/SyncSource.ts | 17 +++++------ .../nocodb/src/services/org-users.service.ts | 6 ++-- 4 files changed, 15 insertions(+), 52 deletions(-) diff --git a/packages/nocodb/src/meta/meta.service.ts b/packages/nocodb/src/meta/meta.service.ts index bf9fa2bcc5..7eba9a7215 100644 --- a/packages/nocodb/src/meta/meta.service.ts +++ b/packages/nocodb/src/meta/meta.service.ts @@ -326,35 +326,6 @@ export class MetaService { return query.del(); } - /*** - * Delete meta data with condition (USE WITH CAUTION) - * @param target - Table name - * @param idOrCondition - If string, will delete the record with the given id. If object, will delete the record with the given condition. - * @param xcCondition - Additional nested or complex condition to be added to the query. - */ - public async metaDeleteAll( - target: string, - idOrCondition: string | { [p: string]: any }, - xcCondition?: Condition, - ): Promise { - const query = this.knexConnection(target); - - if (typeof idOrCondition !== 'object') { - query.where('id', idOrCondition); - } else if (idOrCondition) { - query.where(idOrCondition); - } - - if (xcCondition) { - query.condition(xcCondition, {}); - } - - // Check if a condition is present in the query builder and throw an error if not. - this.checkConditionPresent(query, 'delete'); - - return query.del(); - } - /*** * Get meta data * @param workspace_id - Workspace id diff --git a/packages/nocodb/src/models/BaseUser.ts b/packages/nocodb/src/models/BaseUser.ts index c6dac92b30..a313d792c7 100644 --- a/packages/nocodb/src/models/BaseUser.ts +++ b/packages/nocodb/src/models/BaseUser.ts @@ -8,12 +8,12 @@ import { CacheGetType, CacheScope, MetaTable, - RootScopes, } from '~/utils/globals'; import Noco from '~/Noco'; import NocoCache from '~/cache/NocoCache'; import { extractProps } from '~/helpers/extractProps'; import { parseMetaProp } from '~/utils/modelUtils'; +import { NcError } from '~/helpers/catchError'; export default class BaseUser { fk_workspace_id?: string; @@ -359,14 +359,11 @@ export default class BaseUser { userId: string, ncMeta = Noco.ncMeta, ): Promise { - return await ncMeta.metaList2( - RootScopes.BASE, - RootScopes.BASE, - MetaTable.PROJECT_USERS, - { - condition: { fk_user_id: userId }, - }, - ); + if (!userId) NcError.badRequest('User Id is required'); + + return await ncMeta.knex(MetaTable.PROJECT_USERS).where({ + fk_user_id: userId, + }); } static async getProjectsList( diff --git a/packages/nocodb/src/models/SyncSource.ts b/packages/nocodb/src/models/SyncSource.ts index 2c3e42e698..93d5e3293a 100644 --- a/packages/nocodb/src/models/SyncSource.ts +++ b/packages/nocodb/src/models/SyncSource.ts @@ -150,17 +150,14 @@ export default class SyncSource { ); } - static async deleteByUserId( - context: NcContext, - userId: string, - ncMeta = Noco.ncMeta, - ) { - throw new Error('Method not implemented.'); - + static async deleteByUserId(userId: string, ncMeta = Noco.ncMeta) { if (!userId) NcError.badRequest('User Id is required'); - return await ncMeta.metaDeleteAll(MetaTable.SYNC_SOURCE, { - fk_user_id: userId, - }); + return await ncMeta + .knex(MetaTable.SYNC_SOURCE) + .where({ + fk_user_id: userId, + }) + .del(); } } diff --git a/packages/nocodb/src/services/org-users.service.ts b/packages/nocodb/src/services/org-users.service.ts index e0aae4fabd..d3a386aa13 100644 --- a/packages/nocodb/src/services/org-users.service.ts +++ b/packages/nocodb/src/services/org-users.service.ts @@ -16,7 +16,7 @@ import { validatePayload } from '~/helpers'; import { NcError } from '~/helpers/catchError'; import { extractProps } from '~/helpers/extractProps'; import { randomTokenString } from '~/helpers/stringHelpers'; -import { BaseUser, Store, User } from '~/models'; +import { BaseUser, Store, SyncSource, User } from '~/models'; import Noco from '~/Noco'; import { MetaTable, RootScopes } from '~/utils/globals'; @@ -65,7 +65,6 @@ export class OrgUsersService { } // delete base user entry and assign to super admin - // TODO-TENANT: scope this to org const baseUsers = await BaseUser.getProjectsIdList(param.userId, ncMeta); // todo: clear cache @@ -84,8 +83,7 @@ export class OrgUsersService { } // delete sync source entry - // TODO-TENANT: ENABLE THIS & CONFIRM SCOPE - // await SyncSource.deleteByUserId(param.userId, ncMeta); + await SyncSource.deleteByUserId(param.userId, ncMeta); // delete user await User.delete(param.userId, ncMeta); From be7f60e388125db1162674e26380e0bea970936a Mon Sep 17 00:00:00 2001 From: Pranav C Date: Fri, 14 Jun 2024 08:35:58 +0000 Subject: [PATCH 15/27] refactor: type corrections and update state to deleting and delete filter in background to avoid duplicate click --- packages/nc-gui/composables/useViewFilters.ts | 119 ++++++++++-------- 1 file changed, 64 insertions(+), 55 deletions(-) diff --git a/packages/nc-gui/composables/useViewFilters.ts b/packages/nc-gui/composables/useViewFilters.ts index 51e905bd01..f4d3c302bb 100644 --- a/packages/nc-gui/composables/useViewFilters.ts +++ b/packages/nc-gui/composables/useViewFilters.ts @@ -10,12 +10,14 @@ import type { ComputedRef, Ref } from 'vue' import type { SelectProps } from 'ant-design-vue' import { UITypes, isSystemColumn } from 'nocodb-sdk' +type ColumnFilterType = FilterType & { status?: string; id?: string; children?: ColumnFilterType[]; is_group?: boolean } + export function useViewFilters( view: Ref, _parentId: Ref | null | string, autoApply?: ComputedRef, reloadData?: () => void, - _currentFilters?: Filter[], + _currentFilters?: ColumnFilterType[], isNestedRoot?: boolean, isWebhook?: boolean, isLink?: boolean, @@ -27,7 +29,7 @@ export function useViewFilters( const currentFilters = ref(_currentFilters) - const btLookupTypesMap = ref({}) + const btLookupTypesMap = ref>({}) const reloadHook = inject(ReloadViewDataHookInj) @@ -45,15 +47,15 @@ export function useViewFilters( const { addUndo, clone, defineViewScope } = useUndoRedo() - const _filters = ref([...(currentFilters.value || [])]) + const _filters = ref([...(currentFilters.value || [])]) const nestedMode = computed(() => isPublic.value || !isUIAllowed('filterSync') || !isUIAllowed('filterChildrenRead')) - const filters = computed({ + const filters = computed({ get: () => { return nestedMode.value && !isLink && !isWebhook ? currentFilters.value! : _filters.value }, - set: (value: Filter[]) => { + set: (value: ColumnFilterType[]) => { if (nestedMode.value) { currentFilters.value = value if (!isLink && !isWebhook) { @@ -117,9 +119,9 @@ export function useViewFilters( }, {}) }) - const lastFilters = ref([]) + const lastFilters = ref([]) - watchOnce(filters, (filters: Filter[]) => { + watchOnce(filters, (filters: ColumnFilterType[]) => { lastFilters.value = clone(filters) }) @@ -131,7 +133,7 @@ export function useViewFilters( } const isComparisonOpAllowed = ( - filter: FilterType, + filter: ColumnFilterType, compOp: { text: string value: string @@ -141,7 +143,7 @@ export function useViewFilters( }, ) => { const isNullOrEmptyOp = ['empty', 'notempty', 'null', 'notnull'].includes(compOp.value) - const uidt = types.value[filter.fk_column_id] + const uidt = types.value[filter.fk_column_id!] if (compOp.includedTypes) { // include allowed values only if selected column type matches @@ -167,7 +169,7 @@ export function useViewFilters( } const isComparisonSubOpAllowed = ( - filter: FilterType, + filter: ColumnFilterType, compOp: { text: string value: string @@ -176,7 +178,7 @@ export function useViewFilters( excludedTypes?: UITypes[] }, ) => { - const uidt = types.value[filter.fk_column_id] + const uidt = types.value[filter.fk_column_id!] if (compOp.includedTypes) { // include allowed values only if selected column type matches @@ -187,7 +189,7 @@ export function useViewFilters( } } - const placeholderFilter = (): Filter => { + const placeholderFilter = (): ColumnFilterType => { const logicalOps = new Set(filters.value.slice(1).map((filter) => filter.logical_op)) return { @@ -200,7 +202,7 @@ export function useViewFilters( } } - const placeholderGroupFilter = (): Filter => { + const placeholderGroupFilter = (): ColumnFilterType => { const logicalOps = new Set(filters.value.slice(1).map((filter) => filter.logical_op)) return { @@ -210,12 +212,12 @@ export function useViewFilters( } } - const loadAllChildFilters = async (filters: Filter[]) => { + const loadAllChildFilters = async (filters: ColumnFilterType[]) => { // Array to store promises of child filter loading const promises = [] // Array to store all child filters - const allChildFilters: Filter[] = [] + const allChildFilters: ColumnFilterType[] = [] // Iterate over all filters for (const filter of filters) { @@ -223,7 +225,7 @@ export function useViewFilters( if (filter.id && filter.is_group) { // Load children filters from the backend const childFilterPromise = $api.dbTableFilter.childrenRead(filter.id).then((response) => { - const childFilters = response.list as Filter[] + const childFilters = response.list as ColumnFilterType[] allChildFilters.push(...childFilters) return loadAllChildFilters(childFilters) }) @@ -235,7 +237,7 @@ export function useViewFilters( await Promise.all(promises) // Push all child filters into the allFilters array - if (!isLink && !isWebhook) allFilters.value.push(...allChildFilters) + if (!isLink && !isWebhook) allFilters.value.push(...(allChildFilters as FilterType[])) } const loadFilters = async ({ @@ -259,25 +261,25 @@ export function useViewFilters( try { if (isWebhook || hookId) { if (parentId.value) { - filters.value = (await $api.dbTableFilter.childrenRead(parentId.value)).list as Filter[] + filters.value = (await $api.dbTableFilter.childrenRead(parentId.value)).list as ColumnFilterType[] } else if (hookId && !isNestedRoot) { - filters.value = (await $api.dbTableWebhookFilter.read(hookId)).list as Filter[] + filters.value = (await $api.dbTableWebhookFilter.read(hookId)).list as ColumnFilterType[] } } else { if (isLink || linkColId?.value) { if (parentId.value) { - filters.value = (await $api.dbTableFilter.childrenRead(parentId.value)).list as Filter[] + filters.value = (await $api.dbTableFilter.childrenRead(parentId.value)).list as ColumnFilterType[] } else if (linkColId?.value && !isNestedRoot) { - filters.value = (await $api.dbTableLinkFilter.read(linkColId?.value)).list as Filter[] + filters.value = (await $api.dbTableLinkFilter.read(linkColId?.value)).list as ColumnFilterType[] } } else { if (parentId.value) { - filters.value = (await $api.dbTableFilter.childrenRead(parentId.value)).list as Filter[] + filters.value = (await $api.dbTableFilter.childrenRead(parentId.value)).list as ColumnFilterType[] } else { - filters.value = (await $api.dbTableFilter.read(view.value!.id!)).list as Filter[] + filters.value = (await $api.dbTableFilter.read(view.value!.id!)).list as ColumnFilterType[] if (loadAllFilters) { - allFilters.value = [...filters.value] - await loadAllChildFilters(allFilters.value) + allFilters.value = [...filters.value] as FilterType[] + await loadAllChildFilters(allFilters.value as ColumnFilterType[]) } } } @@ -311,23 +313,26 @@ export function useViewFilters( ...filter, children: undefined, fk_parent_id: parentId.value, - })) as unknown as FilterType + } as FilterType)) as ColumnFilterType } else if (linkId || linkColId?.value) { filters.value[+i] = (await $api.dbTableLinkFilter.create(linkId || linkColId.value, { ...filter, children: undefined, fk_parent_id: parentId.value, - })) as unknown as FilterType + } as FilterType)) as ColumnFilterType } else { - filters.value[+i] = await $api.dbTableFilter.create(view?.value?.id as string, { - ...filter, - fk_parent_id: parentId.value, - }) + filters.value[+i] = (await $api.dbTableFilter.create( + view?.value?.id as string, + { + ...filter, + fk_parent_id: parentId.value, + } as FilterType, + )) as ColumnFilterType } if (children) filters.value[+i].children = children - if (!isLink && !isWebhook) allFilters.value.push(filters.value[+i]) + if (!isLink && !isWebhook) allFilters.value.push(filters.value[+i] as FilterType) } } @@ -338,9 +343,9 @@ export function useViewFilters( } } - const saveOrUpdateDebounced = useCachedDebouncedFunction(saveOrUpdate, 500, (_filter: Filter, i: number) => i) + const saveOrUpdateDebounced = useCachedDebouncedFunction(saveOrUpdate, 500, (_filter: ColumnFilterType, i: number) => i) - async function saveOrUpdate(filter: Filter, i: number, force = false, undo = false, skipDataReload = false) { + async function saveOrUpdate(filter: ColumnFilterType, i: number, force = false, undo = false, skipDataReload = false) { // if already in progress the debounced function which will call this function again with 500ms delay until it's not saving if (savingStatus[i]) { return saveOrUpdateDebounced(filter, i, force, undo, skipDataReload) @@ -360,7 +365,7 @@ export function useViewFilters( fn: (prop: string, data: any) => { const f = filters.value[i] if (f) { - f[prop as keyof Filter] = data + f[prop as keyof ColumnFilterType] = data saveOrUpdate(f, i, force, true) } }, @@ -370,11 +375,11 @@ export function useViewFilters( fn: (prop: string, data: any) => { const f = filters.value[i] if (f) { - f[prop as keyof Filter] = data + f[prop as keyof ColumnFilterType] = data saveOrUpdate(f, i, force, true) } }, - args: [Object.keys(delta)[0], filter[Object.keys(delta)[0] as keyof Filter]], + args: [Object.keys(delta)[0], filter[Object.keys(delta)[0] as keyof ColumnFilterType]], }, scope: defineViewScope({ view: activeView.value }), }) @@ -402,13 +407,13 @@ export function useViewFilters( if (linkColId?.value) { const savedFilter = await $api.dbTableLinkFilter.create(linkColId.value, { ...filter, - fk_parent_id: parentId, + fk_parent_id: parentId.value, }) // extract id from saved filter and update the filter object // avoiding whole object update to prevent overwriting of current filter object changes filters.value[i] = { ...filters.value[i], - fk_parent_id: parentId, + fk_parent_id: parentId.value, id: savedFilter.id, status: undefined, } @@ -422,12 +427,12 @@ export function useViewFilters( // avoiding whole object update to prevent overwriting of current filter object changes filters.value[i] = { ...filters.value[i], - fk_parent_id: parentId, + fk_parent_id: parentId.value, id: savedFilter.id, status: undefined, } } - if (!isLink && !isWebhook) allFilters.value.push(filters.value[+i]) + if (!isLink && !isWebhook) allFilters.value.push(filters.value[+i] as FilterType) } } catch (e: any) { console.log(e) @@ -441,7 +446,7 @@ export function useViewFilters( if (!isWebhook && !skipDataReload && !isLink) reloadData?.() } - function deleteFilterGroupFromAllFilters(filter: Filter) { + function deleteFilterGroupFromAllFilters(filter: ColumnFilterType) { if (!isLink && !isWebhook) return // Find all child filters of the specified parentId @@ -458,11 +463,13 @@ export function useViewFilters( allFilters.value = allFilters.value.filter((f) => f.id !== filter.id && f.fk_parent_id !== filter.id) } - const deleteFilter = async (filter: Filter, i: number, undo = false) => { + const deleteFilter = async (filter: ColumnFilterType, i: number, undo = false) => { + // update the filter status + filter.status = 'delete' if (!undo && !filter.is_group) { addUndo({ undo: { - fn: async (fl: Filter) => { + fn: async (fl: ColumnFilterType) => { fl.status = 'create' filters.value.splice(i, 0, fl) await saveOrUpdate(fl, i, false, true) @@ -515,7 +522,9 @@ export function useViewFilters( } } const addFilter = async (undo = false, draftFilter: Partial = {}) => { - filters.value.push(draftFilter?.fk_column_id ? { ...placeholderFilter(), ...draftFilter } : placeholderFilter()) + filters.value.push( + (draftFilter?.fk_column_id ? { ...placeholderFilter(), ...draftFilter } : placeholderFilter()) as ColumnFilterType, + ) if (!undo) { addUndo({ undo: { @@ -526,7 +535,7 @@ export function useViewFilters( args: [filters.value.length - 1], }, redo: { - fn: async (i: number, fl: Filter) => { + fn: async (i: number, fl: ColumnFilterType) => { fl.status = 'create' filters.value.splice(i, 0, fl) await saveOrUpdate(fl, i, false, true) @@ -545,7 +554,7 @@ export function useViewFilters( const addFilterGroup = async () => { const child = placeholderFilter() - const placeHolderGroupFilter: Filter = placeholderGroupFilter() + const placeHolderGroupFilter: ColumnFilterType = placeholderGroupFilter() if (nestedMode.value) placeHolderGroupFilter.children = [child] @@ -577,28 +586,28 @@ export function useViewFilters( // method to extract looked up column meta for all bt lookup columns // it helps to decide the condition operations for the column const loadBtLookupTypes = async () => { - const btLookupTypes = {} + const btLookupTypes: Record = {} try { for (const col of meta.value?.columns || []) { if (col.uidt !== UITypes.Lookup) continue - let nextCol = col + let nextCol: ColumnType | undefined = col // check all the relation of nested lookup columns is bt or not // include the column only if all only if all relations are bt while (nextCol && nextCol.uidt === UITypes.Lookup) { // extract the relation column meta - const lookupRelation = (await getMeta(nextCol.fk_model_id))?.columns?.find( - (c) => c.id === (nextCol.colOptions as LookupType).fk_relation_column_id, + const lookupRelation = (await getMeta(nextCol.fk_model_id!))?.columns?.find( + (c) => c.id === (nextCol!.colOptions as LookupType).fk_relation_column_id, ) - const relatedTableMeta = await getMeta((lookupRelation.colOptions as LinkToAnotherRecordType).fk_related_model_id) - nextCol = relatedTableMeta?.columns?.find((c) => c.id === (nextCol.colOptions as LookupType).fk_lookup_column_id) + const relatedTableMeta = await getMeta((lookupRelation?.colOptions as LinkToAnotherRecordType).fk_related_model_id!) + nextCol = relatedTableMeta?.columns?.find((c) => c.id === (nextCol!.colOptions as LookupType).fk_lookup_column_id) // if next column is same as root lookup column then break the loop // since it's going to be a circular loop - if (nextCol.id === col.id) { + if (nextCol?.id === col.id) { break } } - btLookupTypes[col.id] = nextCol + btLookupTypes[col.id!] = nextCol } btLookupTypesMap.value = btLookupTypes } catch (e) { From 03017f31abb7112f1ebb7e17db8c829372a20c5a Mon Sep 17 00:00:00 2001 From: Pranav C Date: Fri, 14 Jun 2024 08:35:58 +0000 Subject: [PATCH 16/27] refactor: handle if lookuprelation not found --- packages/nc-gui/composables/useViewFilters.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/nc-gui/composables/useViewFilters.ts b/packages/nc-gui/composables/useViewFilters.ts index f4d3c302bb..5b834476d8 100644 --- a/packages/nc-gui/composables/useViewFilters.ts +++ b/packages/nc-gui/composables/useViewFilters.ts @@ -418,8 +418,7 @@ export function useViewFilters( status: undefined, } } else { - console.log(parentId.value) - const savedFilter = await $api.dbTableFilter.create(view.value.id!, { + const savedFilter = await $api.dbTableFilter.create(view.value!.id!, { ...filter, fk_parent_id: parentId.value, }) @@ -455,7 +454,7 @@ export function useViewFilters( // Recursively delete child filter of child filter childFilters.forEach((childFilter) => { if (childFilter.is_group) { - deleteFilterGroupFromAllFilters(childFilter) + deleteFilterGroupFromAllFilters(childFilter as ColumnFilterType) } }) @@ -598,6 +597,12 @@ export function useViewFilters( const lookupRelation = (await getMeta(nextCol.fk_model_id!))?.columns?.find( (c) => c.id === (nextCol!.colOptions as LookupType).fk_relation_column_id, ) + + // this is less likely to happen but if relation column is not found then break the loop + if (!lookupRelation) { + break + } + const relatedTableMeta = await getMeta((lookupRelation?.colOptions as LinkToAnotherRecordType).fk_related_model_id!) nextCol = relatedTableMeta?.columns?.find((c) => c.id === (nextCol!.colOptions as LookupType).fk_lookup_column_id) From da706f4252ff169d7527251f9c2c2bfa762d840d Mon Sep 17 00:00:00 2001 From: Mert E Date: Fri, 14 Jun 2024 12:05:03 +0300 Subject: [PATCH 17/27] fix: avoid marking updated on select (#8741) * fix: avoid marking updated on select * fix: handle null/undefined meta * fix: use local meta for field details * fix: avoid creating options on update * fix: improve readability --- .../smartsheet/column/AttachmentOptions.vue | 2 +- .../smartsheet/column/BarcodeOptions.vue | 20 +-- .../smartsheet/column/CheckboxOptions.vue | 10 +- .../smartsheet/column/CurrencyOptions.vue | 7 +- .../smartsheet/column/DateOptions.vue | 9 +- .../smartsheet/column/DateTimeOptions.vue | 18 +-- .../smartsheet/column/DecimalOptions.vue | 5 +- .../smartsheet/column/DurationOptions.vue | 6 +- .../smartsheet/column/LinkOptions.vue | 2 +- .../smartsheet/column/NumberOptions.vue | 4 +- .../smartsheet/column/PercentOptions.vue | 6 +- .../smartsheet/column/RatingOptions.vue | 36 +----- .../smartsheet/column/TimeOptions.vue | 4 +- .../smartsheet/column/UserOptions.vue | 7 +- .../components/smartsheet/details/Fields.vue | 45 +++++-- packages/nc-gui/composables/useViewGroupBy.ts | 2 + packages/nc-gui/helpers/columnDefaultMeta.ts | 119 ++++++++++++++++++ .../nocodb/src/services/columns.service.ts | 2 +- 18 files changed, 207 insertions(+), 97 deletions(-) create mode 100644 packages/nc-gui/helpers/columnDefaultMeta.ts diff --git a/packages/nc-gui/components/smartsheet/column/AttachmentOptions.vue b/packages/nc-gui/components/smartsheet/column/AttachmentOptions.vue index ac631a85be..be8a20d35f 100644 --- a/packages/nc-gui/components/smartsheet/column/AttachmentOptions.vue +++ b/packages/nc-gui/components/smartsheet/column/AttachmentOptions.vue @@ -33,7 +33,7 @@ vModel.value.meta = { // allow all mime types by default supportedAttachmentMimeTypes: ['*'], }), - ...vModel.value.meta, + ...(vModel.value.meta || {}), } const expandedKeys = ref<(string | number)[]>([]) diff --git a/packages/nc-gui/components/smartsheet/column/BarcodeOptions.vue b/packages/nc-gui/components/smartsheet/column/BarcodeOptions.vue index e1085cffaa..14bff16e65 100644 --- a/packages/nc-gui/components/smartsheet/column/BarcodeOptions.vue +++ b/packages/nc-gui/components/smartsheet/column/BarcodeOptions.vue @@ -1,5 +1,5 @@ diff --git a/packages/nc-gui/components/smartsheet/column/DateTimeOptions.vue b/packages/nc-gui/components/smartsheet/column/DateTimeOptions.vue index 8ecb98be33..81c4e69ae9 100644 --- a/packages/nc-gui/components/smartsheet/column/DateTimeOptions.vue +++ b/packages/nc-gui/components/smartsheet/column/DateTimeOptions.vue @@ -1,5 +1,5 @@ diff --git a/packages/nc-gui/components/smartsheet/column/DecimalOptions.vue b/packages/nc-gui/components/smartsheet/column/DecimalOptions.vue index 11adec8061..42ac23ffd2 100644 --- a/packages/nc-gui/components/smartsheet/column/DecimalOptions.vue +++ b/packages/nc-gui/components/smartsheet/column/DecimalOptions.vue @@ -1,4 +1,6 @@ diff --git a/packages/nc-gui/components/smartsheet/column/LinkOptions.vue b/packages/nc-gui/components/smartsheet/column/LinkOptions.vue index 3c4fd075c0..69109f7e4c 100644 --- a/packages/nc-gui/components/smartsheet/column/LinkOptions.vue +++ b/packages/nc-gui/components/smartsheet/column/LinkOptions.vue @@ -44,7 +44,7 @@ setAdditionalValidations({ vModel.value.meta = { singular: '', plural: '', - ...vModel.value.meta, + ...(vModel.value.meta || {}), } diff --git a/packages/nc-gui/components/smartsheet/column/NumberOptions.vue b/packages/nc-gui/components/smartsheet/column/NumberOptions.vue index e43bb4efcd..2732180a26 100644 --- a/packages/nc-gui/components/smartsheet/column/NumberOptions.vue +++ b/packages/nc-gui/components/smartsheet/column/NumberOptions.vue @@ -1,4 +1,6 @@ diff --git a/packages/nc-gui/components/smartsheet/column/PercentOptions.vue b/packages/nc-gui/components/smartsheet/column/PercentOptions.vue index 26c43fd463..7e3592dbe8 100644 --- a/packages/nc-gui/components/smartsheet/column/PercentOptions.vue +++ b/packages/nc-gui/components/smartsheet/column/PercentOptions.vue @@ -1,4 +1,6 @@ diff --git a/packages/nc-gui/components/smartsheet/column/RatingOptions.vue b/packages/nc-gui/components/smartsheet/column/RatingOptions.vue index 596d282016..892517542f 100644 --- a/packages/nc-gui/components/smartsheet/column/RatingOptions.vue +++ b/packages/nc-gui/components/smartsheet/column/RatingOptions.vue @@ -1,4 +1,6 @@ diff --git a/packages/nc-gui/components/smartsheet/column/UserOptions.vue b/packages/nc-gui/components/smartsheet/column/UserOptions.vue index 4235bb120e..f8135393d7 100644 --- a/packages/nc-gui/components/smartsheet/column/UserOptions.vue +++ b/packages/nc-gui/components/smartsheet/column/UserOptions.vue @@ -1,4 +1,6 @@