From 1a6add63381a6b503bfee0c015dbc1a6beae5e44 Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Wed, 21 Sep 2022 09:22:58 +0200 Subject: [PATCH] show a message if there are no property editor UIs registered for a property editor --- .../editor-view-data-type-edit.element.ts | 33 ++++++++++++++----- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/editors/data-type/views/edit/editor-view-data-type-edit.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/editors/data-type/views/edit/editor-view-data-type-edit.element.ts index 4fcf09eb4a..323b9af5ef 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/editors/data-type/views/edit/editor-view-data-type-edit.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/editors/data-type/views/edit/editor-view-data-type-edit.element.ts @@ -1,5 +1,5 @@ import { UUITextStyles } from '@umbraco-ui/uui-css/lib'; -import { css, html, LitElement } from 'lit'; +import { css, html, LitElement, nothing } from 'lit'; import { customElement, state } from 'lit/decorators.js'; import { when } from 'lit-html/directives/when.js'; import { Subscription, map } from 'rxjs'; @@ -37,6 +37,9 @@ export class UmbEditorViewDataTypeEditElement extends UmbContextConsumerMixin(Li @state() private _propertyEditorUIAlias = ''; + @state() + private _availablePropertyEditorUIsCount = 0; + private _dataTypeContext?: UmbDataTypeContext; private _extensionRegistry?: UmbExtensionRegistry; private _propertyEditorStore?: UmbPropertyEditorStore; @@ -73,6 +76,8 @@ export class UmbEditorViewDataTypeEditElement extends UmbContextConsumerMixin(Li } private _observeDataType() { + if (!this._dataTypeContext || !this._propertyEditorStore || !this._extensionRegistry) return; + this._dataTypeSubscription?.unsubscribe(); this._dataTypeSubscription = this._dataTypeContext?.data.subscribe((dataType: DataTypeEntity) => { @@ -121,6 +126,7 @@ export class UmbEditorViewDataTypeEditElement extends UmbContextConsumerMixin(Li ) .subscribe((availablePropertyEditorUIs) => { // Select the Property Editor UI if there is only one available + this._availablePropertyEditorUIsCount = availablePropertyEditorUIs.length; if (availablePropertyEditorUIs?.length === 1) { this._selectPropertyEditorUI(availablePropertyEditorUIs[0].alias); } @@ -234,16 +240,25 @@ export class UmbEditorViewDataTypeEditElement extends UmbContextConsumerMixin(Li .alias=${this._propertyEditorUIAlias} border> - - - + + ${this._availablePropertyEditorUIsCount > 1 + ? html` + + + + ` + : nothing} ` - : html``} + : html` + ${this._availablePropertyEditorUIsCount > 0 + ? html`` + : html`No Property Editor UIs registered for this Property Editor`} + `} `; } }