filter available property editor UIs in picker

This commit is contained in:
Mads Rasmussen
2022-09-21 10:16:35 +02:00
parent 4a4bec11fb
commit 80e58b7ac8
2 changed files with 16 additions and 4 deletions

View File

@@ -170,10 +170,12 @@ export class UmbEditorViewDataTypeEditElement extends UmbContextConsumerMixin(Li
}
private _openPropertyEditorUIPicker() {
if (!this._dataType) return;
if (!this._dataType || !this._dataType.propertyEditorAlias) return;
const selection = this._dataType.propertyEditorUIAlias ? [this._dataType.propertyEditorUIAlias] : [];
const modalHandler = this._modalService?.propertyEditorUIPicker({ selection });
const modalHandler = this._modalService?.propertyEditorUIPicker({
propertyEditorAlias: this._dataType.propertyEditorAlias,
selection: this._dataType.propertyEditorUIAlias ? [this._dataType.propertyEditorUIAlias] : [],
});
modalHandler?.onClose().then(({ selection } = {}) => {
if (!selection) return;

View File

@@ -4,13 +4,14 @@ import { customElement, property, state } from 'lit/decorators.js';
import { ifDefined } from 'lit-html/directives/if-defined.js';
import { UmbContextConsumerMixin } from '../../../../context';
import type { Subscription } from 'rxjs';
import { map, Subscription } from 'rxjs';
import type { UUIComboboxListElement, UUIComboboxListEvent } from '@umbraco-ui/uui';
import type { UmbModalHandler } from '../../modal-handler';
import type { UmbExtensionRegistry } from '../../../../extension';
import type { ManifestPropertyEditorUI } from '../../../../models';
export interface UmbModalPropertyEditorUIPickerData {
propertyEditorAlias: string;
selection?: Array<string>;
}
@@ -49,8 +50,17 @@ export class UmbModalLayoutPropertyEditorUIPickerElement extends UmbContextConsu
}
private _usePropertyEditorUIs() {
if (!this.data) return;
this._propertyEditorUIsSubscription = this._extensionRegistry
?.extensionsOfType('propertyEditorUI')
.pipe(
map((propertyEditorUIs) =>
propertyEditorUIs.filter((propertyEditorUI) =>
propertyEditorUI.meta.propertyEditors.includes(this.data?.propertyEditorAlias ?? '')
)
)
)
.subscribe((propertyEditorUIs) => {
this._propertyEditorUIs = propertyEditorUIs;
});