diff --git a/src/components/grid.js b/src/components/grid.js new file mode 100644 index 0000000..16e8fa5 --- /dev/null +++ b/src/components/grid.js @@ -0,0 +1,42 @@ +/** + * File: grid.js + * Author: Markus Grigull + * Date: 27.07.2017 + * + * This file is part of VILLASweb. + * + * VILLASweb is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * VILLASweb is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with VILLASweb. If not, see . + ******************************************************************************/ + +import React from 'react'; + +class Grid extends React.Component { + render() { + if (this.props.disabled) return false; + + return ( + + + + + + + + + + ); + } +} + +export default Grid; diff --git a/src/containers/visualization.js b/src/containers/visualization.js index bedb458..1140dea 100644 --- a/src/containers/visualization.js +++ b/src/containers/visualization.js @@ -30,6 +30,7 @@ import ToolboxItem from '../components/toolbox-item'; import Dropzone from '../components/dropzone'; import Widget from './widget'; import EditWidget from '../components/dialog/edit-widget'; +import Grid from '../components/grid'; import UserStore from '../stores/user-store'; import VisualizationStore from '../stores/visualization-store'; @@ -61,7 +62,6 @@ class Visualization extends Component { project: prevState.project || null, simulation: prevState.simulation || null, editing: prevState.editing || false, - grid: prevState.grid || [1, 1], editModal: prevState.editModal || false, modalData: prevState.modalData || null, @@ -339,7 +339,11 @@ class Visualization extends Component { value = 1; } - this.setState({ grid: [value, value] }); + let visualization = Object.assign({}, this.state.visualization, { + grid: value + }); + + this.setState({ visualization }); } render() { @@ -374,9 +378,9 @@ class Visualization extends Component { {this.state.editing &&
- Grid: {this.state.grid[0] > 1 ? this.state.grid[0] : 'Disabled'} + Grid: {this.state.visualization.grid > 1 ? this.state.visualization.grid : 'Disabled'} - this.setGrid(value)} /> + this.setGrid(value)} />
} @@ -390,9 +394,9 @@ class Visualization extends Component { - - - + + + @@ -401,8 +405,10 @@ class Visualization extends Component { this.handleDrop(item, position)} editing={this.state.editing}> {current_widgets != null && Object.keys(current_widgets).map( (widget_key) => ( - this.widgetChange(w, k)} onWidgetStatusChange={(w, k) => this.widgetStatusChange(w, k)} editing={this.state.editing} index={widget_key} grid={this.state.grid} /> + this.widgetChange(w, k)} onWidgetStatusChange={(w, k) => this.widgetStatusChange(w, k)} editing={this.state.editing} index={widget_key} grid={[this.state.visualization.grid, this.state.visualization.grid]} /> ))} + + {current_widgets != null &&