This commit is contained in:
seb
2026-10-30 05:02:47 +01:00
parent 05f1311892
commit 6ca7597c59
3 changed files with 116 additions and 8 deletions

View File

@@ -19,17 +19,18 @@ export default class ArticleSearchDialog extends PureComponent {
this.state = {
assigningSku: null,
error: null,
showAllArticles: false,
};
}
componentDidUpdate(prevProps) {
if (!prevProps.open && this.props.open) {
this.setState({ assigningSku: null, error: null });
this.setState({ assigningSku: null, error: null, showAllArticles: false });
}
}
handleClose = () => {
this.setState({ assigningSku: null, error: null });
this.setState({ assigningSku: null, error: null, showAllArticles: false });
this.props.onClose?.();
};
@@ -61,9 +62,9 @@ export default class ArticleSearchDialog extends PureComponent {
render() {
const { open, onClose, line, kind = 'delivery', supplierArticles: propSupplierArticles } = this.props;
const { assigningSku, error } = this.state;
const { assigningSku, error, showAllArticles } = this.state;
const isDelivery = kind === 'delivery';
const onlySupplierArticles = isDelivery && !line;
const onlySupplierArticles = isDelivery && !line && !showAllArticles;
const rawSku = line?.sku != null ? String(line.sku).trim() : '';
const supplierArticlesList = onlySupplierArticles
@@ -122,7 +123,7 @@ export default class ArticleSearchDialog extends PureComponent {
<Box>
<Typography variant="h6" component="div" fontWeight={600}>
{line
? 'Existierenden Artikel zuordnen'
? (isDelivery ? 'Artikel neu zuordnen' : 'Existierenden Artikel zuordnen')
: isDelivery
? 'Lieferanten-Artikel auswählen'
: 'Artikel auswählen'}
@@ -134,7 +135,21 @@ export default class ArticleSearchDialog extends PureComponent {
{line?.name ? ` · ${line.name}` : ''}
</>
) : isDelivery ? (
'Nur mit dem ausgewählten Lieferanten verknüpfte Artikel'
<Box component="span" sx={{ display: 'inline-flex', alignItems: 'center', gap: 1 }}>
<span>
{showAllArticles
? 'Alle Artikel im Katalog durchsuchen'
: 'Nur mit dem ausgewählten Lieferanten verknüpfte Artikel'}
</span>
<Button
size="small"
variant="text"
onClick={() => this.setState({ showAllArticles: !showAllArticles })}
sx={{ fontSize: '0.72rem', py: 0, px: 0.75, textTransform: 'none', minWidth: 'auto', fontWeight: 600 }}
>
{showAllArticles ? 'Nur Lieferanten-Artikel' : 'Alle Artikel durchsuchen'}
</Button>
</Box>
) : (
'Artikel für Beleg auswählen'
)}

View File

@@ -766,6 +766,30 @@ class ManifestFormLine extends PureComponent {
/>
)}
{this.props.onSearchArticle && (
<Button
size="small"
variant="text"
startIcon={<SearchIcon sx={{ fontSize: 14 }} />}
disabled={this.props.saving || this.props.supplierArticleBusy || this.isFullyLedgered()}
onClick={this.handleSearchArticle}
sx={{
fontSize: '0.7rem',
fontWeight: 600,
textTransform: 'none',
minWidth: 'auto',
py: 0.25,
px: 1,
color: 'primary.main',
'&:hover': {
bgcolor: 'primary.50',
},
}}
>
Artikel neu zuordnen
</Button>
)}
{/* Brand */}
{cachedArticle.brand?.name && (
<BrandLabel
@@ -1124,6 +1148,30 @@ class ManifestFormLine extends PureComponent {
/>
)}
{this.props.onSearchArticle && (
<Button
size="small"
variant="text"
startIcon={<SearchIcon sx={{ fontSize: 14 }} />}
disabled={this.props.saving || this.props.supplierArticleBusy || this.isFullyLedgered()}
onClick={this.handleSearchArticle}
sx={{
fontSize: '0.7rem',
fontWeight: 600,
textTransform: 'none',
minWidth: 'auto',
py: 0.25,
px: 1,
color: 'primary.main',
'&:hover': {
bgcolor: 'primary.50',
},
}}
>
Artikel neu zuordnen
</Button>
)}
{/* Brand */}
{(fullArticle.brand?.name || article.brand?.name) && (
<BrandLabel
@@ -1307,6 +1355,34 @@ class ManifestFormLine extends PureComponent {
);
}
if (this.props.onSearchArticle) {
return (
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.75, py: 0.25 }}>
<Button
size="small"
variant="text"
startIcon={<SearchIcon sx={{ fontSize: 14 }} />}
disabled={this.isFullyLedgered()}
onClick={this.handleSearchArticle}
sx={{
fontSize: '0.7rem',
fontWeight: 600,
textTransform: 'none',
minWidth: 'auto',
py: 0.25,
px: 1,
color: 'primary.main',
'&:hover': {
bgcolor: 'primary.50',
},
}}
>
Artikel suchen
</Button>
</Box>
);
}
return null;
}