Commit 6fa61d07 authored by Sonja Happ's avatar Sonja Happ

initialize temporal widget as empty before it is overwritten with props widget

parent d954941d
......@@ -28,18 +28,13 @@ import CreateControls from './edit-widget-control-creator';
class EditWidgetDialog extends React.Component {
valid = true;
constructor(props) {
super(props);
this.state = {
temporal: {
name: '',
simulationModel: '',
signal: 0
}
temporal: {},
};
}
......@@ -49,7 +44,7 @@ class EditWidgetDialog extends React.Component {
};
}
onClose(canceled) {
if (canceled === false) {
......@@ -73,7 +68,7 @@ class EditWidgetDialog extends React.Component {
}
handleChange(e) {
// TODO: check what we really need in this function. Can we reduce its complexity?
if (e.constructor === Array) {
// Every property in the array will be updated
let changes = e.reduce( (changesObject, event) => {
......@@ -84,7 +79,7 @@ class EditWidgetDialog extends React.Component {
this.setState({ temporal: Object.assign({}, this.state.temporal, changes ) });
}
if(e.target.type !== 'text'){
let changeObject = {};
if (e.target.id === 'lockAspect') {
......@@ -106,28 +101,25 @@ class EditWidgetDialog extends React.Component {
} else if (e.target.type === 'number') {
changeObject[e.target.id] = Number(e.target.value);
}
else {
changeObject[e.target.id] = e.target.value;
}
let finalChange = this.state.temporal;
finalChange.customProperties[e.target.id] = changeObject[e.target.id];
this.setState({ temporal: finalChange});
}
else{
if(this.state.temporal[e.target.id]){
let finalChange = this.state.temporal;
finalChange[e.target.id] = e.target.value;
this.setState({ temporal: finalChange});
}
}
}
resetState() {
......
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