u
This commit is contained in:
@@ -220,6 +220,7 @@ class ManifestForm extends PureComponent {
|
||||
void this.loadEdit();
|
||||
} else {
|
||||
void this.loadPartiesOnly();
|
||||
void ensureDocumentNumber(this.props.kind).catch(() => {});
|
||||
}
|
||||
|
||||
if (this.draftAutomat) {
|
||||
|
||||
@@ -26,6 +26,8 @@ import { notifyError, notifyErrorMessage } from '../../utils/notify';
|
||||
import entityAutomat from '../../automats/entityAutomat';
|
||||
import customergroupAutomat from '../../automats/customergroupAutomat';
|
||||
import supplierAutomat from '../../automats/supplierAutomat';
|
||||
import numberAutomat from '../../automats/numberAutomat';
|
||||
import { getNextDocumentNumber, ensureDocumentNumber } from '../../utils/documentNumber';
|
||||
import {
|
||||
SURFACE_RAISED,
|
||||
} from '../../colors';
|
||||
@@ -231,6 +233,40 @@ class ManifestHeader extends PureComponent {
|
||||
this.props.onPdfUpload?.(file);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this._cancelled = false;
|
||||
this.unsubNumber = numberAutomat.subscribe(this, () => {
|
||||
this.forceUpdate();
|
||||
});
|
||||
void numberAutomat.actions.ensureLoaded().catch(() => {});
|
||||
if (!this.props.number && this.props.docId == null) {
|
||||
void ensureDocumentNumber(this.props.kind)
|
||||
.then(() => {
|
||||
if (!this._cancelled) this.forceUpdate();
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
if (
|
||||
!this.props.number &&
|
||||
this.props.docId == null &&
|
||||
(prevProps.kind !== this.props.kind || prevProps.docId !== this.props.docId)
|
||||
) {
|
||||
void ensureDocumentNumber(this.props.kind)
|
||||
.then(() => {
|
||||
if (!this._cancelled) this.forceUpdate();
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this._cancelled = true;
|
||||
this.unsubNumber?.();
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
kind,
|
||||
@@ -273,6 +309,9 @@ class ManifestHeader extends PureComponent {
|
||||
|
||||
const hasArticles = this.hasArticles();
|
||||
const isEdit = docId != null;
|
||||
const previewNumber =
|
||||
this.props.previewNumber ??
|
||||
(!number && !isEdit ? getNextDocumentNumber(kind) : null);
|
||||
const hasAttachments = Array.isArray(attachments) && attachments.length > 0;
|
||||
const hasParty = partyId != null && partyId !== '';
|
||||
const partyValid = kind !== 'order' || hasParty;
|
||||
@@ -400,12 +439,25 @@ class ManifestHeader extends PureComponent {
|
||||
<SingleLineTextEdit
|
||||
size="small"
|
||||
label="Nummer"
|
||||
value={number || ''}
|
||||
value={number || previewNumber || ''}
|
||||
disabled
|
||||
placeholder="–"
|
||||
title={
|
||||
!number && previewNumber
|
||||
? 'Vorschau der nächsten Nummer (wird beim Speichern vergeben)'
|
||||
: undefined
|
||||
}
|
||||
slotProps={{
|
||||
inputLabel: { shrink: true },
|
||||
}}
|
||||
sx={{
|
||||
flex: { xs: '1 1 100%', sm: '1 1 120px' },
|
||||
minWidth: { sm: 100 },
|
||||
...(!number && previewNumber && {
|
||||
'& .MuiInputBase-input.Mui-disabled': {
|
||||
fontStyle: 'italic',
|
||||
},
|
||||
}),
|
||||
}}
|
||||
/>
|
||||
{useExternalNumber ? (
|
||||
|
||||
Reference in New Issue
Block a user