From 8d00d931b06df49192972b5e2adda391d8ea192e Mon Sep 17 00:00:00 2001 From: Stephan Date: Tue, 17 Nov 2015 16:29:57 +0100 Subject: [PATCH] U4-7414 Deleted tab's properties should become generic properties --- src/Umbraco.Core/Models/ContentTypeBase.cs | 12 ++++++++++++ .../umbraco/controls/ContentTypeControlNew.ascx.cs | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Core/Models/ContentTypeBase.cs b/src/Umbraco.Core/Models/ContentTypeBase.cs index c1c8e3270c..2398a6c2e6 100644 --- a/src/Umbraco.Core/Models/ContentTypeBase.cs +++ b/src/Umbraco.Core/Models/ContentTypeBase.cs @@ -533,6 +533,18 @@ namespace Umbraco.Core.Models /// Name of the to remove public void RemovePropertyGroup(string propertyGroupName) { + // if no group exists with that name, do nothing + var group = PropertyGroups[propertyGroupName]; + if (group == null) return; + + // re-assign the group's properties to no group + foreach (var property in group.PropertyTypes) + { + property.PropertyGroupId = new Lazy(() => 0); + _propertyTypes.Add(property); + } + + // actually remove the group PropertyGroups.RemoveItem(propertyGroupName); OnPropertyChanged(PropertyGroupCollectionSelector); } 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 eed2947b23..44b4da1864 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.cs @@ -1475,7 +1475,8 @@ jQuery(document).ready(function() {{ refreshDropDowns(); }}); var propertyGroup = _contentType.ContentTypeItem.PropertyGroups.FirstOrDefault(x => x.Id == propertyGroupId); if (propertyGroup != null && string.IsNullOrEmpty(propertyGroup.Name) == false) { - _contentType.ContentTypeItem.PropertyGroups.Remove(propertyGroup.Name); + // use RemovePropertyGroup so properties become generic + _contentType.ContentTypeItem.RemovePropertyGroup(propertyGroup.Name); _contentType.Save(); } //}