feat: add list filter to board view (#241)
* feat: add list filter to board view * feat: implement API-driven list filtering * refactor: remove unnecessary list join from card filtering queries * feat: enable list filter options for public boards * refactor(perf): move to main query --------- Co-authored-by: Henry <henry_ball@hotmail.co.uk>
This commit is contained in:
@@ -70,6 +70,7 @@ export const getByPublicId = async (
|
||||
filters: {
|
||||
members: string[];
|
||||
labels: string[];
|
||||
lists: string[];
|
||||
type: "regular" | "template" | undefined;
|
||||
},
|
||||
) => {
|
||||
@@ -231,6 +232,19 @@ export const getByPublicId = async (
|
||||
orderBy: [asc(cards.index)],
|
||||
},
|
||||
},
|
||||
where: and(
|
||||
isNull(lists.deletedAt),
|
||||
filters.lists.length > 0
|
||||
? inArray(lists.publicId, filters.lists)
|
||||
: undefined,
|
||||
),
|
||||
orderBy: [asc(lists.index)],
|
||||
},
|
||||
allLists: {
|
||||
columns: {
|
||||
publicId: true,
|
||||
name: true,
|
||||
},
|
||||
where: isNull(lists.deletedAt),
|
||||
orderBy: [asc(lists.index)],
|
||||
},
|
||||
@@ -268,6 +282,7 @@ export const getBySlug = async (
|
||||
filters: {
|
||||
members: string[];
|
||||
labels: string[];
|
||||
lists: string[];
|
||||
},
|
||||
) => {
|
||||
let cardIds: string[] = [];
|
||||
@@ -379,6 +394,19 @@ export const getBySlug = async (
|
||||
orderBy: [asc(cards.index)],
|
||||
},
|
||||
},
|
||||
where: and(
|
||||
isNull(lists.deletedAt),
|
||||
filters.lists.length > 0
|
||||
? inArray(lists.publicId, filters.lists)
|
||||
: undefined,
|
||||
),
|
||||
orderBy: [asc(lists.index)],
|
||||
},
|
||||
allLists: {
|
||||
columns: {
|
||||
publicId: true,
|
||||
name: true,
|
||||
},
|
||||
where: isNull(lists.deletedAt),
|
||||
orderBy: [asc(lists.index)],
|
||||
},
|
||||
|
||||
@@ -73,6 +73,7 @@ export const boardsRelations = relations(boards, ({ one, many }) => ({
|
||||
relationName: "boardCreatedByUser",
|
||||
}),
|
||||
lists: many(lists),
|
||||
allLists: many(lists),
|
||||
labels: many(labels),
|
||||
deletedBy: one(users, {
|
||||
fields: [boards.deletedBy],
|
||||
|
||||
Reference in New Issue
Block a user