Merge branch 'dev-v7-contenttypeeditor' of https://github.com/umbraco/Umbraco-CMS into dev-v7-contenttypeeditor
This commit is contained in:
@@ -47,6 +47,9 @@ namespace Umbraco.Web.Models.ContentEditing
|
||||
[DataMember(Name = "dataTypeId")]
|
||||
public int DataTypeId { get; set; }
|
||||
|
||||
[DataMember(Name = "groupId")]
|
||||
public int GroupId { get; set; }
|
||||
|
||||
[DataMember(Name = "contentTypeId")]
|
||||
public int ContentTypeId { get; set; }
|
||||
}
|
||||
|
||||
@@ -30,16 +30,6 @@ namespace Umbraco.Web.Models.ContentEditing
|
||||
[DataMember(Name = "properties")]
|
||||
public IEnumerable<PropertyTypeDisplay> Properties { get; set; }
|
||||
|
||||
//TODO: Why is there recursive list of PropertyTypeGroupDisplay? Not sure how this
|
||||
// is intended to work but seems like it will become very complicated. This will also
|
||||
// mean that serialization won't work very well because you cannot serialize a recursive
|
||||
// property. These models should just be flat lists of properties and groups with properties
|
||||
// indicating where they've come from. These models don't have to be an exact representation
|
||||
// of their data structures, they should be structured in the simplest format in order for
|
||||
// us to pass data to and from the editor, and that's it.
|
||||
// [DataMember(Name = "groups")]
|
||||
// public IEnumerable<PropertyTypeGroupDisplay> Groups { get; set; }
|
||||
|
||||
//Indicate if this tab was inherited
|
||||
[DataMember(Name = "inherited")]
|
||||
public bool Inherited { get; set; }
|
||||
@@ -47,5 +37,7 @@ namespace Umbraco.Web.Models.ContentEditing
|
||||
[DataMember(Name = "contentTypeId")]
|
||||
public int ContentTypeId { get; set; }
|
||||
|
||||
[DataMember(Name = "parentTabContentTypes")]
|
||||
public IEnumerable<int> ParentTabContentTypes { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +58,15 @@ namespace Umbraco.Web.Models.Mapping
|
||||
.ForMember(dto => dto.Trashed, expression => expression.Ignore())
|
||||
.ForMember(x => x.AdditionalData, expression => expression.Ignore());
|
||||
|
||||
config.CreateMap<ContentTypeSort, EntityBasic>()
|
||||
.ForMember(basic => basic.Icon, expression => expression.UseValue("icon-grid"))
|
||||
.ForMember(basic => basic.Path, expression => expression.UseValue(""))
|
||||
.ForMember(basic => basic.ParentId, expression => expression.UseValue(-1))
|
||||
.ForMember(dto => dto.Trashed, expression => expression.Ignore())
|
||||
.ForMember(x => x.AdditionalData, expression => expression.Ignore());
|
||||
|
||||
|
||||
|
||||
config.CreateMap<SearchResult, EntityBasic>()
|
||||
//default to document icon
|
||||
.ForMember(x => x.Icon, expression => expression.Ignore())
|
||||
|
||||
@@ -34,10 +34,12 @@ namespace Umbraco.Web.Models.Mapping
|
||||
foreach(var tab in ct.CompositionPropertyGroups){
|
||||
var group = new PropertyTypeGroupDisplay() { Id = tab.Id, Inherited = true, Name = tab.Name, SortOrder = tab.SortOrder };
|
||||
group.ContentTypeId = ct.Id;
|
||||
group.ParentTabContentTypes = new[] { ct.Id };
|
||||
|
||||
if (tab.ParentId.HasValue)
|
||||
group.ParentGroupId = tab.ParentId.Value;
|
||||
|
||||
group.Properties = MapProperties(tab.PropertyTypes, ct.Id);
|
||||
group.Properties = MapProperties(tab.PropertyTypes, ct.Id, tab.Id);
|
||||
groups.Add(tab.Id, group);
|
||||
}
|
||||
}
|
||||
@@ -66,7 +68,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
var mergedProperties = new List<PropertyTypeDisplay>();
|
||||
mergedProperties.AddRange(group.Properties);
|
||||
|
||||
var newproperties = MapProperties( ownTab.PropertyTypes , source.Id).Where(x => mergedProperties.Any( y => y.Id == x.Id ) == false);
|
||||
var newproperties = MapProperties( ownTab.PropertyTypes , source.Id, ownTab.Id).Where(x => mergedProperties.Any( y => y.Id == x.Id ) == false);
|
||||
mergedProperties.AddRange(newproperties);
|
||||
|
||||
group.Properties = mergedProperties.OrderBy(x => x.SortOrder);
|
||||
@@ -76,10 +78,50 @@ namespace Umbraco.Web.Models.Mapping
|
||||
if (genericProperties.Any())
|
||||
{
|
||||
var genericTab = new PropertyTypeGroupDisplay() { Id = 0, Name = "Generic properties", ParentGroupId = 0, ContentTypeId = source.Id, SortOrder = 999, Inherited = false };
|
||||
genericTab.Properties = MapProperties(genericProperties, source.Id);
|
||||
genericTab.Properties = MapProperties(genericProperties, source.Id, 0);
|
||||
groups.Add(0, genericTab);
|
||||
}
|
||||
|
||||
|
||||
//merge tabs based on names (magic and insanity)
|
||||
var nameGroupedGroups = groups.Values.GroupBy(x => x.Name);
|
||||
if (nameGroupedGroups.Any(x => x.Count() > 1))
|
||||
{
|
||||
var sortedGroups = new List<PropertyTypeGroupDisplay>();
|
||||
|
||||
foreach (var groupOfGroups in nameGroupedGroups)
|
||||
{
|
||||
//single name groups
|
||||
if(groupOfGroups.Count() == 1)
|
||||
sortedGroups.Add(groupOfGroups.First());
|
||||
else{
|
||||
//multiple name groups
|
||||
|
||||
//find the mother tab - if we have our own use it. otherwise pick a random inherited one - since it wont matter
|
||||
var mainTab = groupOfGroups.FirstOrDefault(x => x.Inherited == false);
|
||||
if (mainTab == null)
|
||||
mainTab = groupOfGroups.First();
|
||||
|
||||
|
||||
//take all properties from all the other tabs and merge into one tab
|
||||
var properties = new List<PropertyTypeDisplay>();
|
||||
properties.AddRange(mainTab.Properties);
|
||||
properties.AddRange(groupOfGroups.Where(x => x.Id != mainTab.Id).SelectMany(x => x.Properties));
|
||||
mainTab.Properties = properties;
|
||||
|
||||
//lock the tab
|
||||
mainTab.Inherited = true;
|
||||
|
||||
//collect all the involved content types
|
||||
mainTab.ParentTabContentTypes = groupOfGroups.Where(x => x.ContentTypeId != source.Id).Select(x => x.ContentTypeId);
|
||||
sortedGroups.Add(mainTab);
|
||||
}
|
||||
}
|
||||
|
||||
return sortedGroups.OrderBy(x => x.SortOrder);
|
||||
}
|
||||
|
||||
|
||||
return groups.Values.OrderBy(x => x.SortOrder);
|
||||
}
|
||||
|
||||
@@ -98,7 +140,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
return mappedGroups;
|
||||
}
|
||||
*/
|
||||
private IEnumerable<PropertyTypeDisplay> MapProperties(IEnumerable<PropertyType> properties, int contentTypeId)
|
||||
private IEnumerable<PropertyTypeDisplay> MapProperties(IEnumerable<PropertyType> properties, int contentTypeId, int groupId)
|
||||
{
|
||||
var mappedProperties = new List<PropertyTypeDisplay>();
|
||||
foreach (var p in properties)
|
||||
@@ -118,7 +160,8 @@ namespace Umbraco.Web.Models.Mapping
|
||||
View = editor.ValueEditor.View,
|
||||
Config = editor.PreValueEditor.ConvertDbToEditor(editor.DefaultPreValues, preVals) ,
|
||||
Value = "",
|
||||
ContentTypeId = contentTypeId
|
||||
ContentTypeId = contentTypeId,
|
||||
GroupId = groupId
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user