diff --git a/VERSION b/VERSION index 62321af..5a68790 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.10.3 \ No newline at end of file +1.10.4 \ No newline at end of file diff --git a/src/Umbraco.Community.BlockPreview/Controllers/BlockPreviewApiController.cs b/src/Umbraco.Community.BlockPreview/Controllers/BlockPreviewApiController.cs index 659ebec..e8476c3 100644 --- a/src/Umbraco.Community.BlockPreview/Controllers/BlockPreviewApiController.cs +++ b/src/Umbraco.Community.BlockPreview/Controllers/BlockPreviewApiController.cs @@ -112,7 +112,9 @@ public async Task PreviewListBlock( [FromQuery] string blockEditorAlias = "", [FromQuery] string contentElementAlias = "", [FromQuery] string culture = "", - [FromQuery] Guid documentTypeKey = default) + [FromQuery] Guid documentTypeKey = default, + [FromQuery] string contentUdi = "", + [FromQuery] string? settingsUdi = default) { string markup; _ = culture; @@ -125,7 +127,7 @@ public async Task PreviewListBlock( await SetupPublishedRequest(currentCulture, content); - markup = await _blockPreviewService.RenderListBlock(blockData, ControllerContext); + markup = await _blockPreviewService.RenderListBlock(blockData, ControllerContext, contentUdi, settingsUdi); } catch (Exception ex) { diff --git a/src/Umbraco.Community.BlockPreview/Interfaces/IBlockPreviewService.cs b/src/Umbraco.Community.BlockPreview/Interfaces/IBlockPreviewService.cs index ed455f8..6573779 100644 --- a/src/Umbraco.Community.BlockPreview/Interfaces/IBlockPreviewService.cs +++ b/src/Umbraco.Community.BlockPreview/Interfaces/IBlockPreviewService.cs @@ -7,7 +7,7 @@ public interface IBlockPreviewService { Task RenderGridBlock(BlockValue blockData, ControllerContext controllerContext, string blockEditorAlias = "", Guid documentTypeUnique = default, string contentUdi = "", string? settingsUdi = default); - Task RenderListBlock(BlockValue blockData, ControllerContext controllerContext); + Task RenderListBlock(BlockValue blockData, ControllerContext controllerContext, string contentUdi = "", string? settingsUdi = default); #if NET8_0 Task RenderRichTextBlock(BlockValue blockData, ControllerContext controllerContext); diff --git a/src/Umbraco.Community.BlockPreview/Services/BlockPreviewService.cs b/src/Umbraco.Community.BlockPreview/Services/BlockPreviewService.cs index 089be5a..b16ee97 100644 --- a/src/Umbraco.Community.BlockPreview/Services/BlockPreviewService.cs +++ b/src/Umbraco.Community.BlockPreview/Services/BlockPreviewService.cs @@ -151,18 +151,28 @@ public async Task RenderGridBlock( public async Task RenderListBlock( BlockValue blockData, - ControllerContext controllerContext) + ControllerContext controllerContext, + string contentUdi = "", + string? settingsUdi = default) { if (blockData == null) return string.Empty; - BlockItemData? contentData = blockData.ContentData.FirstOrDefault(); + if (!UdiParser.TryParse(contentUdi, out Udi? contentUdiParsed)) + return string.Empty; + + UdiParser.TryParse(settingsUdi!, out Udi? settingsUdiParsed); + + BlockItemData? contentData = blockData.ContentData.FirstOrDefault(x => x.Udi == contentUdiParsed); if (contentData == null) return string.Empty; IPublishedElement? contentElement = ConvertToElement(contentData, true); - BlockItemData? settingsData = blockData.SettingsData.FirstOrDefault(); + BlockItemData? settingsData = settingsUdiParsed != null + ? blockData.SettingsData.FirstOrDefault(x => x.Udi == settingsUdiParsed) + : null; + IPublishedElement? settingsElement = settingsData != null ? ConvertToElement(settingsData, true) : default; Type? contentBlockType = FindBlockType(contentElement?.ContentType.Alias); diff --git a/src/Umbraco.Community.BlockPreview/Umbraco.Community.BlockPreview.csproj b/src/Umbraco.Community.BlockPreview/Umbraco.Community.BlockPreview.csproj index df6edf7..7c9e522 100644 --- a/src/Umbraco.Community.BlockPreview/Umbraco.Community.BlockPreview.csproj +++ b/src/Umbraco.Community.BlockPreview/Umbraco.Community.BlockPreview.csproj @@ -16,7 +16,7 @@ True - 1.10.3 + 1.10.4 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/js/controllers/block-preview.controller.js b/src/Umbraco.Community.BlockPreview/wwwroot/App_Plugins/Umbraco.Community.BlockPreview/js/controllers/block-preview.controller.js index 2cb1823..f51d07d 100644 --- a/src/Umbraco.Community.BlockPreview/wwwroot/App_Plugins/Umbraco.Community.BlockPreview/js/controllers/block-preview.controller.js +++ b/src/Umbraco.Community.BlockPreview/wwwroot/App_Plugins/Umbraco.Community.BlockPreview/js/controllers/block-preview.controller.js @@ -104,7 +104,9 @@ $scope.blockEditorAlias, $scope.contentElementAlias, $scope.language, - $scope.documentTypeKey) + $scope.documentTypeKey, + $scope.contentUdi, + $scope.settingsUdi) .then(function (data) { $scope.markup = $sce.trustAsHtml(data); $scope.loading = false; diff --git a/src/Umbraco.Community.BlockPreview/wwwroot/App_Plugins/Umbraco.Community.BlockPreview/js/resources/preview.resource.js b/src/Umbraco.Community.BlockPreview/wwwroot/App_Plugins/Umbraco.Community.BlockPreview/js/resources/preview.resource.js index bf1728f..3780f90 100644 --- a/src/Umbraco.Community.BlockPreview/wwwroot/App_Plugins/Umbraco.Community.BlockPreview/js/resources/preview.resource.js +++ b/src/Umbraco.Community.BlockPreview/wwwroot/App_Plugins/Umbraco.Community.BlockPreview/js/resources/preview.resource.js @@ -39,12 +39,14 @@ blockEditorAlias, contentElementAlias, culture, - documentTypeKey) + documentTypeKey, + contentUdi, + settingsUdi) { culture = culture || ''; return umbRequestHelper.resourcePromise( - $http.post(`${apiListUrl}?nodeKey=${nodeKey}&blockEditorAlias=${blockEditorAlias}&contentElementAlias=${contentElementAlias}&culture=${culture}&documentTypeKey=${documentTypeKey}`, blockData), + $http.post(`${apiListUrl}?nodeKey=${nodeKey}&blockEditorAlias=${blockEditorAlias}&contentElementAlias=${contentElementAlias}&culture=${culture}&documentTypeKey=${documentTypeKey}&contentUdi=${contentUdi}&settingsUdi=${settingsUdi}`, blockData), 'Failed getting block preview markup' ); };