@@ -7,6 +7,11 @@ import { UmbPropertyValueChangeEvent } from '@umbraco-cms/backoffice/property-ed
77import { UMB_DATA_TYPE_WORKSPACE_CONTEXT } from '@umbraco-cms/backoffice/data-type' ;
88import type { UmbBlockTypeWithGroupKey } from '@umbraco-cms/backoffice/block-type' ;
99import type { UUIComboboxElement , UUIComboboxEvent , UUIInputEvent } from '@umbraco-cms/backoffice/external/uui' ;
10+ import { UmbRepositoryItemsManager } from '@umbraco-cms/backoffice/repository' ;
11+ import {
12+ UMB_DOCUMENT_TYPE_ITEM_REPOSITORY_ALIAS ,
13+ type UmbDocumentTypeItemModel ,
14+ } from '@umbraco-cms/backoffice/document-type' ;
1015
1116@customElement ( 'umb-property-editor-ui-block-grid-area-type-permission' )
1217export class UmbPropertyEditorUIBlockGridAreaTypePermissionElement
@@ -24,20 +29,41 @@ export class UmbPropertyEditorUIBlockGridAreaTypePermissionElement
2429 @state ( )
2530 private _value : Array < UmbBlockGridTypeAreaTypePermission > = [ ] ;
2631
32+ _blockTypes : Array < UmbBlockTypeWithGroupKey > = [ ] ;
33+
2734 @state ( )
28- private _blockTypes : Array < UmbBlockTypeWithGroupKey > = [ ] ;
35+ private _blockTypesWithElementName : Array < { type : UmbBlockTypeWithGroupKey ; name : string } > = [ ] ;
2936
3037 @state ( )
3138 private _blockGroups : Array < UmbBlockGridTypeGroupType > = [ ] ;
3239
40+ #itemsManager = new UmbRepositoryItemsManager < UmbDocumentTypeItemModel > (
41+ this ,
42+ UMB_DOCUMENT_TYPE_ITEM_REPOSITORY_ALIAS ,
43+ ( x ) => x . unique ,
44+ ) ;
45+
3346 constructor ( ) {
3447 super ( ) ;
3548
49+ this . observe ( this . #itemsManager. items , ( items ) => {
50+ this . _blockTypesWithElementName = items
51+ . map ( ( item ) => {
52+ const blockType = this . _blockTypes . find ( ( block ) => block . contentElementTypeKey === item . unique ) ;
53+ if ( blockType ) {
54+ return { type : blockType , name : item . name } ;
55+ }
56+ return undefined ;
57+ } )
58+ . filter ( ( x ) => x !== undefined ) as Array < { type : UmbBlockTypeWithGroupKey ; name : string } > ;
59+ } ) ;
60+
3661 this . consumeContext ( UMB_DATA_TYPE_WORKSPACE_CONTEXT , async ( context ) => {
3762 this . observe (
3863 await context . propertyValueByAlias < Array < UmbBlockTypeWithGroupKey > > ( 'blocks' ) ,
3964 ( blockTypes ) => {
4065 this . _blockTypes = blockTypes ?? [ ] ;
66+ this . #itemsManager. setUniques ( blockTypes . map ( ( block ) => block . contentElementTypeKey ) ) ;
4167 } ,
4268 'observeBlockType' ,
4369 ) ;
@@ -103,7 +129,7 @@ export class UmbPropertyEditorUIBlockGridAreaTypePermissionElement
103129 this . _value ,
104130 ( permission ) => permission ,
105131 ( permission , index ) => {
106- const showCategoryHeader = this . _blockGroups . length && this . _blockTypes . length ;
132+ const showCategoryHeader = this . _blockGroups . length > 0 && this . _blockTypesWithElementName . length > 0 ;
107133
108134 return html `<div class= "permission-setting" >
109135 <uui- combobox
@@ -169,13 +195,13 @@ export class UmbPropertyEditorUIBlockGridAreaTypePermissionElement
169195
170196 #renderBlockTypes( area : UmbBlockGridTypeAreaTypePermission ) {
171197 return repeat (
172- this . _blockTypes ,
173- ( block ) => block . contentElementTypeKey ,
198+ this . _blockTypesWithElementName ,
199+ ( block ) => block . type . contentElementTypeKey ,
174200 ( block ) =>
175201 html `<uui- combobox- lis t- option
176- .value = ${ block . contentElementTypeKey }
177- ?selected= ${ area . elementTypeKey === block . contentElementTypeKey } >
178- ${ block . label }
202+ .value = ${ block . type . contentElementTypeKey }
203+ ?selected= ${ area . elementTypeKey === block . type . contentElementTypeKey } >
204+ ${ block . name }
179205 </ uui- combobox- lis t- option> ` ,
180206 ) ;
181207 }
0 commit comments