Related to #1323 changeRank is called after the end of ajax call

Before the changeRank function was called in then() after changeParent.
Now it is called in case of success in the changeParent ajax call
This commit is contained in:
Matthieu Leproux
2021-05-14 14:43:01 +02:00
parent ee38fbe4ce
commit 9838c1955c

View File

@@ -217,14 +217,14 @@ function applyMove(event) {
function moveNode(node, rank, parent) {
return new Promise ((res, rej) => {
if (parent != null) {
changeParent(node, parent).then(changeRank(node, rank)).then(() => res()).catch(() => rej())
changeParent(node, parent, rank).then(() => res()).catch(() => rej())
} else if (rank != null) {
changeRank(node, rank).then(() => res()).catch(() => rej())
}
})
}
function changeParent(node, parent) {
function changeParent(node, parent, rank) {
return new Promise((res, rej) => {
jQuery.ajax({
url: "ws.php?format=json&method=pwg.categories.move",
@@ -237,6 +237,7 @@ function changeParent(node, parent) {
success: function (raw_data) {
data = jQuery.parseJSON(raw_data);
if (data.stat === "ok") {
changeRank(node, rank)
res();
} else {
rej(raw_data);