clean up - revert test code

This commit is contained in:
Niels Lyngsø
2024-05-21 09:59:45 +02:00
parent d94e4c8b7e
commit 5b647c33ba
3 changed files with 15 additions and 13 deletions

View File

@@ -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',

View File

@@ -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 });
}
/**

View File

@@ -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',
});