Permalink
Browse files

MINOR Fixed drag'n'drop in SecurityAdmin (thanks frankmullenger)

  • Loading branch information...
1 parent 160f712 commit bc2bb53274fc307d1791b2a7093425967846d3f5 @chillu chillu committed Dec 18, 2011
Showing with 7 additions and 12 deletions.
  1. +6 −4 admin/javascript/LeftAndMain.Tree.js
  2. +1 −8 admin/templates/Includes/SecurityAdmin_Content.ss
@@ -13,7 +13,8 @@
onmatch: function() {
this._super();
- this.setHints($.parseJSON(this.attr('data-hints')));
+ var hints = this.attr('data-hints');
+ if(hints) this.setHints($.parseJSON(hints));
/**
* @todo Icon and page type hover support
@@ -56,14 +57,15 @@
// Check if a node is allowed to be moved.
// Caution: Runs on every drag over a new node
'check_move': function(data) {
-
var movedNode = $(data.o), newParent = $(data.np),
isMovedOntoContainer = data.ot.get_container()[0] == data.np[0],
movedNodeClass = movedNode.getClassname(),
newParentClass = newParent.getClassname(),
// Check allowedChildren of newParent or against root node rules
hints = self.getHints(),
- disallowedChildren = hints[newParentClass ? newParentClass : 'Root'].disallowedChildren || [];
+ disallowedChildren = [];
+
+ if(hints) disallowedChildren = hints[newParentClass ? newParentClass : 'Root'].disallowedChildren || [];
var isAllowed = (
// Don't allow moving the root node
movedNode.data('id') != 0
@@ -72,7 +74,7 @@
// Children are generally allowed on parent
&& !newParent.hasClass('nochildren')
// movedNode is allowed as a child
- && ($.inArray(movedNodeClass, disallowedChildren) == -1)
+ && (!disallowedChildren.length || $.inArray(movedNodeClass, disallowedChildren) == -1)
);
return isAllowed;
@@ -8,14 +8,7 @@
$AddForm
- <div class="checkboxAboveTree">
- <input type="checkbox" id="sortitems" />
- <label for="sortitems">
- <% _t('ENABLEDRAGGING','Allow drag &amp; drop reordering', PR_HIGH) %>
- </label>
- </div>
-
- <div data-url-tree="$Link(getsubtree)" data-url-savetreenode="$Link(savetreenode)" class="cms-tree jstree jstree-apple">
+ <div data-url-tree="$Link(getsubtree)" data-url-savetreenode="$Link(savetreenode)" class="cms-tree draggable jstree jstree-apple">
$SiteTreeAsUL
</div>

0 comments on commit bc2bb53

Please sign in to comment.