feat: bulk metadata edit for existing documents #331

Merged
marcel merged 23 commits from feat/issue-225-bulk-metadata-edit into main 2026-04-25 19:27:53 +02:00
2 changed files with 11 additions and 7 deletions
Showing only changes of commit 2bb8fb8968 - Show all commits

View File

@@ -20,8 +20,13 @@ import type { components } from '$lib/generated/api';
type Person = components['schemas']['Person'];
// Mirrors the backend `DocumentBatchSummary` JSON shape one-to-one — the route
// passes the parsed `/api/documents/batch-metadata` response straight in, so
// the field names must match what the backend actually serializes (id, not
// documentId). The FileEntry built from each summary still uses both `id` and
// `documentId` so the save handler can drive the PATCH payload by UUID.
export type BulkEditEntry = {
documentId: string;
id: string;
title: string;
pdfUrl: string;
};
@@ -71,15 +76,14 @@ let archiveFolder = $state('');
// has already been resolved into `initialEditEntries`.
if (mode === 'edit') {
for (const entry of untrack(() => initialEditEntries)) {
const id = entry.documentId; // reuse documentId as the local FileEntry key
files.set(id, {
id,
documentId: entry.documentId,
files.set(entry.id, {
id: entry.id,
documentId: entry.id,
title: entry.title,
status: 'idle',
previewUrl: entry.pdfUrl
});
if (!activeId) activeId = id;
if (!activeId) activeId = entry.id;
}
}

View File

@@ -317,7 +317,7 @@ describe('BulkDocumentEditLayout', () => {
describe('BulkDocumentEditLayout — mode="edit"', () => {
const editEntry = (i: number) => ({
documentId: `doc-${i}`,
id: `doc-${i}`,
title: `Brief ${i}`,
pdfUrl: `/api/documents/doc-${i}/file`
});