u
This commit is contained in:
@@ -1148,6 +1148,13 @@ class ManifestForm extends PureComponent {
|
||||
if (this.state.saving) 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';
|
||||
let body;
|
||||
try {
|
||||
|
||||
@@ -274,9 +274,11 @@ class ManifestHeader extends PureComponent {
|
||||
const hasArticles = this.hasArticles();
|
||||
const isEdit = docId != null;
|
||||
const hasAttachments = Array.isArray(attachments) && attachments.length > 0;
|
||||
const canSave = isEdit
|
||||
? Boolean(isDirty)
|
||||
: Boolean(hasArticles || hasAttachments);
|
||||
const hasParty = partyId != null && partyId !== '';
|
||||
const partyValid = kind !== 'order' || hasParty;
|
||||
const canSave =
|
||||
partyValid &&
|
||||
(isEdit ? Boolean(isDirty) : Boolean(hasArticles || hasAttachments));
|
||||
|
||||
// Delivery: number is server-allocated/read-only; the caller reference
|
||||
// lives in the editable externalNumber field.
|
||||
@@ -375,8 +377,8 @@ class ManifestHeader extends PureComponent {
|
||||
{...params}
|
||||
inputRef={this.partyInputRef}
|
||||
label={dirtyFields?.partyId ? `${partyLabel} *` : partyLabel}
|
||||
required={kind === 'order'}
|
||||
error={isPartyEmpty}
|
||||
helperText={Boolean(partyError) && isPartyEmpty ? 'Kunde für Bestellung erforderlich' : undefined}
|
||||
onKeyDown={this.handlePartyKeyDown}
|
||||
slotProps={{
|
||||
...params.slotProps,
|
||||
|
||||
@@ -527,6 +527,8 @@ export async function buildManifestBody(
|
||||
if (!Number.isNaN(pid)) {
|
||||
body[partyField] = pid;
|
||||
}
|
||||
} else if (kind === 'order') {
|
||||
throw new Error('Für eine Bestellung ist ein Kunde erforderlich.');
|
||||
} else if (isEdit) {
|
||||
body[partyField] = null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user