@gisce/ooui 0.2.11 → 0.2.14
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.d.ts +19 -0
- package/dist/Graph.js +79 -0
- package/dist/Graph.js.map +1 -0
- package/dist/helpers/attributeParser.js +8 -1
- package/dist/helpers/attributeParser.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/Graph.ts +65 -0
- package/src/helpers/attributeParser.ts +13 -1
- package/src/index.ts +2 -14
- package/src/spec/Graph.spec.ts +16 -0
- package/src/spec/attributeParser.spec.ts +27 -0
- package/dist/Graph/Graph.d.ts +0 -8
- package/dist/Graph/Graph.js +0 -23
- package/dist/Graph/Graph.js.map +0 -1
- package/dist/Graph/Graph.spec.d.ts +0 -1
- package/dist/Graph/Graph.spec.js +0 -26
- package/dist/Graph/Graph.spec.js.map +0 -1
- package/dist/Graph/GraphAxis.d.ts +0 -15
- package/dist/Graph/GraphAxis.js +0 -32
- package/dist/Graph/GraphAxis.js.map +0 -1
- package/dist/Graph/GraphFactory.d.ts +0 -3
- package/dist/Graph/GraphFactory.js +0 -20
- package/dist/Graph/GraphFactory.js.map +0 -1
- package/dist/Graph/GraphIndicator.d.ts +0 -12
- package/dist/Graph/GraphIndicator.js +0 -66
- package/dist/Graph/GraphIndicator.js.map +0 -1
- package/dist/Graph/GraphLine.d.ts +0 -9
- package/dist/Graph/GraphLine.js +0 -43
- package/dist/Graph/GraphLine.js.map +0 -1
- package/dist/Graph/graphHelper.d.ts +0 -6
- package/dist/Graph/graphHelper.js +0 -32
- package/dist/Graph/graphHelper.js.map +0 -1
- package/dist/Graph/index.d.ts +0 -5
- package/dist/Graph/index.js +0 -6
- package/dist/Graph/index.js.map +0 -1
- package/src/Graph/Graph.spec.ts +0 -36
- package/src/Graph/Graph.ts +0 -17
- package/src/Graph/GraphAxis.ts +0 -33
- package/src/Graph/GraphFactory.ts +0 -26
- package/src/Graph/GraphIndicator.ts +0 -41
- package/src/Graph/GraphLine.ts +0 -24
- package/src/Graph/graphHelper.ts +0 -42
- package/src/Graph/index.ts +0 -5
package/dist/Graph.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
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;
|
|
7
|
+
_color: string | null;
|
|
8
|
+
get color(): string | null;
|
|
9
|
+
_icon: string | null;
|
|
10
|
+
get icon(): string | null;
|
|
11
|
+
_suffix: string | null;
|
|
12
|
+
get suffix(): string | null;
|
|
13
|
+
_totalDomain: string | null;
|
|
14
|
+
get totalDomain(): string | null;
|
|
15
|
+
_showPercent: boolean;
|
|
16
|
+
get showPercent(): boolean;
|
|
17
|
+
constructor(xml: string);
|
|
18
|
+
}
|
|
19
|
+
export default Graph;
|
package/dist/Graph.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
var Graph = /** @class */ (function () {
|
|
2
|
+
function Graph(xml) {
|
|
3
|
+
this._string = null;
|
|
4
|
+
this._color = null;
|
|
5
|
+
this._icon = null;
|
|
6
|
+
this._suffix = null;
|
|
7
|
+
this._totalDomain = null;
|
|
8
|
+
this._showPercent = false;
|
|
9
|
+
var parser = new DOMParser();
|
|
10
|
+
var view = parser.parseFromString(xml, "text/xml");
|
|
11
|
+
this._string = view.documentElement.getAttribute("string");
|
|
12
|
+
var type = view.documentElement.getAttribute("type");
|
|
13
|
+
this._color = view.documentElement.getAttribute("color");
|
|
14
|
+
this._icon = view.documentElement.getAttribute("icon");
|
|
15
|
+
this._totalDomain = view.documentElement.getAttribute("totalDomain");
|
|
16
|
+
this._suffix = view.documentElement.getAttribute("suffix");
|
|
17
|
+
var showPercent = view.documentElement.getAttribute("showPercent");
|
|
18
|
+
if (showPercent &&
|
|
19
|
+
(showPercent === "1" ||
|
|
20
|
+
(typeof showPercent === "boolean" && showPercent === true))) {
|
|
21
|
+
this._showPercent = true;
|
|
22
|
+
}
|
|
23
|
+
if (type === "indicator") {
|
|
24
|
+
this._type = "indicator";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
Object.defineProperty(Graph.prototype, "string", {
|
|
28
|
+
get: function () {
|
|
29
|
+
return this._string;
|
|
30
|
+
},
|
|
31
|
+
enumerable: false,
|
|
32
|
+
configurable: true
|
|
33
|
+
});
|
|
34
|
+
Object.defineProperty(Graph.prototype, "type", {
|
|
35
|
+
get: function () {
|
|
36
|
+
return this._type;
|
|
37
|
+
},
|
|
38
|
+
enumerable: false,
|
|
39
|
+
configurable: true
|
|
40
|
+
});
|
|
41
|
+
Object.defineProperty(Graph.prototype, "color", {
|
|
42
|
+
get: function () {
|
|
43
|
+
return this._color;
|
|
44
|
+
},
|
|
45
|
+
enumerable: false,
|
|
46
|
+
configurable: true
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(Graph.prototype, "icon", {
|
|
49
|
+
get: function () {
|
|
50
|
+
return this._icon;
|
|
51
|
+
},
|
|
52
|
+
enumerable: false,
|
|
53
|
+
configurable: true
|
|
54
|
+
});
|
|
55
|
+
Object.defineProperty(Graph.prototype, "suffix", {
|
|
56
|
+
get: function () {
|
|
57
|
+
return this._suffix;
|
|
58
|
+
},
|
|
59
|
+
enumerable: false,
|
|
60
|
+
configurable: true
|
|
61
|
+
});
|
|
62
|
+
Object.defineProperty(Graph.prototype, "totalDomain", {
|
|
63
|
+
get: function () {
|
|
64
|
+
return this._totalDomain;
|
|
65
|
+
},
|
|
66
|
+
enumerable: false,
|
|
67
|
+
configurable: true
|
|
68
|
+
});
|
|
69
|
+
Object.defineProperty(Graph.prototype, "showPercent", {
|
|
70
|
+
get: function () {
|
|
71
|
+
return this._showPercent;
|
|
72
|
+
},
|
|
73
|
+
enumerable: false,
|
|
74
|
+
configurable: true
|
|
75
|
+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I,CAAC,CAAC,EAC7D;YACA,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;SAC1B;QAED,IAAI,IAAI,KAAK,WAAW,EAAE;YACxB,IAAI,CAAC,KAAK,GAAG,WAAW,CAAC;SAC1B;IACH,CAAC;IAzDD,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;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,yBAAM;aAAV;YACE,OAAO,IAAI,CAAC,OAAO,CAAC;QACtB,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;IA0BH,YAAC;AAAD,CAAC,AA5DD,IA4DC;AAED,eAAe,KAAK,CAAC"}
|
|
@@ -15,10 +15,17 @@ var evaluateCondition = function (_a) {
|
|
|
15
15
|
if (fields[fieldName] === undefined) {
|
|
16
16
|
return false;
|
|
17
17
|
}
|
|
18
|
-
if (values[fieldName] === undefined &&
|
|
18
|
+
if (values[fieldName] === undefined &&
|
|
19
|
+
fields[fieldName].type !== "boolean" &&
|
|
20
|
+
fields[fieldName].type !== "many2one") {
|
|
19
21
|
return false;
|
|
20
22
|
}
|
|
21
23
|
var filteredExpectedValue = expectedValue;
|
|
24
|
+
if (fields[fieldName].type === "many2one" &&
|
|
25
|
+
expectedValue === false &&
|
|
26
|
+
values[fieldName] === undefined) {
|
|
27
|
+
filteredExpectedValue = undefined;
|
|
28
|
+
}
|
|
22
29
|
if (fields[fieldName].type === "boolean" &&
|
|
23
30
|
(expectedValue === 0 || expectedValue === 1)) {
|
|
24
31
|
filteredExpectedValue = expectedValue === 0 ? false : true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attributeParser.js","sourceRoot":"","sources":["../../src/helpers/attributeParser.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,IAAM,iBAAiB,GAAG,UAAC,EAQ1B;QAPC,KAAK,WAAA,EACL,MAAM,YAAA,EACN,MAAM,YAAA;IAMC,IAAA,SAAS,GAA6B,KAAK,GAAlC,EAAE,QAAQ,GAAmB,KAAK,GAAxB,EAAE,aAAa,GAAI,KAAK,GAAT,CAAU;IAEnD,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,SAAS,EAAE;QACnC,OAAO,KAAK,CAAC;KACd;IAED,
|
|
1
|
+
{"version":3,"file":"attributeParser.js","sourceRoot":"","sources":["../../src/helpers/attributeParser.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,IAAM,iBAAiB,GAAG,UAAC,EAQ1B;QAPC,KAAK,WAAA,EACL,MAAM,YAAA,EACN,MAAM,YAAA;IAMC,IAAA,SAAS,GAA6B,KAAK,GAAlC,EAAE,QAAQ,GAAmB,KAAK,GAAxB,EAAE,aAAa,GAAI,KAAK,GAAT,CAAU;IAEnD,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,SAAS,EAAE;QACnC,OAAO,KAAK,CAAC;KACd;IAED,IACE,MAAM,CAAC,SAAS,CAAC,KAAK,SAAS;QAC/B,MAAM,CAAC,SAAS,CAAC,CAAC,IAAI,KAAK,SAAS;QACpC,MAAM,CAAC,SAAS,CAAC,CAAC,IAAI,KAAK,UAAU,EACrC;QACA,OAAO,KAAK,CAAC;KACd;IAED,IAAI,qBAAqB,GAAG,aAAa,CAAC;IAE1C,IACE,MAAM,CAAC,SAAS,CAAC,CAAC,IAAI,KAAK,UAAU;QACrC,aAAa,KAAK,KAAK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AAM,QAAA;YACN,MAAM,QAAA;SACP,CAAC;QACJ,CAAC,CAAC,EAAE,CAAC;IAEP,sCAAY,aAAa,GAAK,gBAAgB,KAAE,KAAK,EAAE,SAAS,IAAG;AACrE,CAAC,CAAC;AAEF,OAAO,EAAE,kBAAkB,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
|
|
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 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 };
|
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
|
|
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 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 };
|
|
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,SAAS,CAAC;AAC5B,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,IAAI,MA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
|
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
|
+
_suffix: string | null = null;
|
|
25
|
+
get suffix(): string | null {
|
|
26
|
+
return this._suffix;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
_totalDomain: string | null = null;
|
|
30
|
+
get totalDomain(): string | null {
|
|
31
|
+
return this._totalDomain;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
_showPercent: boolean = false;
|
|
35
|
+
get showPercent(): boolean {
|
|
36
|
+
return this._showPercent;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
constructor(xml: string) {
|
|
40
|
+
const parser = new DOMParser();
|
|
41
|
+
const view: Document = parser.parseFromString(xml, "text/xml");
|
|
42
|
+
this._string = view.documentElement.getAttribute("string");
|
|
43
|
+
const type = view.documentElement.getAttribute("type");
|
|
44
|
+
|
|
45
|
+
this._color = view.documentElement.getAttribute("color");
|
|
46
|
+
this._icon = view.documentElement.getAttribute("icon");
|
|
47
|
+
this._totalDomain = view.documentElement.getAttribute("totalDomain");
|
|
48
|
+
this._suffix = view.documentElement.getAttribute("suffix");
|
|
49
|
+
|
|
50
|
+
const showPercent = view.documentElement.getAttribute("showPercent");
|
|
51
|
+
if (
|
|
52
|
+
showPercent &&
|
|
53
|
+
(showPercent === "1" ||
|
|
54
|
+
(typeof showPercent === "boolean" && showPercent === true))
|
|
55
|
+
) {
|
|
56
|
+
this._showPercent = true;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (type === "indicator") {
|
|
60
|
+
this._type = "indicator";
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export default Graph;
|
|
@@ -13,12 +13,24 @@ const evaluateCondition = ({
|
|
|
13
13
|
return false;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
if (
|
|
16
|
+
if (
|
|
17
|
+
values[fieldName] === undefined &&
|
|
18
|
+
fields[fieldName].type !== "boolean" &&
|
|
19
|
+
fields[fieldName].type !== "many2one"
|
|
20
|
+
) {
|
|
17
21
|
return false;
|
|
18
22
|
}
|
|
19
23
|
|
|
20
24
|
let filteredExpectedValue = expectedValue;
|
|
21
25
|
|
|
26
|
+
if (
|
|
27
|
+
fields[fieldName].type === "many2one" &&
|
|
28
|
+
expectedValue === false &&
|
|
29
|
+
values[fieldName] === undefined
|
|
30
|
+
) {
|
|
31
|
+
filteredExpectedValue = undefined;
|
|
32
|
+
}
|
|
33
|
+
|
|
22
34
|
if (
|
|
23
35
|
fields[fieldName].type === "boolean" &&
|
|
24
36
|
(expectedValue === 0 || expectedValue === 1)
|
package/src/index.ts
CHANGED
|
@@ -33,14 +33,7 @@ import Timeline from "./Timeline";
|
|
|
33
33
|
import Indicator from "./Indicator";
|
|
34
34
|
import Dashboard from "./Dashboard";
|
|
35
35
|
import DashboardItem from "./DashboardItem";
|
|
36
|
-
import
|
|
37
|
-
Graph,
|
|
38
|
-
GraphAxis,
|
|
39
|
-
GraphIndicator,
|
|
40
|
-
GraphLine,
|
|
41
|
-
GraphType,
|
|
42
|
-
parseGraph,
|
|
43
|
-
} from "./Graph";
|
|
36
|
+
import Graph from "./Graph";
|
|
44
37
|
|
|
45
38
|
export {
|
|
46
39
|
Char,
|
|
@@ -78,10 +71,5 @@ export {
|
|
|
78
71
|
Indicator,
|
|
79
72
|
Dashboard,
|
|
80
73
|
DashboardItem,
|
|
81
|
-
Graph
|
|
82
|
-
GraphAxis,
|
|
83
|
-
GraphIndicator,
|
|
84
|
-
GraphLine,
|
|
85
|
-
GraphType,
|
|
86
|
-
parseGraph,
|
|
74
|
+
Graph
|
|
87
75
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
});
|
|
@@ -28,6 +28,9 @@ const fields = {
|
|
|
28
28
|
change_adm: {
|
|
29
29
|
type: "boolean",
|
|
30
30
|
},
|
|
31
|
+
autoconsum_id: {
|
|
32
|
+
type: "many2one",
|
|
33
|
+
},
|
|
31
34
|
};
|
|
32
35
|
|
|
33
36
|
describe("An Attribute Parser", () => {
|
|
@@ -169,5 +172,29 @@ describe("An Attribute Parser", () => {
|
|
|
169
172
|
});
|
|
170
173
|
expect(evaluatedAttrs.invisible).toBeTruthy();
|
|
171
174
|
});
|
|
175
|
+
it("should properly parse a many2one attribute with false value", () => {
|
|
176
|
+
const tagAttributes = {
|
|
177
|
+
attrs: "{'invisible': [('autoconsum_id', '=', False)]}",
|
|
178
|
+
};
|
|
179
|
+
const values = { autoconsum_id: false };
|
|
180
|
+
const evaluatedAttrs = evaluateAttributes({
|
|
181
|
+
tagAttributes,
|
|
182
|
+
values,
|
|
183
|
+
fields,
|
|
184
|
+
});
|
|
185
|
+
expect(evaluatedAttrs.invisible).toBeTruthy();
|
|
186
|
+
});
|
|
187
|
+
it.only("should properly parse a many2one attribute with undefined value", () => {
|
|
188
|
+
const tagAttributes = {
|
|
189
|
+
attrs: "{'invisible': [('autoconsum_id', '=', False)]}",
|
|
190
|
+
};
|
|
191
|
+
const values = { autoconsum_id: undefined };
|
|
192
|
+
const evaluatedAttrs = evaluateAttributes({
|
|
193
|
+
tagAttributes,
|
|
194
|
+
values,
|
|
195
|
+
fields,
|
|
196
|
+
});
|
|
197
|
+
expect(evaluatedAttrs.invisible).toBeTruthy();
|
|
198
|
+
});
|
|
172
199
|
});
|
|
173
200
|
});
|
package/dist/Graph/Graph.d.ts
DELETED
package/dist/Graph/Graph.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
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
|
package/dist/Graph/Graph.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/Graph/Graph.spec.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,IAAM,KAAK,GAAG,UAAU,CAAC,GAAG,CAAmB,CAAC;QAEhD,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC1C,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACrC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;QACrD,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,+CAA+C,EAAE;;QAClD,IAAM,GAAG,GAAG,mLAKX,CAAC;QAEF,IAAM,KAAK,GAAG,UAAU,CAAC,GAAG,CAAc,CAAC;QAC3C,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAChC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QAC9B,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QAC9B,MAAM,OAAC,KAAK,CAAC,CAAC,0CAAE,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACxC,MAAM,OAAC,KAAK,CAAC,CAAC,0CAAE,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACxC,MAAM,OAAC,KAAK,CAAC,CAAC,0CAAE,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAChC,MAAM,OAAC,KAAK,CAAC,CAAC,0CAAE,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAChC,MAAM,OAAC,KAAK,CAAC,CAAC,0CAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC;QACrC,MAAM,OAAC,KAAK,CAAC,CAAC,0CAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
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
|
-
}
|
package/dist/Graph/GraphAxis.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,20 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,12 +0,0 @@
|
|
|
1
|
-
import { Graph } from "./Graph";
|
|
2
|
-
export declare class GraphIndicator extends Graph {
|
|
3
|
-
_color: string | null;
|
|
4
|
-
get color(): string | null;
|
|
5
|
-
_icon: string | null;
|
|
6
|
-
get icon(): string | null;
|
|
7
|
-
_totalDomain: string | null;
|
|
8
|
-
get totalDomain(): string | null;
|
|
9
|
-
_showPercent: boolean;
|
|
10
|
-
get showPercent(): boolean;
|
|
11
|
-
constructor(element: HTMLElement);
|
|
12
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
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._type = "indicator";
|
|
24
|
-
_this._color = element.getAttribute("color");
|
|
25
|
-
_this._icon = element.getAttribute("icon");
|
|
26
|
-
_this._totalDomain = element.getAttribute("totalDomain");
|
|
27
|
-
var showPercent = element.getAttribute("showPercent");
|
|
28
|
-
if (showPercent &&
|
|
29
|
-
(showPercent === "1" ||
|
|
30
|
-
(typeof showPercent === "boolean" && showPercent === true))) {
|
|
31
|
-
_this._showPercent = true;
|
|
32
|
-
}
|
|
33
|
-
return _this;
|
|
34
|
-
}
|
|
35
|
-
Object.defineProperty(GraphIndicator.prototype, "color", {
|
|
36
|
-
get: function () {
|
|
37
|
-
return this._color;
|
|
38
|
-
},
|
|
39
|
-
enumerable: false,
|
|
40
|
-
configurable: true
|
|
41
|
-
});
|
|
42
|
-
Object.defineProperty(GraphIndicator.prototype, "icon", {
|
|
43
|
-
get: function () {
|
|
44
|
-
return this._icon;
|
|
45
|
-
},
|
|
46
|
-
enumerable: false,
|
|
47
|
-
configurable: true
|
|
48
|
-
});
|
|
49
|
-
Object.defineProperty(GraphIndicator.prototype, "totalDomain", {
|
|
50
|
-
get: function () {
|
|
51
|
-
return this._totalDomain;
|
|
52
|
-
},
|
|
53
|
-
enumerable: false,
|
|
54
|
-
configurable: true
|
|
55
|
-
});
|
|
56
|
-
Object.defineProperty(GraphIndicator.prototype, "showPercent", {
|
|
57
|
-
get: function () {
|
|
58
|
-
return this._showPercent;
|
|
59
|
-
},
|
|
60
|
-
enumerable: false,
|
|
61
|
-
configurable: true
|
|
62
|
-
});
|
|
63
|
-
return GraphIndicator;
|
|
64
|
-
}(Graph));
|
|
65
|
-
export { GraphIndicator };
|
|
66
|
-
//# sourceMappingURL=GraphIndicator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GraphIndicator.js","sourceRoot":"","sources":["../../src/Graph/GraphIndicator.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC;IAAoC,kCAAK;IAqBvC,wBAAY,OAAoB;QAAhC,YACE,kBAAM,OAAO,CAAC,SAef;QApCD,YAAM,GAAkB,IAAI,CAAC;QAK7B,WAAK,GAAkB,IAAI,CAAC;QAK5B,kBAAY,GAAkB,IAAI,CAAC;QAKnC,kBAAY,GAAY,KAAK,CAAC;QAQ5B,KAAI,CAAC,KAAK,GAAG,WAAW,CAAC;QACzB,KAAI,CAAC,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAC5C,KAAI,CAAC,KAAK,GAAG,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QAC1C,KAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;QACxD,IAAM,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;QAExD,IACE,WAAW;YACX,CAAC,WAAW,KAAK,GAAG;gBAClB,CAAC,OAAO,WAAW,KAAK,SAAS,IAAI,WAAW,KAAK,IAAI,CAAC,CAAC,EAC7D;YACA,KAAI,CAAC,YAAY,GAAG,IAAI,CAAC;SAC1B;;IACH,CAAC;IAnCD,sBAAI,iCAAK;aAAT;YACE,OAAO,IAAI,CAAC,MAAM,CAAC;QACrB,CAAC;;;OAAA;IAGD,sBAAI,gCAAI;aAAR;YACE,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;;;OAAA;IAGD,sBAAI,uCAAW;aAAf;YACE,OAAO,IAAI,CAAC,YAAY,CAAC;QAC3B,CAAC;;;OAAA;IAGD,sBAAI,uCAAW;aAAf;YACE,OAAO,IAAI,CAAC,YAAY,CAAC;QAC3B,CAAC;;;OAAA;IAmBH,qBAAC;AAAD,CAAC,AAtCD,CAAoC,KAAK,GAsCxC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
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
|
-
}
|
package/dist/Graph/GraphLine.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,32 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/Graph/index.d.ts
DELETED
package/dist/Graph/index.js
DELETED
package/dist/Graph/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/src/Graph/Graph.spec.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
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
|
-
});
|
package/src/Graph/Graph.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
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
|
-
}
|
package/src/Graph/GraphAxis.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
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
|
-
constructor(element: HTMLElement) {
|
|
25
|
-
super(element);
|
|
26
|
-
|
|
27
|
-
this._type = "indicator";
|
|
28
|
-
this._color = element.getAttribute("color");
|
|
29
|
-
this._icon = element.getAttribute("icon");
|
|
30
|
-
this._totalDomain = element.getAttribute("totalDomain");
|
|
31
|
-
const showPercent = element.getAttribute("showPercent");
|
|
32
|
-
|
|
33
|
-
if (
|
|
34
|
-
showPercent &&
|
|
35
|
-
(showPercent === "1" ||
|
|
36
|
-
(typeof showPercent === "boolean" && showPercent === true))
|
|
37
|
-
) {
|
|
38
|
-
this._showPercent = true;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
package/src/Graph/GraphLine.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
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
|
-
}
|
package/src/Graph/graphHelper.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
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
|
-
};
|