From 02811aefad3b45182888ed7d696d76f97680ee68 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 11:41:03 +0530 Subject: [PATCH] refactor: filter and sort api corrections Signed-off-by: Pranav C --- packages/nocodb/src/lib/noco-models/Filter.ts | 2 +- .../noco/meta/helpers/extractProjectIdAndAuthenticate.ts | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/nocodb/src/lib/noco-models/Filter.ts b/packages/nocodb/src/lib/noco-models/Filter.ts index 8a220fce30..b9c2a95802 100644 --- a/packages/nocodb/src/lib/noco-models/Filter.ts +++ b/packages/nocodb/src/lib/noco-models/Filter.ts @@ -388,7 +388,7 @@ export default class Filter { await deleteRecursively(filter); } - private static async get(id: string, ncMeta = Noco.ncMeta) { + public static async get(id: string, ncMeta = Noco.ncMeta) { let filterObj = id && (await NocoCache.get( diff --git a/packages/nocodb/src/lib/noco/meta/helpers/extractProjectIdAndAuthenticate.ts b/packages/nocodb/src/lib/noco/meta/helpers/extractProjectIdAndAuthenticate.ts index fa25b310e5..b30e33bb83 100644 --- a/packages/nocodb/src/lib/noco/meta/helpers/extractProjectIdAndAuthenticate.ts +++ b/packages/nocodb/src/lib/noco/meta/helpers/extractProjectIdAndAuthenticate.ts @@ -9,6 +9,8 @@ import FormViewColumn from '../../../noco-models/FormViewColumn'; import GalleryViewColumn from '../../../noco-models/GalleryViewColumn'; import Project from '../../../noco-models/Project'; import Column from '../../../noco-models/Column'; +import Filter from '../../../noco-models/Filter'; +import Sort from '../../../noco-models/Sort'; export default async (req, res, next) => { try { @@ -70,6 +72,12 @@ export default async (req, res, next) => { } else if (params.columnId) { const column = await Column.get({ colId: params.columnId }); req.ncProjectId = column?.project_id; + } else if (params.filterId) { + const filter = await Filter.get(params.filterId); + req.ncProjectId = filter?.project_id; + } else if (params.sortId) { + const sort = await Sort.get(params.sortId); + req.ncProjectId = sort?.project_id; } const user = await new Promise((resolve, _reject) => {