This commit is contained in:
seb
2026-10-14 14:46:44 +02:00
parent 49f8f2f93f
commit 4188d8f46f
6 changed files with 597 additions and 26 deletions

View File

@@ -6,12 +6,14 @@ import CircularProgress from '@mui/material/CircularProgress';
import Stack from '@mui/material/Stack';
import TextField from '@mui/material/TextField';
import Chip from '@mui/material/Chip';
import Typography from '@mui/material/Typography';
import UploadFileIcon from '@mui/icons-material/UploadFile';
import Inventory2OutlinedIcon from '@mui/icons-material/Inventory2Outlined';
import CheckCircleOutlineOutlinedIcon from '@mui/icons-material/CheckCircleOutlineOutlined';
import SingleLineTextEdit from 'dashgui/SingleLineTextEdit';
import { PanelTile } from 'dashgui/panels';
import { enqueueSnackbar } from 'notistack';
import RestoreIcon from '@mui/icons-material/Restore';
import FileDropzone from '../FileDropzone';
import AttachmentList from './AttachmentList';
import { hasArticleLines, manifestConfig, partyDisplayName } from './manifestConfig';
@@ -232,10 +234,14 @@ class ManifestHeader extends PureComponent {
onNumberChange,
onExternalNumberChange,
onSave,
onRestore,
actionsColor,
docId,
ledgerSummary,
onOpenBookDialog,
isDirty,
dirtyFields,
dirtySummary,
} = this.props;
const hasArticles = this.hasArticles();
@@ -250,7 +256,7 @@ class ManifestHeader extends PureComponent {
(this.state.createdParty?.id === partyId ? this.state.createdParty : null);
const isDateEmpty = !date || String(date).trim() === '';
const isPartyEmpty = partyId == null || partyId === '';
const isPartyEmpty = kind !== 'quote' && (partyId == null || partyId === '');
return (
<>
@@ -267,7 +273,7 @@ class ManifestHeader extends PureComponent {
<TextField
size="small"
type="date"
label={dateLabel}
label={dirtyFields?.date ? `${dateLabel} *` : dateLabel}
value={date}
error={isDateEmpty}
disabled={saving || pdfUploading}
@@ -279,6 +285,12 @@ class ManifestHeader extends PureComponent {
sx={{
flex: { xs: '1 1 100%', sm: '1 1 150px' },
minWidth: { sm: 130 },
...(dirtyFields?.date && {
'& .MuiOutlinedInput-notchedOutline': {
borderColor: 'warning.main',
borderWidth: 2,
},
}),
}}
/>
<Autocomplete
@@ -328,7 +340,7 @@ class ManifestHeader extends PureComponent {
renderInput={(params) => (
<TextField
{...params}
label={partyLabel}
label={dirtyFields?.partyId ? `${partyLabel} *` : partyLabel}
error={isPartyEmpty}
onKeyDown={this.handlePartyKeyDown}
slotProps={{
@@ -338,6 +350,14 @@ class ManifestHeader extends PureComponent {
autoComplete: 'off',
},
}}
sx={{
...(dirtyFields?.partyId && {
'& .MuiOutlinedInput-notchedOutline': {
borderColor: 'warning.main',
borderWidth: 2,
},
}),
}}
/>
)}
/>
@@ -355,13 +375,19 @@ class ManifestHeader extends PureComponent {
{useExternalNumber ? (
<SingleLineTextEdit
size="small"
label="Referenz"
label={dirtyFields?.externalNumber ? 'Referenz *' : 'Referenz'}
value={externalNumber ?? ''}
disabled={saving || pdfUploading}
onChange={onExternalNumberChange}
sx={{
flex: { xs: '1 1 100%', sm: '1 1 120px' },
minWidth: { sm: 100 },
...(dirtyFields?.externalNumber && {
'& .MuiOutlinedInput-notchedOutline': {
borderColor: 'warning.main',
borderWidth: 2,
},
}),
}}
/>
) : null}
@@ -424,7 +450,7 @@ class ManifestHeader extends PureComponent {
<Stack spacing={1.5} sx={{ pt: 0.5 }}>
<Button
variant="contained"
color="primary"
color={isDirty ? 'warning' : 'primary'}
disabled={saving}
onClick={onSave}
sx={{
@@ -432,10 +458,61 @@ class ManifestHeader extends PureComponent {
fontWeight: 700,
fontSize: '0.875rem',
whiteSpace: 'nowrap',
...(isDirty && {
boxShadow: (theme) => `0 0 0 2px ${theme.palette.warning.main}`,
}),
}}
>
{saving ? 'Speichern…' : 'Speichern'}
{saving ? 'Speichern…' : isDirty ? 'Speichern *' : 'Speichern'}
</Button>
{isDirty && onRestore && (
<Button
variant="outlined"
color="warning"
size="small"
startIcon={<RestoreIcon />}
disabled={saving}
onClick={onRestore}
sx={{
height: 34,
fontWeight: 700,
fontSize: '0.8rem',
whiteSpace: 'nowrap',
textTransform: 'none',
borderWidth: 1.5,
'&:hover': { borderWidth: 1.5 },
}}
>
Wiederherstellen
</Button>
)}
{isDirty && dirtySummary && dirtySummary.length > 0 && (
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 0.5, pt: 0.25 }}>
<Typography variant="caption" sx={{ color: 'warning.dark', fontWeight: 700, fontSize: '0.72rem' }}>
Geänderte Felder:
</Typography>
<Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 0.5 }}>
{dirtySummary.map((item) => (
<Chip
key={item}
size="small"
color="warning"
variant="filled"
label={item}
sx={{
height: 20,
fontSize: '0.68rem',
fontWeight: 700,
bgcolor: 'rgba(237, 108, 2, 0.15)',
color: 'warning.dark',
border: '1px solid',
borderColor: 'warning.main',
}}
/>
))}
</Box>
</Box>
)}
{docId != null && kind === 'delivery' && onOpenBookDialog && (
<Button
variant={ledgerSummary?.status === 'booked' ? 'outlined' : 'contained'}