From 61d97464c3771d27defbc7ca3bfbc33fd3541a15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20P=C3=B6ttker?= Date: Tue, 5 May 2026 14:57:26 +0200 Subject: [PATCH] feat: add dateinameTemplate support to barcode scanner and display document names in inbox detail view --- .../src/barcode/barcode-scanner.service.ts | 2 + paperless-frontend/src/api/inbox.ts | 1 + .../src/pages/InboxDetailPage.tsx | 42 ++++++++++++++++--- paperless-frontend/src/pages/SettingsPage.tsx | 4 +- 4 files changed, 42 insertions(+), 7 deletions(-) diff --git a/paperless-backend/src/barcode/barcode-scanner.service.ts b/paperless-backend/src/barcode/barcode-scanner.service.ts index cbc627d..e95483d 100644 --- a/paperless-backend/src/barcode/barcode-scanner.service.ts +++ b/paperless-backend/src/barcode/barcode-scanner.service.ts @@ -17,6 +17,7 @@ export interface MatchedBarcode { value: string; templateId: number | null; templateName: string | null; + dateinameTemplate: string | null; splitBefore: boolean; actions: BarcodeActionType[]; } @@ -113,6 +114,7 @@ export class BarcodeScannerService implements OnApplicationBootstrap { value: qr.value, templateId: tpl?.Id ?? null, templateName: tpl?.Name ?? null, + dateinameTemplate: tpl?.DateinameTemplate ?? null, splitBefore: tpl?.SplitBefore ?? false, actions: tpl?.Actions ?? [], }; diff --git a/paperless-frontend/src/api/inbox.ts b/paperless-frontend/src/api/inbox.ts index 5a86090..6c1ce9d 100644 --- a/paperless-frontend/src/api/inbox.ts +++ b/paperless-frontend/src/api/inbox.ts @@ -8,6 +8,7 @@ export interface InboxBarcode { value: string; templateId: number | null; templateName: string | null; + dateinameTemplate: string | null; splitBefore: boolean; actions: BarcodeActionType[]; } diff --git a/paperless-frontend/src/pages/InboxDetailPage.tsx b/paperless-frontend/src/pages/InboxDetailPage.tsx index 4dfae18..9d51f24 100644 --- a/paperless-frontend/src/pages/InboxDetailPage.tsx +++ b/paperless-frontend/src/pages/InboxDetailPage.tsx @@ -28,12 +28,14 @@ const { Title } = Typography; interface DocumentSegment { index: number; pages: number[]; + belegname: string | null; } function buildDocuments( pageCount: number, splitPages: number[], deletedPages: number[], + barcodes: import('../api/inbox').InboxBarcode[], ): DocumentSegment[] { if (pageCount === 0) return []; const deleted = new Set(deletedPages); @@ -44,15 +46,25 @@ function buildDocuments( for (let n = 1; n <= pageCount; n++) { if (deleted.has(n)) continue; if (splits.has(n) && current.length > 0) { - docs.push({ index: docs.length, pages: current }); + docs.push({ index: docs.length, pages: current, belegname: null }); current = []; } current.push(n); } if (current.length > 0) { - docs.push({ index: docs.length, pages: current }); + docs.push({ index: docs.length, pages: current, belegname: null }); } - return docs; + + // Belegname (DateinameTemplate) pro Segment bestimmen + return docs.map((seg) => { + let barcode: import('../api/inbox').InboxBarcode | undefined; + if (seg.index === 0) { + barcode = barcodes[0]; + } else { + barcode = barcodes.find((b) => b.splitBefore && b.page === seg.pages[0]); + } + return { ...seg, belegname: barcode?.dateinameTemplate ?? null }; + }); } function thumbImageStyle(rotation: number, shortSidePx: number): React.CSSProperties { @@ -559,7 +571,7 @@ export default function InboxDetailPage() { const splitPages = file.barcodes .filter((b) => b.splitBefore) .map((b) => b.page); - return buildDocuments(file.pageCount, splitPages, file.deletedPages); + return buildDocuments(file.pageCount, splitPages, file.deletedPages, file.barcodes); }, [file]); const effectivePages = useMemo(() => { @@ -925,13 +937,32 @@ export default function InboxDetailPage() { return (
+ {doc.belegname && ( +
+ {doc.belegname} +
+ )} +
setSelectedPage(cover)} style={{ cursor: 'pointer', padding: 2, border: active ? '2px solid #1677ff' : '2px solid transparent', borderRadius: 6, - flex: '0 0 auto', position: 'relative', width: 92, height: 120, @@ -976,6 +1007,7 @@ export default function InboxDetailPage() { {doc.pages.length}
+
); }) )} diff --git a/paperless-frontend/src/pages/SettingsPage.tsx b/paperless-frontend/src/pages/SettingsPage.tsx index 55552f8..0f5e1c2 100644 --- a/paperless-frontend/src/pages/SettingsPage.tsx +++ b/paperless-frontend/src/pages/SettingsPage.tsx @@ -1955,8 +1955,8 @@ function BarcodeTemplatesTab() {