From dc158fee2e27ecb9566506bcddd7ad901790b1d7 Mon Sep 17 00:00:00 2001 From: Morten Christensen Date: Wed, 9 Jan 2013 14:37:54 -0100 Subject: [PATCH] Fixes U4-1393 so Tabs shows as expected on both Content- and MediaTypes. Corrected malformed query for PropertyGroups. --- .../Persistence/Factories/PropertyGroupFactory.cs | 6 ++++-- .../Persistence/Repositories/ContentTypeBaseRepository.cs | 8 ++++---- src/Umbraco.Web/Umbraco.Web.csproj | 4 +++- .../umbraco/controls/ContentTypeControlNew.ascx.cs | 2 +- src/umbraco.cms/businesslogic/ContentType.cs | 4 ++++ 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/Umbraco.Core/Persistence/Factories/PropertyGroupFactory.cs b/src/Umbraco.Core/Persistence/Factories/PropertyGroupFactory.cs index 5653f0f86b..5ec7f12292 100644 --- a/src/Umbraco.Core/Persistence/Factories/PropertyGroupFactory.cs +++ b/src/Umbraco.Core/Persistence/Factories/PropertyGroupFactory.cs @@ -28,7 +28,9 @@ namespace Umbraco.Core.Persistence.Factories group.SortOrder = groupDto.SortOrder; group.PropertyTypes = new PropertyTypeCollection(); - foreach (var typeDto in groupDto.PropertyTypeDtos) + //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 typeDtos) { group.PropertyTypes.Add(new PropertyType(typeDto.DataTypeDto.ControlId, typeDto.DataTypeDto.DbType.EnumParse(true)) @@ -53,7 +55,7 @@ namespace Umbraco.Core.Persistence.Factories public IEnumerable BuildDto(IEnumerable entity) { - return entity.Select(propertyGroup => BuildGroupDto(propertyGroup)).ToList(); + return entity.Select(BuildGroupDto).ToList(); } #endregion diff --git a/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs index c5c32f8c01..f2976e3aa1 100644 --- a/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs @@ -235,12 +235,12 @@ namespace Umbraco.Core.Persistence.Repositories var sql = new Sql(); sql.Select("*") .From() - .RightJoin() + .LeftJoin() .On(left => left.Id, right => right.PropertyTypeGroupId) - .InnerJoin() + .LeftJoin() .On(left => left.DataTypeId, right => right.DataTypeId) - .Where(x => x.ContentTypeId == id) - .OrderBy(x => x.PropertyTypeGroupId); + .Where(x => x.ContentTypeNodeId == id) + .OrderBy(x => x.Id); var dtos = Database.Fetch(new GroupPropertyTypeRelator().Map, sql); diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index f4118f75e8..95969dc266 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -2072,7 +2072,9 @@ - + + ASPXCodeBehind + ASPXCodeBehind diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.cs index e7f6bed492..5533eeb599 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.cs @@ -341,7 +341,7 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }}); } private void bindDataGenericProperties(bool Refresh) { - var tabs = cType.getVirtualTabs.DistinctBy(x => x.ContentType).ToArray(); + var tabs = cType.getVirtualTabs; var dtds = cms.businesslogic.datatype.DataTypeDefinition.GetAll(); PropertyTypes.Controls.Clear(); diff --git a/src/umbraco.cms/businesslogic/ContentType.cs b/src/umbraco.cms/businesslogic/ContentType.cs index 4cc0c38e13..59652b27a2 100644 --- a/src/umbraco.cms/businesslogic/ContentType.cs +++ b/src/umbraco.cms/businesslogic/ContentType.cs @@ -6,6 +6,7 @@ using System.Runtime.CompilerServices; using System.Linq; using Umbraco.Core; using Umbraco.Core.Models; +using Umbraco.Core.Persistence.Caching; using umbraco.cms.businesslogic.cache; using umbraco.cms.businesslogic.propertytype; using umbraco.cms.businesslogic.web; @@ -1128,6 +1129,9 @@ namespace umbraco.cms.businesslogic /// The id. public static void FlushFromCache(int id) { + //Ensure that MediaTypes are reloaded from db by clearing cache + InMemoryCacheProvider.Current.Clear(); + ContentType ct = new ContentType(id); Cache.ClearCacheItem(string.Format("UmbracoContentType{0}", id)); Cache.ClearCacheItem(ct.GetPropertiesCacheKey());