Skip to content
Snippets Groups Projects
Commit 445c692a authored by Mingsong Hu's avatar Mingsong Hu
Browse files

Refresh whole tree after an item is relocated under a non-draggable parent

parent 2183646c
No related branches found
No related tags found
No related merge requests found
...@@ -124,19 +124,28 @@ ...@@ -124,19 +124,28 @@
else { else {
var parentText = parent_node.text; var parentText = parent_node.text;
} }
// Update the nodes changed in the server side. if (parent_node.data && !parent_node.data.draggable) {
if (response.updated_nodes) { // The parent node is not draggable.
let update_nodes = response.updated_nodes; // We have to update all duplicated nodes
for (const id in update_nodes) { // by refreshing the whole tree.
let node = thisTree.get_node(id); thisTree.refresh();
if (node) { }
node.data.weight = update_nodes[id]; else {
// Update the nodes changed in the server side.
if (response.updated_nodes) {
let update_nodes = response.updated_nodes;
for (const id in update_nodes) {
let node = thisTree.get_node(id);
if (node) {
node.data.weight = update_nodes[id];
}
} }
//Refresh the tree without reloading data from server.
thisTree.sort(parent_node, true);
thisTree.redraw(true);
} }
//Refresh the tree without reloading data from server.
thisTree.sort(parent_node, true);
thisTree.redraw(true);
} }
let message = Drupal.t('@node is moved to position @position under @parent', {'@node': data.node.text, '@parent': parentText, '@position': data.position + 1}); let message = Drupal.t('@node is moved to position @position under @parent', {'@node': data.node.text, '@parent': parentText, '@position': data.position + 1});
// Inform user the movement. // Inform user the movement.
drupalMessages.clear(); drupalMessages.clear();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment