init commit of strongly typed models for implementations of a block editor and the upcoming block list editor

This commit is contained in:
Shannon
2020-01-30 17:36:40 +11:00
parent 537674a0b3
commit 772e46b93a
5 changed files with 75 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
using System.Collections.Generic;
using Umbraco.Core.Models.PublishedContent;
namespace Umbraco.Core.Models.Blocks
{
/// <summary>
/// The base class for any strongly typed model for a Block editor implementation
/// </summary>
public abstract class BlockEditorModel
{
/// <summary>
/// The data items of the Block List editor
/// </summary>
public IEnumerable<IPublishedElement> Data { get; }
}
}

View File

@@ -0,0 +1,20 @@
using System;
using Umbraco.Core.Models.PublishedContent;
namespace Umbraco.Core.Models.Blocks
{
/// <summary>
/// Represents a layout item for the Block List editor
/// </summary>
public class BlockListLayoutReference : IBlockElement<IPublishedElement>
{
public BlockListLayoutReference(Udi udi, IPublishedElement settings)
{
Udi = udi ?? throw new ArgumentNullException(nameof(udi));
Settings = settings ?? throw new ArgumentNullException(nameof(settings));
}
public Udi Udi { get; }
public IPublishedElement Settings { get; }
}
}

View File

@@ -0,0 +1,17 @@
using System.Collections.Generic;
namespace Umbraco.Core.Models.Blocks
{
/// <summary>
/// The strongly typed model for the Block List editor
/// </summary>
public class BlockListModel : BlockEditorModel
{
/// <summary>
/// The layout items of the Block List editor
/// </summary>
public IEnumerable<BlockListLayoutReference> Layout { get; }
}
}

View File

@@ -0,0 +1,18 @@
namespace Umbraco.Core.Models.Blocks
{
// TODO: IBlockElement doesn't make sense, this is a reference to an actual element with some settings
// and always has to do with the "Layout", should possibly be called IBlockReference or IBlockLayout or IBlockLayoutReference
/// <summary>
/// Represents a data item for a Block editor implementation
/// </summary>
/// <typeparam name="TSettings"></typeparam>
/// <remarks>
/// see: https://github.com/umbraco/rfcs/blob/907f3758cf59a7b6781296a60d57d537b3b60b8c/cms/0011-block-data-structure.md#strongly-typed
/// </remarks>
public interface IBlockElement<TSettings>
{
Udi Udi { get; }
TSettings Settings { get; }
}
}

View File

@@ -129,6 +129,10 @@
-->
<Compile Include="AssemblyExtensions.cs" />
<Compile Include="Migrations\Upgrade\V_8_6_0\AddMainDomLock.cs" />
<Compile Include="Models\Blocks\BlockEditorModel.cs" />
<Compile Include="Models\Blocks\BlockListLayoutReference.cs" />
<Compile Include="Models\Blocks\BlockListModel.cs" />
<Compile Include="Models\Blocks\IBlockElement.cs" />
<Compile Include="Runtime\IMainDomLock.cs" />
<Compile Include="Runtime\MainDomSemaphoreLock.cs" />
<Compile Include="Runtime\SqlMainDomLock.cs" />