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