mirror of
https://git.rwth-aachen.de/acs/public/villas/web/
synced 2025-03-09 00:00:01 +01:00
Fix updating elements in array-store
This commit is contained in:
parent
1c69dd6b5b
commit
b7d2d57e0d
1 changed files with 10 additions and 3 deletions
|
@ -26,13 +26,20 @@ class ArrayStore extends ReduceStore {
|
|||
updateElements(state, newElements) {
|
||||
// search for existing element to update
|
||||
state.forEach((element, index, array) => {
|
||||
newElements.forEach((updateElement, index) => {
|
||||
newElements = newElements.filter((updateElement, newIndex) => {
|
||||
if (element._id === updateElement._id) {
|
||||
array[index] = element;
|
||||
// update each property
|
||||
for (var key in updateElement) {
|
||||
if (updateElement.hasOwnProperty(key)) {
|
||||
array[index][key] = updateElement[key];
|
||||
}
|
||||
}
|
||||
|
||||
// remove updated element from update list
|
||||
newElements.splice(index, 1);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue