Finalizes the implementation of getting the menu items rendering for child of listview items for both content and media.
This commit is contained in:
@@ -91,31 +91,22 @@ namespace Umbraco.Web.Models.Mapping
|
||||
|
||||
}
|
||||
|
||||
private static void AfterMap(IContent content, ContentItemDisplay display)
|
||||
{
|
||||
MapGenericCustomProperties(content, display);
|
||||
MapTreeNodeUrl(content, display);
|
||||
}
|
||||
|
||||
private static void MapTreeNodeUrl(IContent content, ContentItemDisplay display)
|
||||
{
|
||||
if (HttpContext.Current == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var urlHelper = new UrlHelper(new RequestContext(new HttpContextWrapper(HttpContext.Current), new RouteData()));
|
||||
var url = urlHelper.GetUmbracoApiService<ContentTreeController>(controller => controller.GetTreeNode(display.Id.ToString(), null));
|
||||
display.TreeNodeUrl = url;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Maps the generic tab with custom properties for content
|
||||
/// </summary>
|
||||
/// <param name="content"></param>
|
||||
/// <param name="display"></param>
|
||||
private static void MapGenericCustomProperties(IContent content, ContentItemDisplay display)
|
||||
private static void AfterMap(IContent content, ContentItemDisplay display)
|
||||
{
|
||||
//map the tree node url
|
||||
if (HttpContext.Current != null)
|
||||
{
|
||||
var urlHelper = new UrlHelper(new RequestContext(new HttpContextWrapper(HttpContext.Current), new RouteData()));
|
||||
var url = urlHelper.GetUmbracoApiService<ContentTreeController>(controller => controller.GetTreeNode(display.Id.ToString(), null));
|
||||
display.TreeNodeUrl = url;
|
||||
}
|
||||
|
||||
//fill in the template config to be passed to the template drop down.
|
||||
var templateItemConfig = new Dictionary<string, string> { { "", "Choose..." } };
|
||||
foreach (var t in content.ContentType.AllowedTemplates)
|
||||
|
||||
@@ -3,12 +3,16 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using AutoMapper;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Mapping;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Umbraco.Web.Trees;
|
||||
|
||||
namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
@@ -30,15 +34,15 @@ namespace Umbraco.Web.Models.Mapping
|
||||
.ForMember(
|
||||
dto => dto.ContentTypeAlias,
|
||||
expression => expression.MapFrom(content => content.ContentType.Alias))
|
||||
.ForMember(
|
||||
dto => dto.IsChildOfListView,
|
||||
expression => expression.MapFrom(content => content.Parent().ContentType.IsContainer))
|
||||
.ForMember(
|
||||
dto => dto.ContentTypeName,
|
||||
expression => expression.MapFrom(content => content.ContentType.Name))
|
||||
.ForMember(display => display.Properties, expression => expression.Ignore())
|
||||
.ForMember(display => display.Tabs, expression => expression.ResolveUsing<TabsAndPropertiesResolver>())
|
||||
.AfterMap(MapGenericCustomProperties);
|
||||
/*
|
||||
.AfterMap((media, display) => TabsAndPropertiesResolver.MapGenericProperties(media, display));
|
||||
*/
|
||||
.AfterMap(AfterMap);
|
||||
|
||||
//FROM IMedia TO ContentItemBasic<ContentPropertyBasic, IMedia>
|
||||
config.CreateMap<IMedia, ContentItemBasic<ContentPropertyBasic, IMedia>>()
|
||||
@@ -59,8 +63,15 @@ namespace Umbraco.Web.Models.Mapping
|
||||
expression => expression.ResolveUsing<OwnerResolver<IMedia>>());
|
||||
}
|
||||
|
||||
private static void MapGenericCustomProperties(IMedia media, MediaItemDisplay display)
|
||||
private static void AfterMap(IMedia media, MediaItemDisplay display)
|
||||
{
|
||||
//map the tree node url
|
||||
if (HttpContext.Current != null)
|
||||
{
|
||||
var urlHelper = new UrlHelper(new RequestContext(new HttpContextWrapper(HttpContext.Current), new RouteData()));
|
||||
var url = urlHelper.GetUmbracoApiService<MediaTreeController>(controller => controller.GetTreeNode(display.Id.ToString(), null));
|
||||
display.TreeNodeUrl = url;
|
||||
}
|
||||
|
||||
if (media.ContentType.IsContainer)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user