@gisce/ooui 0.2.9 → 0.2.12

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.
Files changed (45) hide show
  1. package/dist/Graph/Graph.d.ts +8 -0
  2. package/dist/Graph/Graph.js +23 -0
  3. package/dist/Graph/Graph.js.map +1 -0
  4. package/dist/Graph/Graph.spec.d.ts +1 -0
  5. package/dist/Graph/Graph.spec.js +26 -0
  6. package/dist/Graph/Graph.spec.js.map +1 -0
  7. package/dist/Graph/GraphAxis.d.ts +15 -0
  8. package/dist/Graph/GraphAxis.js +32 -0
  9. package/dist/Graph/GraphAxis.js.map +1 -0
  10. package/dist/Graph/GraphFactory.d.ts +3 -0
  11. package/dist/Graph/GraphFactory.js +20 -0
  12. package/dist/Graph/GraphFactory.js.map +1 -0
  13. package/dist/{Graph.d.ts → Graph/GraphIndicator.d.ts} +5 -8
  14. package/dist/Graph/GraphIndicator.js +75 -0
  15. package/dist/Graph/GraphIndicator.js.map +1 -0
  16. package/dist/Graph/GraphLine.d.ts +9 -0
  17. package/dist/Graph/GraphLine.js +43 -0
  18. package/dist/Graph/GraphLine.js.map +1 -0
  19. package/dist/Graph/graphHelper.d.ts +6 -0
  20. package/dist/Graph/graphHelper.js +32 -0
  21. package/dist/Graph/graphHelper.js.map +1 -0
  22. package/dist/Graph/index.d.ts +5 -0
  23. package/dist/Graph/index.js +6 -0
  24. package/dist/Graph/index.js.map +1 -0
  25. package/dist/helpers/onChangeParser.js +0 -1
  26. package/dist/helpers/onChangeParser.js.map +1 -1
  27. package/dist/index.d.ts +2 -2
  28. package/dist/index.js +2 -2
  29. package/dist/index.js.map +1 -1
  30. package/package.json +1 -1
  31. package/src/Graph/Graph.spec.ts +36 -0
  32. package/src/Graph/Graph.ts +17 -0
  33. package/src/Graph/GraphAxis.ts +33 -0
  34. package/src/Graph/GraphFactory.ts +26 -0
  35. package/src/Graph/GraphIndicator.ts +47 -0
  36. package/src/Graph/GraphLine.ts +24 -0
  37. package/src/Graph/graphHelper.ts +42 -0
  38. package/src/Graph/index.ts +5 -0
  39. package/src/helpers/onChangeParser.ts +0 -1
  40. package/src/index.ts +14 -2
  41. package/src/spec/Form.spec.ts +5 -2
  42. package/dist/Graph.js +0 -70
  43. package/dist/Graph.js.map +0 -1
  44. package/src/Graph.ts +0 -59
  45. package/src/spec/Graph.spec.ts +0 -16
@@ -0,0 +1,8 @@
1
+ export declare type GraphType = "indicator" | "line" | "bar" | "pie";
2
+ export declare class Graph {
3
+ _string: string | null;
4
+ get string(): string | null;
5
+ _type?: GraphType;
6
+ get type(): GraphType | undefined;
7
+ constructor(element: HTMLElement);
8
+ }
@@ -0,0 +1,23 @@
1
+ var Graph = /** @class */ (function () {
2
+ function Graph(element) {
3
+ this._string = null;
4
+ this._string = element.getAttribute("string");
5
+ }
6
+ Object.defineProperty(Graph.prototype, "string", {
7
+ get: function () {
8
+ return this._string;
9
+ },
10
+ enumerable: false,
11
+ configurable: true
12
+ });
13
+ Object.defineProperty(Graph.prototype, "type", {
14
+ get: function () {
15
+ return this._type;
16
+ },
17
+ enumerable: false,
18
+ configurable: true
19
+ });
20
+ return Graph;
21
+ }());
22
+ export { Graph };
23
+ //# sourceMappingURL=Graph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Graph.js","sourceRoot":"","sources":["../../src/Graph/Graph.ts"],"names":[],"mappings":"AAEA;IAWE,eAAY,OAAoB;QAVhC,YAAO,GAAkB,IAAI,CAAC;QAW5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAChD,CAAC;IAXD,sBAAI,yBAAM;aAAV;YACE,OAAO,IAAI,CAAC,OAAO,CAAC;QACtB,CAAC;;;OAAA;IAGD,sBAAI,uBAAI;aAAR;YACE,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;;;OAAA;IAKH,YAAC;AAAD,CAAC,AAdD,IAcC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,26 @@
1
+ import { parseGraph } from "..";
2
+ describe("A Graph", function () {
3
+ it("should parse a basic XML title and type indicator", function () {
4
+ var xml = "<?xml version=\"1.0\"?>\n <graph string=\"My indicator\" type=\"indicator\" color=\"red:debt>0;green:debt==0\" icon=\"slack\" />\n ";
5
+ var graph = parseGraph(xml);
6
+ expect(graph.string).toBe("My indicator");
7
+ expect(graph.type).toBe("indicator");
8
+ expect(graph.color).toBe("red:debt>0;green:debt==0");
9
+ expect(graph.icon).toBe("slack");
10
+ });
11
+ it("should parse a chart graph XML with type line", function () {
12
+ var _a, _b, _c, _d, _e, _f;
13
+ var xml = "<?xml version=\"1.0\"?>\n <graph type=\"line\">\n <field name=\"data_alta\" axis=\"x\"/>\n <field name=\"data_alta\" operator=\"+\" axis=\"y\"/>\n </graph>\n ";
14
+ var graph = parseGraph(xml);
15
+ expect(graph.type).toBe("line");
16
+ expect(graph.x).toBeDefined();
17
+ expect(graph.y).toBeDefined();
18
+ expect((_a = graph.x) === null || _a === void 0 ? void 0 : _a.name).toBe("data_alta");
19
+ expect((_b = graph.y) === null || _b === void 0 ? void 0 : _b.name).toBe("data_alta");
20
+ expect((_c = graph.x) === null || _c === void 0 ? void 0 : _c.axis).toBe("x");
21
+ expect((_d = graph.y) === null || _d === void 0 ? void 0 : _d.axis).toBe("y");
22
+ expect((_e = graph.x) === null || _e === void 0 ? void 0 : _e.operator).toBeNull();
23
+ expect((_f = graph.y) === null || _f === void 0 ? void 0 : _f.operator).toBe("+");
24
+ });
25
+ });
26
+ //# sourceMappingURL=Graph.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Graph.spec.js","sourceRoot":"","sources":["../../src/Graph/Graph.spec.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAEhC,QAAQ,CAAC,SAAS,EAAE;IAClB,EAAE,CAAC,mDAAmD,EAAE;QACtD,IAAM,GAAG,GAAG,2IAEX,CAAC;QAEF,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,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ export declare type Axis = "x" | "y";
2
+ export declare type Operator = "+";
3
+ export declare class GraphAxis {
4
+ _name: string | undefined;
5
+ get name(): string | undefined;
6
+ _axis: Axis | undefined;
7
+ get axis(): Axis | undefined;
8
+ _operator: Operator | undefined;
9
+ get operator(): Operator | undefined;
10
+ constructor({ name, axis, operator, }: {
11
+ name: string;
12
+ axis: Axis;
13
+ operator?: Operator;
14
+ });
15
+ }
@@ -0,0 +1,32 @@
1
+ var GraphAxis = /** @class */ (function () {
2
+ function GraphAxis(_a) {
3
+ var name = _a.name, axis = _a.axis, operator = _a.operator;
4
+ this._name = name;
5
+ this._axis = axis;
6
+ this._operator = operator;
7
+ }
8
+ Object.defineProperty(GraphAxis.prototype, "name", {
9
+ get: function () {
10
+ return this._name;
11
+ },
12
+ enumerable: false,
13
+ configurable: true
14
+ });
15
+ Object.defineProperty(GraphAxis.prototype, "axis", {
16
+ get: function () {
17
+ return this._axis;
18
+ },
19
+ enumerable: false,
20
+ configurable: true
21
+ });
22
+ Object.defineProperty(GraphAxis.prototype, "operator", {
23
+ get: function () {
24
+ return this._operator;
25
+ },
26
+ enumerable: false,
27
+ configurable: true
28
+ });
29
+ return GraphAxis;
30
+ }());
31
+ export { GraphAxis };
32
+ //# sourceMappingURL=GraphAxis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GraphAxis.js","sourceRoot":"","sources":["../../src/Graph/GraphAxis.ts"],"names":[],"mappings":"AAGA;IAgBE,mBAAY,EAQX;YAPC,IAAI,UAAA,EACJ,IAAI,UAAA,EACJ,QAAQ,cAAA;QAMR,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC5B,CAAC;IA1BD,sBAAI,2BAAI;aAAR;YACE,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;;;OAAA;IAGD,sBAAI,2BAAI;aAAR;YACE,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;;;OAAA;IAGD,sBAAI,+BAAQ;aAAZ;YACE,OAAO,IAAI,CAAC,SAAS,CAAC;QACxB,CAAC;;;OAAA;IAeH,gBAAC;AAAD,CAAC,AA7BD,IA6BC"}
@@ -0,0 +1,3 @@
1
+ import { GraphIndicator } from "./GraphIndicator";
2
+ import { GraphLine } from "./GraphLine";
3
+ export declare const parseGraph: (xml: string) => GraphIndicator | GraphLine;
@@ -0,0 +1,20 @@
1
+ import { GraphIndicator } from "./GraphIndicator";
2
+ import { GraphLine } from "./GraphLine";
3
+ var GraphTypes = {
4
+ indicator: GraphIndicator,
5
+ line: GraphLine,
6
+ };
7
+ export var parseGraph = function (xml) {
8
+ var parser = new DOMParser();
9
+ var view = parser.parseFromString(xml, "text/xml");
10
+ var type = view.documentElement.getAttribute("type");
11
+ if (!type) {
12
+ throw new Error(type + " is not a valid graph");
13
+ }
14
+ var graphModel = GraphTypes[type];
15
+ if (!graphModel) {
16
+ throw new Error(type + " not found as a GraphModel");
17
+ }
18
+ return new graphModel(view.documentElement);
19
+ };
20
+ //# sourceMappingURL=GraphFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GraphFactory.js","sourceRoot":"","sources":["../../src/Graph/GraphFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,IAAM,UAAU,GAA2B;IACzC,SAAS,EAAE,cAAc;IACzB,IAAI,EAAE,SAAS;CAChB,CAAC;AAEF,MAAM,CAAC,IAAM,UAAU,GAAG,UAAC,GAAW;IACpC,IAAM,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;IAC/B,IAAM,IAAI,GAAa,MAAM,CAAC,eAAe,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IAE/D,IAAM,IAAI,GAAG,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAEvD,IAAI,CAAC,IAAI,EAAE;QACT,MAAM,IAAI,KAAK,CAAI,IAAI,0BAAuB,CAAC,CAAC;KACjD;IAED,IAAM,UAAU,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IAEpC,IAAI,CAAC,UAAU,EAAE;QACf,MAAM,IAAI,KAAK,CAAI,IAAI,+BAA4B,CAAC,CAAC;KACtD;IAED,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;AAC9C,CAAC,CAAC"}
@@ -1,9 +1,5 @@
1
- export declare type GraphType = "indicator";
2
- declare class Graph {
3
- _string: string | null;
4
- get string(): string | null;
5
- _type?: GraphType;
6
- get type(): GraphType | undefined;
1
+ import { Graph } from "./Graph";
2
+ export declare class GraphIndicator extends Graph {
7
3
  _color: string | null;
8
4
  get color(): string | null;
9
5
  _icon: string | null;
@@ -12,6 +8,7 @@ declare class Graph {
12
8
  get totalDomain(): string | null;
13
9
  _showPercent: boolean;
14
10
  get showPercent(): boolean;
15
- constructor(xml: string);
11
+ _suffix: string | null;
12
+ get suffix(): string | null;
13
+ constructor(element: HTMLElement);
16
14
  }
17
- export default Graph;
@@ -0,0 +1,75 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ extendStatics(d, b);
10
+ function __() { this.constructor = d; }
11
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
+ };
13
+ })();
14
+ import { Graph } from "./Graph";
15
+ var GraphIndicator = /** @class */ (function (_super) {
16
+ __extends(GraphIndicator, _super);
17
+ function GraphIndicator(element) {
18
+ var _this = _super.call(this, element) || this;
19
+ _this._color = null;
20
+ _this._icon = null;
21
+ _this._totalDomain = null;
22
+ _this._showPercent = false;
23
+ _this._suffix = null;
24
+ _this._type = "indicator";
25
+ _this._color = element.getAttribute("color");
26
+ _this._icon = element.getAttribute("icon");
27
+ _this._suffix = element.getAttribute("suffix");
28
+ _this._totalDomain = element.getAttribute("totalDomain");
29
+ var showPercent = element.getAttribute("showPercent");
30
+ if (showPercent &&
31
+ (showPercent === "1" ||
32
+ (typeof showPercent === "boolean" && showPercent === true))) {
33
+ _this._showPercent = true;
34
+ }
35
+ return _this;
36
+ }
37
+ Object.defineProperty(GraphIndicator.prototype, "color", {
38
+ get: function () {
39
+ return this._color;
40
+ },
41
+ enumerable: false,
42
+ configurable: true
43
+ });
44
+ Object.defineProperty(GraphIndicator.prototype, "icon", {
45
+ get: function () {
46
+ return this._icon;
47
+ },
48
+ enumerable: false,
49
+ configurable: true
50
+ });
51
+ Object.defineProperty(GraphIndicator.prototype, "totalDomain", {
52
+ get: function () {
53
+ return this._totalDomain;
54
+ },
55
+ enumerable: false,
56
+ configurable: true
57
+ });
58
+ Object.defineProperty(GraphIndicator.prototype, "showPercent", {
59
+ get: function () {
60
+ return this._showPercent;
61
+ },
62
+ enumerable: false,
63
+ configurable: true
64
+ });
65
+ Object.defineProperty(GraphIndicator.prototype, "suffix", {
66
+ get: function () {
67
+ return this._suffix;
68
+ },
69
+ enumerable: false,
70
+ configurable: true
71
+ });
72
+ return GraphIndicator;
73
+ }(Graph));
74
+ export { GraphIndicator };
75
+ //# sourceMappingURL=GraphIndicator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GraphIndicator.js","sourceRoot":"","sources":["../../src/Graph/GraphIndicator.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAE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CAAC;;;OAAA;IAoBH,qBAAC;AAAD,CAAC,AA5CD,CAAoC,KAAK,GA4CxC"}
@@ -0,0 +1,9 @@
1
+ import { GraphAxis } from ".";
2
+ import { Graph } from "./Graph";
3
+ export declare class GraphLine extends Graph {
4
+ _x: GraphAxis | undefined;
5
+ get x(): GraphAxis | undefined;
6
+ _y: GraphAxis | undefined;
7
+ get y(): GraphAxis | undefined;
8
+ constructor(element: HTMLElement);
9
+ }
@@ -0,0 +1,43 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ extendStatics(d, b);
10
+ function __() { this.constructor = d; }
11
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
+ };
13
+ })();
14
+ import { Graph } from "./Graph";
15
+ import { parseXYAxis } from "./graphHelper";
16
+ var GraphLine = /** @class */ (function (_super) {
17
+ __extends(GraphLine, _super);
18
+ function GraphLine(element) {
19
+ var _this = _super.call(this, element) || this;
20
+ _this._type = "line";
21
+ var xyAxis = parseXYAxis(element.childNodes);
22
+ _this._x = xyAxis.x;
23
+ _this._y = xyAxis.y;
24
+ return _this;
25
+ }
26
+ Object.defineProperty(GraphLine.prototype, "x", {
27
+ get: function () {
28
+ return this._x;
29
+ },
30
+ enumerable: false,
31
+ configurable: true
32
+ });
33
+ Object.defineProperty(GraphLine.prototype, "y", {
34
+ get: function () {
35
+ return this._y;
36
+ },
37
+ enumerable: false,
38
+ configurable: true
39
+ });
40
+ return GraphLine;
41
+ }(Graph));
42
+ export { GraphLine };
43
+ //# sourceMappingURL=GraphLine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GraphLine.js","sourceRoot":"","sources":["../../src/Graph/GraphLine.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;IAA+B,6BAAK;IAUlC,mBAAY,OAAoB;QAAhC,YACE,kBAAM,OAAO,CAAC,SAOf;QALC,KAAI,CAAC,KAAK,GAAG,MAAM,CAAC;QAEpB,IAAM,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAC/C,KAAI,CAAC,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC;QACnB,KAAI,CAAC,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC;;IACrB,CAAC;IAhBD,sBAAI,wBAAC;aAAL;YACE,OAAO,IAAI,CAAC,EAAE,CAAC;QACjB,CAAC;;;OAAA;IAGD,sBAAI,wBAAC;aAAL;YACE,OAAO,IAAI,CAAC,EAAE,CAAC;QACjB,CAAC;;;OAAA;IAUH,gBAAC;AAAD,CAAC,AAnBD,CAA+B,KAAK,GAmBnC"}
@@ -0,0 +1,6 @@
1
+ import { GraphAxis } from ".";
2
+ export declare type XYAxis = {
3
+ x: GraphAxis;
4
+ y: GraphAxis;
5
+ };
6
+ export declare const parseXYAxis: (nodes: NodeListOf<ChildNode>) => XYAxis;
@@ -0,0 +1,32 @@
1
+ import { GraphAxis } from ".";
2
+ export var parseXYAxis = function (nodes) {
3
+ var xyAxis = {};
4
+ Array.prototype.forEach.call(nodes, function (child) {
5
+ if (child.nodeType === child.ELEMENT_NODE) {
6
+ if (child.nodeName === "field") {
7
+ }
8
+ var axis = child.getAttribute("axis");
9
+ var operator = child.getAttribute("operator");
10
+ var name_1 = child.getAttribute("name");
11
+ if (!axis) {
12
+ throw new Error("Field " + name_1 + " doesn't have an axis");
13
+ }
14
+ if (!name_1) {
15
+ throw new Error("Missing name attribute for field");
16
+ }
17
+ var graphAxis = new GraphAxis({
18
+ axis: axis,
19
+ name: name_1,
20
+ operator: operator,
21
+ });
22
+ if (axis === "x") {
23
+ xyAxis.x = graphAxis;
24
+ }
25
+ else if (axis === "y") {
26
+ xyAxis.y = graphAxis;
27
+ }
28
+ }
29
+ });
30
+ return xyAxis;
31
+ };
32
+ //# sourceMappingURL=graphHelper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graphHelper.js","sourceRoot":"","sources":["../../src/Graph/graphHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,SAAS,EAAY,MAAM,GAAG,CAAC;AAO9C,MAAM,CAAC,IAAM,WAAW,GAAG,UAAC,KAA4B;IACtD,IAAM,MAAM,GAAQ,EAAE,CAAC;IAEvB,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,UAAC,KAAc;QACjD,IAAI,KAAK,CAAC,QAAQ,KAAK,KAAK,CAAC,YAAY,EAAE;YACzC,IAAI,KAAK,CAAC,QAAQ,KAAK,OAAO,EAAE;aAC/B;YACD,IAAM,IAAI,GAAG,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;YACxC,IAAM,QAAQ,GAAG,KAAK,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;YAChD,IAAM,MAAI,GAAG,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;YAExC,IAAI,CAAC,IAAI,EAAE;gBACT,MAAM,IAAI,KAAK,CAAC,WAAS,MAAI,0BAAuB,CAAC,CAAC;aACvD;YAED,IAAI,CAAC,MAAI,EAAE;gBACT,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;aACrD;YAED,IAAM,SAAS,GAAG,IAAI,SAAS,CAAC;gBAC9B,IAAI,EAAE,IAAY;gBAClB,IAAI,QAAA;gBACJ,QAAQ,EAAE,QAAoB;aAC/B,CAAC,CAAC;YAEH,IAAI,IAAI,KAAK,GAAG,EAAE;gBAChB,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC;aACtB;iBAAM,IAAI,IAAI,KAAK,GAAG,EAAE;gBACvB,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC;aACtB;SACF;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAgB,CAAC;AAC1B,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from "./Graph";
2
+ export * from "./GraphFactory";
3
+ export * from "./GraphIndicator";
4
+ export * from "./GraphLine";
5
+ export * from "./GraphAxis";
@@ -0,0 +1,6 @@
1
+ export * from "./Graph";
2
+ export * from "./GraphFactory";
3
+ export * from "./GraphIndicator";
4
+ export * from "./GraphLine";
5
+ export * from "./GraphAxis";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Graph/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
@@ -1,7 +1,6 @@
1
1
  var parseOnChange = function (onChangeString) {
2
2
  var splitted = onChangeString
3
3
  .replace(/\s/g, "")
4
- .replace(/'/g, "")
5
4
  .replace(")", "")
6
5
  .split("(");
7
6
  var method = splitted[0];
@@ -1 +1 @@
1
- {"version":3,"file":"onChangeParser.js","sourceRoot":"","sources":["../../src/helpers/onChangeParser.ts"],"names":[],"mappings":"AAAA,IAAM,aAAa,GAAG,UAAC,cAAsB;IAC3C,IAAM,QAAQ,GAAG,cAAc;SAC5B,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;SAClB,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;SACjB,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC;SAChB,KAAK,CAAC,GAAG,CAAC,CAAC;IAEd,IAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC3B,IAAM,SAAS,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC9B,IAAM,YAAY,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAE1C,OAAO;QACL,MAAM,QAAA;QACN,IAAI,EAAE,YAAY;KACnB,CAAC;AACJ,CAAC,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC"}
1
+ {"version":3,"file":"onChangeParser.js","sourceRoot":"","sources":["../../src/helpers/onChangeParser.ts"],"names":[],"mappings":"AAAA,IAAM,aAAa,GAAG,UAAC,cAAsB;IAC3C,IAAM,QAAQ,GAAG,cAAc;SAC5B,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;SAClB,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC;SAChB,KAAK,CAAC,GAAG,CAAC,CAAC;IAEd,IAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC3B,IAAM,SAAS,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC9B,IAAM,YAAY,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAE1C,OAAO;QACL,MAAM,QAAA;QACN,IAAI,EAAE,YAAY;KACnB,CAAC;AACJ,CAAC,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC"}
package/dist/index.d.ts CHANGED
@@ -33,5 +33,5 @@ import Timeline from "./Timeline";
33
33
  import Indicator from "./Indicator";
34
34
  import Dashboard from "./Dashboard";
35
35
  import DashboardItem from "./DashboardItem";
36
- import Graph from "./Graph";
37
- export { Char, Selection, Many2one, Field, Widget, Form, Tree, Boolean, One2many, Integer, Float, FloatTime, Date, DateTime, Many2many, SearchFilter, Container, ContainerWidget, Text, ProgressBar, Notebook, Group, Page, Label, Separator, Button, Reference, Binary, Image, parseContext, transformDomainForChildWidget, Timeline, Indicator, Dashboard, DashboardItem, Graph };
36
+ import { Graph, GraphAxis, GraphIndicator, GraphLine, GraphType, parseGraph } from "./Graph";
37
+ export { Char, Selection, Many2one, Field, Widget, Form, Tree, Boolean, One2many, Integer, Float, FloatTime, Date, DateTime, Many2many, SearchFilter, Container, ContainerWidget, Text, ProgressBar, Notebook, Group, Page, Label, Separator, Button, Reference, Binary, Image, parseContext, transformDomainForChildWidget, Timeline, Indicator, Dashboard, DashboardItem, Graph, GraphAxis, GraphIndicator, GraphLine, GraphType, parseGraph, };
package/dist/index.js CHANGED
@@ -33,6 +33,6 @@ import Timeline from "./Timeline";
33
33
  import Indicator from "./Indicator";
34
34
  import Dashboard from "./Dashboard";
35
35
  import DashboardItem from "./DashboardItem";
36
- import Graph from "./Graph";
37
- export { Char, Selection, Many2one, Field, Widget, Form, Tree, Boolean, One2many, Integer, Float, FloatTime, Date, DateTime, Many2many, SearchFilter, Container, ContainerWidget, Text, ProgressBar, Notebook, Group, Page, Label, Separator, Button, Reference, Binary, Image, parseContext, transformDomainForChildWidget, Timeline, Indicator, Dashboard, DashboardItem, Graph };
36
+ import { Graph, GraphAxis, GraphIndicator, GraphLine, parseGraph, } from "./Graph";
37
+ export { Char, Selection, Many2one, Field, Widget, Form, Tree, Boolean, One2many, Integer, Float, FloatTime, Date, DateTime, Many2many, SearchFilter, Container, ContainerWidget, Text, ProgressBar, Notebook, Group, Page, Label, Separator, Button, Reference, Binary, Image, parseContext, transformDomainForChildWidget, Timeline, Indicator, Dashboard, DashboardItem, Graph, GraphAxis, GraphIndicator, GraphLine, parseGraph, };
38
38
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,KAAK,MAAM,SA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AQ,CAAC;AAC1B,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,KAAK,EACL,SAAS,EACT,cAAc,EACd,SAAS,EAET,UAAU,GACX,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,IAAI,EACJ,SAAS,EACT,QAAQ,EACR,KAAK,EACL,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,OAAO,EACP,KAAK,EACL,SAAS,EACT,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,SAAS,EACT,eAAe,EACf,IAAI,EACJ,WAAW,EACX,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,KAAK,EACL,SAAS,EACT,MAAM,EACN,SAAS,EACT,MAAM,EACN,KAAK,EACL,YAAY,EACZ,6BAA6B,EAC7B,QAAQ,EACR,SAAS,EACT,SAAS,EACT,aAAa,EACb,KAAK,EACL,SAAS,EACT,cAAc,EACd,SAAS,EAET,UAAU,GACX,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gisce/ooui",
3
- "version": "0.2.9",
3
+ "version": "0.2.12",
4
4
  "dependencies": {},
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -0,0 +1,36 @@
1
+ import { GraphIndicator, GraphLine } from ".";
2
+ import { parseGraph } from "..";
3
+
4
+ describe("A Graph", () => {
5
+ it("should parse a basic XML title and type indicator", () => {
6
+ const xml = `<?xml version="1.0"?>
7
+ <graph string="My indicator" type="indicator" color="red:debt>0;green:debt==0" icon="slack" />
8
+ `;
9
+
10
+ const graph = parseGraph(xml) as GraphIndicator;
11
+
12
+ expect(graph.string).toBe("My indicator");
13
+ expect(graph.type).toBe("indicator");
14
+ expect(graph.color).toBe("red:debt>0;green:debt==0");
15
+ expect(graph.icon).toBe("slack");
16
+ });
17
+ it("should parse a chart graph XML with type line", () => {
18
+ const xml = `<?xml version="1.0"?>
19
+ <graph type="line">
20
+ <field name="data_alta" axis="x"/>
21
+ <field name="data_alta" operator="+" axis="y"/>
22
+ </graph>
23
+ `;
24
+
25
+ const graph = parseGraph(xml) as GraphLine;
26
+ expect(graph.type).toBe("line");
27
+ expect(graph.x).toBeDefined();
28
+ expect(graph.y).toBeDefined();
29
+ expect(graph.x?.name).toBe("data_alta");
30
+ expect(graph.y?.name).toBe("data_alta");
31
+ expect(graph.x?.axis).toBe("x");
32
+ expect(graph.y?.axis).toBe("y");
33
+ expect(graph.x?.operator).toBeNull();
34
+ expect(graph.y?.operator).toBe("+");
35
+ });
36
+ });
@@ -0,0 +1,17 @@
1
+ export type GraphType = "indicator" | "line" | "bar" | "pie";
2
+
3
+ export class Graph {
4
+ _string: string | null = null;
5
+ get string(): string | null {
6
+ return this._string;
7
+ }
8
+
9
+ _type?: GraphType;
10
+ get type(): GraphType | undefined {
11
+ return this._type;
12
+ }
13
+
14
+ constructor(element: HTMLElement) {
15
+ this._string = element.getAttribute("string");
16
+ }
17
+ }
@@ -0,0 +1,33 @@
1
+ export type Axis = "x" | "y";
2
+ export type Operator = "+";
3
+
4
+ export class GraphAxis {
5
+ _name: string | undefined;
6
+ get name(): string | undefined {
7
+ return this._name;
8
+ }
9
+
10
+ _axis: Axis | undefined;
11
+ get axis(): Axis | undefined {
12
+ return this._axis;
13
+ }
14
+
15
+ _operator: Operator | undefined;
16
+ get operator(): Operator | undefined {
17
+ return this._operator;
18
+ }
19
+
20
+ constructor({
21
+ name,
22
+ axis,
23
+ operator,
24
+ }: {
25
+ name: string;
26
+ axis: Axis;
27
+ operator?: Operator;
28
+ }) {
29
+ this._name = name;
30
+ this._axis = axis;
31
+ this._operator = operator;
32
+ }
33
+ }
@@ -0,0 +1,26 @@
1
+ import { GraphIndicator } from "./GraphIndicator";
2
+ import { GraphLine } from "./GraphLine";
3
+
4
+ const GraphTypes: { [key: string]: any } = {
5
+ indicator: GraphIndicator,
6
+ line: GraphLine,
7
+ };
8
+
9
+ export const parseGraph = (xml: string): GraphIndicator | GraphLine => {
10
+ const parser = new DOMParser();
11
+ const view: Document = parser.parseFromString(xml, "text/xml");
12
+
13
+ const type = view.documentElement.getAttribute("type");
14
+
15
+ if (!type) {
16
+ throw new Error(`${type} is not a valid graph`);
17
+ }
18
+
19
+ const graphModel = GraphTypes[type];
20
+
21
+ if (!graphModel) {
22
+ throw new Error(`${type} not found as a GraphModel`);
23
+ }
24
+
25
+ return new graphModel(view.documentElement);
26
+ };
@@ -0,0 +1,47 @@
1
+ import { Graph } from "./Graph";
2
+
3
+ export class GraphIndicator extends Graph {
4
+ _color: string | null = null;
5
+ get color(): string | null {
6
+ return this._color;
7
+ }
8
+
9
+ _icon: string | null = null;
10
+ get icon(): string | null {
11
+ return this._icon;
12
+ }
13
+
14
+ _totalDomain: string | null = null;
15
+ get totalDomain(): string | null {
16
+ return this._totalDomain;
17
+ }
18
+
19
+ _showPercent: boolean = false;
20
+ get showPercent(): boolean {
21
+ return this._showPercent;
22
+ }
23
+
24
+ _suffix: string | null = null;
25
+ get suffix(): string | null {
26
+ return this._suffix;
27
+ }
28
+
29
+ constructor(element: HTMLElement) {
30
+ super(element);
31
+
32
+ this._type = "indicator";
33
+ this._color = element.getAttribute("color");
34
+ this._icon = element.getAttribute("icon");
35
+ this._suffix = element.getAttribute("suffix");
36
+ this._totalDomain = element.getAttribute("totalDomain");
37
+ const showPercent = element.getAttribute("showPercent");
38
+
39
+ if (
40
+ showPercent &&
41
+ (showPercent === "1" ||
42
+ (typeof showPercent === "boolean" && showPercent === true))
43
+ ) {
44
+ this._showPercent = true;
45
+ }
46
+ }
47
+ }
@@ -0,0 +1,24 @@
1
+ import { GraphAxis } from ".";
2
+ import { Graph } from "./Graph";
3
+ import { parseXYAxis } from "./graphHelper";
4
+
5
+ export class GraphLine extends Graph {
6
+ _x: GraphAxis | undefined;
7
+ get x(): GraphAxis | undefined {
8
+ return this._x;
9
+ }
10
+
11
+ _y: GraphAxis | undefined;
12
+ get y(): GraphAxis | undefined {
13
+ return this._y;
14
+ }
15
+ constructor(element: HTMLElement) {
16
+ super(element);
17
+
18
+ this._type = "line";
19
+
20
+ const xyAxis = parseXYAxis(element.childNodes);
21
+ this._x = xyAxis.x;
22
+ this._y = xyAxis.y;
23
+ }
24
+ }
@@ -0,0 +1,42 @@
1
+ import { Axis, GraphAxis, Operator } from ".";
2
+
3
+ export type XYAxis = {
4
+ x: GraphAxis;
5
+ y: GraphAxis;
6
+ };
7
+
8
+ export const parseXYAxis = (nodes: NodeListOf<ChildNode>): XYAxis => {
9
+ const xyAxis: any = {};
10
+
11
+ Array.prototype.forEach.call(nodes, (child: Element) => {
12
+ if (child.nodeType === child.ELEMENT_NODE) {
13
+ if (child.nodeName === "field") {
14
+ }
15
+ const axis = child.getAttribute("axis");
16
+ const operator = child.getAttribute("operator");
17
+ const name = child.getAttribute("name");
18
+
19
+ if (!axis) {
20
+ throw new Error(`Field ${name} doesn't have an axis`);
21
+ }
22
+
23
+ if (!name) {
24
+ throw new Error("Missing name attribute for field");
25
+ }
26
+
27
+ const graphAxis = new GraphAxis({
28
+ axis: axis as Axis,
29
+ name,
30
+ operator: operator as Operator,
31
+ });
32
+
33
+ if (axis === "x") {
34
+ xyAxis.x = graphAxis;
35
+ } else if (axis === "y") {
36
+ xyAxis.y = graphAxis;
37
+ }
38
+ }
39
+ });
40
+
41
+ return xyAxis as XYAxis;
42
+ };
@@ -0,0 +1,5 @@
1
+ export * from "./Graph";
2
+ export * from "./GraphFactory";
3
+ export * from "./GraphIndicator";
4
+ export * from "./GraphLine";
5
+ export * from "./GraphAxis";
@@ -1,7 +1,6 @@
1
1
  const parseOnChange = (onChangeString: string) => {
2
2
  const splitted = onChangeString
3
3
  .replace(/\s/g, "")
4
- .replace(/'/g, "")
5
4
  .replace(")", "")
6
5
  .split("(");
7
6
 
package/src/index.ts CHANGED
@@ -33,7 +33,14 @@ import Timeline from "./Timeline";
33
33
  import Indicator from "./Indicator";
34
34
  import Dashboard from "./Dashboard";
35
35
  import DashboardItem from "./DashboardItem";
36
- import Graph from "./Graph";
36
+ import {
37
+ Graph,
38
+ GraphAxis,
39
+ GraphIndicator,
40
+ GraphLine,
41
+ GraphType,
42
+ parseGraph,
43
+ } from "./Graph";
37
44
 
38
45
  export {
39
46
  Char,
@@ -71,5 +78,10 @@ export {
71
78
  Indicator,
72
79
  Dashboard,
73
80
  DashboardItem,
74
- Graph
81
+ Graph,
82
+ GraphAxis,
83
+ GraphIndicator,
84
+ GraphLine,
85
+ GraphType,
86
+ parseGraph,
75
87
  };
@@ -915,7 +915,7 @@ describe("A Form", () => {
915
915
  const xmlViewForm = `<?xml version="1.0"?>
916
916
  <form string="Form1">
917
917
  <field name="field_id" colspan="4" nolabel="1" />
918
- <field name="field_char" on_change="on_change_partner_address_id(partner_address_id, context)" colspan="4" nolabel="1" />
918
+ <field name="field_char" on_change="on_change_partner_address_id(partner_address_id, 'foo', context)" colspan="4" nolabel="1" />
919
919
  </form>`;
920
920
  const form = new Form(fields);
921
921
  form.parse(xmlViewForm, {
@@ -935,7 +935,10 @@ describe("A Form", () => {
935
935
  expect(form.onChangeFields!["field_char"].args[0]).toBe(
936
936
  "partner_address_id"
937
937
  );
938
- expect(form.onChangeFields!["field_char"].args[1]).toBe("context");
938
+ expect(form.onChangeFields!["field_char"].args[1]).toBe(
939
+ "'foo'"
940
+ );
941
+ expect(form.onChangeFields!["field_char"].args[2]).toBe("context");
939
942
  });
940
943
 
941
944
  it("should be able to parse domain for the whole form", () => {
package/dist/Graph.js DELETED
@@ -1,70 +0,0 @@
1
- var Graph = /** @class */ (function () {
2
- function Graph(xml) {
3
- this._string = null;
4
- this._color = null;
5
- this._icon = null;
6
- this._totalDomain = null;
7
- this._showPercent = false;
8
- var parser = new DOMParser();
9
- var view = parser.parseFromString(xml, "text/xml");
10
- this._string = view.documentElement.getAttribute("string");
11
- var type = view.documentElement.getAttribute("type");
12
- this._color = view.documentElement.getAttribute("color");
13
- this._icon = view.documentElement.getAttribute("icon");
14
- this._totalDomain = view.documentElement.getAttribute("totalDomain");
15
- var showPercent = view.documentElement.getAttribute("showPercent");
16
- if (showPercent &&
17
- (showPercent === "1" ||
18
- (typeof showPercent === "boolean" && showPercent === true))) {
19
- this._showPercent = true;
20
- }
21
- if (type === "indicator") {
22
- this._type = "indicator";
23
- }
24
- }
25
- Object.defineProperty(Graph.prototype, "string", {
26
- get: function () {
27
- return this._string;
28
- },
29
- enumerable: false,
30
- configurable: true
31
- });
32
- Object.defineProperty(Graph.prototype, "type", {
33
- get: function () {
34
- return this._type;
35
- },
36
- enumerable: false,
37
- configurable: true
38
- });
39
- Object.defineProperty(Graph.prototype, "color", {
40
- get: function () {
41
- return this._color;
42
- },
43
- enumerable: false,
44
- configurable: true
45
- });
46
- Object.defineProperty(Graph.prototype, "icon", {
47
- get: function () {
48
- return this._icon;
49
- },
50
- enumerable: false,
51
- configurable: true
52
- });
53
- Object.defineProperty(Graph.prototype, "totalDomain", {
54
- get: function () {
55
- return this._totalDomain;
56
- },
57
- enumerable: false,
58
- configurable: true
59
- });
60
- Object.defineProperty(Graph.prototype, "showPercent", {
61
- get: function () {
62
- return this._showPercent;
63
- },
64
- enumerable: false,
65
- configurable: true
66
- });
67
- return Graph;
68
- }());
69
- export default Graph;
70
- //# sourceMappingURL=Graph.js.map
package/dist/Graph.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file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I,uBAAI;aAAR;YACE,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;;;OAAA;IAGD,sBAAI,wBAAK;aAAT;YACE,OAAO,IAAI,CAAC,MAAM,CAAC;QACrB,CAAC;;;OAAA;IAGD,sBAAI,uBAAI;aAAR;YACE,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;;;OAAA;IAGD,sBAAI,8BAAW;aAAf;YACE,OAAO,IAAI,CAAC,YAAY,CAAC;QAC3B,CAAC;;;OAAA;IAGD,sBAAI,8BAAW;aAAf;YACE,OAAO,IAAI,CAAC,YAAY,CAAC;QAC3B,CAAC;;;OAAA;IAyBH,YAAC;AAAD,CAAC,AAtDD,IAsDC;AAED,eAAe,KAAK,CAAC"}
package/src/Graph.ts DELETED
@@ -1,59 +0,0 @@
1
- export type GraphType = "indicator";
2
-
3
- class Graph {
4
- _string: string | null = null;
5
- get string(): string | null {
6
- return this._string;
7
- }
8
-
9
- _type?: GraphType;
10
- get type(): GraphType | undefined {
11
- return this._type;
12
- }
13
-
14
- _color: string | null = null;
15
- get color(): string | null {
16
- return this._color;
17
- }
18
-
19
- _icon: string | null = null;
20
- get icon(): string | null {
21
- return this._icon;
22
- }
23
-
24
- _totalDomain: string | null = null;
25
- get totalDomain(): string | null {
26
- return this._totalDomain;
27
- }
28
-
29
- _showPercent: boolean = false;
30
- get showPercent(): boolean {
31
- return this._showPercent;
32
- }
33
-
34
- constructor(xml: string) {
35
- const parser = new DOMParser();
36
- const view: Document = parser.parseFromString(xml, "text/xml");
37
- this._string = view.documentElement.getAttribute("string");
38
- const type = view.documentElement.getAttribute("type");
39
-
40
- this._color = view.documentElement.getAttribute("color");
41
- this._icon = view.documentElement.getAttribute("icon");
42
- this._totalDomain = view.documentElement.getAttribute("totalDomain");
43
-
44
- const showPercent = view.documentElement.getAttribute("showPercent");
45
- if (
46
- showPercent &&
47
- (showPercent === "1" ||
48
- (typeof showPercent === "boolean" && showPercent === true))
49
- ) {
50
- this._showPercent = true;
51
- }
52
-
53
- if (type === "indicator") {
54
- this._type = "indicator";
55
- }
56
- }
57
- }
58
-
59
- export default Graph;
@@ -1,16 +0,0 @@
1
- import Graph from "../Graph";
2
-
3
- describe("A Graph", () => {
4
- it("should parse a basic XML title and type indicator", () => {
5
- const xml = `<?xml version="1.0"?>
6
- <graph string="My indicator" type="indicator" color="red:debt>0;green:debt==0" icon="slack" />
7
- `;
8
-
9
- const graph = new Graph(xml);
10
-
11
- expect(graph.string).toBe("My indicator");
12
- expect(graph.type).toBe("indicator");
13
- expect(graph.color).toBe("red:debt>0;green:debt==0");
14
- expect(graph.icon).toBe("slack");
15
- });
16
- });