diff --git a/src/dashboard/dashboard.js b/src/dashboard/dashboard.js index 2fb1596..630c6ce 100644 --- a/src/dashboard/dashboard.js +++ b/src/dashboard/dashboard.js @@ -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: []}); };