From b4343aaa78f20b62d3cb95c87a6c607d4a36dbab Mon Sep 17 00:00:00 2001 From: Laura Fuentes Grau Date: Sat, 11 Jan 2020 19:16:55 +0100 Subject: [PATCH] wip: restore editability --- src/scenario/scenario.js | 2 +- src/user/edit-own-user.js | 10 +++++----- src/user/user.js | 3 ++- src/widget/edit-widget-min-max-control.js | 19 +++++++++---------- src/widget/edit-widget-number-control.js | 6 ++++-- src/widget/edit-widget-signals-control.js | 4 ++-- src/widget/edit-widget-simulation-control.js | 8 +++++--- src/widget/widget-factory.js | 5 +++++ src/widget/widgets/plot-table.js | 6 ++++-- 9 files changed, 37 insertions(+), 26 deletions(-) diff --git a/src/scenario/scenario.js b/src/scenario/scenario.js index 931dc3b..1ca36eb 100644 --- a/src/scenario/scenario.js +++ b/src/scenario/scenario.js @@ -85,7 +85,7 @@ class Scenario extends React.Component { } } - componentWillMount() { + componentDidMount() { //load selected scenario AppDispatcher.dispatch({ diff --git a/src/user/edit-own-user.js b/src/user/edit-own-user.js index 66f5324..fc63914 100644 --- a/src/user/edit-own-user.js +++ b/src/user/edit-own-user.js @@ -60,11 +60,11 @@ class EditOwnUserDialog extends React.Component { this.setState({ [e.target.id]: e.target.value }); // check all controls - var username = true; - var mail = true; - var pw = true; - var oldPassword = true; - var confirmpassword = true; + let username = true; + let mail = true; + let pw = true; + let oldPassword = true; + let confirmpassword = true; if (this.state.username === '') { username = false; diff --git a/src/user/user.js b/src/user/user.js index 781005b..8e7e67c 100644 --- a/src/user/user.js +++ b/src/user/user.js @@ -56,7 +56,7 @@ class User extends Component { //this.setState({currentUser: data}); let updatedData = {}; - + if(data){ if (data.username !== ''){ updatedData["id"] = data.id; updatedData["username"] = data.username; @@ -97,6 +97,7 @@ class User extends Component { NotificationsDataManager.addNotification(USER_UPDATE_WARNING_NOTIFICATION); } } + } getHumanRoleName(role_key) { diff --git a/src/widget/edit-widget-min-max-control.js b/src/widget/edit-widget-min-max-control.js index ef7f00a..eae6d65 100644 --- a/src/widget/edit-widget-min-max-control.js +++ b/src/widget/edit-widget-min-max-control.js @@ -26,14 +26,13 @@ class EditWidgetMinMaxControl extends React.Component { constructor(props) { super(props); - const widget = {}; - widget[props.controlID + "UseMinMax"] = false; - widget[props.controlId + "Min"] = 0; - widget[props.controlId + "Max"] = 100; - this.state = { - widget - }; + widget: { + customProperties:{ + + } + } + } } componentWillReceiveProps(nextProps) { @@ -45,16 +44,16 @@ class EditWidgetMinMaxControl extends React.Component { console.log(this.state.widget); return {this.props.label} - this.props.handleChange(e)}> + this.props.handleChange(e)}> diff --git a/src/widget/edit-widget-number-control.js b/src/widget/edit-widget-number-control.js index 0328333..e937aa8 100644 --- a/src/widget/edit-widget-number-control.js +++ b/src/widget/edit-widget-number-control.js @@ -27,7 +27,9 @@ class EditWidgetNumberControl extends Component { super(props); this.state = { - widget: {} + widget: { + customProperties:{} + } }; } @@ -40,7 +42,7 @@ class EditWidgetNumberControl extends Component { return ( {this.props.label} - this.props.handleChange(e)} /> + this.props.handleChange(e)} /> ); } diff --git a/src/widget/edit-widget-signals-control.js b/src/widget/edit-widget-signals-control.js index 045a269..19ca43b 100644 --- a/src/widget/edit-widget-signals-control.js +++ b/src/widget/edit-widget-signals-control.js @@ -20,7 +20,7 @@ **********************************************************************************/ import React, { Component } from 'react'; -import { FormGroup, FormCheck, FormLabel, FormControl } from 'react-bootstrap'; +import { FormGroup, FormCheck, FormLabel } from 'react-bootstrap'; class EditWidgetSignalsControl extends Component { constructor(props) { @@ -68,7 +68,7 @@ class EditWidgetSignalsControl extends Component { Signals { signalsToRender.length === 0 || !this.state.widget.hasOwnProperty(this.props.controlId)? ( - No signals available. + No signals available ) : ( signalsToRender.map((signal, index) => ( this.handleSignalChange(e.target.checked, index)}>{signal.name} diff --git a/src/widget/edit-widget-simulation-control.js b/src/widget/edit-widget-simulation-control.js index e6d88ee..8862567 100644 --- a/src/widget/edit-widget-simulation-control.js +++ b/src/widget/edit-widget-simulation-control.js @@ -28,12 +28,14 @@ class EditWidgetSimulationControl extends Component { this.state = { widget: { - simulationModel: '' + customProperties: { + simulationModel: '' + } } }; } - componentWillReceiveProps(nextProps) { + componentDidUpdate(nextProps) { // Update state's widget with props this.setState({ widget: nextProps.widget }); } @@ -44,7 +46,7 @@ class EditWidgetSimulationControl extends Component { return ( Simulation Model - this.props.handleChange(e)}> + this.props.handleChange(e)}> { this.props.simulationModels.length === 0 ? ( diff --git a/src/widget/widget-factory.js b/src/widget/widget-factory.js index b131e2d..eb2dc68 100644 --- a/src/widget/widget-factory.js +++ b/src/widget/widget-factory.js @@ -162,6 +162,11 @@ class WidgetFactory { widget.customProperties.orientation = WidgetSlider.OrientationTypes.HORIZONTAL.value; // Assign default orientation widget.customProperties.simulationModel = defaultSimulationModel; widget.customProperties.signal = 0; + widget.customProperties.rangeMin = 0; + widget.customProperties.rangeMax = 200; + widget.customProperties.rangeUseMinMax = true; + widget.customProperties.showUnit = true + break; case 'Gauge': widget.customProperties.simulationModel = defaultSimulationModel; diff --git a/src/widget/widgets/plot-table.js b/src/widget/widgets/plot-table.js index 2f9b552..7cd0cbf 100644 --- a/src/widget/widgets/plot-table.js +++ b/src/widget/widgets/plot-table.js @@ -48,7 +48,7 @@ class WidgetPlotTable extends Component { // Identify if there was a change in the preselected signals if (JSON.stringify(nextProps.widget.customProperties.preselectedSignals) !== JSON.stringify(this.props.widget.customProperties.preselectedSignals) || this.state.preselectedSignals.length === 0) { - // Update the currently selected signals by intersecting with the preselected signals + // Update the currently selected signals by intersecting with the preselected signalsWidget // Do the same with the plot values var intersection = this.computeIntersection(nextProps.widget.customProperties.preselectedSignals, nextProps.widget.customProperties.signals); this.setState({ signals: intersection }); @@ -65,6 +65,7 @@ class WidgetPlotTable extends Component { updatePreselectedSignalsState(nextProps) { // Create checkboxes using the signal indices from simulation model + if(nextProps.simulationModel.outputMapping){ const preselectedSignals = nextProps.simulationModel.outputMapping.reduce( // Loop through simulation model signals (accum, model_signal, signal_index) => { @@ -80,8 +81,9 @@ class WidgetPlotTable extends Component { } return accum; }, []); - + this.setState({ preselectedSignals }); + } } updateSignalSelection(signal_index, checked) {
- Min: this.props.handleChange(e)} /> + Min: this.props.handleChange(e)} /> - Max: this.props.handleChange(e)} /> + Max: this.props.handleChange(e)} />