File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change 1
1
import Selection from "./Selection" ;
2
+ import { replaceEntities } from "./helpers/attributeParser" ;
2
3
3
4
class Indicator extends Selection {
4
5
_nolabel : boolean = true ;
@@ -30,6 +31,11 @@ class Indicator extends Selection {
30
31
this . _suffix = value ;
31
32
}
32
33
34
+ _color : string | undefined = undefined ;
35
+ get color ( ) : string | undefined {
36
+ return this . _color ;
37
+ }
38
+
33
39
/**
34
40
* Action id
35
41
*/
@@ -58,8 +64,9 @@ class Indicator extends Selection {
58
64
this . _suffix = "" ;
59
65
if ( this . _parsedWidgetProps ) {
60
66
this . _card = this . _parsedWidgetProps . card || false ;
61
- this . _icon = this . _parsedWidgetProps . icon || "" ;
67
+ this . _icon = replaceEntities ( this . _parsedWidgetProps . icon ) || "" ;
62
68
this . _suffix = this . _parsedWidgetProps . suffix || "" ;
69
+ this . _color = replaceEntities ( this . _parsedWidgetProps . color ) || "" ;
63
70
}
64
71
if ( props ) {
65
72
if ( props . action_id ) {
Original file line number Diff line number Diff line change @@ -43,4 +43,20 @@ describe("An Indicator", () => {
43
43
const widget = widgetFactory . createWidget ( "indicator" , props ) ;
44
44
expect ( widget . card ) . toBe ( false ) ;
45
45
} ) ;
46
+ it ( "should allow conditions in icon widget props" , ( ) => {
47
+ const widgetFactory = new WidgetFactory ( ) ;
48
+ const props = {
49
+ widget_props : "{'icon': 'alert-triange:value>10;wallet:value==0'}" ,
50
+ } ;
51
+ const widget = widgetFactory . createWidget ( "indicator" , props ) ;
52
+ expect ( widget . icon ) . toBe ( "alert-triange:value>10;wallet:value==0" ) ;
53
+ } ) ;
54
+ it ( "should allow color in widget props" , ( ) => {
55
+ const widgetFactory = new WidgetFactory ( ) ;
56
+ const props = {
57
+ widget_props : "{'color': 'red'}" ,
58
+ } ;
59
+ const widget = widgetFactory . createWidget ( "indicator" , props ) ;
60
+ expect ( widget . color ) . toBe ( "red" ) ;
61
+ } ) ;
46
62
} ) ;
You can’t perform that action at this time.
0 commit comments