Fix bug when moving groups up the list
This commit is contained in:
parent
4a5a75cfa8
commit
abed596f79
|
@ -62,12 +62,21 @@ function groupMoved(dropEvt) {
|
||||||
groupsStore.getAll().onsuccess = function (evt) {
|
groupsStore.getAll().onsuccess = function (evt) {
|
||||||
var groups = evt.target.result;
|
var groups = evt.target.result;
|
||||||
|
|
||||||
|
if (newIndex > oldIndex) {
|
||||||
for (let g of groups) {
|
for (let g of groups) {
|
||||||
if (g.groupIndex > oldIndex && g.groupIndex <= newIndex) {
|
if (g.groupIndex > oldIndex && g.groupIndex <= newIndex) {
|
||||||
g.groupIndex--;
|
g.groupIndex--;
|
||||||
groupsStore.put(g);
|
groupsStore.put(g);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else { // oldIndex > newIndex
|
||||||
|
for (let g of groups) {
|
||||||
|
if (g.groupIndex < oldIndex && g.groupIndex >= newIndex) {
|
||||||
|
g.groupIndex++;
|
||||||
|
groupsStore.put(g);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
groups[oldIndex].groupIndex = newIndex;
|
groups[oldIndex].groupIndex = newIndex;
|
||||||
groupsStore.put(groups[oldIndex]);
|
groupsStore.put(groups[oldIndex]);
|
||||||
|
|
Loading…
Reference in a new issue