Get the generic property tab rendering properly with a url list as well.

This commit is contained in:
Shannon
2013-08-12 15:57:54 +10:00
parent 1e2af42ce6
commit 8525468312
11 changed files with 175 additions and 36 deletions

View File

@@ -18,8 +18,17 @@ namespace Umbraco.Web.Models.ContentEditing
[DataMember(Name = "publishDate")]
public DateTime? PublishDate { get; set; }
[DataMember(Name = "releaseDate")]
public DateTime? ReleaseDate { get; set; }
[DataMember(Name = "removeDate")]
public DateTime? RemoveDate { get; set; }
[DataMember(Name = "template")]
public string Template { get; set; }
[DataMember(Name = "urls")]
public string[] Urls { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using AutoMapper;
@@ -8,6 +9,7 @@ using Umbraco.Core.Models.Mapping;
using Umbraco.Core.PropertyEditors;
using Umbraco.Web.Models.ContentEditing;
using umbraco;
using Umbraco.Web.Routing;
namespace Umbraco.Web.Models.Mapping
{
@@ -40,18 +42,53 @@ namespace Umbraco.Web.Models.Mapping
.ForMember(
dto => dto.PublishDate,
expression => expression.MapFrom(content => GetPublishedDate(content, applicationContext)))
.ForMember(
.ForMember(
dto => dto.Template,
expression => expression.MapFrom(content => content.Template.Name))
.ForMember(
dto => dto.ReleaseDate,
expression => expression.MapFrom(content => content.ReleaseDate))
.ForMember(
dto => dto.RemoveDate,
expression => expression.MapFrom(content => content.ExpireDate))
.ForMember(
dto => dto.Urls,
expression => expression.MapFrom(content =>
UmbracoContext.Current == null
? new[] {"Cannot generate urls without a current Umbraco Context"}
: content.GetContentUrls()))
.ForMember(display => display.Properties, expression => expression.Ignore())
.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
}));
.AfterMap((content, display) => TabsAndPropertiesResolver.MapGenericProperties(
content, display,
new ContentPropertyDisplay
{
Alias = string.Format("{0}releasedate", Constants.PropertyEditors.InternalGenericPropertiesPrefix),
Label = ui.Text("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}removedate", Constants.PropertyEditors.InternalGenericPropertiesPrefix),
Label = ui.Text("content", "removeDate"),
Value = display.RemoveDate.HasValue ? display.RemoveDate.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}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
},
new ContentPropertyDisplay
{
Alias = string.Format("{0}urls", Constants.PropertyEditors.InternalGenericPropertiesPrefix),
Label = ui.Text("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
}));
//FROM IContent TO ContentItemBasic<ContentPropertyBasic, IContent>
config.CreateMap<IContent, ContentItemBasic<ContentPropertyBasic, IContent>>()

View File

@@ -42,6 +42,13 @@ namespace Umbraco.Web.Models.Mapping
var contentProps = new List<ContentPropertyDisplay>
{
new ContentPropertyDisplay
{
Alias = string.Format("{0}id", Constants.PropertyEditors.InternalGenericPropertiesPrefix),
Label = "Id",
Value = display.Id.ToInvariantString(),
View = labelEditor
},
new ContentPropertyDisplay
{
Alias = string.Format("{0}creator", Constants.PropertyEditors.InternalGenericPropertiesPrefix),
@@ -54,7 +61,7 @@ namespace Umbraco.Web.Models.Mapping
{
Alias = string.Format("{0}createdate", Constants.PropertyEditors.InternalGenericPropertiesPrefix),
Label = ui.Text("content", "createDate"),
Description = "Time this document was created", //TODO: Localize this
Description = "Date/time this document was created", //TODO: Localize this
Value = display.CreateDate.ToIsoString(),
View = labelEditor
},
@@ -62,17 +69,10 @@ namespace Umbraco.Web.Models.Mapping
{
Alias = string.Format("{0}updatedate", Constants.PropertyEditors.InternalGenericPropertiesPrefix),
Label = ui.Text("content", "updateDate"),
Description = "Time this document was last updated", //TODO: Localize this
Description = "Date/time this document was created", //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),