diff --git a/src/Umbraco.Core/Constants-PropertyEditors.cs b/src/Umbraco.Core/Constants-PropertyEditors.cs
index eb2b3525a7..753cd72116 100644
--- a/src/Umbraco.Core/Constants-PropertyEditors.cs
+++ b/src/Umbraco.Core/Constants-PropertyEditors.cs
@@ -36,6 +36,11 @@ namespace Umbraco.Core
///
public static class Aliases
{
+ ///
+ /// CheckBox List.
+ ///
+ public const string BlockList = "Umbraco.BlockList";
+
///
/// CheckBox List.
///
diff --git a/src/Umbraco.Core/Models/Blocks/BlockEditorModel.cs b/src/Umbraco.Core/Models/Blocks/BlockEditorModel.cs
index 7d00623ccf..307b69f6e0 100644
--- a/src/Umbraco.Core/Models/Blocks/BlockEditorModel.cs
+++ b/src/Umbraco.Core/Models/Blocks/BlockEditorModel.cs
@@ -1,4 +1,6 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
+using System.Runtime.Serialization;
using Umbraco.Core.Models.PublishedContent;
namespace Umbraco.Core.Models.Blocks
@@ -8,9 +10,20 @@ namespace Umbraco.Core.Models.Blocks
///
public abstract class BlockEditorModel
{
+ protected BlockEditorModel(IEnumerable data)
+ {
+ Data = data ?? throw new ArgumentNullException(nameof(data));
+ }
+
+ public BlockEditorModel()
+ {
+ }
+
+
///
/// The data items of the Block List editor
///
- public IEnumerable Data { get; }
+ [DataMember(Name = "data")]
+ public IEnumerable Data { get; set; }
}
}
diff --git a/src/Umbraco.Core/Models/Blocks/BlockListLayoutReference.cs b/src/Umbraco.Core/Models/Blocks/BlockListLayoutReference.cs
index 444bb7249f..163b564c9f 100644
--- a/src/Umbraco.Core/Models/Blocks/BlockListLayoutReference.cs
+++ b/src/Umbraco.Core/Models/Blocks/BlockListLayoutReference.cs
@@ -1,4 +1,5 @@
using System;
+using System.Runtime.Serialization;
using Umbraco.Core.Models.PublishedContent;
namespace Umbraco.Core.Models.Blocks
@@ -6,6 +7,7 @@ namespace Umbraco.Core.Models.Blocks
///
/// Represents a layout item for the Block List editor
///
+ [DataContract(Name = "blockListLayout", Namespace = "")]
public class BlockListLayoutReference : IBlockElement
{
public BlockListLayoutReference(Udi udi, IPublishedElement settings)
@@ -14,7 +16,10 @@ namespace Umbraco.Core.Models.Blocks
Settings = settings ?? throw new ArgumentNullException(nameof(settings));
}
- public Udi Udi { get; }
- public IPublishedElement Settings { get; }
+ [DataMember(Name = "udi")]
+ public Udi Udi { get; set; }
+
+ [DataMember(Name = "settings")]
+ public IPublishedElement Settings { get; set; }
}
}
diff --git a/src/Umbraco.Core/Models/Blocks/BlockListModel.cs b/src/Umbraco.Core/Models/Blocks/BlockListModel.cs
index 5331ca3891..36dd8af7c1 100644
--- a/src/Umbraco.Core/Models/Blocks/BlockListModel.cs
+++ b/src/Umbraco.Core/Models/Blocks/BlockListModel.cs
@@ -1,16 +1,30 @@
using System.Collections.Generic;
+using System.Runtime.Serialization;
+using Umbraco.Core.Models.PublishedContent;
namespace Umbraco.Core.Models.Blocks
{
///
/// The strongly typed model for the Block List editor
///
+ [DataContract(Name = "blockList", Namespace = "")]
public class BlockListModel : BlockEditorModel
{
+ public BlockListModel(IEnumerable data, IEnumerable layout)
+ : base(data)
+ {
+ Layout = layout;
+ }
+
+ public BlockListModel()
+ {
+ }
+
///
/// The layout items of the Block List editor
///
- public IEnumerable Layout { get; }
+ [DataMember(Name = "layout")]
+ public IEnumerable Layout { get; set; }
}
diff --git a/src/Umbraco.Core/PropertyEditors/BlockListEditor.cs b/src/Umbraco.Core/PropertyEditors/BlockListEditor.cs
new file mode 100644
index 0000000000..16c6176624
--- /dev/null
+++ b/src/Umbraco.Core/PropertyEditors/BlockListEditor.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Umbraco.Core.PropertyEditors
+{
+ public class BlockListEditor
+ {
+ }
+}
diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj
index 8bf0b9105f..33796a93bf 100755
--- a/src/Umbraco.Core/Umbraco.Core.csproj
+++ b/src/Umbraco.Core/Umbraco.Core.csproj
@@ -133,6 +133,7 @@
+
diff --git a/src/Umbraco.Tests/PropertyEditors/BlockListPropertyValueConverterTests.cs b/src/Umbraco.Tests/PropertyEditors/BlockListPropertyValueConverterTests.cs
new file mode 100644
index 0000000000..f345bf136c
--- /dev/null
+++ b/src/Umbraco.Tests/PropertyEditors/BlockListPropertyValueConverterTests.cs
@@ -0,0 +1,91 @@
+using Moq;
+using NUnit.Framework;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Umbraco.Core;
+using Umbraco.Core.Logging;
+using Umbraco.Core.Models.PublishedContent;
+using Umbraco.Web.PropertyEditors;
+using Umbraco.Web.PropertyEditors.ValueConverters;
+using Umbraco.Web.PublishedCache;
+
+namespace Umbraco.Tests.PropertyEditors
+{
+ [TestFixture]
+ public class BlockListPropertyValueConverterTests
+ {
+ private BlockListPropertyValueConverter Create()
+ {
+ var publishedSnapshotAccessor = Mock.Of();
+ var publishedModelFactory = Mock.Of();
+ var editor = new BlockListPropertyValueConverter(
+ Mock.Of(),
+ publishedModelFactory,
+ new BlockEditorConverter(publishedSnapshotAccessor, publishedModelFactory));
+ return editor;
+ }
+
+ [Test]
+ public void Is_Converter_For()
+ {
+ var editor = Create();
+ Assert.IsTrue(editor.IsConverter(Mock.Of(x => x.EditorAlias == Constants.PropertyEditors.Aliases.BlockList)));
+ Assert.IsFalse(editor.IsConverter(Mock.Of(x => x.EditorAlias == Constants.PropertyEditors.Aliases.NestedContent)));
+ }
+
+ [Test]
+ public void Get_Value_Type_Multiple()
+ {
+ var editor = Create();
+ var config = new BlockListConfiguration
+ {
+ ElementTypes = new[] {
+ new BlockListConfiguration.ElementType
+ {
+ Alias = "Test1"
+ },
+ new BlockListConfiguration.ElementType
+ {
+ Alias = "Test2"
+ }
+ }
+ };
+
+ var dataType = new PublishedDataType(1, "test", new Lazy