From e72d2c08b4c5dd5cf321cdb5dbd47e059075ef25 Mon Sep 17 00:00:00 2001 From: Rick Butterfield Date: Sun, 26 Jan 2025 09:24:54 +0000 Subject: [PATCH] Fix for #88 --- .../blockgrid/Components/heroBlock.cshtml | 3 +- .../uSync/v15/Content/home.config | 42 +++++- .../v15/Content/nested-block-grid-test.config | 30 ++++- .../uSync/v15/Content/test-1.config | 121 ------------------ .../uSync/v15/Content/test.config | 114 ----------------- .../uSync/v15/Content/test_jjdoauzk.config | 114 ----------------- .../uSync/v15/Content/test_km1dao4m.config | 79 ------------ .../uSync/v15/Content/testing-1-2-3.config | 2 - .../v15/ContentTypes/blocksettings.config | 50 ++++++++ .../v15/DataTypes/BlockGridContent.config | 4 +- src/Umbraco.Cms.15.x/uSync/v15/usync.config | 2 - .../umbraco/models/BlockSettings.generated.cs | 60 +++++++++ .../package.json | 2 +- .../public/umbraco-package.json | 2 +- .../Services/BlockPreviewService.cs | 10 +- .../Umbraco.Community.BlockPreview.csproj | 2 +- .../umbraco-package.json | 2 +- 17 files changed, 193 insertions(+), 446 deletions(-) delete mode 100644 src/Umbraco.Cms.15.x/uSync/v15/Content/test-1.config delete mode 100644 src/Umbraco.Cms.15.x/uSync/v15/Content/test.config delete mode 100644 src/Umbraco.Cms.15.x/uSync/v15/Content/test_jjdoauzk.config delete mode 100644 src/Umbraco.Cms.15.x/uSync/v15/Content/test_km1dao4m.config delete mode 100644 src/Umbraco.Cms.15.x/uSync/v15/Content/testing-1-2-3.config create mode 100644 src/Umbraco.Cms.15.x/uSync/v15/ContentTypes/blocksettings.config delete mode 100644 src/Umbraco.Cms.15.x/uSync/v15/usync.config create mode 100644 src/Umbraco.Cms.15.x/umbraco/models/BlockSettings.generated.cs diff --git a/src/Umbraco.Cms.15.x/Views/Partials/blockgrid/Components/heroBlock.cshtml b/src/Umbraco.Cms.15.x/Views/Partials/blockgrid/Components/heroBlock.cshtml index 789add7..7699e5d 100644 --- a/src/Umbraco.Cms.15.x/Views/Partials/blockgrid/Components/heroBlock.cshtml +++ b/src/Umbraco.Cms.15.x/Views/Partials/blockgrid/Components/heroBlock.cshtml @@ -1,4 +1,4 @@ -@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage> +@inherits UmbracoViewPage> @{ var backgroundColor = Model.Content.BackgroundColor; var image = Model.Content.Image; @@ -7,6 +7,7 @@
Dropdown: @Model.Content.Height
Content Picker: @Model.Content.ContentPicker?.Name (@Model.Content.ContentPicker?.Url())
+
Settings Dropdown: @Model.Settings?.Dropdown
- - - - /[-20]/test1 - true - blockGrid - 2023-09-01T17:13:00 - - 0 - - - - - - - - - - \ No newline at end of file diff --git a/src/Umbraco.Cms.15.x/uSync/v15/Content/test.config b/src/Umbraco.Cms.15.x/uSync/v15/Content/test.config deleted file mode 100644 index e9de7bb..0000000 --- a/src/Umbraco.Cms.15.x/uSync/v15/Content/test.config +++ /dev/null @@ -1,114 +0,0 @@ - - - - - /[-20]/Test - true - blockGrid - 2024-04-22T20:05:43 - - 1 - - - - - - - - - - \ No newline at end of file diff --git a/src/Umbraco.Cms.15.x/uSync/v15/Content/test_jjdoauzk.config b/src/Umbraco.Cms.15.x/uSync/v15/Content/test_jjdoauzk.config deleted file mode 100644 index aa8f851..0000000 --- a/src/Umbraco.Cms.15.x/uSync/v15/Content/test_jjdoauzk.config +++ /dev/null @@ -1,114 +0,0 @@ - - - - Home - /Home/Test - false - blockGrid - 2024-04-22T20:05:43 - - 1 - - - - - - - - - - \ No newline at end of file diff --git a/src/Umbraco.Cms.15.x/uSync/v15/Content/test_km1dao4m.config b/src/Umbraco.Cms.15.x/uSync/v15/Content/test_km1dao4m.config deleted file mode 100644 index d7b91b1..0000000 --- a/src/Umbraco.Cms.15.x/uSync/v15/Content/test_km1dao4m.config +++ /dev/null @@ -1,79 +0,0 @@ - - - - Home - /Home/Test - false - blockGrid - 2023-08-25T15:00:50 - - 1 - - - - - - - - - - \ No newline at end of file diff --git a/src/Umbraco.Cms.15.x/uSync/v15/Content/testing-1-2-3.config b/src/Umbraco.Cms.15.x/uSync/v15/Content/testing-1-2-3.config deleted file mode 100644 index 1f0e4f3..0000000 --- a/src/Umbraco.Cms.15.x/uSync/v15/Content/testing-1-2-3.config +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/src/Umbraco.Cms.15.x/uSync/v15/ContentTypes/blocksettings.config b/src/Umbraco.Cms.15.x/uSync/v15/ContentTypes/blocksettings.config new file mode 100644 index 0000000..9c69b4d --- /dev/null +++ b/src/Umbraco.Cms.15.x/uSync/v15/ContentTypes/blocksettings.config @@ -0,0 +1,50 @@ + + + + Block Settings + icon-plugin + folder.png + + False + 00000000-0000-0000-0000-000000000000 + Nothing + true + + False + + + + Blocks + + + + + + + + f1d219c9-cc52-401e-af71-379efadccf13 + Dropdown + dropdown + 7a7da278-de8a-497d-afd4-48fac0cdb671 + Umbraco.DropDown.Flexible + false + + + 0 + Content + Nothing + + + false + + + + + 8ccafae1-eec7-40cc-b395-b8fc995a3a25 + Content + content + Tab + 0 + + + \ No newline at end of file diff --git a/src/Umbraco.Cms.15.x/uSync/v15/DataTypes/BlockGridContent.config b/src/Umbraco.Cms.15.x/uSync/v15/DataTypes/BlockGridContent.config index 0bb4aa2..3526134 100644 --- a/src/Umbraco.Cms.15.x/uSync/v15/DataTypes/BlockGridContent.config +++ b/src/Umbraco.Cms.15.x/uSync/v15/DataTypes/BlockGridContent.config @@ -119,7 +119,7 @@ "label": "", "rowMaxSpan": 1, "rowMinSpan": 1, - "settingsElementTypeKey": null, + "settingsElementTypeKey": "cb6adf93-9c01-476c-970b-7469474db5b4", "stylesheet": "~/css/myblockgridlayout.css", "thumbnail": null, "view": "~/App_Plugins/Umbraco.Community.BlockPreview/views/block-preview.html" @@ -316,8 +316,6 @@ "view": "~/App_Plugins/Umbraco.Community.BlockPreview/views/block-preview.html" } ], - "createLabel": null, - "gridColumns": null, "layoutStylesheet": "~/css/myblockgridlayout.css", "maxPropertyWidth": "100%", "useLiveEditing": false, diff --git a/src/Umbraco.Cms.15.x/uSync/v15/usync.config b/src/Umbraco.Cms.15.x/uSync/v15/usync.config deleted file mode 100644 index 60983ee..0000000 --- a/src/Umbraco.Cms.15.x/uSync/v15/usync.config +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/src/Umbraco.Cms.15.x/umbraco/models/BlockSettings.generated.cs b/src/Umbraco.Cms.15.x/umbraco/models/BlockSettings.generated.cs new file mode 100644 index 0000000..6072c9c --- /dev/null +++ b/src/Umbraco.Cms.15.x/umbraco/models/BlockSettings.generated.cs @@ -0,0 +1,60 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Umbraco.ModelsBuilder.Embedded v15.1.2+559c6c9 +// +// Changes to this file will be lost if the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Linq.Expressions; +using Umbraco.Cms.Core.Models.PublishedContent; +using Umbraco.Cms.Core.PublishedCache; +using Umbraco.Cms.Infrastructure.ModelsBuilder; +using Umbraco.Cms.Core; +using Umbraco.Extensions; + +namespace Umbraco.Cms.Web.Common.PublishedModels +{ + /// Block Settings + [PublishedModel("blockSettings")] + public partial class BlockSettings : PublishedElementModel + { + // helpers +#pragma warning disable 0109 // new is redundant + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "15.1.2+559c6c9")] + public new const string ModelTypeAlias = "blockSettings"; + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "15.1.2+559c6c9")] + public new const PublishedItemType ModelItemType = PublishedItemType.Content; + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "15.1.2+559c6c9")] + [return: global::System.Diagnostics.CodeAnalysis.MaybeNull] + public new static IPublishedContentType GetModelContentType(IPublishedContentTypeCache contentTypeCache) + => PublishedModelUtility.GetModelContentType(contentTypeCache, ModelItemType, ModelTypeAlias); + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "15.1.2+559c6c9")] + [return: global::System.Diagnostics.CodeAnalysis.MaybeNull] + public static IPublishedPropertyType GetModelPropertyType(IPublishedContentTypeCache contentTypeCache, Expression> selector) + => PublishedModelUtility.GetModelPropertyType(GetModelContentType(contentTypeCache), selector); +#pragma warning restore 0109 + + private IPublishedValueFallback _publishedValueFallback; + + // ctor + public BlockSettings(IPublishedElement content, IPublishedValueFallback publishedValueFallback) + : base(content, publishedValueFallback) + { + _publishedValueFallback = publishedValueFallback; + } + + // properties + + /// + /// Dropdown + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "15.1.2+559c6c9")] + [global::System.Diagnostics.CodeAnalysis.MaybeNull] + [ImplementPropertyType("dropdown")] + public virtual string Dropdown => this.Value(_publishedValueFallback, "dropdown"); + } +} diff --git a/src/Umbraco.Community.BlockPreview.UI/package.json b/src/Umbraco.Community.BlockPreview.UI/package.json index 7350392..43bd889 100644 --- a/src/Umbraco.Community.BlockPreview.UI/package.json +++ b/src/Umbraco.Community.BlockPreview.UI/package.json @@ -1,7 +1,7 @@ { "name": "assets", "private": true, - "version": "3.2.1", + "version": "3.2.2", "type": "module", "scripts": { "dev": "vite", diff --git a/src/Umbraco.Community.BlockPreview.UI/public/umbraco-package.json b/src/Umbraco.Community.BlockPreview.UI/public/umbraco-package.json index b9e2366..28d385d 100644 --- a/src/Umbraco.Community.BlockPreview.UI/public/umbraco-package.json +++ b/src/Umbraco.Community.BlockPreview.UI/public/umbraco-package.json @@ -2,7 +2,7 @@ "$schema": "../umbraco-package-schema.json", "name": "Umbraco.Community.BlockPreview", "id": "Umbraco.Community.BlockPreview", - "version": "3.2.1", + "version": "3.2.2", "allowTelemetry": true, "extensions": [ { diff --git a/src/Umbraco.Community.BlockPreview/Services/BlockPreviewService.cs b/src/Umbraco.Community.BlockPreview/Services/BlockPreviewService.cs index dac382c..3e0ae21 100644 --- a/src/Umbraco.Community.BlockPreview/Services/BlockPreviewService.cs +++ b/src/Umbraco.Community.BlockPreview/Services/BlockPreviewService.cs @@ -140,6 +140,7 @@ public async Task RenderGridBlock( IPublishedElement? contentElement = ConvertToElement(contentData, true, content); + FormatBlockData(blockValue?.BlockValue.SettingsData); BlockItemData? settingsData = settingsGuidParsed != Guid.Empty ? blockValue?.BlockValue?.SettingsData.FirstOrDefault(x => x.Key == settingsGuidParsed) : null; @@ -227,6 +228,7 @@ public async Task RenderListBlock( IPublishedElement? contentElement = ConvertToElement(contentData, true, content); + FormatBlockData(blockValue?.BlockValue.SettingsData); BlockItemData? settingsData = settingsGuidParsed != Guid.Empty ? blockValue?.BlockValue?.SettingsData.FirstOrDefault(x => x.Key == settingsGuidParsed) : null; @@ -264,13 +266,15 @@ public async Task RenderRichTextBlock( if (!converter.TryDeserialize(blockData, out BlockEditorData? blockValue)) return string.Format(Constants.ErrorMessages.ErrorTemplate, Constants.ErrorMessages.InvalidBlockData); - BlockItemData? contentData = blockValue.BlockValue?.ContentData.FirstOrDefault(); + FormatBlockData(blockValue?.BlockValue.ContentData); + BlockItemData? contentData = blockValue?.BlockValue?.ContentData.FirstOrDefault(); if (contentData == null) return string.Format(Constants.ErrorMessages.ErrorTemplate, Constants.ErrorMessages.InvalidContentData); IPublishedElement? contentElement = ConvertToElement(contentData, true, content); - BlockItemData? settingsData = blockValue.BlockValue?.SettingsData.FirstOrDefault(); + FormatBlockData(blockValue?.BlockValue.SettingsData); + BlockItemData? settingsData = blockValue?.BlockValue.SettingsData.FirstOrDefault(); IPublishedElement? settingsElement = settingsData != null ? ConvertToElement(settingsData, true, content) : default; Type? contentBlockType = FindBlockType(contentElement?.ContentType.Alias); @@ -342,6 +346,7 @@ public async Task RenderRichTextBlock( if (blockValue != null) { FormatBlockData(blockValue.BlockValue.ContentData); + FormatBlockData(blockValue.BlockValue.SettingsData); property.Value = JsonSerializer.Serialize(blockValue.BlockValue, _jsonSerializerOptions); } } @@ -352,6 +357,7 @@ public async Task RenderRichTextBlock( if (blockValue != null) { FormatBlockData(blockValue.BlockValue.ContentData); + FormatBlockData(blockValue.BlockValue.SettingsData); property.Value = JsonSerializer.Serialize(blockValue.BlockValue, _jsonSerializerOptions); } } diff --git a/src/Umbraco.Community.BlockPreview/Umbraco.Community.BlockPreview.csproj b/src/Umbraco.Community.BlockPreview/Umbraco.Community.BlockPreview.csproj index 2b68a2d..6db39a5 100644 --- a/src/Umbraco.Community.BlockPreview/Umbraco.Community.BlockPreview.csproj +++ b/src/Umbraco.Community.BlockPreview/Umbraco.Community.BlockPreview.csproj @@ -16,7 +16,7 @@ true - 3.2.1 + 3.2.2 Rick Butterfield, Dave Woestenborghs, Matthew Wise $([System.DateTime]::UtcNow.ToString(`yyyy`)) © Rick Butterfield diff --git a/src/Umbraco.Community.BlockPreview/wwwroot/App_Plugins/Umbraco.Community.BlockPreview/umbraco-package.json b/src/Umbraco.Community.BlockPreview/wwwroot/App_Plugins/Umbraco.Community.BlockPreview/umbraco-package.json index b9e2366..28d385d 100644 --- a/src/Umbraco.Community.BlockPreview/wwwroot/App_Plugins/Umbraco.Community.BlockPreview/umbraco-package.json +++ b/src/Umbraco.Community.BlockPreview/wwwroot/App_Plugins/Umbraco.Community.BlockPreview/umbraco-package.json @@ -2,7 +2,7 @@ "$schema": "../umbraco-package-schema.json", "name": "Umbraco.Community.BlockPreview", "id": "Umbraco.Community.BlockPreview", - "version": "3.2.1", + "version": "3.2.2", "allowTelemetry": true, "extensions": [ {