correct block catalogue data parsing
This commit is contained in:
@@ -244,33 +244,32 @@ export class UmbBlockGridEntriesContext
|
||||
// Area entries:
|
||||
if (!this.#areaType) return [];
|
||||
|
||||
if (this.#areaType.specifiedAllowance && this.#areaType.specifiedAllowance.length > 0) {
|
||||
return this.#areaType.specifiedAllowance
|
||||
.flatMap((permission) => {
|
||||
if (permission.groupKey) {
|
||||
return (
|
||||
this._manager
|
||||
?.getBlockTypes()
|
||||
.filter(
|
||||
(blockType) => blockType.groupKey === permission.groupKey && blockType.allowInAreas === true,
|
||||
) ?? []
|
||||
);
|
||||
} else if (permission.elementTypeKey) {
|
||||
return (
|
||||
this._manager?.getBlockTypes().filter((x) => x.contentElementTypeKey === permission.elementTypeKey) ??
|
||||
[]
|
||||
);
|
||||
}
|
||||
return [];
|
||||
})
|
||||
.filter((v, i, a) => a.find((x) => x.contentElementTypeKey === v.contentElementTypeKey) === undefined);
|
||||
if (this.#areaType.specifiedAllowance && this.#areaType.specifiedAllowance?.length > 0) {
|
||||
return (
|
||||
this.#areaType.specifiedAllowance
|
||||
.flatMap((permission) => {
|
||||
if (permission.groupKey) {
|
||||
return (
|
||||
this._manager?.getBlockTypes().filter((blockType) => blockType.groupKey === permission.groupKey) ?? []
|
||||
);
|
||||
} else if (permission.elementTypeKey) {
|
||||
return (
|
||||
this._manager?.getBlockTypes().filter((x) => x.contentElementTypeKey === permission.elementTypeKey) ??
|
||||
[]
|
||||
);
|
||||
}
|
||||
return [];
|
||||
})
|
||||
// Remove duplicates:
|
||||
.filter((v, i, a) => a.findIndex((x) => x.contentElementTypeKey === v.contentElementTypeKey) === i)
|
||||
);
|
||||
}
|
||||
|
||||
// No specific permissions setup, so we will fallback to items allowed in areas:
|
||||
return this._manager.getBlockTypes().filter((x) => x.allowInAreas);
|
||||
}
|
||||
// If no AreaKey, then we are representing the items of the root:
|
||||
|
||||
// Root entries:
|
||||
// If no AreaKey, then we are in the root, looking for items allowed as root:
|
||||
return this._manager.getBlockTypes().filter((x) => x.allowAtRoot);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,9 @@ export class UmbBlockCatalogueModalElement extends UmbModalBaseElement<
|
||||
UmbBlockCatalogueModalData,
|
||||
UmbBlockCatalogueModalValue
|
||||
> {
|
||||
@state()
|
||||
//
|
||||
private _search = '';
|
||||
|
||||
private _groupedBlocks: Array<{ name?: string; blocks: Array<UmbBlockTypeWithGroupKey> }> = [];
|
||||
|
||||
@state()
|
||||
@@ -28,9 +30,6 @@ export class UmbBlockCatalogueModalElement extends UmbModalBaseElement<
|
||||
@state()
|
||||
private _filtered: Array<{ name?: string; blocks: Array<UmbBlockTypeWithGroupKey> }> = [];
|
||||
|
||||
@state()
|
||||
private _search = '';
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
@@ -68,10 +67,11 @@ export class UmbBlockCatalogueModalElement extends UmbModalBaseElement<
|
||||
}));
|
||||
|
||||
this._groupedBlocks = [{ blocks: noGroupBlocks }, ...grouped];
|
||||
this.#onFilter();
|
||||
this.#updateFiltered();
|
||||
}
|
||||
|
||||
#onFilter() {
|
||||
#updateFiltered() {
|
||||
// A minimum of 3 characters is required to start filtering:
|
||||
if (this._search.length <= 3) {
|
||||
this._filtered = this._groupedBlocks;
|
||||
} else {
|
||||
@@ -84,7 +84,7 @@ export class UmbBlockCatalogueModalElement extends UmbModalBaseElement<
|
||||
|
||||
#onSearch(e: UUIInputEvent) {
|
||||
this._search = e.target.value as string;
|
||||
this.#onFilter();
|
||||
this.#updateFiltered();
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
Reference in New Issue
Block a user