@@ -14,27 +14,39 @@ import type { UmbVariantId } from '@umbraco-cms/backoffice/variant';
14
14
import type { UmbPropertyEditorConfigProperty } from '@umbraco-cms/backoffice/property-editor' ;
15
15
import { UmbPropertyEditorConfigCollection } from '@umbraco-cms/backoffice/property-editor' ;
16
16
import type { UmbPropertyEditorUiElement } from '@umbraco-cms/backoffice/extension-registry' ;
17
- import type { UmbPropertyTypeAppearanceModel } from '@umbraco-cms/backoffice/content-type' ;
17
+ import type {
18
+ UmbPropertyTypeAppearanceModel ,
19
+ UmbPropertyTypeValidationModel ,
20
+ } from '@umbraco-cms/backoffice/content-type' ;
18
21
19
22
export class UmbPropertyContext < ValueType = any > extends UmbContextBase < UmbPropertyContext < ValueType > > {
20
23
#alias = new UmbStringState ( undefined ) ;
21
24
public readonly alias = this . #alias. asObservable ( ) ;
25
+
22
26
#label = new UmbStringState ( undefined ) ;
23
27
public readonly label = this . #label. asObservable ( ) ;
28
+
24
29
#description = new UmbStringState ( undefined ) ;
25
30
public readonly description = this . #description. asObservable ( ) ;
31
+
26
32
#appearance = new UmbObjectState < UmbPropertyTypeAppearanceModel | undefined > ( undefined ) ;
27
33
public readonly appearance = this . #appearance. asObservable ( ) ;
34
+
28
35
#value = new UmbDeepState < ValueType | undefined > ( undefined ) ;
29
36
public readonly value = this . #value. asObservable ( ) ;
37
+
30
38
#configValues = new UmbArrayState < UmbPropertyEditorConfigProperty > ( [ ] , ( x ) => x . alias ) ;
31
39
public readonly configValues = this . #configValues. asObservable ( ) ;
32
40
33
41
#config = new UmbClassState < UmbPropertyEditorConfigCollection | undefined > ( undefined ) ;
34
42
public readonly config = this . #config. asObservable ( ) ;
35
43
44
+ #validation = new UmbObjectState < UmbPropertyTypeValidationModel | undefined > ( undefined ) ;
45
+ public readonly validation = this . #validation. asObservable ( ) ;
46
+
36
47
private _editor = new UmbBasicState < UmbPropertyEditorUiElement | undefined > ( undefined ) ;
37
48
public readonly editor = this . _editor . asObservable ( ) ;
49
+
38
50
setEditor ( editor : UmbPropertyEditorUiElement | undefined ) {
39
51
this . _editor . setValue ( editor ?? undefined ) ;
40
52
}
@@ -108,24 +120,28 @@ export class UmbPropertyContext<ValueType = any> extends UmbContextBase<UmbPrope
108
120
public getAlias ( ) : string | undefined {
109
121
return this . #alias. getValue ( ) ;
110
122
}
123
+
111
124
public setLabel ( label : string | undefined ) : void {
112
125
this . #label. setValue ( label ) ;
113
126
}
114
127
public getLabel ( ) : string | undefined {
115
128
return this . #label. getValue ( ) ;
116
129
}
130
+
117
131
public setDescription ( description : string | undefined ) : void {
118
132
this . #description. setValue ( description ) ;
119
133
}
120
134
public getDescription ( ) : string | undefined {
121
135
return this . #description. getValue ( ) ;
122
136
}
137
+
123
138
public setAppearance ( appearance : UmbPropertyTypeAppearanceModel | undefined ) : void {
124
139
this . #appearance. setValue ( appearance ) ;
125
140
}
126
141
public getAppearance ( ) : UmbPropertyTypeAppearanceModel | undefined {
127
142
return this . #appearance. getValue ( ) ;
128
143
}
144
+
129
145
/**
130
146
* Set the value of this property.
131
147
* @param value {ValueType} the whole value to be set
@@ -143,19 +159,28 @@ export class UmbPropertyContext<ValueType = any> extends UmbContextBase<UmbPrope
143
159
public getValue ( ) : ValueType | undefined {
144
160
return this . #value. getValue ( ) ;
145
161
}
162
+
146
163
public setConfig ( config : Array < UmbPropertyEditorConfigProperty > | undefined ) : void {
147
164
this . #configValues. setValue ( config ?? [ ] ) ;
148
165
}
149
166
public getConfig ( ) : Array < UmbPropertyEditorConfigProperty > | undefined {
150
167
return this . #configValues. getValue ( ) ;
151
168
}
169
+
152
170
public setVariantId ( variantId : UmbVariantId | undefined ) : void {
153
171
this . #variantId. setValue ( variantId ) ;
154
172
}
155
173
public getVariantId ( ) : UmbVariantId | undefined {
156
174
return this . #variantId. getValue ( ) ;
157
175
}
158
176
177
+ public setValidation ( validation : UmbPropertyTypeValidationModel | undefined ) : void {
178
+ this . #validation. setValue ( validation ) ;
179
+ }
180
+ public getValidation ( ) : UmbPropertyTypeValidationModel | undefined {
181
+ return this . #validation. getValue ( ) ;
182
+ }
183
+
159
184
public resetValue ( ) : void {
160
185
this . setValue ( undefined ) ; // TODO: We should get the value from the server aka. the value from the persisted data. (Most workspaces holds this data, via dataset) [NL]
161
186
}
0 commit comments