Ensures that a user that has multiple start nodes cannot select the root start node in the tree dialogs
This commit is contained in:
@@ -31,7 +31,7 @@ function umbTreeDirective($compile, $log, $q, $rootScope, treeService, notificat
|
||||
//var showheader = (attrs.showheader !== 'false');
|
||||
var hideoptions = (attrs.hideoptions === 'true') ? "hide-options" : "";
|
||||
var template = '<ul class="umb-tree ' + hideoptions + '"><li class="root">';
|
||||
template += '<div ng-hide="hideheader" on-right-click="altSelect(tree.root, $event)">' +
|
||||
template += '<div ng-class="getNodeCssClass(tree.root)" ng-hide="hideheader" on-right-click="altSelect(tree.root, $event)">' +
|
||||
'<h5>' +
|
||||
'<a href="#/{{section}}" ng-click="select(tree.root, $event)" class="root-link"><i ng-if="enablecheckboxes == \'true\'" ng-class="selectEnabledNodeClass(tree.root)"></i> {{tree.name}}</a></h5>' +
|
||||
'<a 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>' +
|
||||
@@ -310,6 +310,25 @@ function umbTreeDirective($compile, $log, $q, $rootScope, treeService, notificat
|
||||
|
||||
}
|
||||
|
||||
/** Returns the css classses assigned to the node (div element) */
|
||||
scope.getNodeCssClass = function (node) {
|
||||
if (!node) {
|
||||
return '';
|
||||
}
|
||||
|
||||
//TODO: This is called constantly because as a method in a template it's re-evaluated pretty much all the time
|
||||
// it would be better if we could cache the processing. The problem is that some of these things are dynamic.
|
||||
|
||||
var css = [];
|
||||
if (node.cssClasses) {
|
||||
_.each(node.cssClasses, function (c) {
|
||||
css.push(c);
|
||||
});
|
||||
}
|
||||
|
||||
return css.join(" ");
|
||||
};
|
||||
|
||||
scope.selectEnabledNodeClass = function (node) {
|
||||
return node ?
|
||||
node.selected ?
|
||||
@@ -383,6 +402,12 @@ function umbTreeDirective($compile, $log, $q, $rootScope, treeService, notificat
|
||||
defined on the tree
|
||||
*/
|
||||
scope.select = function (n, ev) {
|
||||
|
||||
if (n.metaData && n.metaData.noAccess === true) {
|
||||
ev.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
//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
|
||||
|
||||
@@ -111,7 +111,11 @@ angular.module("umbraco.directives")
|
||||
scope.getNodeCssClass = function (node) {
|
||||
if (!node) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: This is called constantly because as a method in a template it's re-evaluated pretty much all the time
|
||||
// it would be better if we could cache the processing. The problem is that some of these things are dynamic.
|
||||
|
||||
var css = [];
|
||||
if (node.cssClasses) {
|
||||
_.each(node.cssClasses, function(c) {
|
||||
@@ -120,7 +124,8 @@ angular.module("umbraco.directives")
|
||||
}
|
||||
if (node.selected) {
|
||||
css.push("umb-tree-node-checked");
|
||||
}
|
||||
}
|
||||
|
||||
return css.join(" ");
|
||||
};
|
||||
|
||||
|
||||
@@ -44,6 +44,14 @@ function treeService($q, treeResource, iconHelper, notificationsService, eventsS
|
||||
if (!parentNode.section) {
|
||||
parentNode.section = section;
|
||||
}
|
||||
|
||||
if (parentNode.metaData && parentNode.metaData.noAccess === true) {
|
||||
if (!parentNode.cssClasses) {
|
||||
parentNode.cssClasses = [];
|
||||
}
|
||||
parentNode.cssClasses.push("no-access");
|
||||
}
|
||||
|
||||
//create a method outside of the loop to return the parent - otherwise jshint blows up
|
||||
var funcParent = function() {
|
||||
return parentNode;
|
||||
|
||||
@@ -54,6 +54,23 @@ namespace Umbraco.Web.Trees
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Ensure the noAccess metadata is applied for the root node if in dialog mode and the user doesn't have path access to it
|
||||
/// </summary>
|
||||
/// <param name="queryStrings"></param>
|
||||
/// <returns></returns>
|
||||
protected override TreeNode CreateRootNode(FormDataCollection queryStrings)
|
||||
{
|
||||
var node = base.CreateRootNode(queryStrings);
|
||||
|
||||
if (IsDialog(queryStrings) && UserStartNodes.Contains(Constants.System.Root) == false)
|
||||
{
|
||||
node.AdditionalData["noAccess"] = true;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
protected abstract TreeNode GetSingleTreeNode(IUmbracoEntity e, string parentId, FormDataCollection queryStrings);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user