Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit 78cc7c7

Browse files
committed
Merge pull request #30 from uwej711/fix_toplevel_move
fix toplevel move/reorder in the tree
2 parents 7b9663b + f572878 commit 78cc7c7

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

Resources/public/js/init.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ var AdminTree = (function () {
7474
"initially_load": config.path.expanded,
7575
"initially_open": config.path.preloaded
7676
},
77-
"plugins": [ "contextmenu", "themes", "types", "ui", "json_data", "dnd", "crrm", "cookies" ],
77+
"plugins": [ "contextmenu", "themes", "types", "ui", "json_data", "crrm", "dnd", "cookies" ],
7878
"json_data": {
7979
"ajax": {
8080
"url": config.ajax.children_url,
@@ -90,7 +90,7 @@ var AdminTree = (function () {
9090
"types": {
9191
"max_depth": -1,
9292
"max_children": -1,
93-
"valid_children": [ "all"],
93+
"valid_children": "all",
9494
"types": config.types
9595
},
9696
"ui": {
@@ -195,10 +195,16 @@ var AdminTree = (function () {
195195
var oldParent = data.rslt.op;
196196
var newParent = data.rslt.np;
197197

198+
// parent could be the tree
199+
var parent = newParent.attr("id");
200+
if (treeInst.is(newParent)) {
201+
parent = config.rootNode;
202+
}
203+
198204
if (!oldParent.is(newParent)) {
199205
$.post(
200206
config.ajax.move_url,
201-
{ "dropped": dropped.attr("id"), "target": newParent.attr("id") },
207+
{ "dropped": dropped.attr("id"), "target": parent },
202208
function (data) {
203209
dropped.attr("id", data.id);
204210
dropped.attr("url_safe_id", data.url_safe_id);
@@ -207,7 +213,7 @@ var AdminTree = (function () {
207213
} else {
208214
$.post(
209215
config.ajax.reorder_url,
210-
{ "dropped": dropped.attr("id"), "target": target.attr("id"), "parent": newParent.attr("id"), "position": position }
216+
{ "dropped": dropped.attr("id"), "target": target.attr("id"), "parent": parent, "position": position }
211217
);
212218
}
213219
})

0 commit comments

Comments
 (0)