u
This commit is contained in:
@@ -746,6 +746,42 @@ export function createDeliveryEditorAutomat(options = {}) {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Preserve already attached files in the editor so loading a draft manifest does not wipe them out.
|
||||||
|
const currentAttachments =
|
||||||
|
automat.state.attachments?.length > 0
|
||||||
|
? automat.state.attachments
|
||||||
|
: (Array.isArray(automat.state.files) && automat.state.files.length > 0 ? automat.state.files : []);
|
||||||
|
|
||||||
|
const rawManifestAttachments =
|
||||||
|
data.attachments ??
|
||||||
|
data.files ??
|
||||||
|
basedata.attachments ??
|
||||||
|
basedata.files ??
|
||||||
|
null;
|
||||||
|
const manifestAttachments = Array.isArray(rawManifestAttachments) ? rawManifestAttachments : [];
|
||||||
|
|
||||||
|
let attachments = currentAttachments;
|
||||||
|
if (currentAttachments.length === 0) {
|
||||||
|
attachments = manifestAttachments;
|
||||||
|
} else if (manifestAttachments.length > 0) {
|
||||||
|
const existingKeys = new Set(
|
||||||
|
currentAttachments.flatMap((a) => [
|
||||||
|
a.id != null ? String(a.id) : null,
|
||||||
|
a.name ? String(a.name).trim().toLowerCase() : null,
|
||||||
|
]).filter(Boolean)
|
||||||
|
);
|
||||||
|
const newAttachments = manifestAttachments.filter((a) => {
|
||||||
|
const idKey = a.id != null ? String(a.id) : null;
|
||||||
|
const nameKey = a.name ? String(a.name).trim().toLowerCase() : null;
|
||||||
|
if (idKey && existingKeys.has(idKey)) return false;
|
||||||
|
if (nameKey && existingKeys.has(nameKey)) return false;
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
if (newAttachments.length > 0) {
|
||||||
|
attachments = [...currentAttachments, ...newAttachments];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
automat.actions.setDelivery({
|
automat.actions.setDelivery({
|
||||||
id: null,
|
id: null,
|
||||||
deliveryId: null,
|
deliveryId: null,
|
||||||
@@ -758,6 +794,8 @@ export function createDeliveryEditorAutomat(options = {}) {
|
|||||||
type,
|
type,
|
||||||
lines,
|
lines,
|
||||||
lineitems: lines,
|
lineitems: lines,
|
||||||
|
attachments,
|
||||||
|
files: attachments,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -156,13 +156,13 @@ export default class ChatDrawer extends PureComponent {
|
|||||||
stagedReferences: [],
|
stagedReferences: [],
|
||||||
stagedExtractions: s.pendingExtraction
|
stagedExtractions: s.pendingExtraction
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
id: `ext-${Date.now()}`,
|
id: `ext-${Date.now()}`,
|
||||||
text: s.pendingExtraction.text,
|
text: s.pendingExtraction.text,
|
||||||
label: s.pendingExtraction.label || 'parsed invoice',
|
label: s.pendingExtraction.label || 'parsed invoice',
|
||||||
instruction: s.pendingExtraction.instruction || EXTRACTION_MODEL_INSTRUCTION,
|
instruction: s.pendingExtraction.instruction || EXTRACTION_MODEL_INSTRUCTION,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
: [],
|
: [],
|
||||||
previewExtraction: null,
|
previewExtraction: null,
|
||||||
isProcessingFiles: false,
|
isProcessingFiles: false,
|
||||||
@@ -839,7 +839,7 @@ export default class ChatDrawer extends PureComponent {
|
|||||||
try {
|
try {
|
||||||
inputEl.selectionStart = newCursorPos;
|
inputEl.selectionStart = newCursorPos;
|
||||||
inputEl.selectionEnd = newCursorPos;
|
inputEl.selectionEnd = newCursorPos;
|
||||||
} catch {}
|
} catch { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -1949,11 +1949,6 @@ export default class ChatDrawer extends PureComponent {
|
|||||||
type="submit"
|
type="submit"
|
||||||
color="primary"
|
color="primary"
|
||||||
disabled={!canSend}
|
disabled={!canSend}
|
||||||
title={
|
|
||||||
isWorking
|
|
||||||
? 'Modell antwortet gerade…'
|
|
||||||
: 'Senden (Enter)'
|
|
||||||
}
|
|
||||||
sx={{
|
sx={{
|
||||||
bgcolor: isWorking ? 'action.hover' : 'primary.main',
|
bgcolor: isWorking ? 'action.hover' : 'primary.main',
|
||||||
color: isWorking ? 'warning.main' : 'primary.contrastText',
|
color: isWorking ? 'warning.main' : 'primary.contrastText',
|
||||||
|
|||||||
Reference in New Issue
Block a user