u
This commit is contained in:
@@ -3,7 +3,6 @@ import Box from '@mui/material/Box';
|
||||
import IconButton from '@mui/material/IconButton';
|
||||
import Tab from '@mui/material/Tab';
|
||||
import Tabs from '@mui/material/Tabs';
|
||||
import AccountTreeIcon from '@mui/icons-material/AccountTree';
|
||||
import CategoryIcon from '@mui/icons-material/Category';
|
||||
import HistoryIcon from '@mui/icons-material/History';
|
||||
import LabelIcon from '@mui/icons-material/Label';
|
||||
|
||||
@@ -45,7 +45,7 @@ export default class CategoryPickerDialog extends PureComponent {
|
||||
componentDidMount() {
|
||||
if (this.props.categories === undefined || this.props.rootCategoryId === undefined) {
|
||||
this._unsub = categoryAutomat.subscribe((s) => {
|
||||
this.setState((prev) => ({
|
||||
this.setState(() => ({
|
||||
categories: this.props.categories ?? s.categories,
|
||||
rootCategoryId: this.props.rootCategoryId ?? s.rootCategoryId,
|
||||
}));
|
||||
@@ -132,7 +132,6 @@ export default class CategoryPickerDialog extends PureComponent {
|
||||
const dialogTitle = title || (mode === 'single' ? 'Kategorie auswählen' : 'Kategorie zuweisen');
|
||||
const actionLabel = confirmLabel || (mode === 'single' ? 'Auswählen' : 'Zuweisen');
|
||||
|
||||
const selectedNode = categories && selectedId != null ? categories[String(selectedId)] : null;
|
||||
const isAlreadyAssigned =
|
||||
mode !== 'single' && currentCategoryIds.some((id) => String(id) === String(selectedId));
|
||||
const isSelectedDisabled =
|
||||
|
||||
@@ -366,22 +366,20 @@ export default class ArticleViewLists extends PureComponent {
|
||||
const count = Math.max(1, Number(stuecklisteCount) || 1);
|
||||
|
||||
const existingIndex = currentItems.findIndex((i) => i.sku === stuecklisteTargetArticle.sku);
|
||||
let nextItems = [];
|
||||
if (existingIndex >= 0) {
|
||||
nextItems = currentItems.map((item, idx) =>
|
||||
idx === existingIndex ? { ...item, count: item.count + count } : item
|
||||
);
|
||||
} else {
|
||||
nextItems = [
|
||||
...currentItems,
|
||||
{
|
||||
articleId: stuecklisteTargetArticle.id,
|
||||
sku: stuecklisteTargetArticle.sku,
|
||||
count,
|
||||
sort: currentItems.length,
|
||||
},
|
||||
];
|
||||
}
|
||||
const nextItems =
|
||||
existingIndex >= 0
|
||||
? currentItems.map((item, idx) =>
|
||||
idx === existingIndex ? { ...item, count: item.count + count } : item
|
||||
)
|
||||
: [
|
||||
...currentItems,
|
||||
{
|
||||
articleId: stuecklisteTargetArticle.id,
|
||||
sku: stuecklisteTargetArticle.sku,
|
||||
count,
|
||||
sort: currentItems.length,
|
||||
},
|
||||
];
|
||||
|
||||
this.setState({ busy: true });
|
||||
try {
|
||||
@@ -492,25 +490,23 @@ export default class ArticleViewLists extends PureComponent {
|
||||
const count = Math.max(1, Number(optionCount) || 1);
|
||||
|
||||
const existingIndex = currentOptions.findIndex((o) => o.sku === optionTargetArticle.sku);
|
||||
let nextOptions = [];
|
||||
if (existingIndex >= 0) {
|
||||
nextOptions = currentOptions.map((opt, idx) =>
|
||||
idx === existingIndex
|
||||
? { ...opt, count: opt.count + count, mandated: Boolean(optionMandated) }
|
||||
: opt
|
||||
);
|
||||
} else {
|
||||
nextOptions = [
|
||||
...currentOptions,
|
||||
{
|
||||
articleId: optionTargetArticle.id,
|
||||
sku: optionTargetArticle.sku,
|
||||
count,
|
||||
sort: currentOptions.length,
|
||||
mandated: Boolean(optionMandated),
|
||||
},
|
||||
];
|
||||
}
|
||||
const nextOptions =
|
||||
existingIndex >= 0
|
||||
? currentOptions.map((opt, idx) =>
|
||||
idx === existingIndex
|
||||
? { ...opt, count: opt.count + count, mandated: Boolean(optionMandated) }
|
||||
: opt
|
||||
)
|
||||
: [
|
||||
...currentOptions,
|
||||
{
|
||||
articleId: optionTargetArticle.id,
|
||||
sku: optionTargetArticle.sku,
|
||||
count,
|
||||
sort: currentOptions.length,
|
||||
mandated: Boolean(optionMandated),
|
||||
},
|
||||
];
|
||||
|
||||
this.setState({ busy: true });
|
||||
try {
|
||||
@@ -1363,15 +1359,9 @@ export default class ArticleViewLists extends PureComponent {
|
||||
busy,
|
||||
activeCreatorMode,
|
||||
activeListTab,
|
||||
selectedAttributeId,
|
||||
selectedChildValueId,
|
||||
newChildText,
|
||||
isCustomChildValue,
|
||||
stuecklisteTargetArticle,
|
||||
stuecklisteCount,
|
||||
optionTargetArticle,
|
||||
optionCount,
|
||||
optionMandated,
|
||||
removeTargetChild,
|
||||
confirmClearType,
|
||||
} = this.state;
|
||||
|
||||
@@ -184,13 +184,14 @@ export default class ArticleAttributesTab extends PureComponent {
|
||||
return;
|
||||
}
|
||||
|
||||
let nextValues = [];
|
||||
if (isExclusive) {
|
||||
const others = assignedAttributes.filter((a) => a.attributeId !== targetAttr.id);
|
||||
nextValues = [...others.map((a) => a.attributeValueId), targetValId];
|
||||
} else {
|
||||
nextValues = [...assignedAttributes.map((a) => a.attributeValueId), targetValId];
|
||||
}
|
||||
const nextValues = isExclusive
|
||||
? [
|
||||
...assignedAttributes
|
||||
.filter((a) => a.attributeId !== targetAttr.id)
|
||||
.map((a) => a.attributeValueId),
|
||||
targetValId,
|
||||
]
|
||||
: [...assignedAttributes.map((a) => a.attributeValueId), targetValId];
|
||||
|
||||
this.setState({ saving: true });
|
||||
try {
|
||||
@@ -222,19 +223,13 @@ export default class ArticleAttributesTab extends PureComponent {
|
||||
return;
|
||||
}
|
||||
}
|
||||
let nextProps = [];
|
||||
if (isExclusive) {
|
||||
const existing = assignedProperties.filter((p) => p.propertyId !== propId);
|
||||
nextProps = [
|
||||
...existing.map((p) => ({ propertyId: p.propertyId, value: p.value, sort: p.sort })),
|
||||
{ propertyId: propId, value: val },
|
||||
];
|
||||
} else {
|
||||
nextProps = [
|
||||
...assignedProperties.map((p) => ({ propertyId: p.propertyId, value: p.value, sort: p.sort })),
|
||||
{ propertyId: propId, value: val },
|
||||
];
|
||||
}
|
||||
const sourceProps = isExclusive
|
||||
? assignedProperties.filter((p) => p.propertyId !== propId)
|
||||
: assignedProperties;
|
||||
const nextProps = [
|
||||
...sourceProps.map((p) => ({ propertyId: p.propertyId, value: p.value, sort: p.sort })),
|
||||
{ propertyId: propId, value: val },
|
||||
];
|
||||
|
||||
this.setState({ saving: true });
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user