qcobjects-sdk 2.4.60 → 2.4.61
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/.dockerignore +98 -1
- package/.eslintignore +1 -2
- package/.github/workflows/static.yml +91 -0
- package/VERSION +1 -1
- package/config.json +4 -0
- package/package.json +31 -9
- package/src/QCObjects-SDK.d.ts +26 -0
- package/src/QCObjects-SDK.ts +110 -0
- package/src/index.d.ts +1 -1
- package/src/index.mts +2 -0
- package/src/js/org.qcobjects.cloud.auth.session.data.d.ts +1 -0
- package/src/js/{org.qcobjects.cloud.auth.session.data.js → org.qcobjects.cloud.auth.session.data.ts} +28 -22
- package/src/js/org.qcobjects.cloud.auth.session.usertoken.d.ts +2 -0
- package/src/js/org.qcobjects.cloud.auth.session.usertoken.ts +128 -0
- package/src/js/org.qcobjects.components.d.ts +10 -0
- package/src/js/org.qcobjects.components.grid.d.ts +3 -0
- package/src/js/org.qcobjects.components.grid.ts +95 -0
- package/src/js/org.qcobjects.components.list.d.ts +3 -0
- package/src/js/org.qcobjects.components.list.ts +83 -0
- package/src/js/org.qcobjects.components.notifications.d.ts +1 -0
- package/src/js/org.qcobjects.components.notifications.ts +191 -0
- package/src/js/org.qcobjects.components.slider.d.ts +1 -0
- package/src/js/{org.qcobjects.components.slider.js → org.qcobjects.components.slider.ts} +8 -6
- package/src/js/org.qcobjects.components.splashscreen.d.ts +28 -0
- package/src/js/org.qcobjects.components.splashscreen.ts +680 -0
- package/src/js/org.qcobjects.components.ts +336 -0
- package/src/js/org.qcobjects.controllers.d.ts +1 -0
- package/src/js/org.qcobjects.controllers.form.d.ts +1 -0
- package/src/js/{org.qcobjects.controllers.form.js → org.qcobjects.controllers.form.ts} +57 -59
- package/src/js/org.qcobjects.controllers.grid.d.ts +1 -0
- package/src/js/{org.qcobjects.controllers.grid.js → org.qcobjects.controllers.grid.ts} +102 -97
- package/src/js/org.qcobjects.controllers.list.d.ts +1 -0
- package/src/js/{org.qcobjects.controllers.list.js → org.qcobjects.controllers.list.ts} +86 -76
- package/src/js/org.qcobjects.controllers.slider.d.ts +1 -0
- package/src/js/org.qcobjects.controllers.slider.ts +158 -0
- package/src/js/org.qcobjects.controllers.swagger.d.ts +1 -0
- package/src/js/{org.qcobjects.controllers.swagger.js → org.qcobjects.controllers.swagger.ts} +13 -14
- package/src/js/{org.qcobjects.controllers.js → org.qcobjects.controllers.ts} +3 -6
- package/src/js/org.qcobjects.effects.d.ts +20 -0
- package/src/js/org.qcobjects.effects.ts +430 -0
- package/src/js/org.qcobjects.i18n_messages.d.ts +1 -0
- package/src/js/{org.qcobjects.i18n_messages.js → org.qcobjects.i18n_messages.ts} +36 -27
- package/src/js/org.qcobjects.modal.controllers.d.ts +1 -0
- package/src/js/{org.qcobjects.modal.controllers.js → org.qcobjects.modal.controllers.ts} +5 -6
- package/src/js/org.qcobjects.modal.effects.d.ts +1 -0
- package/src/js/{org.qcobjects.modal.effects.js → org.qcobjects.modal.effects.ts} +4 -1
- package/src/js/org.qcobjects.models.d.ts +1 -0
- package/src/js/{org.qcobjects.models.js → org.qcobjects.models.ts} +3 -24
- package/src/js/org.qcobjects.tools.canvas.d.ts +1 -0
- package/src/js/{org.qcobjects.tools.canvas.js → org.qcobjects.tools.canvas.ts} +14 -11
- package/src/js/org.qcobjects.tools.d.ts +1 -0
- package/src/js/org.qcobjects.tools.layouts.d.ts +1 -0
- package/src/js/org.qcobjects.tools.layouts.ts +85 -0
- package/src/js/{org.qcobjects.tools.js → org.qcobjects.tools.ts} +19 -11
- package/src/js/org.qcobjects.views.d.ts +1 -0
- package/src/js/{org.qcobjects.views.js → org.qcobjects.views.ts} +3 -5
- package/tsconfig.json +1 -1
- package/-m +0 -1
- package/src/QCObjects-SDK.js +0 -148
- package/src/index.mjs +0 -2
- package/src/js/org.qcobjects.cloud.auth.session.usertoken.js +0 -116
- package/src/js/org.qcobjects.components.grid.js +0 -65
- package/src/js/org.qcobjects.components.js +0 -276
- package/src/js/org.qcobjects.components.list.js +0 -59
- package/src/js/org.qcobjects.components.notifications.js +0 -190
- package/src/js/org.qcobjects.components.splashscreen.js +0 -645
- package/src/js/org.qcobjects.controllers.slider.js +0 -154
- package/src/js/org.qcobjects.effects.js +0 -345
- package/src/js/org.qcobjects.tools.layouts.js +0 -79
- /package/{css → src/css}/base-modal.css +0 -0
- /package/{css → src/css}/basic-layout-embedded-nav.css +0 -0
- /package/{css → src/css}/basic-layout.css +0 -0
- /package/{css → src/css}/components/horizontal-list.css +0 -0
- /package/{css → src/css}/components/list.css +0 -0
- /package/{css → src/css}/components/splashscreen.css +0 -0
- /package/{css → src/css}/modal.css +0 -0
- /package/src/{index.cjs → index.cts} +0 -0
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Package, Controller, _DOMCreateElement, logger, _DataStringify, ClassFactory, New, ComponentURI, CONFIG, serviceLoader, ControllerParams, QCObjectsElement, QCObjectsShadowedElement } from "qcobjects";
|
|
2
|
+
import { GridComponent } from "./org.qcobjects.components.grid";
|
|
1
3
|
/**
|
|
2
4
|
* QCObjects SDK 2.4
|
|
3
5
|
* ________________
|
|
@@ -22,50 +24,54 @@
|
|
|
22
24
|
* Everyone is permitted to copy and distribute verbatim copies of this
|
|
23
25
|
* license document, but changing it is not allowed.
|
|
24
26
|
*/
|
|
27
|
+
|
|
25
28
|
(function() {
|
|
26
29
|
"use strict";
|
|
30
|
+
type DataGridControllerParams = ControllerParams & {
|
|
31
|
+
rows:number | string | null;
|
|
32
|
+
cols: number | string | null;
|
|
33
|
+
}
|
|
27
34
|
Package("org.qcobjects.controllers.grid",[
|
|
28
35
|
|
|
29
36
|
class GridController extends Controller {
|
|
30
|
-
|
|
31
|
-
|
|
37
|
+
__instanceID!:number;
|
|
38
|
+
rows:number | string | null;
|
|
39
|
+
cols:number | string | null;
|
|
32
40
|
|
|
33
|
-
constructor (
|
|
34
|
-
super(
|
|
41
|
+
constructor (controller:ControllerParams){
|
|
42
|
+
super(controller);
|
|
35
43
|
this.rows=this.component.body.getAttribute("rows");
|
|
36
|
-
this.rows=(this.rows !== null)?(this.rows):(this.component.rows);
|
|
44
|
+
this.rows=(this.rows !== null)?(this.rows):((this.component as typeof GridComponent).rows);
|
|
37
45
|
this.cols=this.component.body.getAttribute("cols");
|
|
38
|
-
this.cols=(this.cols !== null)?(this.cols):(this.component.cols);
|
|
46
|
+
this.cols=(this.cols !== null)?(this.cols):((this.component as typeof GridComponent).cols);
|
|
39
47
|
|
|
40
48
|
}
|
|
41
49
|
|
|
42
50
|
cssGrid (){
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
_componentRoot.append(s);
|
|
51
|
+
const component = this.component;
|
|
52
|
+
const _componentRoot = (component.shadowed)?(component.shadowRoot):(component.body);
|
|
53
|
+
if (typeof this.rows !== "undefined" && typeof this.cols !== "undefined"){
|
|
54
|
+
const s = _DOMCreateElement("style");
|
|
55
|
+
const templateRows = "auto ".repeat(this.rows as number);
|
|
56
|
+
const templateCols = "auto ".repeat(this.cols as number);
|
|
57
|
+
const className = "grid"+this.__instanceID.toString();
|
|
58
|
+
s.innerHTML = `.${className}{
|
|
59
|
+
display: grid; \
|
|
60
|
+
grid-template-rows: ${templateRows}; \
|
|
61
|
+
grid-template-columns: ${templateCols}; \
|
|
62
|
+
margin:0 auto; \
|
|
63
|
+
}`;
|
|
64
|
+
_componentRoot?.append(s);
|
|
58
65
|
if (component.shadowed){
|
|
59
|
-
_componentRoot
|
|
66
|
+
(_componentRoot as ShadowRoot)?.host.classList.add(className);
|
|
60
67
|
} else {
|
|
61
|
-
_componentRoot.classList.add(className);
|
|
68
|
+
((_componentRoot as HTMLDivElement).classList).add(className);
|
|
62
69
|
}
|
|
63
70
|
}
|
|
64
71
|
}
|
|
65
72
|
|
|
66
73
|
done (){
|
|
67
|
-
|
|
68
|
-
controller.cssGrid();
|
|
74
|
+
this.cssGrid();
|
|
69
75
|
|
|
70
76
|
logger.debug("GridComponent built");
|
|
71
77
|
|
|
@@ -74,53 +80,52 @@ Package("org.qcobjects.controllers.grid",[
|
|
|
74
80
|
},
|
|
75
81
|
|
|
76
82
|
class DataGridController extends Controller {
|
|
77
|
-
|
|
78
|
-
|
|
83
|
+
__instanceID!:number;
|
|
84
|
+
rows:number | string | null;
|
|
85
|
+
cols: number | string | null;
|
|
86
|
+
_componentRoot:QCObjectsElement | QCObjectsShadowedElement | HTMLElement | ShadowRoot | undefined;
|
|
79
87
|
|
|
80
|
-
constructor (
|
|
81
|
-
super(
|
|
82
|
-
|
|
83
|
-
controller.component
|
|
84
|
-
controller.
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
controller.cols=controller.component.body.getAttribute("cols");
|
|
88
|
-
controller.cols=(controller.cols !== null)?(controller.cols):(controller.component.cols);
|
|
88
|
+
constructor (controller:DataGridControllerParams){
|
|
89
|
+
super(controller);
|
|
90
|
+
this._componentRoot = (controller.component.shadowed)?(controller.component.shadowRoot):(controller.component.body);
|
|
91
|
+
this.rows=controller.component.body.getAttribute("rows");
|
|
92
|
+
this.rows=(controller.rows !== null)?(controller.rows):((controller.component as typeof GridComponent).rows);
|
|
93
|
+
this.cols=controller.component.body.getAttribute("cols");
|
|
94
|
+
this.cols=(controller.cols !== null)?(controller.cols):((controller.component as typeof GridComponent).cols);
|
|
89
95
|
logger.debug("DataGridController INIT");
|
|
90
96
|
|
|
91
97
|
}
|
|
92
98
|
|
|
93
|
-
getPageIndex (page, totalPage, totalElements) {
|
|
94
|
-
page = new Number(page);
|
|
99
|
+
getPageIndex (page:number, totalPage:number, totalElements:number) {
|
|
95
100
|
page = (page>0)?(page-1):(0);
|
|
96
|
-
totalPage = new Number(totalPage);
|
|
97
|
-
totalElements = new Number(totalElements);
|
|
98
101
|
return [totalElements*page/ totalPage, (totalElements*page/ totalPage) + totalElements/totalPage];
|
|
99
102
|
}
|
|
100
103
|
|
|
101
104
|
addSubcomponents (){
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
this.component.subcomponents = [];
|
|
106
|
+
if (typeof this._componentRoot !== "undefined"){
|
|
107
|
+
this._componentRoot.innerHTML = "";
|
|
108
|
+
}
|
|
109
|
+
this.cssGrid();
|
|
110
|
+
logger.debug(_DataStringify(this.component.data));
|
|
107
111
|
try {
|
|
108
|
-
|
|
112
|
+
const subcomponentClass = this.component.body.getAttribute("subcomponentClass");
|
|
109
113
|
if (subcomponentClass != null){
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
114
|
+
let offset:number;
|
|
115
|
+
let limit:number;
|
|
116
|
+
let pagesNumber:number;
|
|
117
|
+
let list = [...this.component.data];
|
|
118
|
+
let paginateIn = this.component.body.getAttribute("paginate-in");
|
|
119
|
+
let page:number | string | null | undefined;
|
|
115
120
|
paginateIn = (paginateIn !== null)?(paginateIn):("client");
|
|
116
121
|
if (paginateIn === "client"){
|
|
117
|
-
|
|
122
|
+
page = this.component.body.getAttribute("page-number") as unknown as number;
|
|
118
123
|
page = (isNaN(page) || page === null)?(-1):(page);
|
|
119
124
|
if (page !== -1){
|
|
120
|
-
pagesNumber =
|
|
125
|
+
pagesNumber = this.component.body.getAttribute("total-pages") as unknown as number;
|
|
121
126
|
pagesNumber = (isNaN(pagesNumber))?(1):(pagesNumber);
|
|
122
|
-
offset =
|
|
123
|
-
limit =
|
|
127
|
+
offset = this.getPageIndex(page, pagesNumber, list.length)[0];
|
|
128
|
+
limit = this.getPageIndex(page, pagesNumber, list.length)[1];
|
|
124
129
|
} else {
|
|
125
130
|
offset = 0;
|
|
126
131
|
limit = list.length;
|
|
@@ -133,9 +138,10 @@ Package("org.qcobjects.controllers.grid",[
|
|
|
133
138
|
pagesNumber = 1;
|
|
134
139
|
}
|
|
135
140
|
list.map(
|
|
136
|
-
|
|
141
|
+
(record,dataIndex, list) => {
|
|
142
|
+
const _ret_ = undefined;
|
|
137
143
|
try {
|
|
138
|
-
|
|
144
|
+
const _body = _DOMCreateElement("component");
|
|
139
145
|
_body.setAttribute("name",ClassFactory(subcomponentClass).name);
|
|
140
146
|
_body.setAttribute("shadowed",ClassFactory(subcomponentClass).shadowed);
|
|
141
147
|
_body.setAttribute("cached",ClassFactory(subcomponentClass).cached);
|
|
@@ -147,29 +153,29 @@ Package("org.qcobjects.controllers.grid",[
|
|
|
147
153
|
__limit: limit,
|
|
148
154
|
__offset: offset
|
|
149
155
|
});
|
|
150
|
-
|
|
156
|
+
const subcomponent = New(ClassFactory(subcomponentClass),{
|
|
151
157
|
name:"item",
|
|
152
158
|
data:record,
|
|
153
159
|
templateURI:ComponentURI({
|
|
154
|
-
"COMPONENTS_BASE_PATH":CONFIG.get("componentsBasePath"),
|
|
160
|
+
"COMPONENTS_BASE_PATH":CONFIG.get("componentsBasePath", ""),
|
|
155
161
|
"COMPONENT_NAME":ClassFactory(subcomponentClass).name,
|
|
156
|
-
"TPLEXTENSION":CONFIG.get("tplextension"),
|
|
162
|
+
"TPLEXTENSION":CONFIG.get("tplextension", ""),
|
|
157
163
|
"TPL_SOURCE":ClassFactory(subcomponentClass).tplsource
|
|
158
164
|
}),
|
|
159
165
|
body:_body,
|
|
160
166
|
template:ClassFactory(subcomponentClass).template
|
|
161
167
|
});
|
|
162
|
-
subcomponent.done =
|
|
168
|
+
subcomponent.done = this.component.done.bind(subcomponent);
|
|
163
169
|
try {
|
|
164
170
|
if (subcomponent){
|
|
165
171
|
subcomponent.data.__dataIndex = dataIndex;
|
|
166
|
-
if (
|
|
167
|
-
subcomponent.data.__dataLength =
|
|
172
|
+
if (Object.hasOwnProperty.call(this.component.data,"length")){
|
|
173
|
+
subcomponent.data.__dataLength = this.component.data.length;
|
|
168
174
|
}
|
|
169
175
|
logger.debug("adding subcomponent to body");
|
|
170
|
-
|
|
176
|
+
this._componentRoot?.append(subcomponent.body);
|
|
171
177
|
try {
|
|
172
|
-
|
|
178
|
+
this.component.subcomponents.push(subcomponent);
|
|
173
179
|
}catch (e){
|
|
174
180
|
logger.debug("ERROR LOADING SUBCOMPONENT IN DATAGRID");
|
|
175
181
|
}
|
|
@@ -183,6 +189,7 @@ Package("org.qcobjects.controllers.grid",[
|
|
|
183
189
|
} catch (e) {
|
|
184
190
|
logger.debug("ERROR LOADING SUBCOMPONENT IN DATAGRID");
|
|
185
191
|
}
|
|
192
|
+
return _ret_;
|
|
186
193
|
}
|
|
187
194
|
);
|
|
188
195
|
} else {
|
|
@@ -195,50 +202,48 @@ Package("org.qcobjects.controllers.grid",[
|
|
|
195
202
|
}
|
|
196
203
|
|
|
197
204
|
cssGrid (){
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
}";
|
|
205
|
+
const component = this.component;
|
|
206
|
+
const _componentRoot = (component.shadowed)?(component.shadowRoot):(component.body);
|
|
207
|
+
if (typeof this.rows !== "undefined" && typeof this.cols !== "undefined"){
|
|
208
|
+
const s = _DOMCreateElement("style");
|
|
209
|
+
const templateRows = "auto ".repeat(this.rows as number);
|
|
210
|
+
const templateCols = "auto ".repeat(this.cols as number);
|
|
211
|
+
const className = "grid"+this.__instanceID.toString();
|
|
212
|
+
s.innerHTML = `.${className}{
|
|
213
|
+
display: grid; \
|
|
214
|
+
grid-template-rows: ${templateRows}; \
|
|
215
|
+
grid-template-columns: ${templateCols}; \
|
|
216
|
+
margin:0 auto; \
|
|
217
|
+
}`;
|
|
212
218
|
if (component.shadowed){
|
|
213
219
|
component.body.append(s);
|
|
214
|
-
_componentRoot.host.classList.add(className);
|
|
220
|
+
(_componentRoot as ShadowRoot).host.classList.add(className);
|
|
215
221
|
} else {
|
|
216
|
-
_componentRoot
|
|
217
|
-
_componentRoot.classList.add(className);
|
|
222
|
+
_componentRoot?.append(s);
|
|
223
|
+
(_componentRoot as HTMLElement).classList.add(className);
|
|
218
224
|
}
|
|
219
225
|
}
|
|
220
226
|
}
|
|
221
227
|
|
|
222
228
|
done (){
|
|
223
|
-
|
|
224
|
-
var componentInstance = controller.component;
|
|
229
|
+
const componentInstance = this.component;
|
|
225
230
|
logger.debug("DataGridController DONE");
|
|
226
|
-
|
|
231
|
+
const serviceClass = this.component.body.getAttribute("serviceClass");
|
|
227
232
|
if (serviceClass != null){
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
233
|
+
let offset;
|
|
234
|
+
let limit;
|
|
235
|
+
let paginateIn = componentInstance.body.getAttribute("paginate-in");
|
|
231
236
|
paginateIn = (paginateIn !== null)?(paginateIn):("client");
|
|
232
237
|
if (paginateIn === "server"){
|
|
233
|
-
|
|
238
|
+
let page = componentInstance.body.getAttribute("page-number") as unknown as number;
|
|
234
239
|
page = (isNaN(page) || page === null)?(-1):(page);
|
|
235
|
-
|
|
240
|
+
let pagesNumber;
|
|
236
241
|
if (page !== -1){
|
|
237
|
-
|
|
238
|
-
pagesNumber =
|
|
242
|
+
const serverDataCount = (this.component.body.getAttribute("server-data-count")!==null)?(this.component.body.getAttribute("server-data-count") as unknown as number):(1);
|
|
243
|
+
pagesNumber = this.component.body.getAttribute("total-pages") as unknown as number;
|
|
239
244
|
pagesNumber = (isNaN(pagesNumber))?(1):(pagesNumber);
|
|
240
|
-
offset =
|
|
241
|
-
limit =
|
|
245
|
+
offset = this.getPageIndex(page, pagesNumber, serverDataCount)[0];
|
|
246
|
+
limit = this.getPageIndex(page, pagesNumber, serverDataCount)[1];
|
|
242
247
|
// send params in jsonrpc 2.0 style
|
|
243
248
|
componentInstance.serviceData = (typeof componentInstance.serviceData !== "undefined")?(componentInstance.serviceData):({});
|
|
244
249
|
componentInstance.serviceData.params = (typeof componentInstance.serviceData.params !== "undefined")?(componentInstance.serviceData.params):({});
|
|
@@ -249,7 +254,7 @@ Package("org.qcobjects.controllers.grid",[
|
|
|
249
254
|
|
|
250
255
|
serviceLoader(New(ClassFactory(serviceClass),{
|
|
251
256
|
data:componentInstance.serviceData
|
|
252
|
-
})).then(
|
|
257
|
+
}), false).then(
|
|
253
258
|
(successfulResponse)=>{
|
|
254
259
|
// This will show the service response as a plain text
|
|
255
260
|
logger.debug("DONE SERVICE COMPONENT");
|
|
@@ -260,7 +265,7 @@ Package("org.qcobjects.controllers.grid",[
|
|
|
260
265
|
} else {
|
|
261
266
|
componentInstance.data = successfulResponse.service.JSONresponse;
|
|
262
267
|
}
|
|
263
|
-
|
|
268
|
+
this.addSubcomponents();
|
|
264
269
|
|
|
265
270
|
},
|
|
266
271
|
(failedResponse)=>{
|
|
@@ -279,4 +284,4 @@ Package("org.qcobjects.controllers.grid",[
|
|
|
279
284
|
|
|
280
285
|
]);
|
|
281
286
|
|
|
282
|
-
})
|
|
287
|
+
})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Package, Controller, logger, CONFIG, _DataStringify, _DOMCreateElement, New, ClassFactory, ComponentURI, serviceLoader, ControllerParams, QCObjectsElement, QCObjectsShadowedElement, Component } from "qcobjects";
|
|
2
|
+
import { ListComponent } from "./org.qcobjects.components.list";
|
|
1
3
|
/**
|
|
2
4
|
* QCObjects SDK 2.4
|
|
3
5
|
* ________________
|
|
@@ -24,21 +26,30 @@
|
|
|
24
26
|
*/
|
|
25
27
|
(function () {
|
|
26
28
|
"use strict";
|
|
29
|
+
type ListControllerParams = ControllerParams & {
|
|
30
|
+
component: typeof ListComponent;
|
|
31
|
+
valueField:string | undefined;
|
|
32
|
+
labelField:string | undefined;
|
|
33
|
+
|
|
34
|
+
};
|
|
27
35
|
Package("org.qcobjects.controllers.list", [
|
|
28
36
|
|
|
29
37
|
class ListController extends Controller {
|
|
30
|
-
|
|
31
|
-
component
|
|
32
|
-
valueField
|
|
33
|
-
labelField
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
__instanceID!: number;
|
|
39
|
+
component: typeof ListComponent;
|
|
40
|
+
valueField:string | undefined;
|
|
41
|
+
labelField:string | undefined;
|
|
42
|
+
rows:number | string | null;
|
|
43
|
+
cols:number;
|
|
44
|
+
_componentRoot:QCObjectsElement | QCObjectsShadowedElement | HTMLElement | undefined;
|
|
45
|
+
|
|
46
|
+
constructor({component, dependencies = [], valueField = undefined, labelField = undefined}:ListControllerParams) {
|
|
47
|
+
super({component, dependencies, valueField, labelField} as ListControllerParams);
|
|
37
48
|
this.component = component;
|
|
38
49
|
this._componentRoot = (this.component.shadowed) ? (this.component.shadowRoot) : (this.component.body);
|
|
39
50
|
|
|
40
|
-
this.labelField = this.component.body.getAttribute("label-field");
|
|
41
|
-
this.valueField = this.component.body.getAttribute("value-field");
|
|
51
|
+
this.labelField = this.component.body.getAttribute("label-field") as string;
|
|
52
|
+
this.valueField = this.component.body.getAttribute("value-field") as string;
|
|
42
53
|
this.rows = this.component.body.getAttribute("rows");
|
|
43
54
|
this.rows = (this.rows !== null) ? (this.rows) : (this.component.rows);
|
|
44
55
|
this.cols = 1;
|
|
@@ -46,47 +57,46 @@
|
|
|
46
57
|
|
|
47
58
|
}
|
|
48
59
|
|
|
49
|
-
getPageIndex(page, totalPage, totalElements) {
|
|
50
|
-
page = new Number(page);
|
|
60
|
+
getPageIndex(page:number, totalPage:number, totalElements:number) {
|
|
51
61
|
page = (page > 0) ? (page - 1) : (0);
|
|
52
|
-
totalPage = new Number(totalPage);
|
|
53
|
-
totalElements = new Number(totalElements);
|
|
54
62
|
return [totalElements * page / totalPage, (totalElements * page / totalPage) + totalElements / totalPage];
|
|
55
63
|
}
|
|
56
64
|
|
|
57
65
|
addSubcomponents() {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
controller.valueField = controller.component.body.getAttribute("value-field");
|
|
66
|
+
this.component.subcomponents = [];
|
|
67
|
+
const layout = this.component.body.getAttribute("layout");
|
|
68
|
+
const basePath = CONFIG.get("listBasePath", CONFIG.get("remoteSDKPath", ""));
|
|
69
|
+
let cssLayout = "";
|
|
70
|
+
this.labelField = this.component.body.getAttribute("label-field");
|
|
71
|
+
this.valueField = this.component.body.getAttribute("value-field");
|
|
65
72
|
|
|
66
73
|
if (layout === "horizontal") {
|
|
67
74
|
cssLayout = `@import url("${basePath}css/components/horizontal-list.css");`;
|
|
68
75
|
} else {
|
|
69
76
|
cssLayout = `@import url("${basePath}css/components/list.css");`;
|
|
70
77
|
}
|
|
71
|
-
|
|
72
|
-
|
|
78
|
+
if (typeof this._componentRoot !== "undefined"){
|
|
79
|
+
this._componentRoot.innerHTML = `<style>${cssLayout}</style><ul></ul>`;
|
|
80
|
+
}
|
|
81
|
+
logger.debug(_DataStringify(this.component.data));
|
|
73
82
|
try {
|
|
74
|
-
|
|
83
|
+
const subcomponentClass = this.component.body.getAttribute("subcomponentClass");
|
|
75
84
|
if (subcomponentClass != null) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
85
|
+
let offset:number;
|
|
86
|
+
let limit:number;
|
|
87
|
+
let pagesNumber:number;
|
|
88
|
+
let list = [...this.component.data];
|
|
89
|
+
let paginateIn = this.component.body.getAttribute("paginate-in");
|
|
81
90
|
paginateIn = (paginateIn !== null) ? (paginateIn) : ("client");
|
|
91
|
+
let page:number;
|
|
82
92
|
if (paginateIn === "client") {
|
|
83
|
-
|
|
93
|
+
page = this.component.body.getAttribute("page-number");
|
|
84
94
|
page = (isNaN(page) || page === null) ? (-1) : (page);
|
|
85
95
|
if (page !== -1) {
|
|
86
|
-
pagesNumber =
|
|
96
|
+
pagesNumber = this.component.body.getAttribute("total-pages");
|
|
87
97
|
pagesNumber = (isNaN(pagesNumber)) ? (1) : (pagesNumber);
|
|
88
|
-
offset =
|
|
89
|
-
limit =
|
|
98
|
+
offset = this.getPageIndex(page, pagesNumber, list.length)[0];
|
|
99
|
+
limit = this.getPageIndex(page, pagesNumber, list.length)[1];
|
|
90
100
|
} else {
|
|
91
101
|
offset = 0;
|
|
92
102
|
limit = list.length;
|
|
@@ -99,16 +109,17 @@
|
|
|
99
109
|
pagesNumber = 1;
|
|
100
110
|
}
|
|
101
111
|
list.map(
|
|
102
|
-
|
|
112
|
+
(record, dataIndex) => {
|
|
113
|
+
const _ret_=undefined;
|
|
103
114
|
try {
|
|
104
|
-
|
|
105
|
-
record.label = record[
|
|
106
|
-
record.value = record[
|
|
107
|
-
|
|
115
|
+
const _body = _DOMCreateElement("li");
|
|
116
|
+
record.label = record[this.labelField as string];
|
|
117
|
+
record.value = record[this.valueField as string];
|
|
118
|
+
const subcomponent = New(ClassFactory(subcomponentClass), {
|
|
108
119
|
name:"list-item",
|
|
109
120
|
data: {
|
|
110
|
-
label: record[
|
|
111
|
-
value: record[
|
|
121
|
+
label: record[this.labelField as string],
|
|
122
|
+
value: record[this.valueField as string],
|
|
112
123
|
__dataIndex: dataIndex,
|
|
113
124
|
__page: page,
|
|
114
125
|
__totalPages: pagesNumber,
|
|
@@ -116,25 +127,25 @@
|
|
|
116
127
|
__offset: offset
|
|
117
128
|
},
|
|
118
129
|
templateURI: ComponentURI({
|
|
119
|
-
"COMPONENTS_BASE_PATH": CONFIG.get("componentsBasePath"),
|
|
130
|
+
"COMPONENTS_BASE_PATH": CONFIG.get("componentsBasePath", ""),
|
|
120
131
|
"COMPONENT_NAME": ClassFactory(subcomponentClass).name,
|
|
121
|
-
"TPLEXTENSION": CONFIG.get("tplextension"),
|
|
132
|
+
"TPLEXTENSION": CONFIG.get("tplextension", ""),
|
|
122
133
|
"TPL_SOURCE": ClassFactory(subcomponentClass).tplsource
|
|
123
134
|
}),
|
|
124
135
|
body: _body,
|
|
125
136
|
template: ClassFactory(subcomponentClass).template
|
|
126
137
|
});
|
|
127
|
-
subcomponent.done =
|
|
138
|
+
subcomponent.done = this.component.done.bind(subcomponent);
|
|
128
139
|
try {
|
|
129
140
|
if (subcomponent) {
|
|
130
141
|
subcomponent.data.__dataIndex = dataIndex;
|
|
131
|
-
if (
|
|
132
|
-
subcomponent.data.__dataLength =
|
|
142
|
+
if (Object.hasOwnProperty.call(this.component.data, "length")) {
|
|
143
|
+
subcomponent.data.__dataLength = this.component.data.length;
|
|
133
144
|
}
|
|
134
145
|
logger.debug("adding subcomponent to body");
|
|
135
|
-
|
|
146
|
+
(this._componentRoot as QCObjectsElement).subelements("ul").map(ul => ul.append(subcomponent));
|
|
136
147
|
try {
|
|
137
|
-
|
|
148
|
+
this.component.subcomponents.push(subcomponent);
|
|
138
149
|
} catch (e) {
|
|
139
150
|
logger.debug("ERROR LOADING SUBCOMPONENT IN DATAGRID");
|
|
140
151
|
}
|
|
@@ -148,6 +159,7 @@
|
|
|
148
159
|
} catch (e) {
|
|
149
160
|
logger.debug("ERROR LOADING SUBCOMPONENT IN DATAGRID");
|
|
150
161
|
}
|
|
162
|
+
return _ret_;
|
|
151
163
|
}
|
|
152
164
|
);
|
|
153
165
|
} else {
|
|
@@ -160,47 +172,45 @@
|
|
|
160
172
|
}
|
|
161
173
|
|
|
162
174
|
cssGrid() {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}";
|
|
175
|
+
const component = this.component;
|
|
176
|
+
const _componentRoot = (component.shadowed) ? (component.shadowRoot) : (component.body);
|
|
177
|
+
if (typeof this.rows !== "undefined" && typeof this.cols !== "undefined") {
|
|
178
|
+
const s = _DOMCreateElement("style");
|
|
179
|
+
const templateRows = "auto ".repeat(this.rows as number);
|
|
180
|
+
const templateCols = "auto ".repeat(this.cols);
|
|
181
|
+
const className = "grid" + this.__instanceID.toString();
|
|
182
|
+
s.innerHTML = `.${className}{
|
|
183
|
+
display: grid; \
|
|
184
|
+
grid-template-rows: ${templateRows}; \
|
|
185
|
+
grid-template-columns: ${templateCols}; \
|
|
186
|
+
margin:0 auto; \
|
|
187
|
+
}`;
|
|
177
188
|
_componentRoot.append(s);
|
|
178
189
|
_componentRoot.classList.add(className);
|
|
179
190
|
}
|
|
180
191
|
}
|
|
181
192
|
|
|
182
193
|
done() {
|
|
183
|
-
|
|
184
|
-
controller.cssGrid();
|
|
194
|
+
this.cssGrid();
|
|
185
195
|
|
|
186
|
-
|
|
196
|
+
const componentInstance = this.component;
|
|
187
197
|
logger.debug("ListController DONE");
|
|
188
|
-
|
|
198
|
+
const serviceClass = this.component.body.getAttribute("serviceClass");
|
|
189
199
|
if (serviceClass != null) {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
200
|
+
let offset;
|
|
201
|
+
let limit;
|
|
202
|
+
let paginateIn = componentInstance.body.getAttribute("paginate-in");
|
|
193
203
|
paginateIn = (paginateIn !== null) ? (paginateIn) : ("client");
|
|
194
204
|
if (paginateIn === "server") {
|
|
195
|
-
|
|
205
|
+
let page = componentInstance.body.getAttribute("page-number");
|
|
196
206
|
page = (isNaN(page) || page === null) ? (-1) : (page);
|
|
197
|
-
|
|
207
|
+
let pagesNumber;
|
|
198
208
|
if (page !== -1) {
|
|
199
|
-
|
|
200
|
-
pagesNumber =
|
|
209
|
+
const serverDataCount = (this.component.body.getAttribute("server-data-count") !== null) ? (this.component.body.getAttribute("server-data-count")) : (1);
|
|
210
|
+
pagesNumber = this.component.body.getAttribute("total-pages");
|
|
201
211
|
pagesNumber = (isNaN(pagesNumber)) ? (1) : (pagesNumber);
|
|
202
|
-
offset =
|
|
203
|
-
limit =
|
|
212
|
+
offset = this.getPageIndex(page, pagesNumber, serverDataCount)[0];
|
|
213
|
+
limit = this.getPageIndex(page, pagesNumber, serverDataCount)[1];
|
|
204
214
|
// send params in jsonrpc 2.0 style
|
|
205
215
|
componentInstance.serviceData = (typeof componentInstance.serviceData !== "undefined") ? (componentInstance.serviceData) : ({});
|
|
206
216
|
componentInstance.serviceData.params = (typeof componentInstance.serviceData.params !== "undefined") ? (componentInstance.serviceData.params) : ({});
|
|
@@ -211,7 +221,7 @@
|
|
|
211
221
|
|
|
212
222
|
serviceLoader(New(ClassFactory(serviceClass), {
|
|
213
223
|
data: componentInstance.serviceData
|
|
214
|
-
})).then(
|
|
224
|
+
}), false).then(
|
|
215
225
|
(successfulResponse) => {
|
|
216
226
|
// This will show the service response as a plain text
|
|
217
227
|
logger.debug("DONE SERVICE COMPONENT");
|
|
@@ -222,7 +232,7 @@
|
|
|
222
232
|
} else {
|
|
223
233
|
componentInstance.data = successfulResponse.service.JSONresponse;
|
|
224
234
|
}
|
|
225
|
-
|
|
235
|
+
this.addSubcomponents();
|
|
226
236
|
|
|
227
237
|
},
|
|
228
238
|
(failedResponse) => {
|
|
@@ -241,4 +251,4 @@
|
|
|
241
251
|
|
|
242
252
|
]);
|
|
243
253
|
|
|
244
|
-
})
|
|
254
|
+
})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|