@gisce/ooui 2.41.0 → 2.42.0

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.41.0",
3
+ "version": "2.42.0",
4
4
  "engines": {
5
5
  "node": "20.5.0"
6
6
  },
@@ -23,6 +23,16 @@ export class GraphIndicator extends Graph {
23
23
  return this._showPercent;
24
24
  }
25
25
 
26
+ _progressbar: boolean = false;
27
+ get progressbar(): boolean {
28
+ return this._progressbar;
29
+ }
30
+
31
+ _showTotal: boolean = true;
32
+ get showTotal(): boolean {
33
+ return this._showTotal;
34
+ }
35
+
26
36
  _suffix: string | null = null;
27
37
  get suffix(): string | null {
28
38
  return this._suffix;
@@ -43,5 +53,10 @@ export class GraphIndicator extends Graph {
43
53
  this._suffix = element.attributes.suffix || null;
44
54
  this._totalDomain = replaceEntities(element.attributes.totalDomain) || null;
45
55
  this._showPercent = parseBoolAttribute(element.attributes.showPercent);
56
+ this._progressbar = parseBoolAttribute(element.attributes.progressbar);
57
+ this._showTotal =
58
+ element.attributes.showTotal !== undefined
59
+ ? parseBoolAttribute(element.attributes.showTotal)
60
+ : !!this._totalDomain;
46
61
  }
47
62
  }
@@ -55,6 +55,66 @@ describe("A Graph", () => {
55
55
  expect(graph.field).toBe("potencia");
56
56
  expect(graph.operator).toBe("+");
57
57
  });
58
+ it("should parse progressbar, showPercent and showTotal attributes", () => {
59
+ const xml1 = `<?xml version="1.0"?>
60
+ <graph string="My indicator" type="indicator" progressbar="1" />
61
+ `;
62
+
63
+ const graph1 = parseGraph(xml1) as GraphIndicator;
64
+ expect(graph1.progressbar).toBe(true);
65
+ expect(graph1.showPercent).toBe(false);
66
+ expect(graph1.showTotal).toBe(false); // No totalDomain, should default to false
67
+
68
+ const xml2 = `<?xml version="1.0"?>
69
+ <graph string="My indicator" type="indicator" showPercent="1" />
70
+ `;
71
+
72
+ const graph2 = parseGraph(xml2) as GraphIndicator;
73
+ expect(graph2.showPercent).toBe(true);
74
+ expect(graph2.progressbar).toBe(false);
75
+ expect(graph2.showTotal).toBe(false); // No totalDomain, should default to false
76
+
77
+ const xml3 = `<?xml version="1.0"?>
78
+ <graph string="My indicator" type="indicator" />
79
+ `;
80
+
81
+ const graph3 = parseGraph(xml3) as GraphIndicator;
82
+ expect(graph3.showPercent).toBe(false);
83
+ expect(graph3.progressbar).toBe(false);
84
+ expect(graph3.showTotal).toBe(false); // No totalDomain, should default to false
85
+
86
+ const xml4 = `<?xml version="1.0"?>
87
+ <graph string="My indicator" type="indicator" showTotal="0" />
88
+ `;
89
+
90
+ const graph4 = parseGraph(xml4) as GraphIndicator;
91
+ expect(graph4.showTotal).toBe(false);
92
+ });
93
+ it("should set showTotal to true when totalDomain is defined", () => {
94
+ const xml1 = `<?xml version="1.0"?>
95
+ <graph string="My indicator" type="indicator" totalDomain="[('state','=','open')]" />
96
+ `;
97
+
98
+ const graph1 = parseGraph(xml1) as GraphIndicator;
99
+ expect(graph1.totalDomain).toBe("[('state','=','open')]");
100
+ expect(graph1.showTotal).toBe(true); // totalDomain is defined, should default to true
101
+
102
+ const xml2 = `<?xml version="1.0"?>
103
+ <graph string="My indicator" type="indicator" totalDomain="[('state','=','open')]" showTotal="0" />
104
+ `;
105
+
106
+ const graph2 = parseGraph(xml2) as GraphIndicator;
107
+ expect(graph2.totalDomain).toBe("[('state','=','open')]");
108
+ expect(graph2.showTotal).toBe(false); // Explicitly set to false
109
+
110
+ const xml3 = `<?xml version="1.0"?>
111
+ <graph string="My indicator" type="indicator" totalDomain="[('state','=','open')]" showTotal="1" />
112
+ `;
113
+
114
+ const graph3 = parseGraph(xml3) as GraphIndicator;
115
+ expect(graph3.totalDomain).toBe("[('state','=','open')]");
116
+ expect(graph3.showTotal).toBe(true); // Explicitly set to true
117
+ });
58
118
  it("should parse a graph with timerange parameter", () => {
59
119
  const xml = `<?xml version="1.0"?>
60
120
  <graph type="line" timerange="day">