mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
MINOR Fixed drag'n'drop in SecurityAdmin (thanks frankmullenger)
This commit is contained in:
parent
160f712f68
commit
bc2bb53274
@ -13,7 +13,8 @@
|
|||||||
onmatch: function() {
|
onmatch: function() {
|
||||||
this._super();
|
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
|
* @todo Icon and page type hover support
|
||||||
@ -56,14 +57,15 @@
|
|||||||
// Check if a node is allowed to be moved.
|
// Check if a node is allowed to be moved.
|
||||||
// Caution: Runs on every drag over a new node
|
// Caution: Runs on every drag over a new node
|
||||||
'check_move': function(data) {
|
'check_move': function(data) {
|
||||||
|
|
||||||
var movedNode = $(data.o), newParent = $(data.np),
|
var movedNode = $(data.o), newParent = $(data.np),
|
||||||
isMovedOntoContainer = data.ot.get_container()[0] == data.np[0],
|
isMovedOntoContainer = data.ot.get_container()[0] == data.np[0],
|
||||||
movedNodeClass = movedNode.getClassname(),
|
movedNodeClass = movedNode.getClassname(),
|
||||||
newParentClass = newParent.getClassname(),
|
newParentClass = newParent.getClassname(),
|
||||||
// Check allowedChildren of newParent or against root node rules
|
// Check allowedChildren of newParent or against root node rules
|
||||||
hints = self.getHints(),
|
hints = self.getHints(),
|
||||||
disallowedChildren = hints[newParentClass ? newParentClass : 'Root'].disallowedChildren || [];
|
disallowedChildren = [];
|
||||||
|
|
||||||
|
if(hints) disallowedChildren = hints[newParentClass ? newParentClass : 'Root'].disallowedChildren || [];
|
||||||
var isAllowed = (
|
var isAllowed = (
|
||||||
// Don't allow moving the root node
|
// Don't allow moving the root node
|
||||||
movedNode.data('id') != 0
|
movedNode.data('id') != 0
|
||||||
@ -72,7 +74,7 @@
|
|||||||
// Children are generally allowed on parent
|
// Children are generally allowed on parent
|
||||||
&& !newParent.hasClass('nochildren')
|
&& !newParent.hasClass('nochildren')
|
||||||
// movedNode is allowed as a child
|
// movedNode is allowed as a child
|
||||||
&& ($.inArray(movedNodeClass, disallowedChildren) == -1)
|
&& (!disallowedChildren.length || $.inArray(movedNodeClass, disallowedChildren) == -1)
|
||||||
);
|
);
|
||||||
|
|
||||||
return isAllowed;
|
return isAllowed;
|
||||||
|
@ -8,14 +8,7 @@
|
|||||||
|
|
||||||
$AddForm
|
$AddForm
|
||||||
|
|
||||||
<div class="checkboxAboveTree">
|
<div data-url-tree="$Link(getsubtree)" data-url-savetreenode="$Link(savetreenode)" class="cms-tree draggable jstree jstree-apple">
|
||||||
<input type="checkbox" id="sortitems" />
|
|
||||||
<label for="sortitems">
|
|
||||||
<% _t('ENABLEDRAGGING','Allow drag & drop reordering', PR_HIGH) %>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div data-url-tree="$Link(getsubtree)" data-url-savetreenode="$Link(savetreenode)" class="cms-tree jstree jstree-apple">
|
|
||||||
$SiteTreeAsUL
|
$SiteTreeAsUL
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user