Update IContentTypeBase to use group names as property groups (no parent/level 1) for backwards compatibility
This commit is contained in:
@@ -348,7 +348,7 @@ namespace Umbraco.Core.Models
|
|||||||
// get new group, if required, and ensure it exists
|
// get new group, if required, and ensure it exists
|
||||||
var newPropertyGroup = propertyGroupName == null
|
var newPropertyGroup = propertyGroupName == null
|
||||||
? null
|
? null
|
||||||
: PropertyGroups.FirstOrDefault(x => x.Name == propertyGroupName);
|
: PropertyGroups.FirstOrDefault(x => x.Name.InvariantEquals(propertyGroupName) && x.ParentKey == null && x.Level == 1);
|
||||||
if (propertyGroupName != null && newPropertyGroup == null) return false;
|
if (propertyGroupName != null && newPropertyGroup == null) return false;
|
||||||
|
|
||||||
// get old group
|
// get old group
|
||||||
@@ -403,11 +403,11 @@ namespace Umbraco.Core.Models
|
|||||||
public void RemovePropertyGroup(string propertyGroupName)
|
public void RemovePropertyGroup(string propertyGroupName)
|
||||||
{
|
{
|
||||||
// if no group exists with that name, do nothing
|
// if no group exists with that name, do nothing
|
||||||
var group = PropertyGroups[propertyGroupName];
|
var group = PropertyGroups.FirstOrDefault(x => x.Name.InvariantEquals(propertyGroupName) && x.ParentKey == null && x.Level == 1);
|
||||||
if (group == null) return;
|
if (group == null) return;
|
||||||
|
|
||||||
// first remove the group
|
// first remove the group
|
||||||
PropertyGroups.RemoveItem(propertyGroupName);
|
PropertyGroups.Remove(group);
|
||||||
|
|
||||||
// Then re-assign the group's properties to no group
|
// Then re-assign the group's properties to no group
|
||||||
foreach (var property in group.PropertyTypes)
|
foreach (var property in group.PropertyTypes)
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ namespace Umbraco.Core.Models
|
|||||||
private PropertyGroup AddAndReturnPropertyGroup(string name)
|
private PropertyGroup AddAndReturnPropertyGroup(string name)
|
||||||
{
|
{
|
||||||
// ensure we don't have it already
|
// ensure we don't have it already
|
||||||
if (PropertyGroups.Any(x => x.Name == name))
|
if (PropertyGroups.Any(x => x.Name.InvariantEquals(name) && x.ParentKey == null && x.Level == 1))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
// create the new group
|
// create the new group
|
||||||
@@ -227,7 +227,7 @@ namespace Umbraco.Core.Models
|
|||||||
// check if it is inherited - there might be more than 1 but we want the 1st, to
|
// check if it is inherited - there might be more than 1 but we want the 1st, to
|
||||||
// reuse its sort order - if there are more than 1 and they have different sort
|
// reuse its sort order - if there are more than 1 and they have different sort
|
||||||
// orders... there isn't much we can do anyways
|
// orders... there isn't much we can do anyways
|
||||||
var inheritGroup = CompositionPropertyGroups.FirstOrDefault(x => x.Name == name);
|
var inheritGroup = CompositionPropertyGroups.FirstOrDefault(x => x.Name.InvariantEquals(name) && x.ParentKey == null && x.Level == 1);
|
||||||
if (inheritGroup == null)
|
if (inheritGroup == null)
|
||||||
{
|
{
|
||||||
// no, just local, set sort order
|
// no, just local, set sort order
|
||||||
@@ -260,9 +260,8 @@ namespace Umbraco.Core.Models
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// get and ensure a group local to this content type
|
// get and ensure a group local to this content type
|
||||||
var group = PropertyGroups.Contains(propertyGroupName)
|
var group = PropertyGroups.FirstOrDefault(x => x.Name.InvariantEquals(propertyGroupName) && x.ParentKey == null && x.Level == 1)
|
||||||
? PropertyGroups[propertyGroupName]
|
??AddAndReturnPropertyGroup(propertyGroupName);
|
||||||
: AddAndReturnPropertyGroup(propertyGroupName);
|
|
||||||
if (group == null)
|
if (group == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user