1
+ import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api' ;
2
+ import { UmbObjectState , appendToFrozenArray } from '@umbraco-cms/backoffice/observable-api' ;
3
+ import { UmbContextBase } from '@umbraco-cms/backoffice/class-api' ;
4
+ import { UMB_PROPERTY_CONTEXT } from '@umbraco-cms/backoffice/property' ;
5
+ import { umbConfirmModal } from '@umbraco-cms/backoffice/modal' ;
6
+ import { UMB_BLOCK_GRID_AREA_TYPE_ENTRIES_CONTEXT } from '../../property-editors/block-grid-areas-config/block-grid-area-type-entries.context-token.js' ;
1
7
import {
2
8
UmbBlockGridScaleManager ,
3
9
type UmbBlockGridScalableContext ,
4
10
} from '../../context/block-grid-scale-manager/block-grid-scale-manager.controller.js' ;
5
- import { UMB_BLOCK_GRID_AREA_TYPE_ENTRIES_CONTEXT } from '../../property-editors/block-grid-areas-config/block-grid-area-type-entries.context-token.js' ;
6
11
import { UMB_BLOCK_GRID_AREA_CONFIG_ENTRY_CONTEXT } from './block-grid-area-config-entry.context-token.js' ;
7
12
import type { UmbBlockGridTypeAreaType } from '@umbraco-cms/backoffice/block-grid' ;
8
- import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api' ;
9
- import { UmbObjectState } from '@umbraco-cms/backoffice/observable-api' ;
10
- import { UmbContextBase } from '@umbraco-cms/backoffice/class-api' ;
11
- import { UMB_PROPERTY_CONTEXT } from '@umbraco-cms/backoffice/property' ;
12
- import { umbConfirmModal } from '@umbraco-cms/backoffice/modal' ;
13
13
export class UmbBlockGridAreaConfigEntryContext
14
14
extends UmbContextBase < UmbBlockGridAreaConfigEntryContext >
15
15
implements UmbBlockGridScalableContext
@@ -21,6 +21,7 @@ export class UmbBlockGridAreaConfigEntryContext
21
21
//
22
22
#areaKey?: string ;
23
23
#area = new UmbObjectState < UmbBlockGridTypeAreaType | undefined > ( undefined ) ;
24
+ readonly area = this . #area. asObservable ( ) ;
24
25
readonly alias = this . #area. asObservablePart ( ( x ) => x ?. alias ) ;
25
26
readonly columnSpan = this . #area. asObservablePart ( ( x ) => x ?. columnSpan ) ;
26
27
readonly rowSpan = this . #area. asObservablePart ( ( x ) => x ?. rowSpan ?? 1 ) ;
@@ -85,7 +86,19 @@ export class UmbBlockGridAreaConfigEntryContext
85
86
this . #area. setValue ( areaType ) ;
86
87
}
87
88
} ,
88
- 'observeAreaKey' ,
89
+ 'observeAreaData' ,
90
+ ) ;
91
+ this . observe (
92
+ this . area ,
93
+ ( area ) => {
94
+ if ( area && this . #propertyContext) {
95
+ const value = this . #propertyContext. getValue ( ) as Array < UmbBlockGridTypeAreaType > | undefined ;
96
+ if ( ! value ) return ;
97
+ const newValue = appendToFrozenArray ( value , area , ( x ) => x . key === this . #areaKey) ;
98
+ this . #propertyContext?. setValue ( newValue ) ;
99
+ }
100
+ } ,
101
+ 'observeInternalArea' ,
89
102
) ;
90
103
}
91
104
0 commit comments