This commit is contained in:
seb
2026-10-18 19:36:56 +02:00
parent 587170ce9b
commit 94f385e753
3 changed files with 15 additions and 4 deletions

View File

@@ -1148,6 +1148,13 @@ class ManifestForm extends PureComponent {
if (this.state.saving) return false; if (this.state.saving) return false;
if (mode === 'edit' && docId == null) return false; if (mode === 'edit' && docId == null) return false;
if (cfg.kind === 'order' && (this.state.partyId == null || this.state.partyId === '')) {
this.setState({ partyError: true });
notifyErrorMessage('Für eine Bestellung ist ein Kunde erforderlich.');
this.headerRef.current?.focusPartyInput?.();
return false;
}
const isEdit = mode === 'edit'; const isEdit = mode === 'edit';
let body; let body;
try { try {

View File

@@ -274,9 +274,11 @@ class ManifestHeader extends PureComponent {
const hasArticles = this.hasArticles(); const hasArticles = this.hasArticles();
const isEdit = docId != null; const isEdit = docId != null;
const hasAttachments = Array.isArray(attachments) && attachments.length > 0; const hasAttachments = Array.isArray(attachments) && attachments.length > 0;
const canSave = isEdit const hasParty = partyId != null && partyId !== '';
? Boolean(isDirty) const partyValid = kind !== 'order' || hasParty;
: Boolean(hasArticles || hasAttachments); const canSave =
partyValid &&
(isEdit ? Boolean(isDirty) : Boolean(hasArticles || hasAttachments));
// Delivery: number is server-allocated/read-only; the caller reference // Delivery: number is server-allocated/read-only; the caller reference
// lives in the editable externalNumber field. // lives in the editable externalNumber field.
@@ -375,8 +377,8 @@ class ManifestHeader extends PureComponent {
{...params} {...params}
inputRef={this.partyInputRef} inputRef={this.partyInputRef}
label={dirtyFields?.partyId ? `${partyLabel} *` : partyLabel} label={dirtyFields?.partyId ? `${partyLabel} *` : partyLabel}
required={kind === 'order'}
error={isPartyEmpty} error={isPartyEmpty}
helperText={Boolean(partyError) && isPartyEmpty ? 'Kunde für Bestellung erforderlich' : undefined}
onKeyDown={this.handlePartyKeyDown} onKeyDown={this.handlePartyKeyDown}
slotProps={{ slotProps={{
...params.slotProps, ...params.slotProps,

View File

@@ -527,6 +527,8 @@ export async function buildManifestBody(
if (!Number.isNaN(pid)) { if (!Number.isNaN(pid)) {
body[partyField] = pid; body[partyField] = pid;
} }
} else if (kind === 'order') {
throw new Error('Für eine Bestellung ist ein Kunde erforderlich.');
} else if (isEdit) { } else if (isEdit) {
body[partyField] = null; body[partyField] = null;
} }