mirror of
https://git.rwth-aachen.de/acs/public/villas/web/
synced 2025-03-09 00:00:01 +01:00
initialize temporal widget as empty before it is overwritten with props widget
This commit is contained in:
parent
d954941d9f
commit
6fa61d07f8
1 changed files with 8 additions and 16 deletions
|
@ -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() {
|
||||
|
|
Loading…
Add table
Reference in a new issue