From 5b647c33baf58460413eb483ac18dc03ce34ffcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Tue, 21 May 2024 09:59:45 +0200 Subject: [PATCH] clean up - revert test code --- .../context/block-grid-entries.context.ts | 1 - .../block-grid/context/block-grid-entry.context.ts | 13 ++++++++----- .../block/block/context/block-entry.context.ts | 14 +++++++------- 3 files changed, 15 insertions(+), 13 deletions(-) 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 b151e80e55..85aa2cee6f 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 @@ -166,7 +166,6 @@ export class UmbBlockGridEntriesContext this.observe( this.layoutEntries, (layouts) => { - // TODO: CONSIDER await Promise.resolve(); HERE AS WELL, To delay the corrections of layouts in the upward stream. [NL] this._manager?.setLayouts(layouts); }, 'observeThisLayouts', diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/context/block-grid-entry.context.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/context/block-grid-entry.context.ts index cec1dfe913..10360f5bd5 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/context/block-grid-entry.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/context/block-grid-entry.context.ts @@ -31,7 +31,7 @@ export class UmbBlockGridEntryContext { // readonly columnSpan = this._layout.asObservablePart((x) => x?.columnSpan); - readonly rowSpan = this._layout.asObservablePart((x) => x?.rowSpan ?? 1); + readonly rowSpan = this._layout.asObservablePart((x) => x?.rowSpan); readonly columnSpanOptions = this._blockType.asObservablePart((x) => x?.columnSpanOptions ?? []); readonly areaTypeGridColumns = this._blockType.asObservablePart((x) => x?.areaGridColumns); readonly areas = this._blockType.asObservablePart((x) => x?.areas ?? []); @@ -71,8 +71,8 @@ export class UmbBlockGridEntryContext this.observe( observeMultiple([this.minMaxRowSpan, this.rowSpan]), ([minMax, rowSpan]) => { - if (minMax && rowSpan) { - const newRowSpan = Math.max(minMax[0], Math.min(rowSpan, minMax[1])); + if (minMax) { + const newRowSpan = Math.max(minMax[0], Math.min(rowSpan ?? 1, minMax[1])); if (newRowSpan !== rowSpan) { this._layout.update({ rowSpan: newRowSpan }); } @@ -84,7 +84,7 @@ export class UmbBlockGridEntryContext } layoutsOfArea(areaKey: string) { - return this._layout.asObservablePart((x) => x?.areas.find((x) => x.key === areaKey)?.items); + return this._layout.asObservablePart((x) => x?.areas?.find((x) => x.key === areaKey)?.items); } areaType(areaKey: string) { @@ -95,7 +95,7 @@ export class UmbBlockGridEntryContext const frozenValue = this._layout.value; if (!frozenValue) return; const areas = appendToFrozenArray( - frozenValue?.areas, + frozenValue?.areas ?? [], { key: areaKey, items: layouts, @@ -115,6 +115,7 @@ export class UmbBlockGridEntryContext if (!layoutColumns) return; columnSpan = this.#calcColumnSpan(columnSpan, this.getRelevantColumnSpanOptions(), layoutColumns); + if (columnSpan === this.getColumnSpan()) return; this._layout.update({ columnSpan }); } /** @@ -133,6 +134,8 @@ export class UmbBlockGridEntryContext const minMax = this.getMinMaxRowSpan(); if (!minMax) return; rowSpan = Math.max(minMax[0], Math.min(rowSpan, minMax[1])); + if (rowSpan === this.getRowSpan()) return; + this._layoutDataIsFromEntries = false; this._layout.update({ rowSpan }); } /** diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block/context/block-entry.context.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block/context/block-entry.context.ts index 3469d16225..b1ba802802 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/block/block/context/block-entry.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/block/block/context/block-entry.context.ts @@ -198,6 +198,8 @@ export abstract class UmbBlockEntryContext< } } + // Local state to ensure the two way binding dosnt go nuts. [NL] + _layoutDataIsFromEntries?: boolean; #observeLayout() { if (!this._entries || !this.#contentUdi) return; @@ -212,11 +214,8 @@ export abstract class UmbBlockEntryContext< this.layout, async (layout) => { if (layout) { - // Important to await here, as we need to make sure the layout is set for the other blocks of this 'entries-context' before we propagate changes. [NL] - await Promise.resolve(); - const latestValue = layout; //this._layout.getValue(); - if (latestValue) { - this._entries?.setOneLayout(latestValue); + if (layout) { + this._entries?.setOneLayout(layout); } } }, @@ -362,9 +361,10 @@ export abstract class UmbBlockEntryContext< } async requestDelete() { + const blockName = this.getLabel(); await umbConfirmModal(this, { - headline: `Delete ${this.getLabel()}`, - content: 'Are you sure you want to delete this [INSERT BLOCK TYPE NAME]?', + headline: `Delete ${blockName}`, + content: `Are you sure you want to delete this ${blockName}?`, confirmLabel: 'Delete', color: 'danger', });