From 399f5702383487d0033670b3e2753bd04656d0ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Mon, 2 Jan 2023 11:24:54 +0100 Subject: [PATCH] next step --- .../entity-property/entity-property.element.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/components/entity-property/entity-property.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/components/entity-property/entity-property.element.ts index 962476dea7..fd9ace9eac 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/components/entity-property/entity-property.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/components/entity-property/entity-property.element.ts @@ -11,6 +11,7 @@ import '../../property-actions/shared/property-action-menu/property-action-menu. import '../../workspaces/shared/workspace-property-layout/workspace-property-layout.element'; import { UmbContextProviderController } from 'src/core/context-api/provide/context-provider.controller'; import { UmbControllerHostMixin } from 'src/core/controller/controller-host.mixin'; +import { UmbObserverController } from 'src/core/observable-api/observer.controller'; /** * @element umb-entity-property @@ -122,21 +123,30 @@ export class UmbEntityPropertyElement extends UmbControllerHostMixin(UmbObserver private _propertyContext = new UmbWorkspacePropertyContext(""); + private propertyEditorUIObserver?: UmbObserverController; + + constructor() { super(); // TODO: make it easier to create a provider, unless a context should just extends a provider-controller? new UmbContextProviderController(this, 'umbPropertyContext', this._propertyContext); + + this._observePropertyEditorUI(); + this.addEventListener('property-editor-change', this._onPropertyEditorChange as any as EventListener); + } - this.observe(umbExtensionsRegistry.getByAlias(this.propertyEditorUIAlias), (manifest) => { + private _observePropertyEditorUI() { + if(this.propertyEditorUIObserver) { + //this.propertyEditorUIObserver.destroy(); + } + this.propertyEditorUIObserver = new UmbObserverController(this, umbExtensionsRegistry.getByAlias(this.propertyEditorUIAlias), (manifest) => { if (manifest?.type === 'propertyEditorUI') { this._gotData(manifest); } }); - this.addEventListener('property-editor-change', this._onPropertyEditorChange as any as EventListener); } - private _gotData(propertyEditorUIManifest?: ManifestPropertyEditorUI) { if (!propertyEditorUIManifest) { // TODO: if dataTypeKey didn't exist in store, we should do some nice UI.