File tree Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -147,13 +147,19 @@ class Field extends Widget {
147
147
super . readOnly = value ;
148
148
}
149
149
150
+ _raw_props : any ;
151
+ get raw_props ( ) : any {
152
+ return this . _raw_props ;
153
+ }
154
+
150
155
constructor ( props : any ) {
151
156
super ( props ) ;
152
157
153
158
// Activated by default
154
159
this . _activated = true ;
155
160
156
161
if ( props ) {
162
+ this . _raw_props = props ;
157
163
if ( props . name ) {
158
164
this . _id = props . name ;
159
165
}
Original file line number Diff line number Diff line change @@ -7,6 +7,10 @@ class Tag extends Selection {
7
7
get colors ( ) : any | "auto" {
8
8
return this . _parsedWidgetProps . colors || { } ;
9
9
}
10
+
11
+ get colorField ( ) : string | null {
12
+ return this . _parsedWidgetProps ?. colorField || null ;
13
+ }
10
14
}
11
15
12
16
export default Tag ;
Original file line number Diff line number Diff line change @@ -44,4 +44,26 @@ describe("A Tag widget", () => {
44
44
expect ( widget . colors ) . toStrictEqual ( "auto" ) ;
45
45
} ) ;
46
46
} ) ;
47
+
48
+ describe ( "colorField property" , ( ) => {
49
+ it ( "should have default colorField to null" , ( ) => {
50
+ const widgetFactory = new WidgetFactory ( ) ;
51
+ const props = {
52
+ name : "status" ,
53
+ } ;
54
+ const widget = widgetFactory . createWidget ( "tag" , props ) ;
55
+
56
+ expect ( widget . colorField ) . toBeNull ( ) ;
57
+ } ) ;
58
+ it ( "should parse colorField property" , ( ) => {
59
+ const widgetFactory = new WidgetFactory ( ) ;
60
+ const props = {
61
+ name : "status" ,
62
+ widget_props : '{"colorField": "color"}' ,
63
+ } ;
64
+ const widget = widgetFactory . createWidget ( "tag" , props ) ;
65
+
66
+ expect ( widget . colorField ) . toBe ( "color" ) ;
67
+ } ) ;
68
+ } ) ;
47
69
} ) ;
You can’t perform that action at this time.
0 commit comments