Fix bug when moving groups up the list

This commit is contained in:
Neil Brommer 2017-12-28 13:41:36 -08:00
parent 4a5a75cfa8
commit abed596f79

View file

@ -62,10 +62,19 @@ function groupMoved(dropEvt) {
groupsStore.getAll().onsuccess = function (evt) { groupsStore.getAll().onsuccess = function (evt) {
var groups = evt.target.result; var groups = evt.target.result;
for (let g of groups) { if (newIndex > oldIndex) {
if (g.groupIndex > oldIndex && g.groupIndex <= newIndex) { for (let g of groups) {
g.groupIndex--; if (g.groupIndex > oldIndex && g.groupIndex <= newIndex) {
groupsStore.put(g); g.groupIndex--;
groupsStore.put(g);
}
}
} else { // oldIndex > newIndex
for (let g of groups) {
if (g.groupIndex < oldIndex && g.groupIndex >= newIndex) {
g.groupIndex++;
groupsStore.put(g);
}
} }
} }