This commit is contained in:
seb
2026-10-18 19:10:43 +02:00
parent 596d0dc6f1
commit 199bf869a6
7 changed files with 143 additions and 18 deletions

View File

@@ -37,7 +37,8 @@ import {
ArticleSearchDialog,
BookDeliveryDialog,
} from '../../components/manifest';
import { loadParties, apiFor, resolveLineSkus } from '../../components/manifest/manifestConfig';
import { loadParties, apiFor, resolveLineSkus, sortSuppliers } from '../../components/manifest/manifestConfig';
import supplierAutomat from '../../automats/supplierAutomat';
import warehouseAutomat from '../../automats/warehouseAutomat';
import { article as articleApi, delivery as deliveryApi } from '../../api';
import { getCategoryState } from '../../automats/categoryAutomat';
@@ -108,6 +109,12 @@ class LieferungNeuPage extends PureComponent {
super(props);
this.cfg = manifestConfig('delivery');
this.automat = getDeliveryEditorAutomat(props.docId);
if (
supplierAutomat.state.status === 'ready' &&
(!this.automat.state.deliveryEntities || this.automat.state.deliveryEntities.length === 0)
) {
this.automat.actions.setDeliveryEntities(sortSuppliers(supplierAutomat.state.suppliers));
}
const initialDate = this.automat.state.date || (props.docId == null ? todayInputValue() : null);
if (props.docId == null && !this.automat.state.date) {
this.automat.actions.setDate(initialDate);
@@ -181,6 +188,11 @@ class LieferungNeuPage extends PureComponent {
this._warehouseUnsub = warehouseAutomat.subscribe(this, (state) => ({
warehouses: state.warehouses,
}));
this._supplierUnsub = supplierAutomat.subscribe(this, (state) => {
if (state.status === 'ready' && Array.isArray(state.suppliers)) {
this.automat.actions.setDeliveryEntities(sortSuppliers(state.suppliers));
}
});
void warehouseAutomat.actions.load().catch(() => { });
this._cancelled = false;
if (this.props.docId != null) {
@@ -225,6 +237,7 @@ class LieferungNeuPage extends PureComponent {
this.unsubscribe?.();
this._settingsUnsub?.();
this._warehouseUnsub?.();
this._supplierUnsub?.();
}
async loadPartiesOnly() {