mirror of
https://git.rwth-aachen.de/acs/public/villas/web/
synced 2025-03-09 00:00:01 +01:00
Merge branch '28-fix-missing-content' into 'develop'
Fix project and simulator-data new dialog Closes #28 See merge request !3
This commit is contained in:
commit
980697fefe
2 changed files with 25 additions and 5 deletions
|
@ -43,21 +43,30 @@ class NewProjectDialog extends Component {
|
|||
}
|
||||
|
||||
resetState() {
|
||||
this.setState({ name: '', simulation: this.props.simulations[0]._id });
|
||||
this.setState({
|
||||
name: '',
|
||||
simulation: this.props.simulations[0] != null ? this.props.simulations[0]._id : ''
|
||||
});
|
||||
}
|
||||
|
||||
validateForm(target) {
|
||||
// check all controls
|
||||
var name = true;
|
||||
var simulation = true;
|
||||
|
||||
if (this.state.name === '') {
|
||||
name = false;
|
||||
}
|
||||
|
||||
this.valid = name;
|
||||
if (this.state.simulation === '') {
|
||||
simulation = false;
|
||||
}
|
||||
|
||||
this.valid = name && simulation;
|
||||
|
||||
// return state to control
|
||||
if (target === 'name') return name ? "success" : "error";
|
||||
else if (target === 'simulation') return simulation ? "success" : "error";
|
||||
}
|
||||
|
||||
render() {
|
||||
|
@ -69,7 +78,7 @@ class NewProjectDialog extends Component {
|
|||
<FormControl type="text" placeholder="Enter name" value={this.state.name} onChange={(e) => this.handleChange(e)} />
|
||||
<FormControl.Feedback />
|
||||
</FormGroup>
|
||||
<FormGroup controlId="simulation">
|
||||
<FormGroup controlId="simulation" validationState={this.validateForm('simulation')}>
|
||||
<ControlLabel>Simulation</ControlLabel>
|
||||
<FormControl componentClass="select" placeholder="Select simulation" value={this.state.simulation} onChange={(e) => this.handleChange(e)}>
|
||||
{this.props.simulations.map(simulation => (
|
||||
|
|
|
@ -72,28 +72,39 @@ class NewSimulationModelDialog extends Component {
|
|||
}
|
||||
|
||||
resetState() {
|
||||
this.setState({ name: '', simulator: this.props.simulators[0]._id, length: '1', mapping: [ { name: 'Signal', type: 'Type' } ] });
|
||||
this.setState({
|
||||
name: '',
|
||||
simulator: this.props.simulators[0] != null ? this.props.simulators[0]._id : '',
|
||||
length: '1',
|
||||
mapping: [ { name: 'Signal', type: 'Type' } ]
|
||||
});
|
||||
}
|
||||
|
||||
validateForm(target) {
|
||||
// check all controls
|
||||
var name = true;
|
||||
var length = true;
|
||||
var simulator = true;
|
||||
|
||||
if (this.state.name === '') {
|
||||
name = false;
|
||||
}
|
||||
|
||||
if (this.state.simulator === '') {
|
||||
simulator = false;
|
||||
}
|
||||
|
||||
// test if simulatorid is a number (in a string, not type of number)
|
||||
if (!/^\d+$/.test(this.state.length)) {
|
||||
length = false;
|
||||
}
|
||||
|
||||
this.valid = name && length;
|
||||
this.valid = name && length && simulator;
|
||||
|
||||
// return state to control
|
||||
if (target === 'name') return name ? "success" : "error";
|
||||
else if (target === 'length') return length ? "success" : "error";
|
||||
else if (target === 'simulator') return simulator ? "success" : "error";
|
||||
}
|
||||
|
||||
render() {
|
||||
|
|
Loading…
Add table
Reference in a new issue