Phase 7: Search, filters, templates, and archive UI
Add full-text card search (PostgreSQL tsvector + GIN index) with navbar SearchBar, client-side board filters (label/assignee/due date), board templates (3 system templates + save-as-template API), and archive toggle for both board listing and board view. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,12 +1,18 @@
|
||||
import type { PageServerLoad } from './$types.js';
|
||||
import { withTenant } from '$lib/server/rls.js';
|
||||
import { prisma } from '$lib/server/db.js';
|
||||
|
||||
export const load: PageServerLoad = async ({ locals }) => {
|
||||
export const load: PageServerLoad = async ({ locals, url }) => {
|
||||
const tenant = locals.tenant;
|
||||
if (!tenant) return { boards: [], categories: [] };
|
||||
if (!tenant) return { boards: [], categories: [], templates: [] };
|
||||
|
||||
const showArchived = url.searchParams.get('archived') === 'true';
|
||||
|
||||
const result = await withTenant(tenant.id, async (tx) => {
|
||||
const where: any = { tenantId: tenant.id, archived: false };
|
||||
const where: any = { tenantId: tenant.id };
|
||||
if (!showArchived) {
|
||||
where.archived = false;
|
||||
}
|
||||
|
||||
if (!locals.user) {
|
||||
where.visibility = 'PUBLIC';
|
||||
@@ -40,5 +46,23 @@ export const load: PageServerLoad = async ({ locals }) => {
|
||||
return { boards, categories };
|
||||
});
|
||||
|
||||
return result;
|
||||
// Fetch templates (system + tenant) — only if logged in
|
||||
let templates: any[] = [];
|
||||
if (locals.user) {
|
||||
const [systemTemplates, tenantTemplates] = await Promise.all([
|
||||
prisma.boardTemplate.findMany({
|
||||
where: { tenantId: null },
|
||||
orderBy: { name: 'asc' }
|
||||
}),
|
||||
withTenant(tenant.id, async (tx) => {
|
||||
return tx.boardTemplate.findMany({
|
||||
where: { tenantId: tenant.id },
|
||||
orderBy: { name: 'asc' }
|
||||
});
|
||||
})
|
||||
]);
|
||||
templates = [...systemTemplates, ...tenantTemplates];
|
||||
}
|
||||
|
||||
return { ...result, templates };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user