From f2f6ab90eb0a25ede8cf93f1ba7d147d6c10a06e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Mon, 26 Aug 2024 22:12:28 +0200 Subject: [PATCH] grid onSubmit handler --- .../context/block-grid-entries.context.ts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/context/block-grid-entries.context.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/context/block-grid-entries.context.ts index 6cb5c0d2c1..a1d19fb1db 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/context/block-grid-entries.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/context/block-grid-entries.context.ts @@ -137,6 +137,26 @@ export class UmbBlockGridEntriesContext }, }; }) + .onSubmit(async (value, data) => { + if (value?.create && data) { + const created = await this.create( + value.create.contentElementTypeKey, + // We can parse an empty object, cause the rest will be filled in by others. + {} as any, + data.originData as UmbBlockGridWorkspaceOriginData, + ); + if (created) { + this.insert( + created.layout, + created.content, + created.settings, + data.originData as UmbBlockGridWorkspaceOriginData, + ); + } else { + throw new Error('Failed to create block'); + } + } + }) .observeRouteBuilder((routeBuilder) => { // TODO: Does it make any sense that this is a state? Check usage and confirm. [NL] this._catalogueRouteBuilderState.setValue(routeBuilder);