Commit 0dc1365a authored by Laura Fuentes Grau's avatar Laura Fuentes Grau

wip: Cancel restores old dashboard

parent 0bfeb325
...@@ -62,7 +62,7 @@ class Dashboard extends Component { ...@@ -62,7 +62,7 @@ class Dashboard extends Component {
let dashboards = DashboardStore.getState() let dashboards = DashboardStore.getState()
let rawDashboard = dashboards[props.match.params.dashboard - 1]; let rawDashboard = dashboards[props.match.params.dashboard - 1];
if (rawDashboard) { if (rawDashboard) {
dashboard = Map(rawDashboard); dashboard = Map(rawDashboard);
...@@ -163,6 +163,7 @@ class Dashboard extends Component { ...@@ -163,6 +163,7 @@ class Dashboard extends Component {
modalData: null, modalData: null,
modalIndex: null, modalIndex: null,
widgetChangeData: [], widgetChangeData: [],
widgetAddData:[],
maxWidgetHeight: maxHeight || null, maxWidgetHeight: maxHeight || null,
dropZoneHeight: maxHeight +80 || null, dropZoneHeight: maxHeight +80 || null,
...@@ -303,6 +304,11 @@ class Dashboard extends Component { ...@@ -303,6 +304,11 @@ class Dashboard extends Component {
token: this.state.sessionToken, token: this.state.sessionToken,
data: widget data: widget
}); });
let tempChanges = this.state.widgetAddData;
tempChanges.push(widget);
this.setState({ widgetAddData: tempChanges})
/*let widgets = []; /*let widgets = [];
widgets = this.state.dashboard.get('widgets'); widgets = this.state.dashboard.get('widgets');
...@@ -396,6 +402,8 @@ class Dashboard extends Component { ...@@ -396,6 +402,8 @@ class Dashboard extends Component {
saveEditing() { saveEditing() {
// Provide the callback so it can be called when state change is applied // Provide the callback so it can be called when state change is applied
// TODO: Check if callback is needed // TODO: Check if callback is needed
this.state.widgetChangeData.forEach( widget => { this.state.widgetChangeData.forEach( widget => {
AppDispatcher.dispatch({ AppDispatcher.dispatch({
type: 'widgets/start-edit', type: 'widgets/start-edit',
...@@ -420,7 +428,21 @@ class Dashboard extends Component { ...@@ -420,7 +428,21 @@ class Dashboard extends Component {
} }
cancelEditing() { cancelEditing() {
this.setState({ editing: false, widgetChangeData: [] }); console.log("cancelEditing the add data: ");
console.log(this.state.widgetAddData);
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,
param: '?dashboardID=1'
});
this.setState({ editing: false, widgetChangeData: [], widgetAddData: [] });
}; };
......
...@@ -82,11 +82,12 @@ class Widget extends React.Component { ...@@ -82,11 +82,12 @@ class Widget extends React.Component {
if (this.state.sessionToken == null) { if (this.state.sessionToken == null) {
return; return;
} }
AppDispatcher.dispatch({
/*AppDispatcher.dispatch({
type: 'files/start-load', type: 'files/start-load',
token: this.state.sessionToken, token: this.state.sessionToken,
param: '?objectID=1&objectType=widget' param: '?objectID=1&objectType=widget'
}); });*/
AppDispatcher.dispatch({ AppDispatcher.dispatch({
type: 'simulationModels/start-load', type: 'simulationModels/start-load',
......
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