From ef091e8c3a2f3026526ee8f4bc5d2c6e4303071e Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 22 Oct 2015 23:41:18 +0200 Subject: [PATCH 1/2] U4-7296 http://issues.umbraco.org/issue/U4-7296 --- .../urllist/urllist.controller.js | 1 + .../propertyeditors/urllist/urllist.html | 10 +++++- .../ContentEditing/ContentPropertyDisplay.cs | 3 ++ .../Models/Mapping/ContentModelMapper.cs | 35 ++++++++++++++----- .../Mapping/TabsAndPropertiesResolver.cs | 8 ----- 5 files changed, 40 insertions(+), 17 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/urllist/urllist.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/urllist/urllist.controller.js index 65b3aed589..43587839ab 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/urllist/urllist.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/urllist/urllist.controller.js @@ -5,6 +5,7 @@ angular.module('umbraco').controller("Umbraco.PropertyEditors.UrlListController" $scope.renderModel = _.map($scope.model.value.split(","), function (item) { return { url: item, + linkText: $scope.model.linkText, urlTarget: ($scope.config && $scope.config.target) ? $scope.config.target : "_blank" }; }); diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/urllist/urllist.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/urllist/urllist.html index f26f4dd9c1..6766e7b39c 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/urllist/urllist.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/urllist/urllist.html @@ -1,7 +1,15 @@ 
\ No newline at end of file diff --git a/src/Umbraco.Web/Models/ContentEditing/ContentPropertyDisplay.cs b/src/Umbraco.Web/Models/ContentEditing/ContentPropertyDisplay.cs index a563910d4f..bd995f827b 100644 --- a/src/Umbraco.Web/Models/ContentEditing/ContentPropertyDisplay.cs +++ b/src/Umbraco.Web/Models/ContentEditing/ContentPropertyDisplay.cs @@ -35,5 +35,8 @@ namespace Umbraco.Web.Models.ContentEditing [DataMember(Name = "validation")] public PropertyTypeValidation Validation { get; set; } + + [DataMember(Name = "linkText")] + public string LinkText { get; set; } } } \ No newline at end of file diff --git a/src/Umbraco.Web/Models/Mapping/ContentModelMapper.cs b/src/Umbraco.Web/Models/Mapping/ContentModelMapper.cs index 0c7dbffd49..f332f7bd8d 100644 --- a/src/Umbraco.Web/Models/Mapping/ContentModelMapper.cs +++ b/src/Umbraco.Web/Models/Mapping/ContentModelMapper.cs @@ -2,22 +2,16 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; -using System.Linq.Expressions; -using System.Runtime.Serialization; -using System.Threading; using System.Web; using System.Web.Mvc; using System.Web.Routing; using AutoMapper; -using Newtonsoft.Json; using Umbraco.Core; using Umbraco.Core.Models; using Umbraco.Core.Models.Mapping; -using Umbraco.Core.PropertyEditors; using Umbraco.Core.Services; using Umbraco.Web.Models.ContentEditing; using Umbraco.Web.Trees; -using umbraco; using Umbraco.Web.Routing; using umbraco.BusinessLogic.Actions; @@ -78,7 +72,8 @@ namespace Umbraco.Web.Models.Mapping .ForMember(display => display.Tabs, expression => expression.ResolveUsing()) .ForMember(display => display.AllowedActions, expression => expression.ResolveUsing( new ActionButtonsResolver(new Lazy(() => applicationContext.Services.UserService)))) - .AfterMap((media, display) => AfterMap(media, display, applicationContext.Services.DataTypeService, applicationContext.Services.TextService)); + .AfterMap((media, display) => AfterMap(media, display, applicationContext.Services.DataTypeService, applicationContext.Services.TextService, + applicationContext.Services.ContentTypeService, applicationContext.Services.UserService)); //FROM IContent TO ContentItemBasic config.CreateMap>() @@ -119,7 +114,10 @@ namespace Umbraco.Web.Models.Mapping /// /// /// - private static void AfterMap(IContent content, ContentItemDisplay display, IDataTypeService dataTypeService, ILocalizedTextService localizedText) + /// + /// + private static void AfterMap(IContent content, ContentItemDisplay display, IDataTypeService dataTypeService, ILocalizedTextService localizedText, + IContentTypeService contentTypeService, IUserService userService) { //map the tree node url if (HttpContext.Current != null) @@ -142,8 +140,29 @@ namespace Umbraco.Web.Models.Mapping TabsAndPropertiesResolver.AddListView(display, "content", dataTypeService); } + var currentDocumentType = contentTypeService.GetContentType(display.ContentTypeAlias); + var currentDocumentTypeName = currentDocumentType == null ? String.Empty : currentDocumentType.Name; + var docTypeValue = String.Empty; + +#if (DEBUG) + var currentUser = userService.GetUserById(UmbracoContext.Current.Security.CurrentUser.Id); + if (currentUser.AllowedSections.Any(x => x.Equals("settings"))) + { + var currentDocumentTypeId = currentDocumentType == null ? String.Empty : currentDocumentType.Id.ToString(CultureInfo.InvariantCulture); + docTypeValue = string.Format("#/settings/framed/%252Fumbraco%252Fsettings%252FeditNodeTypeNew.aspx%253Fid%253D{0}", currentDocumentTypeId); + } +#endif + TabsAndPropertiesResolver.MapGenericProperties( content, display, + new ContentPropertyDisplay + { + Alias = string.Format("{0}doctype", Constants.PropertyEditors.InternalGenericPropertiesPrefix), + Label = localizedText.Localize("content/documentType"), + Value = docTypeValue, + LinkText = currentDocumentTypeName, + View = "urllist" //TODO: Hard coding this because the templatepicker doesn't necessarily need to be a resolvable (real) property editor + }, new ContentPropertyDisplay { Alias = string.Format("{0}releasedate", Constants.PropertyEditors.InternalGenericPropertiesPrefix), diff --git a/src/Umbraco.Web/Models/Mapping/TabsAndPropertiesResolver.cs b/src/Umbraco.Web/Models/Mapping/TabsAndPropertiesResolver.cs index 325b8df3e3..8948bcc371 100644 --- a/src/Umbraco.Web/Models/Mapping/TabsAndPropertiesResolver.cs +++ b/src/Umbraco.Web/Models/Mapping/TabsAndPropertiesResolver.cs @@ -4,7 +4,6 @@ using System.Linq; using AutoMapper; using Umbraco.Core; using Umbraco.Core.Dictionary; -using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.PropertyEditors; using Umbraco.Core.Services; @@ -91,13 +90,6 @@ namespace Umbraco.Web.Models.Mapping Description = ui.Text("content", "updateDateDesc"), Value = display.UpdateDate.ToIsoString(), View = labelEditor - }, - new ContentPropertyDisplay - { - Alias = string.Format("{0}doctype", Constants.PropertyEditors.InternalGenericPropertiesPrefix), - Label = ui.Text("content", "documentType"), - Value = TranslateItem(display.ContentTypeName, CreateDictionary()), - View = labelEditor } }; From 738815170c40007a48ad5cdbd569e359ef1a3092 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 23 Oct 2015 00:21:42 +0200 Subject: [PATCH 2/2] more nullchecks needed? null check that we can access user --- .../Models/Mapping/ContentModelMapper.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.Web/Models/Mapping/ContentModelMapper.cs b/src/Umbraco.Web/Models/Mapping/ContentModelMapper.cs index f332f7bd8d..d1141738b2 100644 --- a/src/Umbraco.Web/Models/Mapping/ContentModelMapper.cs +++ b/src/Umbraco.Web/Models/Mapping/ContentModelMapper.cs @@ -73,7 +73,8 @@ namespace Umbraco.Web.Models.Mapping .ForMember(display => display.AllowedActions, expression => expression.ResolveUsing( new ActionButtonsResolver(new Lazy(() => applicationContext.Services.UserService)))) .AfterMap((media, display) => AfterMap(media, display, applicationContext.Services.DataTypeService, applicationContext.Services.TextService, - applicationContext.Services.ContentTypeService, applicationContext.Services.UserService)); + applicationContext.Services.ContentTypeService, applicationContext.Services.UserService, + UmbracoContext.Current != null && UmbracoContext.Current.Security.CurrentUser != null)); //FROM IContent TO ContentItemBasic config.CreateMap>() @@ -116,8 +117,9 @@ namespace Umbraco.Web.Models.Mapping /// /// /// + /// private static void AfterMap(IContent content, ContentItemDisplay display, IDataTypeService dataTypeService, ILocalizedTextService localizedText, - IContentTypeService contentTypeService, IUserService userService) + IContentTypeService contentTypeService, IUserService userService, Boolean canAccessUser) { //map the tree node url if (HttpContext.Current != null) @@ -145,11 +147,14 @@ namespace Umbraco.Web.Models.Mapping var docTypeValue = String.Empty; #if (DEBUG) - var currentUser = userService.GetUserById(UmbracoContext.Current.Security.CurrentUser.Id); - if (currentUser.AllowedSections.Any(x => x.Equals("settings"))) + if (canAccessUser) { - var currentDocumentTypeId = currentDocumentType == null ? String.Empty : currentDocumentType.Id.ToString(CultureInfo.InvariantCulture); - docTypeValue = string.Format("#/settings/framed/%252Fumbraco%252Fsettings%252FeditNodeTypeNew.aspx%253Fid%253D{0}", currentDocumentTypeId); + var currentUser = userService.GetUserById(UmbracoContext.Current.Security.CurrentUser.Id); + if (currentUser.AllowedSections.Any(x => x.Equals("settings"))) + { + var currentDocumentTypeId = currentDocumentType == null ? String.Empty : currentDocumentType.Id.ToString(CultureInfo.InvariantCulture); + docTypeValue = string.Format("#/settings/framed/%252Fumbraco%252Fsettings%252FeditNodeTypeNew.aspx%253Fid%253D{0}", currentDocumentTypeId); + } } #endif