@gisce/ooui 2.40.0-alpha.7 → 2.40.0-alpha.9
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/Graph/GraphIndicator.d.ts +2 -0
- package/dist/Graph/GraphIndicator.d.ts.map +1 -1
- package/dist/Kanban.d.ts +13 -0
- package/dist/Kanban.d.ts.map +1 -1
- package/dist/helpers/onChangeParser.d.ts.map +1 -1
- package/dist/ooui.es.js +457 -444
- package/dist/ooui.es.js.map +1 -1
- package/package.json +1 -1
- package/src/Graph/GraphIndicator.ts +9 -0
- package/src/Kanban.ts +16 -0
- package/src/helpers/onChangeParser.ts +8 -1
- package/src/spec/Graph.spec.ts +11 -1
- package/src/spec/Kanban.spec.ts +39 -0
package/package.json
CHANGED
|
@@ -28,6 +28,11 @@ export class GraphIndicator extends Graph {
|
|
|
28
28
|
return this._progressbar;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
_showTotal: boolean = true;
|
|
32
|
+
get showTotal(): boolean {
|
|
33
|
+
return this._showTotal;
|
|
34
|
+
}
|
|
35
|
+
|
|
31
36
|
_suffix: string | null = null;
|
|
32
37
|
get suffix(): string | null {
|
|
33
38
|
return this._suffix;
|
|
@@ -49,5 +54,9 @@ export class GraphIndicator extends Graph {
|
|
|
49
54
|
this._totalDomain = replaceEntities(element.attributes.totalDomain) || null;
|
|
50
55
|
this._showPercent = parseBoolAttribute(element.attributes.showPercent);
|
|
51
56
|
this._progressbar = parseBoolAttribute(element.attributes.progressbar);
|
|
57
|
+
this._showTotal =
|
|
58
|
+
element.attributes.showTotal !== undefined
|
|
59
|
+
? parseBoolAttribute(element.attributes.showTotal)
|
|
60
|
+
: true;
|
|
52
61
|
}
|
|
53
62
|
}
|
package/src/Kanban.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { replaceEntities } from "./helpers/attributeParser";
|
|
|
5
5
|
import { parseBoolAttribute, ParsedNode } from "./helpers/nodeParser";
|
|
6
6
|
import * as txml from "txml";
|
|
7
7
|
import { parseContext } from "./helpers/contextParser";
|
|
8
|
+
import { parseOnChange } from "./helpers/onChangeParser";
|
|
8
9
|
|
|
9
10
|
export type KanbanField = Widget & {
|
|
10
11
|
sum?: string; // Aggregation label (e.g., "Total hours")
|
|
@@ -106,6 +107,16 @@ class Kanban {
|
|
|
106
107
|
return this._colors;
|
|
107
108
|
}
|
|
108
109
|
|
|
110
|
+
/**
|
|
111
|
+
* Custom function to call when a card moves between columns
|
|
112
|
+
* Example: "handle_state_change" or with args "handle_state_change(field, from, to)"
|
|
113
|
+
* If not defined, the frontend should use the default on_change_column method
|
|
114
|
+
*/
|
|
115
|
+
_on_change_column: { method: string; args: string[] } | null = null;
|
|
116
|
+
get on_change_column(): { method: string; args: string[] } | null {
|
|
117
|
+
return this._on_change_column;
|
|
118
|
+
}
|
|
119
|
+
|
|
109
120
|
/**
|
|
110
121
|
* Context for each field in the kanban
|
|
111
122
|
*/
|
|
@@ -165,6 +176,11 @@ class Kanban {
|
|
|
165
176
|
this._status = replaceEntities(this._status);
|
|
166
177
|
}
|
|
167
178
|
|
|
179
|
+
// Parse on_change_column attribute
|
|
180
|
+
if (view.attributes.on_change_column) {
|
|
181
|
+
this._on_change_column = parseOnChange(view.attributes.on_change_column);
|
|
182
|
+
}
|
|
183
|
+
|
|
168
184
|
const widgetFactory = new WidgetFactory();
|
|
169
185
|
|
|
170
186
|
// Parse children (fields and buttons)
|
|
@@ -3,7 +3,14 @@ const parseOnChange = (onChangeString: string) => {
|
|
|
3
3
|
|
|
4
4
|
const method = splitted[0];
|
|
5
5
|
const argsGross = splitted[1];
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
// Handle case where there are no parentheses (no arguments)
|
|
8
|
+
const argsSplitted = argsGross
|
|
9
|
+
? argsGross
|
|
10
|
+
.split(",")
|
|
11
|
+
.map((arg) => arg.trim())
|
|
12
|
+
.filter((arg) => arg.length > 0)
|
|
13
|
+
: [];
|
|
7
14
|
|
|
8
15
|
return {
|
|
9
16
|
method,
|
package/src/spec/Graph.spec.ts
CHANGED
|
@@ -55,7 +55,7 @@ describe("A Graph", () => {
|
|
|
55
55
|
expect(graph.field).toBe("potencia");
|
|
56
56
|
expect(graph.operator).toBe("+");
|
|
57
57
|
});
|
|
58
|
-
it("should parse progressbar and
|
|
58
|
+
it("should parse progressbar, showPercent and showTotal attributes", () => {
|
|
59
59
|
const xml1 = `<?xml version="1.0"?>
|
|
60
60
|
<graph string="My indicator" type="indicator" progressbar="1" />
|
|
61
61
|
`;
|
|
@@ -63,6 +63,7 @@ describe("A Graph", () => {
|
|
|
63
63
|
const graph1 = parseGraph(xml1) as GraphIndicator;
|
|
64
64
|
expect(graph1.progressbar).toBe(true);
|
|
65
65
|
expect(graph1.showPercent).toBe(false);
|
|
66
|
+
expect(graph1.showTotal).toBe(true);
|
|
66
67
|
|
|
67
68
|
const xml2 = `<?xml version="1.0"?>
|
|
68
69
|
<graph string="My indicator" type="indicator" showPercent="1" />
|
|
@@ -71,6 +72,7 @@ describe("A Graph", () => {
|
|
|
71
72
|
const graph2 = parseGraph(xml2) as GraphIndicator;
|
|
72
73
|
expect(graph2.showPercent).toBe(true);
|
|
73
74
|
expect(graph2.progressbar).toBe(false);
|
|
75
|
+
expect(graph2.showTotal).toBe(true);
|
|
74
76
|
|
|
75
77
|
const xml3 = `<?xml version="1.0"?>
|
|
76
78
|
<graph string="My indicator" type="indicator" />
|
|
@@ -79,6 +81,14 @@ describe("A Graph", () => {
|
|
|
79
81
|
const graph3 = parseGraph(xml3) as GraphIndicator;
|
|
80
82
|
expect(graph3.showPercent).toBe(false);
|
|
81
83
|
expect(graph3.progressbar).toBe(false);
|
|
84
|
+
expect(graph3.showTotal).toBe(true);
|
|
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);
|
|
82
92
|
});
|
|
83
93
|
it("should parse a graph with timerange parameter", () => {
|
|
84
94
|
const xml = `<?xml version="1.0"?>
|
package/src/spec/Kanban.spec.ts
CHANGED
|
@@ -360,4 +360,43 @@ describe("A Kanban", () => {
|
|
|
360
360
|
expect(tree.aggregations.planned_hours).toBe("Total Planned");
|
|
361
361
|
expect(tree.aggregations.priority).toBe("Total Priority");
|
|
362
362
|
});
|
|
363
|
+
|
|
364
|
+
it("should parse on_change_column attribute with simple method name", () => {
|
|
365
|
+
const xmlWithOnChange = `<?xml version="1.0"?>
|
|
366
|
+
<kanban column_field="state" on_change_column="handle_state_change">
|
|
367
|
+
<field name="name"/>
|
|
368
|
+
</kanban>
|
|
369
|
+
`;
|
|
370
|
+
const tree = new Kanban(FIELDS);
|
|
371
|
+
tree.parse(xmlWithOnChange);
|
|
372
|
+
|
|
373
|
+
expect(tree.on_change_column).toBeDefined();
|
|
374
|
+
expect(tree.on_change_column?.method).toBe("handle_state_change");
|
|
375
|
+
expect(tree.on_change_column?.args).toHaveLength(0);
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
it("should parse on_change_column attribute with method and arguments", () => {
|
|
379
|
+
const xmlWithOnChangeArgs = `<?xml version="1.0"?>
|
|
380
|
+
<kanban column_field="state" on_change_column="handle_column_change(field, from_column, to_column, context)">
|
|
381
|
+
<field name="name"/>
|
|
382
|
+
</kanban>
|
|
383
|
+
`;
|
|
384
|
+
const tree = new Kanban(FIELDS);
|
|
385
|
+
tree.parse(xmlWithOnChangeArgs);
|
|
386
|
+
|
|
387
|
+
expect(tree.on_change_column).toBeDefined();
|
|
388
|
+
expect(tree.on_change_column?.method).toBe("handle_column_change");
|
|
389
|
+
expect(tree.on_change_column?.args).toHaveLength(4);
|
|
390
|
+
expect(tree.on_change_column?.args[0]).toBe("field");
|
|
391
|
+
expect(tree.on_change_column?.args[1]).toBe("from_column");
|
|
392
|
+
expect(tree.on_change_column?.args[2]).toBe("to_column");
|
|
393
|
+
expect(tree.on_change_column?.args[3]).toBe("context");
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
it("should return null for on_change_column when not defined", () => {
|
|
397
|
+
const tree = new Kanban(FIELDS);
|
|
398
|
+
tree.parse(XML_VIEW_KANBAN_MINIMAL);
|
|
399
|
+
|
|
400
|
+
expect(tree.on_change_column).toBeNull();
|
|
401
|
+
});
|
|
363
402
|
});
|