diff --git a/src/Umbraco.Web/Models/Trees/TreeNode.cs b/src/Umbraco.Web/Models/Trees/TreeNode.cs index 7f270fa500..ea0ba78ca7 100644 --- a/src/Umbraco.Web/Models/Trees/TreeNode.cs +++ b/src/Umbraco.Web/Models/Trees/TreeNode.cs @@ -28,7 +28,7 @@ namespace Umbraco.Web.Models.Trees AdditionalData = new Dictionary(); ChildNodesUrl = getChildNodesUrl; MenuUrl = menuUrl; - //default + //default Icon = "icon-folder-close"; } @@ -50,6 +50,40 @@ namespace Umbraco.Web.Models.Trees [DataMember(Name = "name")] public string Title { get; set; } + /// + /// The tree nodetype which refers to the type of node rendered in the tree + /// + [DataMember(Name = "nodetype")] + public string NodeType { get; set; } + + /// + /// Optional: The Route path for the editor for this node + /// + /// + /// If this is not set, then the route path will be automatically determined by: {section}/edit/{id} + /// + [DataMember(Name = "routePath")] + public string RoutePath { get; set; } + + /// + /// The JSON url to load the nodes children + /// + [DataMember(Name = "childNodesUrl")] + public string ChildNodesUrl { get; set; } + + /// + /// The JSON url to load the menu from + /// + [DataMember(Name = "menuUrl")] + public string MenuUrl { get; set; } + + /// + /// A dictionary to support any additional meta data that should be rendered for the node which is + /// useful for custom action commands such as 'create', 'copy', etc... + /// + [DataMember(Name = "metaData")] + public Dictionary AdditionalData { get; private set; } + /// /// The icon to use for the node, this can be either a path to an image or a Css class. /// If a '/' is found in the string then it will be considered a path to an image. @@ -57,12 +91,6 @@ namespace Umbraco.Web.Models.Trees [DataMember(Name = "icon")] public string Icon { get; set; } - /// - /// The tree nodetype which refers to the type of node rendered in the tree - /// - [DataMember(Name = "nodetype")] - public string NodeType { get; set; } - /// /// Returns true if the icon represents a CSS class instead of a file path /// @@ -95,36 +123,10 @@ namespace Umbraco.Web.Models.Trees } /// - /// Optional: The Route path for the editor for this node + /// A list of additional/custom css classes to assign to the node /// - /// - /// If this is not set, then the route path will be automatically determined by: {section}/edit/{id} - /// - [DataMember(Name = "routePath")] - public string RoutePath { get; set; } - - /// - /// The JSON url to load the nodes children - /// - [DataMember(Name = "childNodesUrl")] - public string ChildNodesUrl { get; set; } - - /// - /// The JSON url to load the menu from - /// - [DataMember(Name = "menuUrl")] - public string MenuUrl { get; set; } - - /// - /// A dictionary to support any additional meta data that should be rendered for the node which is - /// useful for custom action commands such as 'create', 'copy', etc... - /// - [DataMember(Name = "metaData")] - public Dictionary AdditionalData { get; private set; } - - ///// - ///// The UI style to give the model - ///// - //public NodeStyle Style { get; private set; } + [DataMember(Name = "cssClasses")] + public IList CssClasses { get; private set; } } + } diff --git a/src/Umbraco.Web/Models/Trees/TreeNodeExtensions.cs b/src/Umbraco.Web/Models/Trees/TreeNodeExtensions.cs index 17eab1fb85..1d974a22b7 100644 --- a/src/Umbraco.Web/Models/Trees/TreeNodeExtensions.cs +++ b/src/Umbraco.Web/Models/Trees/TreeNodeExtensions.cs @@ -13,5 +13,41 @@ { treeNode.AdditionalData[LegacyJsCallbackKey] = jsCallback; } + + /// + /// Sets the node style to show that it is currently protected publicly + /// + /// + public static void SetProtectedStyle(this TreeNode treeNode) + { + if (treeNode.CssClasses.Contains("protected") == false) + { + treeNode.CssClasses.Add("protected"); + } + } + + /// + /// Sets the node style to show that it is has unpublished versions (but is currently published) + /// + /// + public static void SetHasUnpublishedVersionStyle(this TreeNode treeNode) + { + if (treeNode.CssClasses.Contains("has-unpublished-version") == false) + { + treeNode.CssClasses.Add("has-unpublished-version"); + } + } + + /// + /// Sets the node style to show that it is is not published + /// + /// + public static void SetNotPublishedStyle(this TreeNode treeNode) + { + if (treeNode.CssClasses.Contains("not-published") == false) + { + treeNode.CssClasses.Add("not-published"); + } + } } } \ No newline at end of file diff --git a/src/Umbraco.Web/Trees/ContentTreeController.cs b/src/Umbraco.Web/Trees/ContentTreeController.cs index 3628e9e714..3039463176 100644 --- a/src/Umbraco.Web/Trees/ContentTreeController.cs +++ b/src/Umbraco.Web/Trees/ContentTreeController.cs @@ -14,6 +14,7 @@ using Umbraco.Web.Mvc; using umbraco; using umbraco.BusinessLogic.Actions; using umbraco.businesslogic; +using umbraco.cms.businesslogic.web; using umbraco.interfaces; using Constants = Umbraco.Core.Constants; @@ -79,6 +80,15 @@ namespace Umbraco.Web.Trees e.ContentTypeIcon, hasChildren); + if (e.IsPublished == false) + node.SetNotPublishedStyle(); + + if (e.HasPendingChanges) + node.SetHasUnpublishedVersionStyle(); + + if (Access.IsProtected(e.Id, e.Path)) + node.SetProtectedStyle(); + nodes.Add(node); } }