diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbcontentnodeinfo.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbcontentnodeinfo.directive.js index 5f9917a018..fea44d126b 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbcontentnodeinfo.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbcontentnodeinfo.directive.js @@ -27,10 +27,10 @@ }; // get available templates - scope.availableTemplates = getAvailableTemplates(scope.node); + scope.availableTemplates = scope.node.allowedTemplates.items; // get document type details - scope.documentType = getDocumentType(scope.node); + scope.documentType = scope.node.docTypeValue[0]; loadAuditTrail(); @@ -111,40 +111,6 @@ }); } - function getAvailableTemplates(node) { - - var availableTemplates = {}; - - // find the templates in the properties array - angular.forEach(node.properties, function (property) { - if (property.alias === "_umb_template") { - if (property.config && property.config.items) { - availableTemplates = property.config.items; - } - } - }); - - return availableTemplates; - - } - - function getDocumentType(node) { - - var documentType = {}; - - // find the document type in the properties array - angular.forEach(node.properties, function (property) { - if (property.alias === "_umb_doctype") { - if (property.value && property.value.length > 0) { - documentType = property.value[0]; - } - } - }); - - return documentType; - - } - function setPublishDate(date) { // update publish value diff --git a/src/Umbraco.Web/Models/ContentEditing/ContentItemDisplay.cs b/src/Umbraco.Web/Models/ContentEditing/ContentItemDisplay.cs index 197f5e88d1..23331a6ce0 100644 --- a/src/Umbraco.Web/Models/ContentEditing/ContentItemDisplay.cs +++ b/src/Umbraco.Web/Models/ContentEditing/ContentItemDisplay.cs @@ -29,8 +29,11 @@ namespace Umbraco.Web.Models.ContentEditing [DataMember(Name = "template")] public string TemplateAlias { get; set; } - [DataMember(Name = "allowedTemplates")] - public object TemplateConfig { get; set; } + [DataMember(Name = "allowedTemplates")] + public object AllowedTemplates { get; set; } + + [DataMember(Name = "docTypeValue")] + public object DocTypeValue { get; set; } [DataMember(Name = "urls")] public string[] Urls { get; set; } diff --git a/src/Umbraco.Web/Models/Mapping/ContentModelMapper.cs b/src/Umbraco.Web/Models/Mapping/ContentModelMapper.cs index 68448ba4de..01a74baf74 100644 --- a/src/Umbraco.Web/Models/Mapping/ContentModelMapper.cs +++ b/src/Umbraco.Web/Models/Mapping/ContentModelMapper.cs @@ -38,12 +38,11 @@ namespace Umbraco.Web.Models.Mapping .ForMember(display => display.Trashed, expression => expression.MapFrom(content => content.Trashed)) .ForMember(display => display.PublishDate, expression => expression.MapFrom(content => GetPublishedDate(content))) .ForMember(display => display.TemplateAlias, expression => expression.MapFrom(content => content.Template.Alias)) - .ForMember(display => display.TemplateConfig, expression => expression.ResolveUsing(content => AvailableTemplates(content, applicationContext.Services.TextService))) .ForMember(display => display.HasPublishedVersion, expression => expression.MapFrom(content => content.HasPublishedVersion)) .ForMember(display => display.Urls, expression => expression.MapFrom(content => UmbracoContext.Current == null - ? new[] {"Cannot generate urls without a current Umbraco Context"} + ? new[] { "Cannot generate urls without a current Umbraco Context" } : content.GetContentUrls(UmbracoContext.Current))) .ForMember(display => display.Properties, expression => expression.Ignore()) .ForMember(display => display.AllowPreview, expression => expression.Ignore()) @@ -107,20 +106,22 @@ namespace Umbraco.Web.Models.Mapping display.TreeNodeUrl = url; } + //fill in the template config to be passed to the template drop down. + var templateItemConfig = new Dictionary { { "", localizedText.Localize("general/choose") } }; + foreach (var t in content.ContentType.AllowedTemplates + .Where(t => t.Alias.IsNullOrWhiteSpace() == false && t.Name.IsNullOrWhiteSpace() == false)) + { + templateItemConfig.Add(t.Alias, t.Name); + } + + if (content.ContentType.IsContainer) { TabsAndPropertiesResolver.AddListView(display, "content", dataTypeService, localizedText); } var properties = new List - { - new ContentPropertyDisplay - { - Alias = string.Format("{0}doctype", Constants.PropertyEditors.InternalGenericPropertiesPrefix), - Label = localizedText.Localize("content/documentType"), - Value = localizedText.UmbracoDictionaryTranslate(display.ContentTypeName), - View = PropertyEditorResolver.Current.GetByAlias(Constants.PropertyEditors.NoEditAlias).ValueEditor.View - }, + { new ContentPropertyDisplay { Alias = string.Format("{0}releasedate", Constants.PropertyEditors.InternalGenericPropertiesPrefix), @@ -147,17 +148,7 @@ namespace Umbraco.Web.Models.Mapping } //TODO: Fix up hard coded datepicker }, - new ContentPropertyDisplay - { - Alias = string.Format("{0}template", Constants.PropertyEditors.InternalGenericPropertiesPrefix), - Label = localizedText.Localize("template/template"), - Value = display.TemplateAlias, - View = "dropdown", //TODO: Hard coding until we make a real dropdown property editor to lookup - Config = new Dictionary - { - {"items", ""} - } - } + }; @@ -177,8 +168,30 @@ namespace Umbraco.Web.Models.Mapping //TODO: Hard coding this is not good var docTypeLink = string.Format("#/settings/documenttypes/edit/{0}", currentDocumentTypeId); + var templateProperty = new ContentPropertyDisplay + { + Alias = string.Format("{0}template", + Constants.PropertyEditors.InternalGenericPropertiesPrefix), + Label = localizedText.Localize("template/template"), + Value = display.TemplateAlias, + View = + "dropdown", //TODO: Hard coding until we make a real dropdown property editor to lookup + Config = new Dictionary + { + {"items", templateItemConfig} + } + }; + //Replace the doc type property - var docTypeProperty = genericProperties.First(x => x.Alias == string.Format("{0}doctype", Constants.PropertyEditors.InternalGenericPropertiesPrefix)); + var docTypeProperty = new ContentPropertyDisplay + { + Alias = string.Format("{0}doctype", + Constants.PropertyEditors.InternalGenericPropertiesPrefix), + Label = localizedText.Localize("content/documentType"), + Value = localizedText.UmbracoDictionaryTranslate(display.ContentTypeName), + View = PropertyEditorResolver.Current.GetByAlias(Constants.PropertyEditors.NoEditAlias) + .ValueEditor.View + }; docTypeProperty.Value = new List { new @@ -190,10 +203,14 @@ namespace Umbraco.Web.Models.Mapping } }; //TODO: Hard coding this because the templatepicker doesn't necessarily need to be a resolvable (real) property editor - docTypeProperty.View = "urllist"; - } - - // inject 'Link to document' as the first generic property + docTypeProperty.View = "urllist"; + + //Moving template and docType properties to the root node (issue U4-10311) + display.AllowedTemplates = templateProperty.Config; + display.DocTypeValue = docTypeProperty.Value; + } + + // inject 'Link to document' as the first generic property genericProperties.Insert(0, new ContentPropertyDisplay { Alias = string.Format("{0}urls", Constants.PropertyEditors.InternalGenericPropertiesPrefix), @@ -238,19 +255,5 @@ namespace Umbraco.Web.Models.Mapping return permissions; } } - - - private static Dictionary AvailableTemplates(IContent content, ILocalizedTextService localizedText) - { - //fill in the template config to be passed to the template drop down. - var templateItemConfig = new Dictionary { { "", localizedText.Localize("general/choose") } }; - foreach (var t in content.ContentType.AllowedTemplates - .Where(t => t.Alias.IsNullOrWhiteSpace() == false && t.Name.IsNullOrWhiteSpace() == false)) - { - templateItemConfig.Add(t.Alias, t.Name); - } - - return templateItemConfig; - } } } \ No newline at end of file