1
0
Fork 0
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:
Markus Grigull 2017-03-21 11:37:18 +01:00
parent 1c69dd6b5b
commit b7d2d57e0d

View file

@ -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;
});
});