Changes allowed content types to list<int>
This commit is contained in:
@@ -15,7 +15,7 @@ namespace Umbraco.Web.Models.ContentEditing
|
||||
//initialize collections so at least their never null
|
||||
AllowedTemplates = new List<EntityBasic>();
|
||||
AvailableCompositeContentTypes = new List<EntityBasic>();
|
||||
AllowedContentTypes = new List<EntityBasic>();
|
||||
AllowedContentTypes = new List<int>();
|
||||
CompositeContentTypes = new List<string>();
|
||||
Groups = new List<PropertyTypeGroupDisplay>();
|
||||
}
|
||||
@@ -30,10 +30,11 @@ namespace Umbraco.Web.Models.ContentEditing
|
||||
[DataMember(Name = "defaultTemplate")]
|
||||
public EntityBasic DefaultTemplate { get; set; }
|
||||
|
||||
[DataMember(Name = "allowedContentTypes")]
|
||||
public IEnumerable<EntityBasic> AllowedContentTypes { get; set; }
|
||||
|
||||
|
||||
[DataMember(Name = "allowedContentTypes")]
|
||||
public IEnumerable<int> AllowedContentTypes { get; set; }
|
||||
|
||||
//List view
|
||||
[DataMember(Name = "isContainer")]
|
||||
public bool IsContainer { get; set; }
|
||||
|
||||
@@ -7,6 +7,7 @@ using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Mapping;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
@@ -47,17 +48,27 @@ namespace Umbraco.Web.Models.Mapping
|
||||
.ForMember(dto => dto.UpdateDate, expression => expression.Ignore())
|
||||
.ForMember(dto => dto.SortOrder, expression => expression.Ignore())
|
||||
|
||||
//mapped in aftermap
|
||||
.ForMember(dto => dto.AllowedContentTypes, expression => expression.Ignore())
|
||||
|
||||
//ignore, we'll do this in after map
|
||||
.ForMember(dto => dto.PropertyGroups, expression => expression.Ignore())
|
||||
.AfterMap((source, dest) =>
|
||||
{
|
||||
|
||||
dest.PropertyGroups = new PropertyGroupCollection();
|
||||
foreach (var groupDisplay in source.Groups.Where(x => !x.Name.IsNullOrWhiteSpace() ) )
|
||||
{
|
||||
dest.PropertyGroups.Add(Mapper.Map<PropertyGroup>(groupDisplay));
|
||||
}
|
||||
|
||||
//Sync allowed child types
|
||||
var allowedTypes = new List<ContentTypeSort>();
|
||||
var proposedAllowed = source.AllowedContentTypes.ToArray();
|
||||
for (int i = 0; i < proposedAllowed.Length; i++)
|
||||
allowedTypes.Add(new ContentTypeSort(proposedAllowed[i], i));
|
||||
|
||||
dest.AllowedContentTypes = allowedTypes;
|
||||
|
||||
//sync compositions
|
||||
var current = dest.CompositionAliases();
|
||||
var proposed = source.CompositeContentTypes;
|
||||
@@ -73,8 +84,12 @@ namespace Umbraco.Web.Models.Mapping
|
||||
if(add_ct != null)
|
||||
dest.AddContentType(add_ct);
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
config.CreateMap<ContentTypeSort, int>().ConvertUsing(x => x.Id.Value);
|
||||
config.CreateMap<IContentTypeComposition, string>().ConvertUsing(x => x.Alias);
|
||||
config.CreateMap<IContentType, ContentTypeDisplay>()
|
||||
//Ignore because this is not actually used for content types
|
||||
|
||||
Reference in New Issue
Block a user