This commit is contained in:
seb
2026-10-17 01:48:41 +02:00
parent 0b0ffb2203
commit bb22da7aae
2 changed files with 21 additions and 8 deletions

View File

@@ -780,7 +780,7 @@ const actions = {
const currentActive = targetFilterKey === getFilterKey(automat.state); const currentActive = targetFilterKey === getFilterKey(automat.state);
if (currentActive) { if (currentActive) {
automat.setState({ automat.setState({
items: entry.items, items: [...entry.items],
total: currentTotal, total: currentTotal,
unfilteredTotal, unfilteredTotal,
status: 'ready', status: 'ready',

View File

@@ -1,4 +1,4 @@
import { PureComponent, createRef } from 'react'; import { Component, PureComponent, createRef } from 'react';
import Box from '@mui/material/Box'; import Box from '@mui/material/Box';
import Button from '@mui/material/Button'; import Button from '@mui/material/Button';
import Chip from '@mui/material/Chip'; import Chip from '@mui/material/Chip';
@@ -178,8 +178,9 @@ const rowContext = {
}; };
// MARK: <DeliveryRow/> // MARK: <DeliveryRow/>
class DeliveryRow extends PureComponent { class DeliveryRow extends Component {
supplierName(supplierId) { supplierName(supplierId, fallbackName) {
if (fallbackName) return fallbackName;
if (supplierId == null) return '–'; if (supplierId == null) return '–';
const supplier = rowContext.suppliersById[supplierId]; const supplier = rowContext.suppliersById[supplierId];
return partyDisplayName('delivery', supplier) || `Lieferant #${supplierId}`; return partyDisplayName('delivery', supplier) || `Lieferant #${supplierId}`;
@@ -220,9 +221,14 @@ class DeliveryRow extends PureComponent {
const { busyId, onOpen, onDelete, onOpenBookDialog } = rowContext; const { busyId, onOpen, onDelete, onOpenBookDialog } = rowContext;
const files = Array.isArray(delivery.files) ? delivery.files : []; const files = Array.isArray(delivery.files) ? delivery.files : [];
const totalPositions = delivery.ledger?.totalPositions ?? delivery.ledger?.total ?? delivery.positions ?? 0; const totalPositions = Number(delivery.positions || delivery.ledger?.totalPositions || delivery.ledger?.total || 0);
const completelyBooked = delivery.ledger?.completelyOnLedgerPositions ?? delivery.ledger?.bookedPositions ?? 0; const isBooked = Boolean(delivery.ledger?.isBooked || delivery.isBooked);
const unbooked = delivery.ledger?.unbookedPositions ?? Math.max(0, totalPositions - completelyBooked); const completelyBooked = Number(delivery.ledger?.completelyOnLedgerPositions || delivery.ledger?.bookedPositions || (isBooked ? totalPositions : 0));
const unbooked = isBooked
? 0
: (delivery.ledger?.unbookedPositions != null
? Number(delivery.ledger.unbookedPositions)
: Math.max(0, totalPositions - completelyBooked));
return ( return (
<ListItemButton <ListItemButton
@@ -250,7 +256,7 @@ class DeliveryRow extends PureComponent {
<Box sx={{ gridColumn: 3, gridRow: 2, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}> <Box sx={{ gridColumn: 3, gridRow: 2, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
<Typography variant="body1" sx={{ fontWeight: 500, ...ellipsisSx }}> <Typography variant="body1" sx={{ fontWeight: 500, ...ellipsisSx }}>
{this.supplierName(delivery.supplierId)} {this.supplierName(delivery.supplierId, delivery.supplierName)}
</Typography> </Typography>
</Box> </Box>
@@ -659,6 +665,13 @@ export class DeliveryList extends PureComponent {
unfilteredTotal: state.unfilteredTotal ?? 0, unfilteredTotal: state.unfilteredTotal ?? 0,
filterKey: deliveryAutomat.getFilterKey(state), filterKey: deliveryAutomat.getFilterKey(state),
})); }));
if (this.state.items !== deliveryAutomat.state.items) {
this.setState({
items: deliveryAutomat.state.items,
unfilteredTotal: deliveryAutomat.state.unfilteredTotal ?? 0,
filterKey: deliveryAutomat.getFilterKey(deliveryAutomat.state),
});
}
this.unsubNumber = numberAutomat.subscribe(this, () => { this.unsubNumber = numberAutomat.subscribe(this, () => {
this.headerItem = createDummyTestDelivery(); this.headerItem = createDummyTestDelivery();
this.forceUpdate(); this.forceUpdate();