Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { UMB_PROPERTY_DATASET_CONTEXT } from '@umbraco-cms/backoffice/property';
import { UmbModalRouteRegistrationController } from '@umbraco-cms/backoffice/router';
import { incrementString } from '@umbraco-cms/backoffice/utils';

import '../../components/block-grid-area-config-entry/index.js';
@customElement('umb-property-editor-ui-block-grid-areas-config')
export class UmbPropertyEditorUIBlockGridAreasConfigElement
extends UmbLitElement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,9 @@ export class UmbPropertyEditorUIBlockGridElement
#settingsDataPathTranslator?: UmbBlockElementDataValidationPathTranslator;
#managerContext = new UmbBlockGridManagerContext(this);
//
private _value: UmbBlockGridValueModel = {
layout: {},
contentData: [],
settingsData: [],
expose: [],
};
private _value: UmbBlockGridValueModel | undefined = undefined;

#lastValue: UmbBlockGridValueModel | undefined = undefined;

public set config(config: UmbPropertyEditorConfigCollection | undefined) {
if (!config) return;
Expand All @@ -68,6 +65,13 @@ export class UmbPropertyEditorUIBlockGridElement

@property({ attribute: false })
public override set value(value: UmbBlockGridValueModel | undefined) {
this.#lastValue = value;

if (!value) {
this._value = undefined;
return;
}

const buildUpValue: Partial<UmbBlockGridValueModel> = value ? { ...value } : {};
buildUpValue.layout ??= {};
buildUpValue.contentData ??= [];
Expand All @@ -80,7 +84,7 @@ export class UmbPropertyEditorUIBlockGridElement
this.#managerContext.setSettings(this._value.settingsData);
this.#managerContext.setExposes(this._value.expose);
}
public override get value(): UmbBlockGridValueModel {
public override get value(): UmbBlockGridValueModel | undefined {
return this._value;
}

Expand Down Expand Up @@ -116,13 +120,24 @@ export class UmbPropertyEditorUIBlockGridElement
this.#managerContext.exposes,
]).pipe(debounceTime(20)),
([layouts, contents, settings, exposes]) => {
this._value = {
...this._value,
layout: { [UMB_BLOCK_GRID_PROPERTY_EDITOR_SCHEMA_ALIAS]: layouts },
contentData: contents,
settingsData: settings,
expose: exposes,
};
if (layouts.length === 0) {
this._value = undefined;
} else {
this._value = {
...this._value,
layout: { [UMB_BLOCK_GRID_PROPERTY_EDITOR_SCHEMA_ALIAS]: layouts },
contentData: contents,
settingsData: settings,
expose: exposes,
};
}

// If we don't have a value set from the outside or an internal value, we don't want to set the value.
// This is added to prevent the block grid from setting an empty value on startup.
if (this.#lastValue === undefined && this._value === undefined) {
return;
}

propertyContext.setValue(this._value);
},
'motherObserver',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,19 @@ export class UmbPropertyEditorUIBlockListElement

//#catalogueModal: UmbModalRouteRegistrationController<typeof UMB_BLOCK_CATALOGUE_MODAL.DATA, undefined>;

private _value: UmbBlockListValueModel = {
layout: {},
contentData: [],
settingsData: [],
expose: [],
};
private _value: UmbBlockListValueModel | undefined = undefined;

#lastValue: UmbBlockListValueModel | undefined = undefined;

@property({ attribute: false })
public override set value(value: UmbBlockListValueModel | undefined) {
this.#lastValue = value;

if (!value) {
this._value = undefined;
return;
}

const buildUpValue: Partial<UmbBlockListValueModel> = value ? { ...value } : {};
buildUpValue.layout ??= {};
buildUpValue.contentData ??= [];
Expand Down Expand Up @@ -188,13 +192,24 @@ export class UmbPropertyEditorUIBlockListElement
this.#managerContext.exposes,
]).pipe(debounceTime(20)),
([layouts, contents, settings, exposes]) => {
this._value = {
...this._value,
layout: { [UMB_BLOCK_LIST_PROPERTY_EDITOR_SCHEMA_ALIAS]: layouts },
contentData: contents,
settingsData: settings,
expose: exposes,
};
if (layouts.length === 0) {
this._value = undefined;
} else {
this._value = {
...this._value,
layout: { [UMB_BLOCK_LIST_PROPERTY_EDITOR_SCHEMA_ALIAS]: layouts },
contentData: contents,
settingsData: settings,
expose: exposes,
};
}

// If we don't have a value set from the outside or an internal value, we don't want to set the value.
// This is added to prevent the block list from setting an empty value on startup.
if (this.#lastValue === undefined && this._value === undefined) {
return;
}

context.setValue(this._value);
},
'motherObserver',
Expand Down