|
|
|
@ -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; |
|
|
|
|