@gisce/ooui 0.2.2 → 0.2.3

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.
@@ -4,6 +4,12 @@ declare class Indicator extends Field {
4
4
  _card: boolean;
5
5
  get card(): boolean;
6
6
  set card(value: boolean);
7
+ _icon: string;
8
+ get icon(): string;
9
+ set icon(value: string);
10
+ _suffix: string;
11
+ get suffix(): string;
12
+ set suffix(value: string);
7
13
  constructor(props: any);
8
14
  }
9
15
  export default Indicator;
package/dist/Indicator.js CHANGED
@@ -18,8 +18,12 @@ var Indicator = /** @class */ (function (_super) {
18
18
  var _this = _super.call(this, props) || this;
19
19
  _this._nolabel = true;
20
20
  _this._card = false;
21
+ _this._icon = "";
22
+ _this._suffix = "";
21
23
  if (_this._parsedWidgetProps) {
22
- _this._card = _this._parsedWidgetProps.card;
24
+ _this._card = _this._parsedWidgetProps.card || false;
25
+ _this._icon = _this._parsedWidgetProps.icon || "";
26
+ _this._suffix = _this._parsedWidgetProps.suffix || "";
23
27
  }
24
28
  return _this;
25
29
  }
@@ -33,6 +37,26 @@ var Indicator = /** @class */ (function (_super) {
33
37
  enumerable: false,
34
38
  configurable: true
35
39
  });
40
+ Object.defineProperty(Indicator.prototype, "icon", {
41
+ get: function () {
42
+ return this._icon;
43
+ },
44
+ set: function (value) {
45
+ this._icon = value;
46
+ },
47
+ enumerable: false,
48
+ configurable: true
49
+ });
50
+ Object.defineProperty(Indicator.prototype, "suffix", {
51
+ get: function () {
52
+ return this._suffix;
53
+ },
54
+ set: function (value) {
55
+ this._suffix = value;
56
+ },
57
+ enumerable: false,
58
+ configurable: true
59
+ });
36
60
  return Indicator;
37
61
  }(Field));
38
62
  export default Indicator;
@@ -1 +1 @@
1
- {"version":3,"file":"Indicator.js","sourceRoot":"","sources":["../src/Indicator.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,SAAS,CAAC;AAE5B;IAAwB,6BAAK;IAW3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S,KAAc;YACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACrB,CAAC;;;OAHA;IAKD,sBAAI,2BAAI;aAAR;YACE,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;aACD,UAAS,KAAa;YACpB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACrB,CAAC;;;OAHA;IAKD,sBAAI,6BAAM;aAAV;YACE,OAAO,IAAI,CAAC,OAAO,CAAC;QACtB,CAAC;aACD,UAAW,KAAa;YACtB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACvB,CAAC;;;OAHA;IAgBH,gBAAC;AAAD,CAAC,AApCD,CAAwB,KAAK,GAoC5B;AAGD,eAAe,SAAS,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gisce/ooui",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "dependencies": {},
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/Indicator.ts CHANGED
@@ -10,12 +10,30 @@ class Indicator extends Field {
10
10
  set card(value: boolean) {
11
11
  this._card = value;
12
12
  }
13
+ _icon: string;
14
+ get icon(): string {
15
+ return this._icon;
16
+ }
17
+ set icon(value: string) {
18
+ this._icon = value;
19
+ }
20
+ _suffix: string;
21
+ get suffix(): string {
22
+ return this._suffix;
23
+ }
24
+ set suffix(value: string) {
25
+ this._suffix = value;
26
+ }
13
27
 
14
28
  constructor(props: any) {
15
29
  super(props);
16
30
  this._card = false;
31
+ this._icon = "";
32
+ this._suffix = "";
17
33
  if (this._parsedWidgetProps) {
18
- this._card = this._parsedWidgetProps.card;
34
+ this._card = this._parsedWidgetProps.card || false;
35
+ this._icon = this._parsedWidgetProps.icon || "";
36
+ this._suffix = this._parsedWidgetProps.suffix || "";
19
37
  }
20
38
  }
21
39
  }
@@ -19,9 +19,28 @@ describe("An Indicator", () => {
19
19
  it('should parse widget props', () => {
20
20
  const widgetFactory = new WidgetFactory();
21
21
  const props = {
22
- widget_props: "{'card': true}"
22
+ widget_props: "{'card': true, 'icon': 'wallet', 'suffix': '€'}"
23
23
  };
24
24
  const widget = widgetFactory.createWidget("indicator", props);
25
25
  expect(widget.card).toBe(true);
26
+ expect(widget.icon).toBe('wallet');
27
+ expect(widget.suffix).toBe('€');
28
+ });
29
+ it('icon and suffix should be an empty string if not defined', () => {
30
+ const widgetFactory = new WidgetFactory();
31
+ const props = {
32
+ widget_props: "{'card': true}"
33
+ };
34
+ const widget = widgetFactory.createWidget("indicator", props);
35
+ expect(widget.icon).toBe("");
36
+ expect(widget.suffix).toBe("");
37
+ });
38
+ it('card should be false if not defined', () => {
39
+ const widgetFactory = new WidgetFactory();
40
+ const props = {
41
+ widget_props: "{'icon': 'wallet'}"
42
+ };
43
+ const widget = widgetFactory.createWidget("indicator", props);
44
+ expect(widget.card).toBe(false);
26
45
  });
27
46
  });