feat: add functionality to manually split documents at specific pages via the UI and API
Build and Push Multi-Platform Images / build-and-push (push) Successful in 33s
Build and Push Multi-Platform Images / build-and-push (push) Successful in 33s
This commit is contained in:
@@ -21,6 +21,7 @@ export interface InboxFile {
|
||||
source: InboxSource;
|
||||
pageCount: number;
|
||||
deletedPages: number[];
|
||||
manualSplitPages: number[];
|
||||
rotations: Record<string, number>;
|
||||
barcodes: MatchedBarcode[];
|
||||
createdAt: string;
|
||||
@@ -60,6 +61,7 @@ export class InboxService {
|
||||
source: doc.Source,
|
||||
pageCount: doc.PageCount,
|
||||
deletedPages: [...(doc.DeletedPages ?? [])].sort((a, b) => a - b),
|
||||
manualSplitPages: [...(doc.ManualSplitPages ?? [])].sort((a, b) => a - b),
|
||||
rotations: { ...(doc.Rotations ?? {}) },
|
||||
barcodes: await this.barcodeScanner.getMatched(doc),
|
||||
createdAt: doc.CreatedAt.toISOString(),
|
||||
@@ -142,7 +144,7 @@ export class InboxService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Setzt alle markierten Bearbeitungen (DeletedPages, Rotations) zurück.
|
||||
* Setzt alle markierten Bearbeitungen (DeletedPages, Rotations, ManualSplitPages) zurück.
|
||||
*/
|
||||
async resetEdits(id: string, preferredUsername: string | null): Promise<void> {
|
||||
const { doc } = await this.resolveDocument(id, preferredUsername);
|
||||
@@ -155,9 +157,31 @@ export class InboxService {
|
||||
doc.Rotations = {};
|
||||
changed = true;
|
||||
}
|
||||
if (doc.ManualSplitPages && doc.ManualSplitPages.length > 0) {
|
||||
doc.ManualSplitPages = [];
|
||||
changed = true;
|
||||
}
|
||||
if (changed) await this.documentRepo.save(doc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setzt oder entfernt einen manuellen Trennpunkt vor der angegebenen Seite.
|
||||
*/
|
||||
async toggleManualSplit(id: string, page: number, preferredUsername: string | null): Promise<void> {
|
||||
const { doc } = await this.resolveDocument(id, preferredUsername);
|
||||
if (!Number.isInteger(page) || page < 2 || page > doc.PageCount) {
|
||||
throw new BadRequestException('Ungültige Seitennummer für Trennung');
|
||||
}
|
||||
const splits = new Set<number>(doc.ManualSplitPages ?? []);
|
||||
if (splits.has(page)) {
|
||||
splits.delete(page);
|
||||
} else {
|
||||
splits.add(page);
|
||||
}
|
||||
doc.ManualSplitPages = Array.from(splits).sort((a, b) => a - b);
|
||||
await this.documentRepo.save(doc);
|
||||
}
|
||||
|
||||
async deleteDocument(id: string, preferredUsername: string | null): Promise<void> {
|
||||
const { doc } = await this.resolveDocument(id, preferredUsername);
|
||||
const dir = this.pageCache.documentDir(doc.Id);
|
||||
|
||||
Reference in New Issue
Block a user