1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/web/ synced 2025-03-16 00:00:03 +01:00

Cancel Editing now deletes newly dropped widgets

This commit is contained in:
Laura Fuentes Grau 2020-04-24 14:57:10 +02:00
parent 78e13798f9
commit cf41a751c3

View file

@ -185,17 +185,6 @@ class Dashboard extends Component {
});
/*let widgets = [];
widgets = this.state.dashboard.get('widgets');
const widgetKey = Dashboard.getNewWidgetKey();
widgets[widgetKey] = widget;
const dashboard = this.state.dashboard.set('widgets',widgets);
// this.increaseHeightWithWidget(widget);
this.setState({ dashboard });*/
};
@ -205,13 +194,9 @@ class Dashboard extends Component {
}
widgetChange(widget, index, callback = null){
AppDispatcher.dispatch({
type: 'widgets/start-edit',
token: this.state.sessionToken,
data: widget
});
let temp = this.state.widgetChangeData;
temp.push(widget);
this.setState({widgetChangeData: temp});
}
@ -295,7 +280,7 @@ class Dashboard extends Component {
data: widget
});
});
this.setState({ editing: false });
this.setState({ editing: false, widgetChangeData: [], widgetAddData: [] });
};
saveChanges() {
@ -313,21 +298,28 @@ class Dashboard extends Component {
cancelEditing() {
//raw widget has no id -> cannot be deleted in its original form
/*
this.state.widgetAddData.forEach( widget => {
let temp = [];
this.state.widgetAddData.forEach(rawWidget => {
this.state.widgets.forEach(widget => {
if(widget.y === rawWidget.y && widget.x === rawWidget.x && widget.type === rawWidget.type){
temp.push(widget);
}
})
})
temp.forEach( widget => {
AppDispatcher.dispatch({
type: 'widgets/start-remove',
data: widget,
token: this.state.sessionToken
});
}); */
});
AppDispatcher.dispatch({
type: 'widgets/start-load',
token: this.state.sessionToken,
param: '?dashboardID=1'
});
this.setState({ editing: false, widgetChangeData: [], widgetAddData: [] });
this.setState({ editing: false, widgetChangeData: [], widgetAddData: []});
};