u
This commit is contained in:
@@ -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',
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
Reference in New Issue
Block a user