Updates move/copy to use the correct usage of checked nodes

This commit is contained in:
Shannon
2014-10-09 14:31:53 +11:00
parent 9cbea5764d
commit 49164ce6ef
6 changed files with 41 additions and 47 deletions

View File

@@ -30,8 +30,10 @@ function umbTreeDirective($compile, $log, $q, $rootScope, treeService, notificat
var hideoptions = (attrs.hideoptions === 'true') ? "hide-options" : "";
var template = '<ul class="umb-tree ' + hideoptions + '"><li class="root">';
template += '<div ng-hide="hideheader">' +
'<h5><a href="#/{{section}}" ng-click="select(this, tree.root, $event)" on-right-click="altSelect(this, tree.root, $event)" class="root-link">{{tree.name}}</a></h5>' +
'<a href class="umb-options" ng-hide="tree.root.isContainer || !tree.root.menuUrl" ng-click="options(this, tree.root, $event)" ng-swipe-right="options(this, tree.root, $event)"><i></i><i></i><i></i></a>' +
'<h5>' +
'<i ng-if="enablecheckboxes == \'true\'" ng-class="selectEnabledNodeClass(tree.root)"></i>' +
'<a href="#/{{section}}" ng-click="select(tree.root, $event)" on-right-click="altSelect(tree.root, $event)" class="root-link">{{tree.name}}</a></h5>' +
'<a href class="umb-options" ng-hide="tree.root.isContainer || !tree.root.menuUrl" ng-click="options(tree.root, $event)" ng-swipe-right="options(tree.root, $event)"><i></i><i></i><i></i></a>' +
'</div>';
template += '<ul>' +
'<umb-tree-item ng-repeat="child in tree.root.children" eventhandler="eventhandler" node="child" current-node="currentNode" tree="this" section="{{section}}" ng-animate="animation()"></umb-tree-item>' +
@@ -296,6 +298,14 @@ function umbTreeDirective($compile, $log, $q, $rootScope, treeService, notificat
}
scope.selectEnabledNodeClass = function (node) {
return node ?
node.selected ?
'icon umb-tree-icon sprTree icon-check blue temporary' :
'' :
'';
};
/** method to set the current animation for the node.
* This changes dynamically based on if we are changing sections or just loading normal tree data.
* When changing sections we don't want all of the tree-ndoes to do their 'leave' animations.
@@ -350,8 +360,8 @@ function umbTreeDirective($compile, $log, $q, $rootScope, treeService, notificat
The tree doesnt know about this, so it raises an event to tell the parent controller
about it.
*/
scope.options = function(e, n, ev) {
emitEvent("treeOptionsClick", { element: e, node: n, event: ev });
scope.options = function(n, ev) {
emitEvent("treeOptionsClick", { element: elem, node: n, event: ev });
};
/**
@@ -360,17 +370,17 @@ function umbTreeDirective($compile, $log, $q, $rootScope, treeService, notificat
and emits it as a treeNodeSelect element if there is a callback object
defined on the tree
*/
scope.select = function (e, n, ev) {
scope.select = function (n, ev) {
//on tree select we need to remove the current node -
// whoever handles this will need to make sure the correct node is selected
//reset current node selection
scope.currentNode = null;
emitEvent("treeNodeSelect", { element: e, node: n, event: ev });
emitEvent("treeNodeSelect", { element: elem, node: n, event: ev });
};
scope.altSelect = function(e, n, ev) {
emitEvent("treeNodeAltSelect", { element: e, tree: scope.tree, node: n, event: ev });
scope.altSelect = function(n, ev) {
emitEvent("treeNodeAltSelect", { element: elem, tree: scope.tree, node: n, event: ev });
};
//watch for section changes

View File

@@ -79,8 +79,12 @@ angular.module("umbraco.directives")
}, 0, false);
}
scope.selectEnabledNodeClass = function(node) {
return node.selected ? 'icon umb-tree-icon sprTree icon-check blue temporary' : node.cssClass;
scope.selectEnabledNodeClass = function (node) {
return node ?
node.selected ?
'icon umb-tree-icon sprTree icon-check blue temporary' :
node.cssClass :
'';
};
//add a method to the node which we can use to call to update the node data if we need to ,

View File

@@ -15,23 +15,13 @@ angular.module("umbraco")
eventsService.emit("editors.content.copyController.select", args);
var c = $(args.event.target.parentElement);
if ($scope.selectedEl) {
$scope.selectedEl.find(".temporary").remove();
$scope.selectedEl.find("i.umb-tree-icon").show();
}
var temp = "<i class='icon umb-tree-icon sprTree icon-check blue temporary'></i>";
var icon = c.find("i.umb-tree-icon");
if (icon.length > 0) {
icon.hide().after(temp);
} else {
c.prepend(temp);
if ($scope.target) {
//un-select if there's a current one selected
$scope.target.selected = false;
}
$scope.target = args.node;
$scope.selectedEl = c;
$scope.target.selected = true;
}
$scope.dialogTreeEventHandler.bind("treeNodeSelect", nodeSelectHandler);

View File

@@ -12,24 +12,13 @@ angular.module("umbraco").controller("Umbraco.Editors.Content.MoveController",
eventsService.emit("editors.content.moveController.select", args);
var c = $(args.event.target.parentElement);
if ($scope.selectedEl) {
$scope.selectedEl.find(".temporary").remove();
$scope.selectedEl.find("i.umb-tree-icon").show();
if ($scope.target) {
//un-select if there's a current one selected
$scope.target.selected = false;
}
var temp = "<i class='icon umb-tree-icon sprTree icon-check blue temporary'></i>";
var icon = c.find("i.umb-tree-icon");
if (icon.length > 0) {
icon.hide().after(temp);
} else {
c.prepend(temp);
}
$scope.target = args.node;
$scope.selectedEl = c;
$scope.target.selected = true;
});
$scope.move = function(){

View File

@@ -26,7 +26,8 @@
hideheader="false"
hideoptions="true"
isdialog="true"
eventhandler="dialogTreeEventHandler">
eventhandler="dialogTreeEventHandler"
enablecheckboxes="true">
</umb-tree>

View File

@@ -19,13 +19,13 @@
</div>
<div ng-hide="success">
<umb-tree
section="content"
hideheader="false"
hideoptions="true"
isdialog="true"
eventhandler="dialogTreeEventHandler">
</umb-tree>
<umb-tree section="content"
hideheader="false"
hideoptions="true"
isdialog="true"
eventhandler="dialogTreeEventHandler"
enablecheckboxes="true">
</umb-tree>
</div>
</div>
</div>