rename ElementTypes to Blocks

This commit is contained in:
Niels Lyngsø
2020-02-25 12:55:27 +01:00
parent 0952d9c9c4
commit 82676ae649
3 changed files with 9 additions and 10 deletions
@@ -47,7 +47,7 @@ namespace Umbraco.Tests.PropertyEditors
private BlockListConfiguration ConfigForMany() => new BlockListConfiguration
{
ElementTypes = new[] {
Blocks = new[] {
new BlockListConfiguration.ElementType
{
Alias = "Test1"
@@ -61,7 +61,7 @@ namespace Umbraco.Tests.PropertyEditors
private BlockListConfiguration ConfigForSingle() => new BlockListConfiguration
{
ElementTypes = new[] {
Blocks = new[] {
new BlockListConfiguration.ElementType
{
Alias = "Test1"
@@ -111,7 +111,7 @@ namespace Umbraco.Tests.PropertyEditors
var valueType = editor.GetPropertyValueType(propType);
var modelType = typeof(IEnumerable<>).MakeGenericType(ModelType.For(config.ElementTypes[0].Alias));
var modelType = typeof(IEnumerable<>).MakeGenericType(ModelType.For(config.Blocks[0].Alias));
// we can't compare the exact match of types because ModelType.For generates a new/different type even if the same alias is used
Assert.AreEqual(modelType.FullName, valueType.FullName);
@@ -10,9 +10,8 @@ namespace Umbraco.Web.PropertyEditors
public class BlockListConfiguration
{
// TODO: rename this to blockDefinitions, cause its not elementTypes, its a dictionary of objects that define blocks, part of a block is the elementType used as content model.
[ConfigurationField("elementTypes", "Available Blocks", "views/propertyeditors/blocklist/prevalue/blocklist.elementtypepicker.html", Description = "Define the available blocks.")]
public ElementType[] ElementTypes { get; set; }
[ConfigurationField("blocks", "Available Blocks", "views/propertyeditors/blocklist/prevalue/blocklist.elementtypepicker.html", Description = "Define the available blocks.")]
public BlockConfiguration[] Blocks { get; set; }
[ConfigurationField("validationLimit", "Amount", "numberrange", Description = "Set a required range of blocks")]
@@ -27,7 +26,7 @@ namespace Umbraco.Web.PropertyEditors
public int? Max { get; set; }
}
public class ElementType
public class BlockConfiguration
{
// TODO: rename this to contentElementTypeAlias, I would like this to be specific, since we have the settings.
[JsonProperty("elementTypeAlias")]
@@ -34,7 +34,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters
/// <inheritdoc />
public override Type GetPropertyValueType(IPublishedPropertyType propertyType)
{
var contentTypes = propertyType.DataType.ConfigurationAs<BlockListConfiguration>().ElementTypes;
var contentTypes = propertyType.DataType.ConfigurationAs<BlockListConfiguration>().Blocks;
return contentTypes.Length == 1
? typeof(IEnumerable<>).MakeGenericType(ModelType.For(contentTypes[0].Alias))
: typeof(IEnumerable<IPublishedElement>);
@@ -58,7 +58,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters
using (_proflog.DebugDuration<BlockListPropertyValueConverter>($"ConvertPropertyToBlockList ({propertyType.DataType.Id})"))
{
var configuration = propertyType.DataType.ConfigurationAs<BlockListConfiguration>();
var contentTypes = configuration.ElementTypes;
var contentTypes = configuration.Blocks;
var elements = (contentTypes.Length == 1
? (IList<IPublishedElement>)_publishedModelFactory.CreateModelList(contentTypes[0].Alias)
: new List<IPublishedElement>())
@@ -116,6 +116,6 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters
}
}
}
}