diff --git a/src/dashboard/dashboard.js b/src/dashboard/dashboard.js index 7180a81..b0e0f6f 100644 --- a/src/dashboard/dashboard.js +++ b/src/dashboard/dashboard.js @@ -56,6 +56,7 @@ class Dashboard extends Component { if (prevState == null) { prevState = {}; } + const sessionToken = LoginStore.getState().token; let maxHeight = null; let dashboard = Map(); @@ -163,7 +164,7 @@ class Dashboard extends Component { modalData: null, modalIndex: null, widgetChangeData: [], - widgetAddData:[], + widgetAddData:prevState.widgetAddData || [], maxWidgetHeight: maxHeight || null, dropZoneHeight: maxHeight +80 || null, @@ -298,6 +299,12 @@ class Dashboard extends Component { handleDrop(widget) { widget.dashboardID = this.state.dashboard.get('id'); console.log(widget); + let tempChanges = this.state.widgetAddData; + tempChanges.push(widget); + console.log("handle drop. the temp changes: "); + console.log(tempChanges); + + this.setState({ widgetAddData: tempChanges}) AppDispatcher.dispatch({ type: 'widgets/start-add', @@ -305,10 +312,7 @@ class Dashboard extends Component { data: widget }); - let tempChanges = this.state.widgetAddData; - tempChanges.push(widget); - - this.setState({ widgetAddData: tempChanges}) + /*let widgets = []; widgets = this.state.dashboard.get('widgets'); @@ -428,15 +432,17 @@ class Dashboard extends Component { } cancelEditing() { - console.log("cancelEditing the add data: "); - console.log(this.state.widgetAddData); + //raw widget has no id -> cannot be deleted in its original form + /* this.state.widgetAddData.forEach( widget => { AppDispatcher.dispatch({ type: 'widgets/start-remove', data: widget, token: this.state.sessionToken }); - }); + }); */ + + AppDispatcher.dispatch({ type: 'widgets/start-load', token: this.state.sessionToken, @@ -462,6 +468,7 @@ class Dashboard extends Component { render() { + const widgets = this.state.dashboard.get('widgets'); const grid = this.state.dashboard.get('grid'); const boxClasses = classNames('section', 'box', { 'fullscreen-padding': this.props.isFullscreen }); diff --git a/src/dashboard/widget-context-menu.js b/src/dashboard/widget-context-menu.js index ae8c40f..1fa0967 100644 --- a/src/dashboard/widget-context-menu.js +++ b/src/dashboard/widget-context-menu.js @@ -113,7 +113,7 @@ class WidgetContextMenu extends React.Component { ); return