u
This commit is contained in:
@@ -7,7 +7,7 @@ import DeleteOutlinedIcon from '@mui/icons-material/DeleteOutlined';
|
||||
import DragIndicatorIcon from '@mui/icons-material/DragIndicator';
|
||||
import SingleLineTextEdit from 'dashgui/SingleLineTextEdit';
|
||||
import { enqueueSnackbar } from 'notistack';
|
||||
import attributeAutomat from '../../automats/attributeAutomat';
|
||||
import companyAutomat from '../../automats/companyAutomat';
|
||||
import { notifyError } from '../../utils/notify';
|
||||
import {
|
||||
SELECT_BG,
|
||||
@@ -56,7 +56,7 @@ class ArtikelMerkmalAuswahl extends PureComponent {
|
||||
async renameAttribute(attribute, name) {
|
||||
this.setState({ busy: true });
|
||||
try {
|
||||
await attributeAutomat.actions.updateAttribute(attribute.id, { name });
|
||||
await companyAutomat.actions.updateAttribute(attribute.id, { name });
|
||||
enqueueSnackbar('Attribut gespeichert.', { variant: 'success' });
|
||||
} catch (err) {
|
||||
this.setState({ draft: attribute.name ?? '' });
|
||||
@@ -87,7 +87,7 @@ class ArtikelMerkmalAuswahl extends PureComponent {
|
||||
const nextExclusive = !attribute.exclusive;
|
||||
this.setState({ busy: true });
|
||||
try {
|
||||
await attributeAutomat.actions.updateAttribute(attribute.id, { exclusive: nextExclusive });
|
||||
await companyAutomat.actions.updateAttribute(attribute.id, { exclusive: nextExclusive });
|
||||
enqueueSnackbar(
|
||||
`Attribut „${attribute.name}“ auf ${nextExclusive ? 'Einzelauswahl' : 'Mehrfachauswahl'} gestellt.`,
|
||||
{ variant: 'info' }
|
||||
@@ -111,7 +111,7 @@ class ArtikelMerkmalAuswahl extends PureComponent {
|
||||
this.setState({ busy: true });
|
||||
void (async () => {
|
||||
try {
|
||||
await attributeAutomat.actions.deleteAttribute(attribute.id);
|
||||
await companyAutomat.actions.deleteAttribute(attribute.id);
|
||||
enqueueSnackbar('Attribut gelöscht.', { variant: 'success' });
|
||||
} catch (err) {
|
||||
notifyError(err);
|
||||
|
||||
@@ -7,7 +7,7 @@ import DeleteOutlinedIcon from '@mui/icons-material/DeleteOutlined';
|
||||
import DragIndicatorIcon from '@mui/icons-material/DragIndicator';
|
||||
import SingleLineTextEdit from 'dashgui/SingleLineTextEdit';
|
||||
import { enqueueSnackbar } from 'notistack';
|
||||
import propertyAutomat from '../../automats/propertyAutomat';
|
||||
import companyAutomat from '../../automats/companyAutomat';
|
||||
import { notifyError } from '../../utils/notify';
|
||||
|
||||
class ArtikelMerkmalText extends PureComponent {
|
||||
@@ -54,7 +54,7 @@ class ArtikelMerkmalText extends PureComponent {
|
||||
async renameProperty(property, name) {
|
||||
this.setState({ busy: true });
|
||||
try {
|
||||
await propertyAutomat.actions.updateProperty(property.id, { name });
|
||||
await companyAutomat.actions.updateProperty(property.id, { name });
|
||||
enqueueSnackbar('Merkmal gespeichert.', { variant: 'success' });
|
||||
} catch (err) {
|
||||
this.setState({ draft: property.name ?? '' });
|
||||
@@ -85,7 +85,7 @@ class ArtikelMerkmalText extends PureComponent {
|
||||
const nextExclusive = !item.exclusive;
|
||||
this.setState({ busy: true });
|
||||
try {
|
||||
await propertyAutomat.actions.updateProperty(item.id, { exclusive: nextExclusive });
|
||||
await companyAutomat.actions.updateProperty(item.id, { exclusive: nextExclusive });
|
||||
enqueueSnackbar(
|
||||
`Merkmal „${item.name}“ auf ${nextExclusive ? 'Einzelauswahl' : 'Mehrfachauswahl'} gestellt.`,
|
||||
{ variant: 'info' }
|
||||
@@ -108,7 +108,7 @@ class ArtikelMerkmalText extends PureComponent {
|
||||
this.setState({ busy: true });
|
||||
void (async () => {
|
||||
try {
|
||||
await propertyAutomat.actions.deleteProperty(item.id);
|
||||
await companyAutomat.actions.deleteProperty(item.id);
|
||||
enqueueSnackbar('Merkmal gelöscht.', { variant: 'success' });
|
||||
} catch (err) {
|
||||
notifyError(err);
|
||||
|
||||
@@ -7,7 +7,7 @@ import DeleteOutlinedIcon from '@mui/icons-material/DeleteOutlined';
|
||||
import DragIndicatorIcon from '@mui/icons-material/DragIndicator';
|
||||
import SingleLineTextEdit from 'dashgui/SingleLineTextEdit';
|
||||
import { enqueueSnackbar } from 'notistack';
|
||||
import attributeAutomat from '../../automats/attributeAutomat';
|
||||
import companyAutomat from '../../automats/companyAutomat';
|
||||
import { notifyError } from '../../utils/notify';
|
||||
|
||||
class ArtikelMerkmalWert extends PureComponent {
|
||||
@@ -54,7 +54,7 @@ class ArtikelMerkmalWert extends PureComponent {
|
||||
async renameValue(item, val) {
|
||||
this.setState({ busy: true });
|
||||
try {
|
||||
await attributeAutomat.actions.updateValue(item.id, { value: val });
|
||||
await companyAutomat.actions.updateValue(item.id, { value: val });
|
||||
enqueueSnackbar('Wert gespeichert.', { variant: 'success' });
|
||||
} catch (err) {
|
||||
this.setState({ draft: item.value ?? '' });
|
||||
@@ -88,7 +88,7 @@ class ArtikelMerkmalWert extends PureComponent {
|
||||
this.setState({ busy: true });
|
||||
void (async () => {
|
||||
try {
|
||||
await attributeAutomat.actions.deleteValue(item.id);
|
||||
await companyAutomat.actions.deleteValue(item.id);
|
||||
enqueueSnackbar('Wert gelöscht.', { variant: 'success' });
|
||||
} catch (err) {
|
||||
notifyError(err);
|
||||
|
||||
@@ -14,7 +14,7 @@ import { PanelTile, PanelTileGrid } from 'dashgui/panels';
|
||||
import BackendError from '../BackendError';
|
||||
import { backendErrorFrom } from '../../utils/backendError';
|
||||
import { notifyError } from '../../utils/notify';
|
||||
import attributeAutomat, { selectAttributes } from '../../automats/attributeAutomat';
|
||||
import companyAutomat, { selectAttributes } from '../../automats/companyAutomat';
|
||||
import ArtikelMerkmalAuswahl from './ArtikelMerkmalAuswahl';
|
||||
import ArtikelMerkmalWert from './ArtikelMerkmalWert';
|
||||
import { BLUE_PANEL, PURPLE_PANEL } from '../../colors';
|
||||
@@ -30,8 +30,8 @@ class AuswahlMerkmaleTab extends PureComponent {
|
||||
const initialSelectedAttrId = initialAttributes[0]?.id ?? null;
|
||||
|
||||
this.state = {
|
||||
attrStatus: attributeAutomat.state.status === 'succeeded' ? 'ready' : 'loading',
|
||||
error: attributeAutomat.state.error || null,
|
||||
attrStatus: companyAutomat.state.attributesStatus === 'succeeded' ? 'ready' : 'loading',
|
||||
error: companyAutomat.state.attributesError || null,
|
||||
attributes: initialAttributes,
|
||||
selectedAttributeId: initialSelectedAttrId,
|
||||
|
||||
@@ -64,9 +64,9 @@ class AuswahlMerkmaleTab extends PureComponent {
|
||||
componentDidMount() {
|
||||
this._cancelled = false;
|
||||
|
||||
this.unsubAttr = attributeAutomat.subscribe((state) => {
|
||||
this.unsubAttr = companyAutomat.subscribe((state) => {
|
||||
if (this._cancelled) return;
|
||||
if (state.status === 'succeeded') {
|
||||
if (state.attributesStatus === 'succeeded') {
|
||||
let selectedId = this.state.selectedAttributeId;
|
||||
if (!selectedId || !state.attributes.some((a) => a.id === selectedId)) {
|
||||
selectedId = state.attributes[0]?.id ?? null;
|
||||
@@ -77,12 +77,12 @@ class AuswahlMerkmaleTab extends PureComponent {
|
||||
attributes: state.attributes,
|
||||
selectedAttributeId: selectedId,
|
||||
});
|
||||
} else if (state.status === 'failed') {
|
||||
this.setState({ attrStatus: 'failed', error: backendErrorFrom(state.error) });
|
||||
} else if (state.attributesStatus === 'failed') {
|
||||
this.setState({ attrStatus: 'failed', error: backendErrorFrom(state.attributesError) });
|
||||
}
|
||||
});
|
||||
}, ['attributes', 'attributesStatus', 'attributesError']);
|
||||
|
||||
if (attributeAutomat.state.status !== 'succeeded') {
|
||||
if (companyAutomat.state.attributesStatus !== 'succeeded') {
|
||||
void this.load();
|
||||
} else {
|
||||
this._initAttrSortable();
|
||||
@@ -216,21 +216,21 @@ class AuswahlMerkmaleTab extends PureComponent {
|
||||
|
||||
async _persistAttrOrder(ids) {
|
||||
try {
|
||||
await attributeAutomat.actions.reorderAttributes(ids);
|
||||
await companyAutomat.actions.reorderAttributes(ids);
|
||||
} catch (err) {
|
||||
if (this._cancelled) return;
|
||||
notifyError(err);
|
||||
void attributeAutomat.actions.load();
|
||||
void companyAutomat.actions.loadAttributes();
|
||||
}
|
||||
}
|
||||
|
||||
async _persistValOrder(attributeId, ids) {
|
||||
try {
|
||||
await attributeAutomat.actions.reorderValues(attributeId, ids);
|
||||
await companyAutomat.actions.reorderValues(attributeId, ids);
|
||||
} catch (err) {
|
||||
if (this._cancelled) return;
|
||||
notifyError(err);
|
||||
void attributeAutomat.actions.load();
|
||||
void companyAutomat.actions.loadAttributes();
|
||||
}
|
||||
}
|
||||
// #endregion
|
||||
@@ -238,11 +238,11 @@ class AuswahlMerkmaleTab extends PureComponent {
|
||||
// #region Actions & Handlers
|
||||
async load() {
|
||||
this.setState({
|
||||
attrStatus: attributeAutomat.state.status === 'succeeded' ? 'ready' : 'loading',
|
||||
attrStatus: companyAutomat.state.attributesStatus === 'succeeded' ? 'ready' : 'loading',
|
||||
error: null,
|
||||
});
|
||||
try {
|
||||
await attributeAutomat.actions.load();
|
||||
await companyAutomat.actions.loadAttributes();
|
||||
} catch (err) {
|
||||
if (this._cancelled) return;
|
||||
this.setState({ error: backendErrorFrom(err) });
|
||||
@@ -263,7 +263,7 @@ class AuswahlMerkmaleTab extends PureComponent {
|
||||
|
||||
this.setState({ attrSubmitting: true });
|
||||
try {
|
||||
const row = await attributeAutomat.actions.createAttribute({
|
||||
const row = await companyAutomat.actions.createAttribute({
|
||||
name,
|
||||
exclusive: true,
|
||||
});
|
||||
@@ -288,7 +288,7 @@ class AuswahlMerkmaleTab extends PureComponent {
|
||||
|
||||
this.setState({ valSubmitting: true });
|
||||
try {
|
||||
await attributeAutomat.actions.createValue(selectedAttributeId, { value });
|
||||
await companyAutomat.actions.createValue(selectedAttributeId, { value });
|
||||
if (this._cancelled) return;
|
||||
this.setState({ valFilter: '', valSubmitting: false });
|
||||
enqueueSnackbar(`Wert „${value}“ angelegt.`, { variant: 'success' });
|
||||
@@ -311,7 +311,7 @@ class AuswahlMerkmaleTab extends PureComponent {
|
||||
|
||||
this.setState({ attrDeletingUnused: true });
|
||||
try {
|
||||
await attributeAutomat.actions.deleteAttributes(unused.map((a) => a.id));
|
||||
await companyAutomat.actions.deleteAttributes(unused.map((a) => a.id));
|
||||
enqueueSnackbar(`${unused.length} ungenutzte Auswahl-Merkmale gelöscht.`, { variant: 'success' });
|
||||
} catch (err) {
|
||||
notifyError(err);
|
||||
@@ -336,7 +336,7 @@ class AuswahlMerkmaleTab extends PureComponent {
|
||||
|
||||
this.setState({ valDeletingUnused: true });
|
||||
try {
|
||||
await attributeAutomat.actions.deleteValues(unused.map((v) => v.id));
|
||||
await companyAutomat.actions.deleteValues(unused.map((v) => v.id));
|
||||
enqueueSnackbar(`${unused.length} ungenutzte Werte gelöscht.`, { variant: 'success' });
|
||||
} catch (err) {
|
||||
notifyError(err);
|
||||
|
||||
@@ -13,7 +13,7 @@ import { PanelTile, PanelTileGrid } from 'dashgui/panels';
|
||||
import BackendError from '../BackendError';
|
||||
import { backendErrorFrom } from '../../utils/backendError';
|
||||
import { notifyError } from '../../utils/notify';
|
||||
import propertyAutomat, { selectProperties } from '../../automats/propertyAutomat';
|
||||
import companyAutomat, { selectProperties } from '../../automats/companyAutomat';
|
||||
import ArtikelMerkmalText from './ArtikelMerkmalText';
|
||||
import { ORANGE_PANEL } from '../../colors';
|
||||
|
||||
@@ -27,8 +27,8 @@ class TextMerkmaleTab extends PureComponent {
|
||||
const initialProperties = selectProperties() || [];
|
||||
|
||||
this.state = {
|
||||
propStatus: propertyAutomat.state.status === 'succeeded' ? 'ready' : 'loading',
|
||||
error: propertyAutomat.state.error || null,
|
||||
propStatus: companyAutomat.state.propertiesStatus === 'succeeded' ? 'ready' : 'loading',
|
||||
error: companyAutomat.state.propertiesError || null,
|
||||
properties: initialProperties,
|
||||
|
||||
propFilter: '',
|
||||
@@ -52,20 +52,20 @@ class TextMerkmaleTab extends PureComponent {
|
||||
this._cancelled = false;
|
||||
console.log('TextMerkmaleTab mounted', this.props);
|
||||
|
||||
this.unsubProp = propertyAutomat.subscribe((state) => {
|
||||
this.unsubProp = companyAutomat.subscribe((state) => {
|
||||
if (this._cancelled) return;
|
||||
if (state.status === 'succeeded') {
|
||||
if (state.propertiesStatus === 'succeeded') {
|
||||
this.setState({
|
||||
propStatus: 'ready',
|
||||
error: null,
|
||||
properties: state.properties,
|
||||
});
|
||||
} else if (state.status === 'failed') {
|
||||
this.setState({ propStatus: 'failed', error: backendErrorFrom(state.error) });
|
||||
} else if (state.propertiesStatus === 'failed') {
|
||||
this.setState({ propStatus: 'failed', error: backendErrorFrom(state.propertiesError) });
|
||||
}
|
||||
});
|
||||
}, ['properties', 'propertiesStatus', 'propertiesError']);
|
||||
|
||||
if (propertyAutomat.state.status !== 'succeeded') {
|
||||
if (companyAutomat.state.propertiesStatus !== 'succeeded') {
|
||||
void this.load();
|
||||
} else {
|
||||
this._initPropSortable();
|
||||
@@ -139,11 +139,11 @@ class TextMerkmaleTab extends PureComponent {
|
||||
|
||||
async _persistPropOrder(ids) {
|
||||
try {
|
||||
await propertyAutomat.actions.reorderProperties(ids);
|
||||
await companyAutomat.actions.reorderProperties(ids);
|
||||
} catch (err) {
|
||||
if (this._cancelled) return;
|
||||
notifyError(err);
|
||||
void propertyAutomat.actions.load();
|
||||
void companyAutomat.actions.loadProperties();
|
||||
}
|
||||
}
|
||||
// #endregion
|
||||
@@ -151,11 +151,11 @@ class TextMerkmaleTab extends PureComponent {
|
||||
// #region Actions & Handlers
|
||||
async load() {
|
||||
this.setState({
|
||||
propStatus: propertyAutomat.state.status === 'succeeded' ? 'ready' : 'loading',
|
||||
propStatus: companyAutomat.state.propertiesStatus === 'succeeded' ? 'ready' : 'loading',
|
||||
error: null,
|
||||
});
|
||||
try {
|
||||
await propertyAutomat.actions.load();
|
||||
await companyAutomat.actions.loadProperties();
|
||||
} catch (err) {
|
||||
if (this._cancelled) return;
|
||||
this.setState({ error: backendErrorFrom(err) });
|
||||
@@ -172,7 +172,7 @@ class TextMerkmaleTab extends PureComponent {
|
||||
|
||||
this.setState({ propSubmitting: true });
|
||||
try {
|
||||
const row = await propertyAutomat.actions.createProperty({
|
||||
const row = await companyAutomat.actions.createProperty({
|
||||
name,
|
||||
exclusive: true,
|
||||
});
|
||||
@@ -198,7 +198,7 @@ class TextMerkmaleTab extends PureComponent {
|
||||
|
||||
this.setState({ propDeletingUnused: true });
|
||||
try {
|
||||
await propertyAutomat.actions.deleteProperties(unused.map((p) => p.id));
|
||||
await companyAutomat.actions.deleteProperties(unused.map((p) => p.id));
|
||||
enqueueSnackbar(`${unused.length} ungenutzte Text-Merkmale gelöscht.`, { variant: 'success' });
|
||||
} catch (err) {
|
||||
notifyError(err);
|
||||
|
||||
Reference in New Issue
Block a user