u
This commit is contained in:
@@ -27,6 +27,9 @@ import entityAutomat from '../../automats/entityAutomat';
|
||||
import customergroupAutomat from '../../automats/customergroupAutomat';
|
||||
import supplierAutomat from '../../automats/supplierAutomat';
|
||||
import numberAutomat from '../../automats/numberAutomat';
|
||||
import quoteAutomat from '../../automats/quoteAutomat';
|
||||
import orderAutomat from '../../automats/orderAutomat';
|
||||
import deliveryAutomat from '../../automats/deliveryAutomat';
|
||||
import { getNextDocumentNumber, ensureDocumentNumber } from '../../utils/documentNumber';
|
||||
import {
|
||||
SURFACE_RAISED,
|
||||
@@ -233,11 +236,30 @@ class ManifestHeader extends PureComponent {
|
||||
this.props.onPdfUpload?.(file);
|
||||
}
|
||||
|
||||
subscribeListAutomat(kind) {
|
||||
this.unsubList?.();
|
||||
this.unsubList = null;
|
||||
const automat =
|
||||
kind === 'quote'
|
||||
? quoteAutomat
|
||||
: kind === 'order'
|
||||
? orderAutomat
|
||||
: kind === 'delivery'
|
||||
? deliveryAutomat
|
||||
: null;
|
||||
if (automat) {
|
||||
this.unsubList = automat.subscribe(this, () => {
|
||||
if (!this._cancelled) this.forceUpdate();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this._cancelled = false;
|
||||
this.unsubNumber = numberAutomat.subscribe(this, () => {
|
||||
this.forceUpdate();
|
||||
});
|
||||
this.subscribeListAutomat(this.props.kind);
|
||||
void numberAutomat.actions.ensureLoaded().catch(() => {});
|
||||
if (!this.props.number && this.props.docId == null) {
|
||||
void ensureDocumentNumber(this.props.kind)
|
||||
@@ -249,6 +271,9 @@ class ManifestHeader extends PureComponent {
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
if (prevProps.kind !== this.props.kind) {
|
||||
this.subscribeListAutomat(this.props.kind);
|
||||
}
|
||||
if (
|
||||
!this.props.number &&
|
||||
this.props.docId == null &&
|
||||
@@ -265,6 +290,7 @@ class ManifestHeader extends PureComponent {
|
||||
componentWillUnmount() {
|
||||
this._cancelled = true;
|
||||
this.unsubNumber?.();
|
||||
this.unsubList?.();
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
Reference in New Issue
Block a user