Commit cf41a751 authored by Laura Fuentes Grau's avatar Laura Fuentes Grau

Cancel Editing now deletes newly dropped widgets

parent 78e13798
......@@ -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: []});
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment