resetState methods for block

This commit is contained in:
Niels Lyngsø
2024-07-04 20:00:27 +02:00
parent 6f7b4b4c70
commit 5924b08834
2 changed files with 13 additions and 6 deletions

View File

@@ -30,9 +30,6 @@ export class UmbBlockTypeWorkspaceContext<BlockTypeData extends UmbBlockTypeWith
readonly name = this.#data.asObservablePart(() => 'block');
readonly unique = this.#data.asObservablePart((data) => data?.contentElementTypeKey);
#properties = new UmbArrayState<PropertyEditorSettingsProperty>([], (x) => x.alias);
readonly properties = this.#properties.asObservable();
constructor(host: UmbControllerHost, args: { manifest: ManifestWorkspace }) {
super(host, args.manifest.alias);
const manifest = args.manifest;
@@ -73,7 +70,7 @@ export class UmbBlockTypeWorkspaceContext<BlockTypeData extends UmbBlockTypeWith
protected override resetState() {
super.resetState();
this.#data.setValue(undefined);
this.#properties.setValue([]);
this.removeUmbControllerByAlias('isNewRedirectController');
}
createPropertyDatasetContext(host: UmbControllerHost): UmbPropertyDatasetContext {
@@ -168,7 +165,6 @@ export class UmbBlockTypeWorkspaceContext<BlockTypeData extends UmbBlockTypeWith
public override destroy(): void {
this.#data.destroy();
this.#properties.destroy();
super.destroy();
}
}

View File

@@ -112,13 +112,24 @@ export class UmbBlockWorkspaceContext<LayoutDataType extends UmbBlockLayoutBaseM
]);
}
protected override resetState() {
super.resetState();
this.#label.setValue(undefined);
this.#layout.setValue(undefined);
this.#initialLayout = undefined;
this.#initialContent = undefined;
this.#initialSettings = undefined;
this.content.reset();
this.settings.reset();
this.removeUmbControllerByAlias('isNewRedirectController');
}
async load(unique: string) {
await this.#retrieveBlockManager;
await this.#retrieveBlockEntries;
await this.#editorConfigPromise;
if (!this.#blockManager || !this.#blockEntries) {
throw new Error('Block manager not found');
return;
}
this.observe(