From 8fd5aa9feff9a06be606b2503dea36eb4dea131c Mon Sep 17 00:00:00 2001 From: sreehari jayaraj Date: Wed, 20 Sep 2023 18:07:03 +0530 Subject: [PATCH] fix(api): include cover image in gallery view --- packages/nocodb/src/helpers/getAst.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/nocodb/src/helpers/getAst.ts b/packages/nocodb/src/helpers/getAst.ts index 52acc65ece..3b3b676b0e 100644 --- a/packages/nocodb/src/helpers/getAst.ts +++ b/packages/nocodb/src/helpers/getAst.ts @@ -5,7 +5,7 @@ import type { LookupColumn, Model, } from '~/models'; -import { View } from '~/models'; +import { GalleryView, View } from '~/models'; const getAst = async ({ query, @@ -32,6 +32,12 @@ const getAst = async ({ dependencyFields.nested = dependencyFields.nested || {}; dependencyFields.fieldsSet = dependencyFields.fieldsSet || new Set(); + let coverImageId; + const gallery = await GalleryView.get(view.id); + if (gallery) { + coverImageId = gallery.fk_cover_image_col_id; + } + if (!model.columns?.length) await model.getColumns(); // extract only pk and pv @@ -59,7 +65,7 @@ const getAst = async ({ } let allowedCols = null; - if (view) + if (view) { allowedCols = (await View.getColumns(view.id)).reduce( (o, c) => ({ ...o, @@ -67,6 +73,10 @@ const getAst = async ({ }), {}, ); + if (coverImageId) { + allowedCols[coverImageId] = 1; + } + } const ast = await model.columns.reduce(async (obj, col: Column) => { let value: number | boolean | { [key: string]: any } = 1;