diff --git a/src/Umbraco.Core/Serialization/JsonCreationConverter.cs b/src/Umbraco.Core/Serialization/JsonCreationConverter.cs index 3a781bbf63..8b8ae8278d 100644 --- a/src/Umbraco.Core/Serialization/JsonCreationConverter.cs +++ b/src/Umbraco.Core/Serialization/JsonCreationConverter.cs @@ -4,33 +4,6 @@ using Newtonsoft.Json.Linq; namespace Umbraco.Core.Serialization { - /// - /// This is used in order to deserialize a json object on a property into a json string since the property's type is 'string' - /// - internal class JsonToStringConverter : JsonConverter - { - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - throw new NotImplementedException(); - } - - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) - { - if (reader.ValueType == typeof(string)) - { - return reader.Value; - } - // Load JObject from stream - JObject jObject = JObject.Load(reader); - return jObject.ToString(); - } - - public override bool CanConvert(Type objectType) - { - return typeof(string).IsAssignableFrom(objectType); - } - } - internal abstract class JsonCreationConverter : JsonConverter { /// diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index e4f17fdd48..6acadd06af 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -691,6 +691,7 @@ + diff --git a/src/Umbraco.Web.UI.Client/common/filters/treeiconclass.filter.js b/src/Umbraco.Web.UI.Client/common/filters/treeiconclass.filter.js new file mode 100644 index 0000000000..a6830145ad --- /dev/null +++ b/src/Umbraco.Web.UI.Client/common/filters/treeiconclass.filter.js @@ -0,0 +1,21 @@ +'use strict'; + +define(['angular'], function (angular) { + + /** + * @ngdoc filter + * @name umbraco.filters:umbTreeIconClass + * @restrict E + * @description This will properly render the tree icon class based on the tree icon set on the server + **/ + function treeIconClassFilter() { + return function (treeNode, standardClasses) { + if (treeNode.iconIsClass) { + return standardClasses + " " + treeNode.icon; + } + return standardClasses; + }; + }; + angular.module('umbraco.filters').filter("umbTreeIconClass", treeIconClassFilter); + +}); \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/common/filters/treeiconimage.filter.js b/src/Umbraco.Web.UI.Client/common/filters/treeiconimage.filter.js new file mode 100644 index 0000000000..a67a56223b --- /dev/null +++ b/src/Umbraco.Web.UI.Client/common/filters/treeiconimage.filter.js @@ -0,0 +1,21 @@ +'use strict'; + +define(['angular'], function (angular) { + + /** + * @ngdoc filter + * @name umbraco.filters:umbTreeIconImage + * @restrict E + * @description This will properly render the tree icon image based on the tree icon set on the server + **/ + function treeIconImageFilter() { + return function (treeNode) { + if (treeNode.iconIsClass) { + return ""; + } + return ""; + }; + }; + angular.module('umbraco.filters').filter("umbTreeIconImage", treeIconImageFilter); + +}); \ No newline at end of file diff --git a/src/Umbraco.Web.UI/umbraco/Views/common/tree.html b/src/Umbraco.Web.UI/umbraco/Views/common/tree.html index 3bc62493b4..4c27139baa 100644 --- a/src/Umbraco.Web.UI/umbraco/Views/common/tree.html +++ b/src/Umbraco.Web.UI/umbraco/Views/common/tree.html @@ -13,7 +13,8 @@ ng-class="{'icon-caret-right': !node.expanded, 'icon-caret-down': node.expanded}" ng-click="getTreeChildren(node)"> - + + {{node.name}} diff --git a/src/Umbraco.Web.UI/umbraco/js/umbraco.filters.js b/src/Umbraco.Web.UI/umbraco/js/umbraco.filters.js index 711c6d98de..f1fe4a6df4 100644 --- a/src/Umbraco.Web.UI/umbraco/js/umbraco.filters.js +++ b/src/Umbraco.Web.UI/umbraco/js/umbraco.filters.js @@ -4,19 +4,51 @@ * Licensed MIT */ 'use strict'; -define([ 'app','angular'], function (app,angular) { -angular.module('umbraco.filters', []) - .filter('interpolate', ['version', function(version) { - return function(text) { - return String(text).replace(/\%VERSION\%/mg, version); - }; - }]) - .filter('propertyEditor', function() { - return function(input) { - return "views/propertyeditors/" + String(input).replace('.', '/') + "/editor.html"; - }; - }); +define(['app', 'angular'], function (app, angular) { + angular.module('umbraco.filters', []) + .filter('interpolate', ['version', function (version) { + return function (text) { + return String(text).replace(/\%VERSION\%/mg, version); + }; + }]) + .filter('propertyEditor', function () { + return function (input) { + return "views/propertyeditors/" + String(input).replace('.', '/') + "/editor.html"; + }; + }); + + /** + * @ngdoc filter + * @name umbraco.filters:umbTreeIconImage + * @restrict E + * @description This will properly render the tree icon image based on the tree icon set on the server + **/ + function treeIconImageFilter() { + return function (treeNode) { + if (treeNode.iconIsClass) { + return ""; + } + return ""; + }; + }; + angular.module('umbraco.filters').filter("umbTreeIconImage", treeIconImageFilter); + + /** + * @ngdoc filter + * @name umbraco.filters:umbTreeIconClass + * @restrict E + * @description This will properly render the tree icon class based on the tree icon set on the server + **/ + function treeIconClassFilter() { + return function (treeNode, standardClasses) { + if (treeNode.iconIsClass) { + return standardClasses + " " + treeNode.icon; + } + return standardClasses; + }; + }; + angular.module('umbraco.filters').filter("umbTreeIconClass", treeIconClassFilter); -return app; + return app; }); \ No newline at end of file diff --git a/src/Umbraco.Web/Trees/TreeNode.cs b/src/Umbraco.Web/Trees/TreeNode.cs index 94917fbc34..5b18f2f750 100644 --- a/src/Umbraco.Web/Trees/TreeNode.cs +++ b/src/Umbraco.Web/Trees/TreeNode.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Runtime.Serialization; using Newtonsoft.Json; +using Umbraco.Core.IO; namespace Umbraco.Web.Trees { @@ -65,6 +66,33 @@ namespace Umbraco.Web.Trees [DataMember(Name = "icon")] public string Icon { get; set; } + /// + /// Returns true if the icon represents a CSS class instead of a file path + /// + [DataMember(Name = "iconIsClass")] + public bool IconIsClass + { + get + { + //if it starts with a '.' or doesn't contain a '.' at all then it is a class + return Icon.StartsWith(".") || Icon.Contains(".") == false; + } + } + + /// + /// Returns the icon file path if the icon is not a class, otherwise returns an empty string + /// + [DataMember(Name = "iconFilePath")] + public string IconFilePath + { + get + { + return IconIsClass + ? string.Empty + : IOHelper.ResolveUrl("~/umbraco/images/umbraco/" + Icon); + } + } + /// /// The URL path for the editor for this model /// diff --git a/src/Umbraco.Web/Trees/TreeNodeCollection.cs b/src/Umbraco.Web/Trees/TreeNodeCollection.cs index e29fb160b1..41f2caed2c 100644 --- a/src/Umbraco.Web/Trees/TreeNodeCollection.cs +++ b/src/Umbraco.Web/Trees/TreeNodeCollection.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Runtime.Serialization; +using Newtonsoft.Json.Linq; namespace Umbraco.Web.Trees { diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index e41f527696..d1cd2891b9 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -303,6 +303,7 @@ +