8c41b33313
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>
51 lines
1.6 KiB
TypeScript
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 });
|
|
};
|