@gisce/ooui 2.29.1 → 2.30.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gisce/ooui",
3
- "version": "2.29.1",
3
+ "version": "2.30.0-alpha.2",
4
4
  "engines": {
5
5
  "node": "20.5.0"
6
6
  },
package/src/Indicator.ts CHANGED
@@ -1,4 +1,5 @@
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 = "";
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) {
@@ -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
  });