-
Notifications
You must be signed in to change notification settings - Fork 3
/
ABViewManagerCore.js
149 lines (138 loc) · 4.56 KB
/
ABViewManagerCore.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/*
* ABViewManager
*
* An interface for managing the different ABViews available in our AppBuilder.
*
*/
var AllViews = [
require("../platform/views/ABView"),
require("../platform/views/ABViewCarousel"),
require("../platform/views/ABViewChart"),
require("../platform/views/ABViewChartArea"),
require("../platform/views/ABViewChartBar"),
require("../platform/views/ABViewChartLine"),
require("../platform/views/ABViewChartPie"),
require("../platform/views/ABViewComment"),
require("../platform/views/ABViewConditionalContainer"),
require("../platform/views/ABViewConnectDataFilter"),
require("../platform/views/ABViewContainer"),
require("../platform/views/ABViewCSVExporter"),
require("../platform/views/ABViewCSVImporter"),
require("../platform/views/ABViewDataFilter"),
require("../platform/views/ABViewDataSelect"),
require("../platform/views/ABViewDataview"),
require("../platform/views/ABViewDocxBuilder"),
require("../platform/views/ABViewGrid"),
require("../platform/views/ABViewImage"),
require("../platform/views/ABViewLabel"),
require("../platform/views/ABViewLayout"),
require("../platform/views/ABViewList"),
require("../platform/views/ABViewMenu"),
require("../platform/views/ABViewOrgChart"),
require("../platform/views/ABViewPage"),
require("../platform/views/ABViewPDFImporter"),
require("../platform/views/ABViewPivot"),
require("../platform/views/ABViewTab"),
require("../platform/views/ABViewText"),
//
// Special Editors
//
require("../platform/views/ABViewGantt"),
require("../platform/views/ABViewKanban"),
require("../platform/views/ABViewReportsManager"),
require("../platform/views/ABViewScheduler"),
//
// Detail Components
//
require("../platform/views/ABViewDetail"),
require("../platform/views/ABViewDetailCheckbox"),
require("../platform/views/ABViewDetailConnect"),
require("../platform/views/ABViewDetailCustom"),
require("../platform/views/ABViewDetailImage"),
// require("../platform/views/ABViewDetailSelectivity"),
require("../platform/views/ABViewDetailText"),
require("../platform/views/ABViewDetailTree"),
//
// Form Components
//
require("../platform/views/ABViewForm"),
require("../platform/views/ABViewFormButton"),
require("../platform/views/ABViewFormCheckbox"),
require("../platform/views/ABViewFormConnect"),
require("../platform/views/ABViewFormCustom"),
require("../platform/views/ABViewFormDatepicker"),
require("../platform/views/ABViewFormJson"),
require("../platform/views/ABViewFormNumber"),
require("../platform/views/ABViewFormReadonly"),
require("../platform/views/ABViewFormSelectMultiple"),
require("../platform/views/ABViewFormSelectSingle"),
require("../platform/views/ABViewFormTextbox"),
require("../platform/views/ABViewFormTree"),
];
/*
* Views
* A name => ABView hash of the different ABViews available.
*/
var Views = {};
AllViews.forEach((v) => {
if (v.default?.common) {
v = v.default;
}
Views[v.common().key] = v;
});
module.exports = class ABViewManagerCore {
/**
* @function allViews
* return all the currently defined ABViews in an array.
* @return [{ABView},...]
*/
static allViews(fn = () => true) {
var views = [];
for (var v in Views) {
var V = Views[v];
if (fn(V)) {
views.push(V);
}
}
return views;
}
/**
* @function newView
* return an instance of an ABView based upon the values.key value.
* @return {ABView}
*/
static newView(values, application, parent) {
parent = parent || null;
if (values.key == "detailselectivity") {
values.key = "detailconnect";
}
// if ((values.key) && (Views[values.key])) {
if (values.key) {
if (!Views[values.key]) {
console.error(
"!! View[" +
values.key +
"] not yet defined. Have an ABView instead:"
);
return new Views["view"](values, application, parent);
}
return new Views[values.key](values, application, parent);
} else {
var err = new Error(`Unknown view key [${values.key}]`);
console.error(err); // show the stack.
console.error({
error: err,
values: values,
application: application,
});
return null;
}
}
static viewClass(key) {
if (Views[key]) {
return Views[key];
}
console.error(`Unknown View Key[${key}]`);
return;
}
};