@gisce/ooui 2.29.1 → 2.30.0-alpha.1
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/dist/Indicator.d.ts +2 -0
- package/dist/Indicator.d.ts.map +1 -1
- package/dist/ooui.es.js +286 -282
- package/dist/ooui.es.js.map +1 -1
- package/package.json +1 -1
- package/src/Indicator.ts +8 -1
- package/src/spec/Indicator.spec.ts +16 -0
package/package.json
CHANGED
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 | 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) {
|
|
@@ -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
|
});
|