Convert level into group type and ensure names are unique again

This commit is contained in:
Ronald Barendse
2021-06-22 11:45:23 +02:00
parent 0e63edb375
commit 17d2c4cab9
24 changed files with 172 additions and 80 deletions

View File

@@ -77,32 +77,29 @@ namespace Umbraco.Core.Models
//Note this is done to ensure existing groups can be renamed
if (item.HasIdentity && item.Id > 0)
{
var exists = Contains(item.Id);
if (exists)
var index = IndexOfKey(item.Id);
if (index != -1)
{
var keyExists = Contains(item.Name);
if (keyExists)
throw new Exception($"Naming conflict: Changing the name of PropertyGroup '{item.Name}' would result in duplicates");
//collection events will be raised in SetItem
SetItem(IndexOfKey(item.Id), item);
SetItem(index, item);
return;
}
}
else
{
var key = GetKeyForItem(item);
if (key != null)
var index = IndexOfKey(item.Name);
if (index != -1)
{
var exists = Contains(key);
if (exists)
{
//collection events will be raised in SetItem
SetItem(IndexOfKey(key), item);
return;
}
//collection events will be raised in SetItem
SetItem(index, item);
return;
}
}
//collection events will be raised in InsertItem
base.Add(item);
}