Merge branch 'v8/8.17' into v9/feature/merge_v8.17-rc
This commit is contained in:
@@ -82,27 +82,35 @@ namespace Umbraco.Cms.Core.Models.ContentEditing
|
||||
yield return validationResult;
|
||||
}
|
||||
|
||||
var duplicateGroups = Groups.GroupBy(x => x.Name).Where(x => x.Count() > 1).ToArray();
|
||||
if (duplicateGroups.Any())
|
||||
foreach (var duplicateGroupAlias in Groups.GroupBy(x => x.Alias).Where(x => x.Count() > 1))
|
||||
{
|
||||
//we need to return the field name with an index so it's wired up correctly
|
||||
var lastIndex = Groups.IndexOf(duplicateGroups.Last().Last());
|
||||
yield return new ValidationResult("Duplicate group names not allowed", new[]
|
||||
var lastGroupIndex = Groups.IndexOf(duplicateGroupAlias.Last());
|
||||
yield return new ValidationResult("Duplicate aliases are not allowed: " + duplicateGroupAlias.Key, new[]
|
||||
{
|
||||
$"Groups[{lastIndex}].Name"
|
||||
// TODO: We don't display the alias yet, so add the validation message to the name
|
||||
$"Groups[{lastGroupIndex}].Name"
|
||||
});
|
||||
}
|
||||
|
||||
var duplicateProperties = Groups.SelectMany(x => x.Properties).Where(x => x.Inherited == false).GroupBy(x => x.Alias).Where(x => x.Count() > 1).ToArray();
|
||||
if (duplicateProperties.Any())
|
||||
foreach (var duplicateGroupName in Groups.GroupBy(x => (x.GetParentAlias(), x.Name)).Where(x => x.Count() > 1))
|
||||
{
|
||||
//we need to return the field name with an index so it's wired up correctly
|
||||
var lastProperty = duplicateProperties.Last().Last();
|
||||
var propertyGroup = Groups.Single(x => x.Properties.Contains(lastProperty));
|
||||
|
||||
yield return new ValidationResult("Duplicate property aliases not allowed: " + lastProperty.Alias, new[]
|
||||
var lastGroupIndex = Groups.IndexOf(duplicateGroupName.Last());
|
||||
yield return new ValidationResult("Duplicate names are not allowed", new[]
|
||||
{
|
||||
$"Groups[{propertyGroup.SortOrder}].Properties[{lastProperty.SortOrder}].Alias"
|
||||
$"Groups[{lastGroupIndex}].Name"
|
||||
});
|
||||
}
|
||||
|
||||
foreach (var duplicatePropertyAlias in Groups.SelectMany(x => x.Properties).GroupBy(x => x.Alias).Where(x => x.Count() > 1))
|
||||
{
|
||||
var lastProperty = duplicatePropertyAlias.Last();
|
||||
var propertyGroup = Groups.Single(x => x.Properties.Contains(lastProperty));
|
||||
var lastPropertyIndex = propertyGroup.Properties.IndexOf(lastProperty);
|
||||
var propertyGroupIndex = Groups.IndexOf(propertyGroup);
|
||||
|
||||
yield return new ValidationResult("Duplicate property aliases not allowed: " + duplicatePropertyAlias.Key, new[]
|
||||
{
|
||||
$"Groups[{propertyGroupIndex}].Properties[{lastPropertyIndex}].Alias"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Umbraco.Cms.Core.Models.ContentEditing
|
||||
{
|
||||
/// <summary>
|
||||
/// A model for retrieving multiple content types based on their aliases.
|
||||
/// </summary>
|
||||
[DataContract(Name = "contentTypes", Namespace = "")]
|
||||
public class ContentTypesByAliases
|
||||
{
|
||||
/// <summary>
|
||||
/// Id of the parent of the content type.
|
||||
/// </summary>
|
||||
[DataMember(Name = "parentId")]
|
||||
[Required]
|
||||
public int ParentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The alias of every content type to get.
|
||||
/// </summary>
|
||||
[DataMember(Name = "contentTypeAliases")]
|
||||
[Required]
|
||||
public string[] ContentTypeAliases { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
@@ -32,12 +33,22 @@ namespace Umbraco.Cms.Core.Models.ContentEditing
|
||||
[DataMember(Name = "id")]
|
||||
public int Id { get; set; }
|
||||
|
||||
[DataMember(Name = "sortOrder")]
|
||||
public int SortOrder { get; set; }
|
||||
[DataMember(Name = "key")]
|
||||
public Guid Key { get; set; }
|
||||
|
||||
[DataMember(Name = "type")]
|
||||
public PropertyGroupType Type { get; set; }
|
||||
|
||||
[Required]
|
||||
[DataMember(Name = "name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Required]
|
||||
[DataMember(Name = "alias")]
|
||||
public string Alias { get; set; }
|
||||
|
||||
[DataMember(Name = "sortOrder")]
|
||||
public int SortOrder { get; set; }
|
||||
}
|
||||
|
||||
[DataContract(Name = "propertyGroup", Namespace = "")]
|
||||
@@ -52,4 +63,10 @@ namespace Umbraco.Cms.Core.Models.ContentEditing
|
||||
[DataMember(Name = "properties")]
|
||||
public IEnumerable<TPropertyType> Properties { get; set; }
|
||||
}
|
||||
|
||||
internal static class PropertyGroupBasicExtensions
|
||||
{
|
||||
public static string GetParentAlias(this PropertyGroupBasic propertyGroup)
|
||||
=> PropertyGroupExtensions.GetParentAlias(propertyGroup.Alias);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Umbraco.Cms.Core.Models.ContentEditing
|
||||
@@ -12,6 +13,12 @@ namespace Umbraco.Cms.Core.Models.ContentEditing
|
||||
[DataMember(Name = "id")]
|
||||
public int Id { get; set; }
|
||||
|
||||
[DataMember(Name = "key")]
|
||||
public Guid Key { get; set; }
|
||||
|
||||
[DataMember(Name = "type")]
|
||||
public int Type { get; set; }
|
||||
|
||||
[DataMember(Name = "active")]
|
||||
public bool IsActive { get; set; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user