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 43587839ab..2637d23f69 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 @@ -1,14 +1,29 @@ angular.module('umbraco').controller("Umbraco.PropertyEditors.UrlListController", function($rootScope, $scope, $filter) { - function formatDisplayValue() { - $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" - }; - }); + function formatDisplayValue() { + if (angular.isArray($scope.model.value)) { + //it's the json value + $scope.renderModel = _.map($scope.model.value, function (item) { + return { + url: item.url, + linkText: item.linkText, + urlTarget: (item.target) ? item.target : "_blank", + icon: (item.icon) ? item.icon : "icon-out" + }; + }); + } + else { + //it's the default csv value + $scope.renderModel = _.map($scope.model.value.split(","), function (item) { + return { + url: item, + linkText: "", + urlTarget: ($scope.config && $scope.config.target) ? $scope.config.target : "_blank", + icon: ($scope.config && $scope.config.icon) ? $scope.config.icon : "icon-out" + }; + }); + } } $scope.getUrl = function(valueUrl) { 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 6766e7b39c..f154a2a7b9 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,15 +1,11 @@ 
\ 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 bd995f827b..343b018000 100644 --- a/src/Umbraco.Web/Models/ContentEditing/ContentPropertyDisplay.cs +++ b/src/Umbraco.Web/Models/ContentEditing/ContentPropertyDisplay.cs @@ -34,9 +34,6 @@ namespace Umbraco.Web.Models.ContentEditing public bool HideLabel { get; set; } [DataMember(Name = "validation")] - public PropertyTypeValidation Validation { get; set; } - - [DataMember(Name = "linkText")] - public string LinkText { get; set; } + public PropertyTypeValidation Validation { 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 d1141738b2..293cc4f1d8 100644 --- a/src/Umbraco.Web/Models/Mapping/ContentModelMapper.cs +++ b/src/Umbraco.Web/Models/Mapping/ContentModelMapper.cs @@ -73,8 +73,7 @@ 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, - UmbracoContext.Current != null && UmbracoContext.Current.Security.CurrentUser != null)); + applicationContext.Services.ContentTypeService)); //FROM IContent TO ContentItemBasic config.CreateMap>() @@ -116,10 +115,8 @@ namespace Umbraco.Web.Models.Mapping /// /// /// - /// - /// - private static void AfterMap(IContent content, ContentItemDisplay display, IDataTypeService dataTypeService, ILocalizedTextService localizedText, - IContentTypeService contentTypeService, IUserService userService, Boolean canAccessUser) + private static void AfterMap(IContent content, ContentItemDisplay display, IDataTypeService dataTypeService, + ILocalizedTextService localizedText, IContentTypeService contentTypeService) { //map the tree node url if (HttpContext.Current != null) @@ -142,68 +139,77 @@ 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) - if (canAccessUser) + var properties = new List { - var currentUser = userService.GetUserById(UmbracoContext.Current.Security.CurrentUser.Id); - if (currentUser.AllowedSections.Any(x => x.Equals("settings"))) + new ContentPropertyDisplay { - var currentDocumentTypeId = currentDocumentType == null ? String.Empty : currentDocumentType.Id.ToString(CultureInfo.InvariantCulture); - docTypeValue = string.Format("#/settings/framed/%252Fumbraco%252Fsettings%252FeditNodeTypeNew.aspx%253Fid%253D{0}", currentDocumentTypeId); + Alias = string.Format("{0}releasedate", Constants.PropertyEditors.InternalGenericPropertiesPrefix), + Label = localizedText.Localize("content/releaseDate"), + Value = display.ReleaseDate.HasValue ? display.ReleaseDate.Value.ToIsoString() : null, + View = "datepicker" //TODO: Hard coding this because the templatepicker doesn't necessarily need to be a resolvable (real) property editor + }, + new ContentPropertyDisplay + { + Alias = string.Format("{0}expiredate", Constants.PropertyEditors.InternalGenericPropertiesPrefix), + Label = localizedText.Localize("content/unpublishDate"), + Value = display.ExpireDate.HasValue ? display.ExpireDate.Value.ToIsoString() : null, + View = "datepicker" //TODO: Hard coding this because the templatepicker doesn't necessarily need to be a resolvable (real) property editor + }, + new ContentPropertyDisplay + { + Alias = string.Format("{0}template", Constants.PropertyEditors.InternalGenericPropertiesPrefix), + Label = "Template", //TODO: localize this? + Value = display.TemplateAlias, + View = "dropdown", //TODO: Hard coding until we make a real dropdown property editor to lookup + Config = new Dictionary + { + {"items", templateItemConfig} + } + }, + new ContentPropertyDisplay + { + Alias = string.Format("{0}urls", Constants.PropertyEditors.InternalGenericPropertiesPrefix), + Label = localizedText.Localize("content/urls"), + Value = string.Join(",", display.Urls), + View = "urllist" //TODO: Hard coding this because the templatepicker doesn't necessarily need to be a resolvable (real) property editor } - } -#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 + TabsAndPropertiesResolver.MapGenericProperties(content, display, properties.ToArray(), + genericProperties => + { + //TODO: This would be much nicer with the IUmbracoContextAccessor so we don't use singletons + //If this is a web request and debugging is enabled and there's a user signed in and the + // user has access tot he settings section, we will + if (HttpContext.Current != null && HttpContext.Current.IsDebuggingEnabled + && UmbracoContext.Current != null && UmbracoContext.Current.Security.CurrentUser != null + && UmbracoContext.Current.Security.CurrentUser.AllowedSections.Any(x => x.Equals(Constants.Applications.Settings))) { - Alias = string.Format("{0}releasedate", Constants.PropertyEditors.InternalGenericPropertiesPrefix), - Label = localizedText.Localize("content/releaseDate"), - Value = display.ReleaseDate.HasValue ? display.ReleaseDate.Value.ToIsoString() : null, - View = "datepicker" //TODO: Hard coding this because the templatepicker doesn't necessarily need to be a resolvable (real) property editor - }, - new ContentPropertyDisplay - { - Alias = string.Format("{0}expiredate", Constants.PropertyEditors.InternalGenericPropertiesPrefix), - Label = localizedText.Localize("content/unpublishDate"), - Value = display.ExpireDate.HasValue ? display.ExpireDate.Value.ToIsoString() : null, - View = "datepicker" //TODO: Hard coding this because the templatepicker doesn't necessarily need to be a resolvable (real) property editor - }, - new ContentPropertyDisplay - { - Alias = string.Format("{0}template", Constants.PropertyEditors.InternalGenericPropertiesPrefix), - Label = "Template", //TODO: localize this? - Value = display.TemplateAlias, - View = "dropdown", //TODO: Hard coding until we make a real dropdown property editor to lookup - Config = new Dictionary + var currentDocumentType = contentTypeService.GetContentType(display.ContentTypeAlias); + var currentDocumentTypeName = currentDocumentType == null ? string.Empty : currentDocumentType.Name; + + var currentDocumentTypeId = currentDocumentType == null ? string.Empty : currentDocumentType.Id.ToString(CultureInfo.InvariantCulture); + //TODO: Hard coding this is not good + var docTypeLink = string.Format("#/settings/framed/%252Fumbraco%252Fsettings%252FeditNodeTypeNew.aspx%253Fid%253D{0}", currentDocumentTypeId); + + //Replace the doc type property + var docTypeProp = genericProperties.First(x => x.Alias == string.Format("{0}doctype", Constants.PropertyEditors.InternalGenericPropertiesPrefix)); + docTypeProp.Value = new List + { + new { - {"items", templateItemConfig} + linkText = currentDocumentTypeName, + url = docTypeLink, + target = "_self", icon = "icon-item-arrangement" } - }, - new ContentPropertyDisplay - { - Alias = string.Format("{0}urls", Constants.PropertyEditors.InternalGenericPropertiesPrefix), - Label = localizedText.Localize("content/urls"), - Value = string.Join(",", display.Urls), - View = "urllist" //TODO: Hard coding this because the templatepicker doesn't necessarily need to be a resolvable (real) property editor - }); + }; + //TODO: Hard coding this because the templatepicker doesn't necessarily need to be a resolvable (real) property editor + docTypeProp.View = "urllist"; + } + }); + } - - /// /// Gets the published date value for the IContent object /// diff --git a/src/Umbraco.Web/Models/Mapping/MemberModelMapper.cs b/src/Umbraco.Web/Models/Mapping/MemberModelMapper.cs index d2558d0451..6b033f4a01 100644 --- a/src/Umbraco.Web/Models/Mapping/MemberModelMapper.cs +++ b/src/Umbraco.Web/Models/Mapping/MemberModelMapper.cs @@ -178,45 +178,48 @@ namespace Umbraco.Web.Models.Mapping display.TreeNodeUrl = url; } - TabsAndPropertiesResolver.MapGenericProperties( - member, display, + var genericProperties = new List + { GetLoginProperty(memberService, member, display), new ContentPropertyDisplay - { - Alias = string.Format("{0}email", Constants.PropertyEditors.InternalGenericPropertiesPrefix), - Label = ui.Text("general", "email"), - Value = display.Email, - View = "email", - Validation = { Mandatory = true } - }, + { + Alias = string.Format("{0}email", Constants.PropertyEditors.InternalGenericPropertiesPrefix), + Label = ui.Text("general", "email"), + Value = display.Email, + View = "email", + Validation = {Mandatory = true} + }, new ContentPropertyDisplay + { + Alias = string.Format("{0}password", Constants.PropertyEditors.InternalGenericPropertiesPrefix), + Label = ui.Text("password"), + //NOTE: The value here is a json value - but the only property we care about is the generatedPassword one if it exists, the newPassword exists + // only when creating a new member and we want to have a generated password pre-filled. + Value = new Dictionary { - Alias = string.Format("{0}password", Constants.PropertyEditors.InternalGenericPropertiesPrefix), - Label = ui.Text("password"), - //NOTE: The value here is a json value - but the only property we care about is the generatedPassword one if it exists, the newPassword exists - // only when creating a new member and we want to have a generated password pre-filled. - Value = new Dictionary - { - {"generatedPassword", member.GetAdditionalDataValueIgnoreCase("GeneratedPassword", null) }, - {"newPassword", member.GetAdditionalDataValueIgnoreCase("NewPassword", null) }, - }, - //TODO: Hard coding this because the changepassword doesn't necessarily need to be a resolvable (real) property editor - View = "changepassword", - //initialize the dictionary with the configuration from the default membership provider - Config = new Dictionary(membersProvider.GetConfiguration()) - { - //the password change toggle will only be displayed if there is already a password assigned. - {"hasPassword", member.RawPasswordValue.IsNullOrWhiteSpace() == false} - } + {"generatedPassword", member.GetAdditionalDataValueIgnoreCase("GeneratedPassword", null)}, + {"newPassword", member.GetAdditionalDataValueIgnoreCase("NewPassword", null)}, }, - new ContentPropertyDisplay + //TODO: Hard coding this because the changepassword doesn't necessarily need to be a resolvable (real) property editor + View = "changepassword", + //initialize the dictionary with the configuration from the default membership provider + Config = new Dictionary(membersProvider.GetConfiguration()) { - Alias = string.Format("{0}membergroup", Constants.PropertyEditors.InternalGenericPropertiesPrefix), - Label = ui.Text("content", "membergroup"), - Value = GetMemberGroupValue(display.Username), - View = "membergroups", - Config = new Dictionary { { "IsRequired", true } } - }); + //the password change toggle will only be displayed if there is already a password assigned. + {"hasPassword", member.RawPasswordValue.IsNullOrWhiteSpace() == false} + } + }, + new ContentPropertyDisplay + { + Alias = string.Format("{0}membergroup", Constants.PropertyEditors.InternalGenericPropertiesPrefix), + Label = ui.Text("content", "membergroup"), + Value = GetMemberGroupValue(display.Username), + View = "membergroups", + Config = new Dictionary {{"IsRequired", true}} + } + }; + + TabsAndPropertiesResolver.MapGenericProperties(member, display, genericProperties); //check if there's an approval field var provider = membersProvider as global::umbraco.providers.members.UmbracoMembershipProvider; diff --git a/src/Umbraco.Web/Models/Mapping/TabsAndPropertiesResolver.cs b/src/Umbraco.Web/Models/Mapping/TabsAndPropertiesResolver.cs index 8948bcc371..ecf5e2da42 100644 --- a/src/Umbraco.Web/Models/Mapping/TabsAndPropertiesResolver.cs +++ b/src/Umbraco.Web/Models/Mapping/TabsAndPropertiesResolver.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; +using System.Web; using AutoMapper; using Umbraco.Core; using Umbraco.Core.Dictionary; @@ -16,7 +18,7 @@ namespace Umbraco.Web.Models.Mapping /// Creates the tabs collection with properties assigned for display models /// internal class TabsAndPropertiesResolver : ValueResolver>> - { + { private ICultureDictionary _cultureDictionary; protected IEnumerable IgnoreProperties { get; set; } @@ -26,7 +28,7 @@ namespace Umbraco.Web.Models.Mapping } public TabsAndPropertiesResolver(IEnumerable ignoreProperties) - { + { if (ignoreProperties == null) throw new ArgumentNullException("ignoreProperties"); IgnoreProperties = ignoreProperties; } @@ -39,6 +41,7 @@ namespace Umbraco.Web.Models.Mapping /// /// Any additional custom properties to assign to the generic properties tab. /// + /// /// /// The generic properties tab is mapped during AfterMap and is responsible for /// setting up the properties such as Created date, updated date, template selected, etc... @@ -46,11 +49,10 @@ namespace Umbraco.Web.Models.Mapping public static void MapGenericProperties( TPersisted content, ContentItemDisplayBase display, - params ContentPropertyDisplay[] customProperties) + IEnumerable customProperties = null, + Action> onGenericPropertiesMapped = null) where TPersisted : IContentBase { - - var genericProps = display.Tabs.Single(x => x.Id == 0); //store the current props to append to the newly inserted ones @@ -59,49 +61,67 @@ namespace Umbraco.Web.Models.Mapping var labelEditor = PropertyEditorResolver.Current.GetByAlias(Constants.PropertyEditors.NoEditAlias).ValueEditor.View; var contentProps = new List + { + new ContentPropertyDisplay { - new ContentPropertyDisplay - { - Alias = string.Format("{0}id", Constants.PropertyEditors.InternalGenericPropertiesPrefix), - Label = "Id", - Value = Convert.ToInt32(display.Id).ToInvariantString() + "
" + display.Key + "", - View = labelEditor - }, - new ContentPropertyDisplay - { - Alias = string.Format("{0}creator", Constants.PropertyEditors.InternalGenericPropertiesPrefix), - Label = ui.Text("content", "createBy"), - Description = ui.Text("content", "createByDesc"), //TODO: Localize this - Value = display.Owner.Name, - View = labelEditor - }, - new ContentPropertyDisplay - { - Alias = string.Format("{0}createdate", Constants.PropertyEditors.InternalGenericPropertiesPrefix), - Label = ui.Text("content", "createDate"), - Description = ui.Text("content", "createDateDesc"), - Value = display.CreateDate.ToIsoString(), - View = labelEditor - }, - new ContentPropertyDisplay - { - Alias = string.Format("{0}updatedate", Constants.PropertyEditors.InternalGenericPropertiesPrefix), - Label = ui.Text("content", "updateDate"), - Description = ui.Text("content", "updateDateDesc"), - Value = display.UpdateDate.ToIsoString(), - View = labelEditor - } - }; + Alias = string.Format("{0}id", Constants.PropertyEditors.InternalGenericPropertiesPrefix), + Label = "Id", + Value = Convert.ToInt32(display.Id).ToInvariantString() + "
" + display.Key + "", + View = labelEditor + }, + new ContentPropertyDisplay + { + Alias = string.Format("{0}creator", Constants.PropertyEditors.InternalGenericPropertiesPrefix), + Label = ui.Text("content", "createBy"), + Description = ui.Text("content", "createByDesc"), //TODO: Localize this + Value = display.Owner.Name, + View = labelEditor + }, + new ContentPropertyDisplay + { + Alias = string.Format("{0}createdate", Constants.PropertyEditors.InternalGenericPropertiesPrefix), + Label = ui.Text("content", "createDate"), + Description = ui.Text("content", "createDateDesc"), + Value = display.CreateDate.ToIsoString(), + View = labelEditor + }, + new ContentPropertyDisplay + { + Alias = string.Format("{0}updatedate", Constants.PropertyEditors.InternalGenericPropertiesPrefix), + Label = ui.Text("content", "updateDate"), + 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 + } + }; - //add the custom ones - contentProps.AddRange(customProperties); + if (customProperties != null) + { + //add the custom ones + contentProps.AddRange(customProperties); + } //now add the user props contentProps.AddRange(currProps); + //callback + if (onGenericPropertiesMapped != null) + { + onGenericPropertiesMapped(contentProps); + } + //re-assign genericProps.Properties = contentProps; + + } ///