Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ACS
Public
VILLASframework
VILLASweb
Commits
a609d540
Commit
a609d540
authored
Nov 21, 2018
by
Steffen Vogel
🎅🏼
Browse files
visualization: do not directly modify state
parent
b8e19704
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/containers/visualization.js
View file @
a609d540
...
...
@@ -150,15 +150,11 @@ class Visualization extends React.Component {
}
}*/
getNewWidgetKey
()
{
// Increase the counter and update the state
return
this
.
state
.
last_widget_key
++
;
}
transformToWidgetsDict
(
widgets
)
{
var
widgetsDict
=
{};
// Create a new key and make a copy of the widget object
widgets
.
forEach
(
(
widget
)
=>
widgetsDict
[
this
.
getNewWidgetKey
()]
=
Object
.
assign
({},
widget
)
);
var
key
=
0
;
widgets
.
forEach
(
(
widget
)
=>
widgetsDict
[
key
++
]
=
Object
.
assign
({},
widget
)
);
return
widgetsDict
;
}
...
...
@@ -216,9 +212,9 @@ class Visualization extends React.Component {
widget
=
WidgetFactory
.
createWidgetOfType
(
item
.
name
,
position
,
defaultSimulationModel
);
var
new_widgets
=
this
.
state
.
visualization
.
widgets
;
var
new_key
=
Object
.
keys
(
new_widgets
).
length
;
var
widget_key
=
this
.
getNewWidgetKey
();
new_widgets
[
widget_key
]
=
widget
;
new_widgets
[
new_key
]
=
widget
;
var
visualization
=
Object
.
assign
({},
this
.
state
.
visualization
,
{
widgets
:
new_widgets
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment