got legacy tree icons showing up now, added a couple of filters for this to work.
This commit is contained in:
@@ -4,33 +4,6 @@ using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Umbraco.Core.Serialization
|
||||
{
|
||||
/// <summary>
|
||||
/// This is used in order to deserialize a json object on a property into a json string since the property's type is 'string'
|
||||
/// </summary>
|
||||
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<T> : JsonConverter
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -691,6 +691,7 @@
|
||||
<Compile Include="Serialization\IStreamedResult.cs" />
|
||||
<Compile Include="Serialization\JsonCreationConverter.cs" />
|
||||
<Compile Include="Serialization\JsonNetSerializer.cs" />
|
||||
<Compile Include="Serialization\JsonToStringConverter.cs" />
|
||||
<Compile Include="Serialization\SerializationExtensions.cs" />
|
||||
<Compile Include="Serialization\SerializationService.cs" />
|
||||
<Compile Include="Serialization\StreamedResult.cs" />
|
||||
|
||||
@@ -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);
|
||||
|
||||
});
|
||||
@@ -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 "<img src='" + treeNode.iconFilePath + "'></img>";
|
||||
};
|
||||
};
|
||||
angular.module('umbraco.filters').filter("umbTreeIconImage", treeIconImageFilter);
|
||||
|
||||
});
|
||||
@@ -13,7 +13,8 @@
|
||||
ng-class="{'icon-caret-right': !node.expanded, 'icon-caret-down': node.expanded}"
|
||||
ng-click="getTreeChildren(node)"></ins>
|
||||
|
||||
<i class="icon umb-tree-icon sprTree {{node.icon}}"></i>
|
||||
<i class="{{node|umbTreeIconClass:'icon umb-tree-icon sprTree'}}" ng-bind-html-unsafe="node|umbTreeIconImage">
|
||||
</i>
|
||||
|
||||
<a ng-href="#{{node.view}}">{{node.name}}</a>
|
||||
<i class="umb-options" ng-click="showContextMenu(node, $event)"><i></i><i></i><i></i></i>
|
||||
|
||||
@@ -17,6 +17,38 @@ angular.module('umbraco.filters', [])
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* @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 "<img src='" + treeNode.iconFilePath + "'></img>";
|
||||
};
|
||||
};
|
||||
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;
|
||||
});
|
||||
@@ -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; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the icon represents a CSS class instead of a file path
|
||||
/// </summary>
|
||||
[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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the icon file path if the icon is not a class, otherwise returns an empty string
|
||||
/// </summary>
|
||||
[DataMember(Name = "iconFilePath")]
|
||||
public string IconFilePath
|
||||
{
|
||||
get
|
||||
{
|
||||
return IconIsClass
|
||||
? string.Empty
|
||||
: IOHelper.ResolveUrl("~/umbraco/images/umbraco/" + Icon);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The URL path for the editor for this model
|
||||
/// </summary>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Umbraco.Web.Trees
|
||||
{
|
||||
|
||||
@@ -303,6 +303,7 @@
|
||||
<Compile Include="Trees\ApplicationTreeExtensions.cs" />
|
||||
<Compile Include="Trees\TreeNode.cs" />
|
||||
<Compile Include="Trees\TreeNodeCollection.cs" />
|
||||
<Compile Include="Trees\TreeNodeSerializer.cs" />
|
||||
<Compile Include="Trees\TreeQueryStringParameters.cs" />
|
||||
<Compile Include="Trees\ApplicationTreeApiController.cs" />
|
||||
<Compile Include="Editors\BackOfficeController.cs" />
|
||||
|
||||
Reference in New Issue
Block a user