Change the icon in the Document Types Tree to be the chosen icon instead of a default one. (#7358)
* - changed the icon in the document types tree to be the icon chose rather than the default doc type icon * - rendered icons for media types and member types * - used null coalescing for icon setting for better null handling Co-authored-by: paulmoriyama <48755798+paulmoriyama@users.noreply.github.com>
This commit is contained in:
@@ -69,15 +69,18 @@ namespace Umbraco.Web.Trees
|
||||
.OrderBy(entity => entity.Name)
|
||||
.Select(dt =>
|
||||
{
|
||||
// get the content type here so we can get the icon from it to use when we create the tree node
|
||||
// and we can enrich the result with content type data that's not available in the entity service output
|
||||
var contentType = contentTypes[dt.Id];
|
||||
|
||||
// since 7.4+ child type creation is enabled by a config option. It defaults to on, but can be disabled if we decide to.
|
||||
// need this check to keep supporting sites where children have already been created.
|
||||
var hasChildren = dt.HasChildren;
|
||||
var node = CreateTreeNode(dt, Constants.ObjectTypes.DocumentType, id, queryStrings, Constants.Icons.ContentType, hasChildren);
|
||||
var node = CreateTreeNode(dt, Constants.ObjectTypes.DocumentType, id, queryStrings, contentType?.Icon ?? Constants.Icons.ContentType, hasChildren);
|
||||
|
||||
node.Path = dt.Path;
|
||||
|
||||
// enrich the result with content type data that's not available in the entity service output
|
||||
var contentType = contentTypes[dt.Id];
|
||||
// now we can enrich the result with content type data that's not available in the entity service output
|
||||
node.Alias = contentType.Alias;
|
||||
node.AdditionalData["isElement"] = contentType.IsElement;
|
||||
|
||||
|
||||
@@ -25,10 +25,12 @@ namespace Umbraco.Web.Trees
|
||||
public class MediaTypeTreeController : TreeController, ISearchableTree
|
||||
{
|
||||
private readonly UmbracoTreeSearcher _treeSearcher;
|
||||
private readonly IMediaTypeService _mediaTypeService;
|
||||
|
||||
public MediaTypeTreeController(UmbracoTreeSearcher treeSearcher, IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoHelper umbracoHelper) : base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper)
|
||||
public MediaTypeTreeController(UmbracoTreeSearcher treeSearcher, IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoHelper umbracoHelper, IMediaTypeService mediaTypeService) : base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper)
|
||||
{
|
||||
_treeSearcher = treeSearcher;
|
||||
_mediaTypeService = mediaTypeService;
|
||||
}
|
||||
|
||||
protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
|
||||
@@ -54,6 +56,8 @@ namespace Umbraco.Web.Trees
|
||||
// if the request is for folders only then just return
|
||||
if (queryStrings["foldersonly"].IsNullOrWhiteSpace() == false && queryStrings["foldersonly"] == "1") return nodes;
|
||||
|
||||
var mediaTypes = _mediaTypeService.GetAll();
|
||||
|
||||
nodes.AddRange(
|
||||
Services.EntityService.GetChildren(intId.Result, UmbracoObjectTypes.MediaType)
|
||||
.OrderBy(entity => entity.Name)
|
||||
@@ -62,7 +66,8 @@ namespace Umbraco.Web.Trees
|
||||
// since 7.4+ child type creation is enabled by a config option. It defaults to on, but can be disabled if we decide to.
|
||||
// need this check to keep supporting sites where children have already been created.
|
||||
var hasChildren = dt.HasChildren;
|
||||
var node = CreateTreeNode(dt, Constants.ObjectTypes.MediaType, id, queryStrings, Constants.Icons.MediaType, hasChildren);
|
||||
var mt = mediaTypes.FirstOrDefault(x => x.Id == dt.Id);
|
||||
var node = CreateTreeNode(dt, Constants.ObjectTypes.MediaType, id, queryStrings, mt?.Icon ?? Constants.Icons.MediaType, hasChildren);
|
||||
|
||||
node.Path = dt.Path;
|
||||
return node;
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Umbraco.Web.Trees
|
||||
{
|
||||
return Services.MemberTypeService.GetAll()
|
||||
.OrderBy(x => x.Name)
|
||||
.Select(dt => CreateTreeNode(dt, Constants.ObjectTypes.MemberType, id, queryStrings, Constants.Icons.MemberType, false));
|
||||
.Select(dt => CreateTreeNode(dt, Constants.ObjectTypes.MemberType, id, queryStrings, dt?.Icon ?? Constants.Icons.MemberType, false));
|
||||
}
|
||||
|
||||
public IEnumerable<SearchResultEntity> Search(string query, int pageSize, long pageIndex, out long totalFound, string searchFrom = null)
|
||||
|
||||
Reference in New Issue
Block a user