u
This commit is contained in:
@@ -97,14 +97,19 @@ function scheduleRebuild() {
|
||||
*/
|
||||
function toIndexRecord(article, categoryId) {
|
||||
const eans = article.eans ?? article.eanCodes ?? article.ean ?? null;
|
||||
const childCount = Number(article.childCount) || 0;
|
||||
const price = article.price ?? article.net ?? article.vknetto ?? null;
|
||||
return {
|
||||
...article,
|
||||
id: article.id,
|
||||
sku: article.sku,
|
||||
name: article.name,
|
||||
price,
|
||||
net: article.net ?? price,
|
||||
eans: Array.isArray(eans) ? eans.filter(Boolean) : eans ? [eans] : [],
|
||||
categories: categoryId != null ? String(categoryId) : null,
|
||||
isParent: Boolean(article.isParent ?? article.is_parent),
|
||||
isParent: Boolean(article.isParent ?? article.is_parent ?? (childCount > 0)),
|
||||
childCount,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -135,7 +140,20 @@ export function buildArticleIndex(views) {
|
||||
ids.add(String(categoryId));
|
||||
existing.categories = Array.from(ids).join(',');
|
||||
}
|
||||
existing.isParent = Boolean(existing.isParent || (article.isParent ?? article.is_parent));
|
||||
const childCount = Number(article.childCount) || 0;
|
||||
if (childCount > (Number(existing.childCount) || 0)) {
|
||||
existing.childCount = childCount;
|
||||
}
|
||||
existing.isParent = Boolean(
|
||||
existing.isParent ||
|
||||
(article.isParent ?? article.is_parent) ||
|
||||
(childCount > 0)
|
||||
);
|
||||
if (existing.price == null && (article.price != null || article.net != null)) {
|
||||
const p = article.price ?? article.net ?? article.vknetto;
|
||||
existing.price = p;
|
||||
existing.net = article.net ?? p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ import { BrandLabel } from '../brand';
|
||||
import { formatPrice } from '../../utils/price';
|
||||
import { formatStock } from './searchFormat';
|
||||
import ResultsPagination from './ResultsPagination';
|
||||
import { BORDER } from '../../colors';
|
||||
import { BORDER, SCRIM_LABEL } from '../../colors';
|
||||
|
||||
const searchResultRowSx = {
|
||||
alignItems: 'center',
|
||||
@@ -45,6 +45,8 @@ const searchResultRowSx = {
|
||||
whiteSpace: 'nowrap',
|
||||
lineHeight: '22px',
|
||||
height: '22px',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
},
|
||||
'& .MuiListItemText-secondary': {
|
||||
overflow: 'hidden',
|
||||
@@ -512,7 +514,52 @@ export default class ArticleSearch extends PureComponent {
|
||||
</ListItemAvatar>
|
||||
|
||||
<ListItemText
|
||||
primary={article.name || '–'}
|
||||
primary={
|
||||
<Box
|
||||
component="span"
|
||||
sx={{
|
||||
display: 'inline-flex',
|
||||
alignItems: 'center',
|
||||
gap: 0.75,
|
||||
maxWidth: '100%',
|
||||
}}
|
||||
>
|
||||
<Box
|
||||
component="span"
|
||||
sx={{
|
||||
overflow: 'hidden',
|
||||
textOverflow: 'ellipsis',
|
||||
whiteSpace: 'nowrap',
|
||||
}}
|
||||
>
|
||||
{article.name || '–'}
|
||||
</Box>
|
||||
{Boolean(article.isParent || article.is_parent || (Number(article.childCount) > 0)) && (
|
||||
<Box
|
||||
component="span"
|
||||
title={`${Number(article.childCount) || 0} Varianten`}
|
||||
sx={{
|
||||
display: 'inline-flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
px: 0.75,
|
||||
py: 0.25,
|
||||
borderRadius: 999,
|
||||
bgcolor: SCRIM_LABEL,
|
||||
color: 'common.white',
|
||||
fontSize: 11,
|
||||
fontWeight: 600,
|
||||
lineHeight: 1.2,
|
||||
whiteSpace: 'nowrap',
|
||||
flexShrink: 0,
|
||||
pointerEvents: 'none',
|
||||
}}
|
||||
>
|
||||
{Number(article.childCount) || 0}
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
}
|
||||
secondary={
|
||||
<Typography
|
||||
component="span"
|
||||
@@ -772,6 +819,30 @@ export default class ArticleSearch extends PureComponent {
|
||||
<Typography variant="body2" fontWeight={600} noWrap sx={{ flex: 1 }}>
|
||||
{article.name || '–'}
|
||||
</Typography>
|
||||
{Boolean(article.isParent || article.is_parent || (Number(article.childCount) > 0)) && (
|
||||
<Box
|
||||
component="span"
|
||||
title={`${Number(article.childCount) || 0} Varianten`}
|
||||
sx={{
|
||||
display: 'inline-flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
px: 0.75,
|
||||
py: 0.2,
|
||||
borderRadius: 999,
|
||||
bgcolor: SCRIM_LABEL,
|
||||
color: 'common.white',
|
||||
fontSize: 11,
|
||||
fontWeight: 600,
|
||||
lineHeight: 1.2,
|
||||
whiteSpace: 'nowrap',
|
||||
flexShrink: 0,
|
||||
pointerEvents: 'none',
|
||||
}}
|
||||
>
|
||||
{Number(article.childCount) || 0}
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1, mt: 0.25, height: 18, minHeight: 18 }}>
|
||||
{(article.brand?.name || article.brandName) && (
|
||||
|
||||
@@ -48,6 +48,7 @@ import {
|
||||
categoryAutomat,
|
||||
} from '../automats';
|
||||
import { BrandLabel } from '../components/brand';
|
||||
import { SCRIM_LABEL } from '../colors';
|
||||
// #endregion
|
||||
|
||||
// #region Styles & Measure Sample
|
||||
@@ -66,6 +67,8 @@ const resultRowSx = {
|
||||
whiteSpace: 'nowrap',
|
||||
lineHeight: '22px',
|
||||
height: '22px',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
},
|
||||
'& .MuiListItemText-secondary': {
|
||||
overflow: 'hidden',
|
||||
@@ -579,22 +582,72 @@ class ArtikelSearchPage extends Component {
|
||||
<Box>
|
||||
{rows.length > 0 && (
|
||||
<List component={Paper} variant="outlined" disablePadding>
|
||||
{rows.map((row, index) => (
|
||||
<ListItemButton
|
||||
key={row.id}
|
||||
type="button"
|
||||
divider={index < rows.length - 1}
|
||||
data-result-row
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={() => {
|
||||
this.persistQuery();
|
||||
this.props.navigate(artikelDetailPath(row));
|
||||
}}
|
||||
sx={resultRowSx}
|
||||
>
|
||||
<ListItemText
|
||||
primary={row.name}
|
||||
secondary={
|
||||
{rows.map((row, index) => {
|
||||
const isParent = Boolean(row.isParent || row.is_parent);
|
||||
const childCount = Number(row.childCount) || 0;
|
||||
const showChildBadge = isParent || childCount > 0;
|
||||
const price = row.price ?? row.net ?? row.vknetto;
|
||||
return (
|
||||
<ListItemButton
|
||||
key={row.id}
|
||||
type="button"
|
||||
divider={index < rows.length - 1}
|
||||
data-result-row
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={() => {
|
||||
this.persistQuery();
|
||||
this.props.navigate(artikelDetailPath(row));
|
||||
}}
|
||||
sx={resultRowSx}
|
||||
>
|
||||
<ListItemText
|
||||
primary={
|
||||
<Box
|
||||
component="span"
|
||||
sx={{
|
||||
display: 'inline-flex',
|
||||
alignItems: 'center',
|
||||
gap: 0.75,
|
||||
maxWidth: '100%',
|
||||
}}
|
||||
>
|
||||
<Box
|
||||
component="span"
|
||||
sx={{
|
||||
overflow: 'hidden',
|
||||
textOverflow: 'ellipsis',
|
||||
whiteSpace: 'nowrap',
|
||||
}}
|
||||
>
|
||||
{row.name}
|
||||
</Box>
|
||||
{showChildBadge && (
|
||||
<Box
|
||||
component="span"
|
||||
title={`${childCount} Varianten`}
|
||||
sx={{
|
||||
display: 'inline-flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
px: 0.75,
|
||||
py: 0.25,
|
||||
borderRadius: 999,
|
||||
bgcolor: SCRIM_LABEL,
|
||||
color: 'common.white',
|
||||
fontSize: 11,
|
||||
fontWeight: 600,
|
||||
lineHeight: 1.2,
|
||||
whiteSpace: 'nowrap',
|
||||
flexShrink: 0,
|
||||
pointerEvents: 'none',
|
||||
}}
|
||||
>
|
||||
{childCount}
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
}
|
||||
secondary={
|
||||
<Typography
|
||||
component="span"
|
||||
variant="body2"
|
||||
@@ -641,10 +694,11 @@ class ArtikelSearchPage extends Component {
|
||||
variant="body2"
|
||||
sx={{ fontWeight: 600, flexShrink: 0, ml: 2 }}
|
||||
>
|
||||
{row.price != null ? formatPrice(row.price) : '—'}
|
||||
{price != null ? formatPrice(price) : '—'}
|
||||
</Typography>
|
||||
</ListItemButton>
|
||||
))}
|
||||
);
|
||||
})}
|
||||
</List>
|
||||
)}
|
||||
</Box>
|
||||
|
||||
Reference in New Issue
Block a user