From ddf0f90a29f4cc2fb6f544b95f12f09f5c6bab53 Mon Sep 17 00:00:00 2001 From: plegall Date: Fri, 14 May 2021 15:50:14 +0200 Subject: [PATCH] (cp 9838c19) 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 2e00275a6..d8c58ec23 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);