Fixing issues related to DocTypes
This commit is contained in:
@@ -4,7 +4,6 @@ using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text.RegularExpressions;
|
||||
using Umbraco.Core.Models.EntityBase;
|
||||
|
||||
namespace Umbraco.Core.Models
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Umbraco.Core.Models
|
||||
{
|
||||
get
|
||||
{
|
||||
var groups = PropertyGroups.Union(ContentTypeComposition.SelectMany(x => x.CompositionPropertyGroups));
|
||||
var groups = ContentTypeComposition.SelectMany(x => x.CompositionPropertyGroups).Union(PropertyGroups);
|
||||
return groups;
|
||||
}
|
||||
}
|
||||
@@ -58,8 +58,7 @@ namespace Umbraco.Core.Models
|
||||
{
|
||||
get
|
||||
{
|
||||
var propertyTypes =
|
||||
PropertyTypes.Union(ContentTypeComposition.SelectMany(x => x.CompositionPropertyTypes));
|
||||
var propertyTypes = ContentTypeComposition.SelectMany(x => x.CompositionPropertyTypes).Union(PropertyTypes);
|
||||
return propertyTypes;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@ namespace Umbraco.Core.Persistence.Factories
|
||||
group.PropertyTypes = new PropertyTypeCollection();
|
||||
|
||||
//Because we are likely to have a group with no PropertyTypes we need to ensure that these are excluded
|
||||
//var typeDtos = groupDto.PropertyTypeDtos.Where(x => x.Id > 0);
|
||||
foreach (var typeDto in groupDto.PropertyTypeDtos)
|
||||
var typeDtos = groupDto.PropertyTypeDtos.Where(x => x.Id > 0);
|
||||
foreach (var typeDto in typeDtos)
|
||||
{
|
||||
group.PropertyTypes.Add(new PropertyType(typeDto.DataTypeDto.ControlId,
|
||||
typeDto.DataTypeDto.DbType.EnumParse<DataTypeDatabaseType>(true))
|
||||
|
||||
@@ -190,12 +190,13 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
Database.Delete<PropertyTypeDto>("WHERE contentTypeId = @Id AND Alias = @Alias", new { Id = entity.Id, Alias = alias });
|
||||
}
|
||||
//Delete Tabs/Groups by excepting entries from db with entries from collections
|
||||
var dbPropertyGroups = Database.Fetch<PropertyTypeGroupDto>("WHERE contenttypeNodeId = @Id", new { Id = entity.Id }).Select(x => x.Text);
|
||||
var entityPropertyGroups = entity.PropertyGroups.Select(x => x.Name);
|
||||
var dbPropertyGroups = Database.Fetch<PropertyTypeGroupDto>("WHERE contenttypeNodeId = @Id", new { Id = entity.Id }).Select(x => new Tuple<int, string>(x.Id, x.Text));
|
||||
var entityPropertyGroups = entity.PropertyGroups.Select(x => new Tuple<int, string>(x.Id, x.Name));
|
||||
var tabs = dbPropertyGroups.Except(entityPropertyGroups);
|
||||
foreach (var tabName in tabs)
|
||||
foreach (var tab in tabs)
|
||||
{
|
||||
Database.Delete<PropertyTypeGroupDto>("WHERE contenttypeNodeId = @Id AND text = @Name", new { Id = entity.Id, Name = tabName });
|
||||
Database.Update<PropertyTypeGroupDto>("SET parentGroupId = NULL WHERE parentGroupId = @TabId", new {TabId = tab.Item1});
|
||||
Database.Delete<PropertyTypeGroupDto>("WHERE contenttypeNodeId = @Id AND text = @Name", new { Id = entity.Id, Name = tab.Item2 });
|
||||
}
|
||||
|
||||
//Run through all groups to insert or update entries
|
||||
@@ -248,7 +249,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
.On<PropertyTypeGroupDto, PropertyTypeDto>(left => left.Id, right => right.PropertyTypeGroupId)
|
||||
.LeftJoin<DataTypeDto>()
|
||||
.On<PropertyTypeDto, DataTypeDto>(left => left.DataTypeId, right => right.DataTypeId)
|
||||
.Where<PropertyTypeDto>(x => x.ContentTypeId == id)
|
||||
.Where<PropertyTypeGroupDto>(x => x.ContentTypeNodeId == id)
|
||||
.OrderBy<PropertyTypeGroupDto>(x => x.Id);
|
||||
|
||||
var dtos = Database.Fetch<PropertyTypeGroupDto, PropertyTypeDto, DataTypeDto, PropertyTypeGroupDto>(new GroupPropertyTypeRelator().Map, sql);
|
||||
|
||||
@@ -132,8 +132,8 @@ namespace umbraco.controls
|
||||
|
||||
var tabId = tab.Id;
|
||||
var propertyGroups = _contentType.ContentTypeItem.CompositionPropertyGroups.Where(x => x.Id == tabId || x.ParentId == tabId);
|
||||
var propertyTypeAliaes = propertyGroups.SelectMany(x => x.PropertyTypes.Select(y => new System.Tuple<int, string>(y.Id, y.Alias)));
|
||||
foreach (var items in propertyTypeAliaes)
|
||||
var propertyTypeAliases = propertyGroups.SelectMany(x => x.PropertyTypes.OrderBy(y => y.SortOrder).Select(y => new System.Tuple<int, string, int>(y.Id, y.Alias, y.SortOrder)));
|
||||
foreach (var items in propertyTypeAliases)
|
||||
{
|
||||
var property = _content.getProperty(items.Item2);
|
||||
if (property != null)
|
||||
|
||||
@@ -941,8 +941,8 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }});
|
||||
var propertyGroup = new PropertyGroup { Name = txtNewTab.Text };
|
||||
if (_contentType.ContentTypeItem.PropertyGroups.Any())
|
||||
{
|
||||
var first = _contentType.ContentTypeItem.PropertyGroups.OrderBy(x => x.SortOrder).First();
|
||||
propertyGroup.SortOrder = first.SortOrder + 1;
|
||||
var last = _contentType.ContentTypeItem.PropertyGroups.OrderBy(x => x.SortOrder).Last();
|
||||
propertyGroup.SortOrder = last.SortOrder + 1;
|
||||
}
|
||||
_contentType.ContentTypeItem.PropertyGroups.Add(propertyGroup);
|
||||
_contentType.Save();
|
||||
|
||||
@@ -673,7 +673,7 @@ namespace umbraco.cms.businesslogic
|
||||
continue;
|
||||
|
||||
//get the propertyId
|
||||
var property = propData.SingleOrDefault(x => x.PropertyTypeId == pt.Id);
|
||||
var property = propData.LastOrDefault(x => x.PropertyTypeId == pt.Id);
|
||||
if (property == null)
|
||||
{
|
||||
//continue;
|
||||
|
||||
Reference in New Issue
Block a user