This commit is contained in:
seb
2026-09-18 06:44:12 +02:00
parent d5ade4923d
commit a537c2f72d
8 changed files with 308 additions and 31 deletions

View File

@@ -13,6 +13,7 @@ import {
ManifestLines,
DELIVERY_LINE_COLUMNS,
buildManifestBody,
restoreAttachmentsFromApi,
dateInputValue,
emptyLine,
lineFromApi,
@@ -160,6 +161,11 @@ class LieferungNeuPage extends PureComponent {
if (doc.externalNumber != null) deliveryEditorAutomat.actions.setExternalNumber(String(doc.externalNumber));
deliveryEditorAutomat.actions.setLineitems(lines);
// Restore attachments with thumbnails
const apiFiles = doc.files ?? [];
const attachments = await restoreAttachmentsFromApi(apiFiles, this.state.attachments);
deliveryEditorAutomat.actions.setAttachments(attachments);
this.setState({
status: 'ready',
partiesLoading: false,
@@ -573,8 +579,10 @@ class LieferungNeuPage extends PureComponent {
textEditorAttachment: attachment,
});
} else if (attachment.file instanceof Blob || attachment.file instanceof File) {
const url = URL.createObjectURL(attachment.file);
window.open(url, '_blank');
if (attachment.file.size > 0) {
const url = URL.createObjectURL(attachment.file);
window.open(url, '_blank');
}
}
}
@@ -614,13 +622,14 @@ class LieferungNeuPage extends PureComponent {
const isCreate = docId == null;
let body;
try {
body = buildManifestBody(
body = await buildManifestBody(
{
number: this.state.number ?? '',
externalNumber: this.state.externalNumber ?? '',
date: this.state.date ?? '',
partyId: this.state.partyId,
lines: this.state.lines,
attachments: this.state.attachments,
},
{
partyField: cfg.partyField,
@@ -663,6 +672,11 @@ class LieferungNeuPage extends PureComponent {
if (doc.externalNumber != null) deliveryEditorAutomat.actions.setExternalNumber(String(doc.externalNumber));
deliveryEditorAutomat.actions.setLineitems(lines);
// Restore attachments with thumbnails
const apiFiles = doc.files ?? [];
const attachments = await restoreAttachmentsFromApi(apiFiles, this.state.attachments);
deliveryEditorAutomat.actions.setAttachments(attachments);
enqueueSnackbar(cfg.savedMsg, { variant: 'success' });
this.setState({ saving: false });
}