Adds node styles and ensures they are set for the content tree nodes, now to get them to display styles
This commit is contained in:
@@ -28,7 +28,7 @@ namespace Umbraco.Web.Models.Trees
|
||||
AdditionalData = new Dictionary<string, object>();
|
||||
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; }
|
||||
|
||||
/// <summary>
|
||||
/// The tree nodetype which refers to the type of node rendered in the tree
|
||||
/// </summary>
|
||||
[DataMember(Name = "nodetype")]
|
||||
public string NodeType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Optional: The Route path for the editor for this node
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If this is not set, then the route path will be automatically determined by: {section}/edit/{id}
|
||||
/// </remarks>
|
||||
[DataMember(Name = "routePath")]
|
||||
public string RoutePath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The JSON url to load the nodes children
|
||||
/// </summary>
|
||||
[DataMember(Name = "childNodesUrl")]
|
||||
public string ChildNodesUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The JSON url to load the menu from
|
||||
/// </summary>
|
||||
[DataMember(Name = "menuUrl")]
|
||||
public string MenuUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 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...
|
||||
/// </summary>
|
||||
[DataMember(Name = "metaData")]
|
||||
public Dictionary<string, object> AdditionalData { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 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; }
|
||||
|
||||
/// <summary>
|
||||
/// The tree nodetype which refers to the type of node rendered in the tree
|
||||
/// </summary>
|
||||
[DataMember(Name = "nodetype")]
|
||||
public string NodeType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the icon represents a CSS class instead of a file path
|
||||
/// </summary>
|
||||
@@ -95,36 +123,10 @@ namespace Umbraco.Web.Models.Trees
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Optional: The Route path for the editor for this node
|
||||
/// A list of additional/custom css classes to assign to the node
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If this is not set, then the route path will be automatically determined by: {section}/edit/{id}
|
||||
/// </remarks>
|
||||
[DataMember(Name = "routePath")]
|
||||
public string RoutePath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The JSON url to load the nodes children
|
||||
/// </summary>
|
||||
[DataMember(Name = "childNodesUrl")]
|
||||
public string ChildNodesUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The JSON url to load the menu from
|
||||
/// </summary>
|
||||
[DataMember(Name = "menuUrl")]
|
||||
public string MenuUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 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...
|
||||
/// </summary>
|
||||
[DataMember(Name = "metaData")]
|
||||
public Dictionary<string, object> AdditionalData { get; private set; }
|
||||
|
||||
///// <summary>
|
||||
///// The UI style to give the model
|
||||
///// </summary>
|
||||
//public NodeStyle Style { get; private set; }
|
||||
[DataMember(Name = "cssClasses")]
|
||||
public IList<string> CssClasses { get; private set; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,5 +13,41 @@
|
||||
{
|
||||
treeNode.AdditionalData[LegacyJsCallbackKey] = jsCallback;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the node style to show that it is currently protected publicly
|
||||
/// </summary>
|
||||
/// <param name="treeNode"></param>
|
||||
public static void SetProtectedStyle(this TreeNode treeNode)
|
||||
{
|
||||
if (treeNode.CssClasses.Contains("protected") == false)
|
||||
{
|
||||
treeNode.CssClasses.Add("protected");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the node style to show that it is has unpublished versions (but is currently published)
|
||||
/// </summary>
|
||||
/// <param name="treeNode"></param>
|
||||
public static void SetHasUnpublishedVersionStyle(this TreeNode treeNode)
|
||||
{
|
||||
if (treeNode.CssClasses.Contains("has-unpublished-version") == false)
|
||||
{
|
||||
treeNode.CssClasses.Add("has-unpublished-version");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the node style to show that it is is not published
|
||||
/// </summary>
|
||||
/// <param name="treeNode"></param>
|
||||
public static void SetNotPublishedStyle(this TreeNode treeNode)
|
||||
{
|
||||
if (treeNode.CssClasses.Contains("not-published") == false)
|
||||
{
|
||||
treeNode.CssClasses.Add("not-published");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user