Gets the IsSensitive property mapped to the display object and changes the property output to show that the field contains sensitive data. Refactors the TabsAndPropertiesResolver and simplifies it a lot which also allows us to pass in an UmbracoContext which we'll need in order to determine a user's rights, etc... Refactors how the TreeNodeUrls are mapped and they now use a proper mapper. This now means we do much less in AfterMap

This commit is contained in:
Shannon
2018-01-25 14:14:12 -07:00
parent b49db0e941
commit 64628c0a9d
19 changed files with 458 additions and 288 deletions

View File

@@ -0,0 +1,34 @@
using System.Web.Mvc;
using AutoMapper;
using Umbraco.Core.Models;
using Umbraco.Web.Trees;
namespace Umbraco.Web.Models.Mapping
{
/// <summary>
/// Gets the tree node url for the content or media
/// </summary>
internal class ContentTreeNodeUrlResolver<TSource, TController> : IValueResolver
where TSource : IContentBase
where TController : ContentTreeControllerBase
{
public ResolutionResult Resolve(ResolutionResult source)
{
return source.New(ResolveCore(source, (TSource)source.Value), typeof(string));
}
private string ResolveCore(ResolutionResult res, TSource source)
{
var umbCtx = res.GetUmbracoContext();
//map the tree node url
if (umbCtx != null)
{
var urlHelper = new UrlHelper(umbCtx.HttpContext.Request.RequestContext);
var url = urlHelper.GetUmbracoApiService<TController>(controller => controller.GetTreeNode(source.Key.ToString("N"), null));
return url;
}
return null;
}
}
}