From 9838c1955cc268276b53f54f36cae3e712852d15 Mon Sep 17 00:00:00 2001 From: Matthieu Leproux Date: Fri, 14 May 2021 14:43:01 +0200 Subject: [PATCH] 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 --- admin/themes/default/js/cat_move.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/admin/themes/default/js/cat_move.js b/admin/themes/default/js/cat_move.js index 393f35555..9971a7ffc 100644 --- a/admin/themes/default/js/cat_move.js +++ b/admin/themes/default/js/cat_move.js @@ -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);