Private
Public Access
1
0
Files
Kanban/src/routes/api/boards/[boardId]/custom-fields/[fieldId]/+server.ts
T
Catherine Renelle 8c41b33313 Add 17 features: My Work view, card copy/numbering, calendar, bulk ops, custom fields, automations, webhooks, invites, import/export, and more
Features implemented across 6 batches:
- Batch A: Fix ColorPicker gradient sync, tenant custom logo, unarchive cards, board backgrounds
- Batch B: My Work view, card copy/duplicate, card numbering (BOARD-123)
- Batch C: Due date reminders (cron), card watching with notifications
- Batch D: Bulk card operations, column sorting, calendar view
- Batch E: Invite by link, board import/export (Pounce + Trello JSON)
- Batch F: Webhooks with HMAC signing, custom fields, automation rules engine

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-27 08:50:15 -05:00

51 lines
1.6 KiB
TypeScript

import { json, error } from '@sveltejs/kit';
import type { RequestHandler } from './$types.js';
import { withTenant } from '$lib/server/rls.js';
import { requireBoardEditor } from '$lib/server/guards.js';
export const PATCH: RequestHandler = async ({ params, request, locals }) => {
const tenant = locals.tenant;
if (!tenant) throw error(400, 'Unknown tenant');
const body = await request.json();
const field = await withTenant(tenant.id, async (tx) => {
await requireBoardEditor(tx, locals.user, params.boardId, tenant.id);
const existing = await tx.customFieldDef.findFirst({
where: { id: params.fieldId, boardId: params.boardId }
});
if (!existing) throw error(404, 'Field not found');
const data: Record<string, any> = {};
if (body.name !== undefined) data.name = body.name;
if (body.options !== undefined) data.options = body.options;
if (body.position !== undefined) data.position = body.position;
return tx.customFieldDef.update({
where: { id: params.fieldId },
data
});
});
return json({ field });
};
export const DELETE: RequestHandler = async ({ params, locals }) => {
const tenant = locals.tenant;
if (!tenant) throw error(400, 'Unknown tenant');
await withTenant(tenant.id, async (tx) => {
await requireBoardEditor(tx, locals.user, params.boardId, tenant.id);
const existing = await tx.customFieldDef.findFirst({
where: { id: params.fieldId, boardId: params.boardId }
});
if (!existing) throw error(404, 'Field not found');
await tx.customFieldDef.delete({ where: { id: params.fieldId } });
});
return json({ ok: true });
};