u
This commit is contained in:
@@ -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