Commit b4343aaa authored by Laura Fuentes Grau's avatar Laura Fuentes Grau

wip: restore editability

parent 60e82fbb
......@@ -85,7 +85,7 @@ class Scenario extends React.Component {
}
}
componentWillMount() {
componentDidMount() {
//load selected scenario
AppDispatcher.dispatch({
......
......@@ -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;
......
......@@ -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) {
......
......@@ -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 <FormGroup>
<FormLabel>{this.props.label}</FormLabel>
<FormCheck id={this.props.controlId + "UseMinMax"} checked={this.state.widget[this.props.controlId + "UseMinMax"] || ''} onChange={e => this.props.handleChange(e)}></FormCheck>
<FormCheck id={this.props.controlId + "UseMinMax"} label= {"UseMinMax"} checked={this.state.widget.customProperties[this.props.controlId + "UseMinMax"] || ''} onChange={e => this.props.handleChange(e)}></FormCheck>
<Table>
<tbody>
<tr>
<td>
Min: <FormControl type="number" step="any" id={this.props.controlId + "Min"} disabled={!this.state.widget[this.props.controlId + "UseMinMax"]} placeholder="Minimum value" value={this.state.widget[this.props.controlId + 'Min']} onChange={e => this.props.handleChange(e)} />
Min: <FormControl type="number" step="any" id={this.props.controlId + "Min"} disabled={!this.state.widget.customProperties[this.props.controlId + "UseMinMax"]} placeholder="Minimum value" value={this.state.widget.customProperties[this.props.controlId + 'Min']} onChange={e => this.props.handleChange(e)} />
</td>
<td>
Max: <FormControl type="number" step="any" id={this.props.controlId + "Max"} disabled={!this.state.widget[this.props.controlId + "UseMinMax"]} placeholder="Maximum value" value={this.state.widget[this.props.controlId + 'Max']} onChange={e => this.props.handleChange(e)} />
Max: <FormControl type="number" step="any" id={this.props.controlId + "Max"} disabled={!this.state.widget.customProperties[this.props.controlId + "UseMinMax"]} placeholder="Maximum value" value={this.state.widget.customProperties[this.props.controlId + 'Max']} onChange={e => this.props.handleChange(e)} />
</td>
</tr>
</tbody>
......
......@@ -27,7 +27,9 @@ class EditWidgetNumberControl extends Component {
super(props);
this.state = {
widget: {}
widget: {
customProperties:{}
}
};
}
......@@ -40,7 +42,7 @@ class EditWidgetNumberControl extends Component {
return (
<FormGroup controlId={this.props.controlId}>
<FormLabel>{this.props.label}</FormLabel>
<FormControl type="number" step="any" value={this.state.widget[this.props.controlId] || 0} onChange={e => this.props.handleChange(e)} />
<FormControl type="number" step="any" value={this.state.widget.customProperties[this.props.controlId] || 0} onChange={e => this.props.handleChange(e)} />
</FormGroup>
);
}
......
......@@ -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 {
<FormLabel>Signals</FormLabel>
{
signalsToRender.length === 0 || !this.state.widget.hasOwnProperty(this.props.controlId)? (
<FormControl.Static>No signals available.</FormControl.Static>
<FormLabel>No signals available</FormLabel>
) : (
signalsToRender.map((signal, index) => (
<FormCheck key={index} checked={this.state.widget[this.props.controlId].indexOf(index) !== -1} onChange={(e) => this.handleSignalChange(e.target.checked, index)}>{signal.name}</FormCheck>
......
......@@ -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 (
<FormGroup controlId="simulationModel">
<FormLabel>Simulation Model</FormLabel>
<FormControl as="select" placeholder="Select simulation model" value={this.state.widget.simulationModel || '' } onChange={(e) => this.props.handleChange(e)}>
<FormControl as="select" placeholder="Select simulation model" value={this.state.widget.customProperties.simulationModel || '' } onChange={(e) => this.props.handleChange(e)}>
{
this.props.simulationModels.length === 0 ? (
<option disabled value style={{ display: 'none' }}> No simulation models available. </option>
......
......@@ -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;
......
......@@ -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) {
......
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