From 0da97ff99290b022005c63d7177e17dc5da58728 Mon Sep 17 00:00:00 2001 From: Daniel Spaude Date: Fri, 10 Feb 2023 20:13:41 +0100 Subject: [PATCH] MapView: 'Mapped by' column values should always be delivered - WIP --- packages/nc-gui/components/smartsheet/Kanban.vue | 2 ++ packages/nc-gui/components/smartsheet/Map.vue | 2 ++ .../nc-gui/components/smartsheet/toolbar/FieldsMenu.vue | 1 + packages/nc-gui/composables/useViewColumns.ts | 3 +++ packages/nc-gui/lib/types.ts | 1 + packages/nocodb-sdk/src/lib/helperFunctions.ts | 3 +++ .../src/lib/db/sql-data-mapper/lib/sql/helpers/getAst.ts | 8 ++++---- 7 files changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/Kanban.vue b/packages/nc-gui/components/smartsheet/Kanban.vue index 7ba8adbc50..774d08eb2f 100644 --- a/packages/nc-gui/components/smartsheet/Kanban.vue +++ b/packages/nc-gui/components/smartsheet/Kanban.vue @@ -111,6 +111,7 @@ const isRowEmpty = (record: any, col: any) => { } reloadViewDataHook?.on(async () => { + // alert('reloadViewDataHook') await loadKanbanMeta() await loadKanbanData() }) @@ -131,6 +132,7 @@ const attachments = (record: any): Attachment[] => { const reloadAttachments = ref(false) reloadViewMetaHook?.on(async () => { + alert('reloadViewMetaHook') await loadKanbanMeta() reloadAttachments.value = true diff --git a/packages/nc-gui/components/smartsheet/Map.vue b/packages/nc-gui/components/smartsheet/Map.vue index f512acefd4..7abcfc2230 100644 --- a/packages/nc-gui/components/smartsheet/Map.vue +++ b/packages/nc-gui/components/smartsheet/Map.vue @@ -155,10 +155,12 @@ onMounted(async () => { }) reloadViewMetaHook?.on(async () => { + alert('reloadViewMetaHook') await loadMapMeta() }) reloadViewDataHook?.on(async () => { + alert('reloadViewDataHook') await loadMapData() }) diff --git a/packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue b/packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue index bb06fb9659..19c0973f8d 100644 --- a/packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue +++ b/packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue @@ -198,6 +198,7 @@ useMenuCloseOnEsc(open) v-model:checked="field.show" v-e="['a:fields:show-hide']" class="shrink" + :disabled="field.isViewEssentialField" @change="saveOrUpdate(field, index)" >
diff --git a/packages/nc-gui/composables/useViewColumns.ts b/packages/nc-gui/composables/useViewColumns.ts index 0922527003..b04eef76c9 100644 --- a/packages/nc-gui/composables/useViewColumns.ts +++ b/packages/nc-gui/composables/useViewColumns.ts @@ -25,6 +25,8 @@ export function useViewColumns( () => isPublic.value || !isUIAllowed('hideAllColumns') || !isUIAllowed('showAllColumns') || isSharedBase.value, ) + const isColumnViewEssential = (column: ColumnType) => column. + const metaColumnById = computed>(() => { if (!meta.value?.columns) return {} @@ -64,6 +66,7 @@ export function useViewColumns( ...currentColumnField, order: currentColumnField.order || order++, system: isSystemColumn(metaColumnById?.value?.[currentColumnField.fk_column_id!]), + isViewEssentialField: isColumnViewEssential(column), } }) .sort((a: Field, b: Field) => a.order - b.order) diff --git a/packages/nc-gui/lib/types.ts b/packages/nc-gui/lib/types.ts index 2024d82f7e..90fdaf1cf6 100644 --- a/packages/nc-gui/lib/types.ts +++ b/packages/nc-gui/lib/types.ts @@ -32,6 +32,7 @@ export interface Field { title: string fk_column_id?: string system?: boolean + isViewEssentialField?: boolean } export type Roles = Record diff --git a/packages/nocodb-sdk/src/lib/helperFunctions.ts b/packages/nocodb-sdk/src/lib/helperFunctions.ts index 5ed58b1372..d61a2a1616 100644 --- a/packages/nocodb-sdk/src/lib/helperFunctions.ts +++ b/packages/nocodb-sdk/src/lib/helperFunctions.ts @@ -11,6 +11,9 @@ const getSystemColumnsIds = (columns) => { const getSystemColumns = (columns) => columns.filter(isSystemColumn) || []; +// const isColumnEssentialForView = (col) => +// col && col.vie + const isSystemColumn = (col) => col && (col.uidt === UITypes.ForeignKey || diff --git a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/helpers/getAst.ts b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/helpers/getAst.ts index 9e6af05f6e..9756fee2f2 100644 --- a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/helpers/getAst.ts +++ b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/helpers/getAst.ts @@ -81,13 +81,13 @@ const getAst = async ({ ...(await obj), [col.title]: allowedCols && (!includePkByDefault || !col.pk) - ? allowedCols[col.id] && + ? (allowedCols[col.id] && (!isSystemColumn(col) || view.show_system_fields) && (!fields?.length || fields.includes(col.title)) && - value - : fields?.length + value) + : (fields?.length ? fields.includes(col.title) && value - : value, + : value), }; }, Promise.resolve({})); };