Ensures internal generic properties are all wired up in c# and fixes up the boolean editor, adds templatepicker html file so that something is rendered and there are no js errors.
This commit is contained in:
@@ -17,6 +17,9 @@ namespace Umbraco.Web.Models.ContentEditing
|
||||
|
||||
[DataMember(Name = "publishDate")]
|
||||
public DateTime? PublishDate { get; set; }
|
||||
|
||||
[DataMember(Name = "template")]
|
||||
public string Template { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,12 @@ namespace Umbraco.Web.Models.ContentEditing
|
||||
Notifications = new List<Notification>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name of the content type
|
||||
/// </summary>
|
||||
[DataMember(Name = "contentTypeName")]
|
||||
public string ContentTypeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// This is used to add custom localized messages/strings to the response for the app to use for localized UI purposes.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
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;
|
||||
|
||||
namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Declares how model mappings for content
|
||||
/// </summary>
|
||||
@@ -15,6 +19,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
public override void ConfigureMappings(IConfiguration config, ApplicationContext applicationContext)
|
||||
{
|
||||
|
||||
//FROM IContent TO ContentItemDisplay
|
||||
config.CreateMap<IContent, ContentItemDisplay>()
|
||||
.ForMember(
|
||||
@@ -29,11 +34,24 @@ namespace Umbraco.Web.Models.Mapping
|
||||
.ForMember(
|
||||
dto => dto.ContentTypeAlias,
|
||||
expression => expression.MapFrom(content => content.ContentType.Alias))
|
||||
.ForMember(
|
||||
dto => dto.ContentTypeName,
|
||||
expression => expression.MapFrom(content => content.ContentType.Name))
|
||||
.ForMember(
|
||||
dto => dto.PublishDate,
|
||||
expression => expression.MapFrom(content => GetPublishedDate(content, applicationContext)))
|
||||
.ForMember(
|
||||
dto => dto.Template,
|
||||
expression => expression.MapFrom(content => content.Template.Name))
|
||||
.ForMember(display => display.Properties, expression => expression.Ignore())
|
||||
.ForMember(display => display.Tabs, expression => expression.ResolveUsing<TabsAndPropertiesResolver>());
|
||||
.ForMember(display => display.Tabs, expression => expression.ResolveUsing<TabsAndPropertiesResolver>())
|
||||
.AfterMap((content, display) => TabsAndPropertiesResolver.MapGenericProperties(content, display, new ContentPropertyDisplay
|
||||
{
|
||||
Alias = string.Format("{0}doctype", Constants.PropertyEditors.InternalGenericPropertiesPrefix),
|
||||
Label = "Template", //TODO: localize this?
|
||||
Value = display.Template,
|
||||
View = "templatepicker" //TODO: Hard coding this because the templatepicker doesn't necessarily need to be a resolvable (real) property editor
|
||||
}));
|
||||
|
||||
//FROM IContent TO ContentItemBasic<ContentPropertyBasic, IContent>
|
||||
config.CreateMap<IContent, ContentItemBasic<ContentPropertyBasic, IContent>>()
|
||||
|
||||
@@ -29,9 +29,13 @@ namespace Umbraco.Web.Models.Mapping
|
||||
expression => expression.MapFrom(content => content.ContentType.Icon))
|
||||
.ForMember(
|
||||
dto => dto.ContentTypeAlias,
|
||||
expression => expression.MapFrom(content => content.ContentType.Alias))
|
||||
expression => expression.MapFrom(content => content.ContentType.Alias))
|
||||
.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>());
|
||||
.ForMember(display => display.Tabs, expression => expression.ResolveUsing<TabsAndPropertiesResolver>())
|
||||
.AfterMap((media, display) => TabsAndPropertiesResolver.MapGenericProperties(media, display));
|
||||
|
||||
//FROM IMedia TO ContentItemBasic<ContentPropertyBasic, IMedia>
|
||||
config.CreateMap<IMedia, ContentItemBasic<ContentPropertyBasic, IMedia>>()
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using AutoMapper;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using umbraco;
|
||||
|
||||
namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
@@ -11,6 +15,83 @@ namespace Umbraco.Web.Models.Mapping
|
||||
/// </summary>
|
||||
internal class TabsAndPropertiesResolver : ValueResolver<IContentBase, IEnumerable<Tab<ContentPropertyDisplay>>>
|
||||
{
|
||||
/// <summary>
|
||||
/// Maps properties on to the generic properties tab
|
||||
/// </summary>
|
||||
/// <param name="content"></param>
|
||||
/// <param name="display"></param>
|
||||
/// <param name="customProperties">
|
||||
/// Any additional custom properties to assign to the generic properties tab.
|
||||
/// </param>
|
||||
/// <remarks>
|
||||
/// The generic properties tab is mapped during AfterMap and is responsible for
|
||||
/// setting up the properties such as Created date, udpated date, template selected, etc...
|
||||
/// </remarks>
|
||||
public static void MapGenericProperties<TPersisted>(
|
||||
TPersisted content,
|
||||
ContentItemDisplayBase<ContentPropertyDisplay, TPersisted> display,
|
||||
params ContentPropertyDisplay[] customProperties)
|
||||
where TPersisted : IContentBase
|
||||
{
|
||||
var genericProps = display.Tabs.Single(x => x.Id == 0);
|
||||
|
||||
//store the current props to append to the newly inserted ones
|
||||
var currProps = genericProps.Properties.ToArray();
|
||||
|
||||
var labelEditor = PropertyEditorResolver.Current.GetById(new Guid(Constants.PropertyEditors.NoEdit)).ValueEditor.View;
|
||||
|
||||
var contentProps = new List<ContentPropertyDisplay>
|
||||
{
|
||||
new ContentPropertyDisplay
|
||||
{
|
||||
Alias = string.Format("{0}creator", Constants.PropertyEditors.InternalGenericPropertiesPrefix),
|
||||
Label = ui.Text("content", "createBy"),
|
||||
Description = "Original author", //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 = "Time this document was created", //TODO: Localize this
|
||||
Value = display.CreateDate.ToIsoString(),
|
||||
View = labelEditor
|
||||
},
|
||||
new ContentPropertyDisplay
|
||||
{
|
||||
Alias = string.Format("{0}updatedate", Constants.PropertyEditors.InternalGenericPropertiesPrefix),
|
||||
Label = ui.Text("content", "updateDate"),
|
||||
Description = "Time this document was last updated", //TODO: Localize this
|
||||
Value = display.UpdateDate.ToIsoString(),
|
||||
View = labelEditor
|
||||
},
|
||||
new ContentPropertyDisplay
|
||||
{
|
||||
Alias = string.Format("{0}id", Constants.PropertyEditors.InternalGenericPropertiesPrefix),
|
||||
Label = "Id",
|
||||
Value = display.Id.ToInvariantString(),
|
||||
View = labelEditor
|
||||
},
|
||||
new ContentPropertyDisplay
|
||||
{
|
||||
Alias = string.Format("{0}doctype", Constants.PropertyEditors.InternalGenericPropertiesPrefix),
|
||||
Label = ui.Text("content", "documentType"),
|
||||
Value = display.ContentTypeName,
|
||||
View = labelEditor
|
||||
}
|
||||
};
|
||||
|
||||
//add the custom ones
|
||||
contentProps.AddRange(customProperties);
|
||||
|
||||
//now add the user props
|
||||
contentProps.AddRange(currProps);
|
||||
|
||||
//re-assign
|
||||
genericProps.Properties = contentProps;
|
||||
}
|
||||
|
||||
protected override IEnumerable<Tab<ContentPropertyDisplay>> ResolveCore(IContentBase content)
|
||||
{
|
||||
var aggregateTabs = new List<Tab<ContentPropertyDisplay>>();
|
||||
|
||||
10
src/Umbraco.Web/PropertyEditors/LabelPropertyEditor.cs
Normal file
10
src/Umbraco.Web/PropertyEditors/LabelPropertyEditor.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
|
||||
namespace Umbraco.Web.PropertyEditors
|
||||
{
|
||||
[PropertyEditor(Constants.PropertyEditors.NoEdit, "Label", "readonlyvalue")]
|
||||
public class LabelPropertyEditor : PropertyEditor
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,6 @@ using Umbraco.Core.PropertyEditors;
|
||||
|
||||
namespace Umbraco.Web.PropertyEditors
|
||||
{
|
||||
|
||||
[PropertyEditor(Constants.PropertyEditors.Textbox, "Textstring", "textstring")]
|
||||
public class TextStringPropertyEditor : PropertyEditor
|
||||
{
|
||||
|
||||
@@ -300,6 +300,7 @@
|
||||
<Compile Include="Editors\ContentController.cs" />
|
||||
<Compile Include="Editors\EntityController.cs" />
|
||||
<Compile Include="Models\PagedResult.cs" />
|
||||
<Compile Include="PropertyEditors\LabelPropertyEditor.cs" />
|
||||
<Compile Include="WebApi\ControllerContextExtensions.cs" />
|
||||
<Compile Include="WebApi\CustomDateTimeConvertor.cs" />
|
||||
<Compile Include="Models\ContentEditing\ContentSortOrder.cs" />
|
||||
|
||||
Reference in New Issue
Block a user