From 4b02ee11757c90899751c1024bcdbaa7723f79f4 Mon Sep 17 00:00:00 2001 From: Ricardo Hernandez-Montoya Date: Mon, 27 Mar 2017 15:09:31 +0200 Subject: [PATCH] issue #26 widget edit changes are applied after save --- src/components/dialog/edit-widget.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/components/dialog/edit-widget.js b/src/components/dialog/edit-widget.js index 506fef3..2b7a21e 100644 --- a/src/components/dialog/edit-widget.js +++ b/src/components/dialog/edit-widget.js @@ -29,7 +29,7 @@ class EditWidgetDialog extends Component { super(props); this.state = { - widget: { + temporal: { name: '', simulator: '', signal: 0 @@ -39,22 +39,23 @@ class EditWidgetDialog extends Component { onClose(canceled) { if (canceled === false) { - this.props.onClose(this.state.widget); + this.props.onClose(this.state.temporal); } else { this.props.onClose(); } } handleChange(e, index) { - var widget = this.state.widget; - widget[e.target.id] = e.target.value; - this.setState({ widget: widget }); + var update = this.state.temporal; + update[e.target.id] = e.target.value; + this.setState({ temporal: update }); //console.log(this.state.widget); } resetState() { - this.setState({ widget: this.props.widget }); + var widget_data = Object.assign({}, this.props.widget); + this.setState({ temporal: widget_data }); } validateForm(target) { @@ -77,13 +78,13 @@ class EditWidgetDialog extends Component { if (this.props.widget) { if (this.props.widget.type === 'Value') { - widgetDialog = this.validateForm(id)} simulation={this.props.simulation} handleChange={(e) => this.handleChange(e)} />; + widgetDialog = this.validateForm(id)} simulation={this.props.simulation} handleChange={(e) => this.handleChange(e)} />; } else if (this.props.widget.type === 'Plot') { - widgetDialog = this.validateForm(id)} simulation={this.props.simulation} handleChange={(e, index) => this.handleChange(e, index)} />; + widgetDialog = this.validateForm(id)} simulation={this.props.simulation} handleChange={(e, index) => this.handleChange(e, index)} />; } else if (this.props.widget.type === 'Table') { - widgetDialog = this.validateForm(id)} simulation={this.props.simulation} handleChange={(e, index) => this.handleChange(e, index)} />; + widgetDialog = this.validateForm(id)} simulation={this.props.simulation} handleChange={(e, index) => this.handleChange(e, index)} />; } else if (this.props.widget.type === 'Image') { - widgetDialog = this.validateForm(id)} simulation={this.props.simulation} handleChange={(e, index) => this.handleChange(e, index)} />; + widgetDialog = this.validateForm(id)} simulation={this.props.simulation} handleChange={(e, index) => this.handleChange(e, index)} />; } } @@ -92,7 +93,7 @@ class EditWidgetDialog extends Component {
Name - this.handleChange(e)} /> + this.handleChange(e)} />