qcobjects-sdk 2.4.62 → 2.4.64
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/VERSION +1 -1
- package/build/QCObjects-SDK.js +97 -0
- package/build/css/base-modal.css +43 -0
- package/build/css/basic-layout-embedded-nav.css +14 -0
- package/build/css/basic-layout.css +76 -0
- package/build/css/components/horizontal-list.css +64 -0
- package/build/css/components/list.css +57 -0
- package/build/css/components/splashscreen.css +111 -0
- package/build/css/modal.css +46 -0
- package/build/index.cjs +4 -0
- package/build/index.js +27 -0
- package/build/index.mjs +2 -0
- package/build/js/org.qcobjects.cloud.auth.session.data.js +125 -0
- package/build/js/org.qcobjects.cloud.auth.session.usertoken.js +109 -0
- package/build/js/org.qcobjects.components.grid.js +81 -0
- package/build/js/org.qcobjects.components.js +292 -0
- package/build/js/org.qcobjects.components.list.js +71 -0
- package/build/js/org.qcobjects.components.notifications.js +179 -0
- package/build/js/org.qcobjects.components.slider.js +193 -0
- package/build/js/org.qcobjects.components.splashscreen.js +642 -0
- package/build/js/org.qcobjects.controllers.form.js +178 -0
- package/build/js/org.qcobjects.controllers.grid.js +258 -0
- package/build/js/org.qcobjects.controllers.js +34 -0
- package/build/js/org.qcobjects.controllers.list.js +228 -0
- package/build/js/org.qcobjects.controllers.slider.js +131 -0
- package/build/js/org.qcobjects.controllers.swagger.js +50 -0
- package/build/js/org.qcobjects.effects.js +417 -0
- package/build/js/org.qcobjects.i18n_messages.js +72 -0
- package/build/js/org.qcobjects.modal.controllers.js +38 -0
- package/build/js/org.qcobjects.modal.effects.js +51 -0
- package/build/js/org.qcobjects.models.js +34 -0
- package/build/js/org.qcobjects.tools.canvas.js +53 -0
- package/build/js/org.qcobjects.tools.js +64 -0
- package/build/js/org.qcobjects.tools.layouts.js +73 -0
- package/build/js/org.qcobjects.views.js +34 -0
- package/build/templates/components/modalyoulose.tpl.html +3 -0
- package/build/templates/components/modalyouwin.tpl.html +4 -0
- package/build/templates/components/splashscreen.tpl.html +128 -0
- package/build/templates/components/swagger-ui.tpl.html +22 -0
- package/package.json +1 -1
- package/public/QCObjects-SDK.js +696 -0
- package/public/QCObjects-SDK.js.map +7 -0
- package/public/css/base-modal.css +2 -0
- package/public/css/base-modal.css.map +7 -0
- package/public/css/basic-layout-embedded-nav.css +2 -0
- package/public/css/basic-layout-embedded-nav.css.map +7 -0
- package/public/css/basic-layout.css +2 -0
- package/public/css/basic-layout.css.map +7 -0
- package/public/css/components/horizontal-list.css +2 -0
- package/public/css/components/horizontal-list.css.map +7 -0
- package/public/css/components/list.css +2 -0
- package/public/css/components/list.css.map +7 -0
- package/public/css/components/splashscreen.css +2 -0
- package/public/css/components/splashscreen.css.map +7 -0
- package/public/css/modal.css +2 -0
- package/public/css/modal.css.map +7 -0
- package/public/index.cjs +4 -0
- package/public/index.js +27 -0
- package/public/index.mjs +2 -0
- package/public/templates/components/modalyoulose.tpl.html +3 -0
- package/public/templates/components/modalyouwin.tpl.html +4 -0
- package/public/templates/components/splashscreen.tpl.html +128 -0
- package/public/templates/components/swagger-ui.tpl.html +22 -0
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const qcobjects_1 = require("qcobjects");
|
|
4
|
+
const org_qcobjects_components_1 = require("./org.qcobjects.components");
|
|
5
|
+
/**
|
|
6
|
+
* QCObjects SDK 2.4
|
|
7
|
+
* ________________
|
|
8
|
+
*
|
|
9
|
+
* Author: Jean Machuca <correojean@gmail.com>
|
|
10
|
+
*
|
|
11
|
+
* Cross Browser Javascript Framework for MVC Patterns
|
|
12
|
+
* QuickCorp/QCObjects is licensed under the
|
|
13
|
+
* GNU Lesser General Public License v3.0
|
|
14
|
+
* [LICENSE] (https://github.com/QuickCorp/QCObjects/blob/master/LICENSE.txt)
|
|
15
|
+
*
|
|
16
|
+
* Permissions of this copyleft license are conditioned on making available
|
|
17
|
+
* complete source code of licensed works and modifications under the same
|
|
18
|
+
* license or the GNU GPLv3. Copyright and license notices must be preserved.
|
|
19
|
+
* Contributors provide an express grant of patent rights. However, a larger
|
|
20
|
+
* work using the licensed work through interfaces provided by the licensed
|
|
21
|
+
* work may be distributed under different terms and without source code for
|
|
22
|
+
* the larger work.
|
|
23
|
+
*
|
|
24
|
+
* Copyright (C) 2015 Jean Machuca,<correojean@gmail.com>
|
|
25
|
+
*
|
|
26
|
+
* Everyone is permitted to copy and distribute verbatim copies of this
|
|
27
|
+
* license document, but changing it is not allowed.
|
|
28
|
+
*/
|
|
29
|
+
(function () {
|
|
30
|
+
"use strict";
|
|
31
|
+
(0, qcobjects_1.Package)("org.qcobjects.controllers.form", [
|
|
32
|
+
class FormValidations extends qcobjects_1.Controller {
|
|
33
|
+
getDefault() {
|
|
34
|
+
return function (fieldName, dataValue, element) {
|
|
35
|
+
const _regex = {
|
|
36
|
+
name: "^[a-zA-Z]+(([',. -][a-zA-Z ])?[a-zA-Z]*)*$",
|
|
37
|
+
email: "^([A-Za-z0-9]+)@([A-Za-z0-9]+).([A-Za-z0-9]+)$"
|
|
38
|
+
};
|
|
39
|
+
const _pattern_ = (element.getAttribute("pattern") || _regex[fieldName]);
|
|
40
|
+
const pattern = new RegExp(_pattern_);
|
|
41
|
+
return pattern.test(dataValue);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
class FormController extends qcobjects_1.Controller {
|
|
46
|
+
hasValidation(element) {
|
|
47
|
+
const fieldName = element.getAttribute("data-field");
|
|
48
|
+
let _hasValidation = false;
|
|
49
|
+
if (typeof this.validations !== "undefined"
|
|
50
|
+
&& Object.hasOwnProperty.call(this.validations, fieldName)) {
|
|
51
|
+
_hasValidation = true;
|
|
52
|
+
}
|
|
53
|
+
return _hasValidation;
|
|
54
|
+
}
|
|
55
|
+
isInvalid(element) {
|
|
56
|
+
let _isInvalid = false;
|
|
57
|
+
const fieldName = element.getAttribute("data-field");
|
|
58
|
+
const dataValue = this.component.data[fieldName];
|
|
59
|
+
const _execValidation = (fieldName, dataValue, element) => {
|
|
60
|
+
return (typeof this.validations !== "undefined"
|
|
61
|
+
&& Object.hasOwnProperty.call(this.validations, fieldName)
|
|
62
|
+
&& this.validations[fieldName].call(null, fieldName, dataValue, element));
|
|
63
|
+
};
|
|
64
|
+
if (typeof this.validations !== "undefined" && (!_execValidation(fieldName, dataValue, element))) {
|
|
65
|
+
_isInvalid = true;
|
|
66
|
+
}
|
|
67
|
+
return _isInvalid;
|
|
68
|
+
}
|
|
69
|
+
isValid(element) {
|
|
70
|
+
return !this.isInvalid(element);
|
|
71
|
+
}
|
|
72
|
+
save() {
|
|
73
|
+
if (this.serviceClass !== "") {
|
|
74
|
+
location.href = this.formSettings.loadingRouting;
|
|
75
|
+
(0, qcobjects_1.serviceLoader)((0, qcobjects_1.New)((0, qcobjects_1.ClassFactory)(this.serviceClass), {
|
|
76
|
+
data: this.component.data
|
|
77
|
+
}), false).then((successfulResponse) => {
|
|
78
|
+
// This will show the service response as a plain text
|
|
79
|
+
console.log("DONE SERVICE COMPONENT");
|
|
80
|
+
try {
|
|
81
|
+
console.log(successfulResponse.service.JSONresponse);
|
|
82
|
+
}
|
|
83
|
+
catch (e) {
|
|
84
|
+
// no json
|
|
85
|
+
}
|
|
86
|
+
location.href = this.formSettings.nextRouting;
|
|
87
|
+
}, (failedResponse) => {
|
|
88
|
+
qcobjects_1.logger.debug(failedResponse);
|
|
89
|
+
location.href = this.formSettings.backRouting;
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
qcobjects_1.logger.debug("No service name declared on serviceClass property");
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
formSaveTouchHandler() {
|
|
97
|
+
qcobjects_1.logger.debug("Saving data...");
|
|
98
|
+
const _componentRoot_ = (this.component.shadowed) ? ((this.component?.shadowRoot).host) : (this.component.body);
|
|
99
|
+
this.component.executeBindings();
|
|
100
|
+
if (this.formValidatorModal != null) {
|
|
101
|
+
const componentElementFields = _componentRoot_.subelements("*[data-field]");
|
|
102
|
+
const fieldsToValidate = componentElementFields.filter(f => this.hasValidation(f));
|
|
103
|
+
const _labelledby = function (parentElement, element) {
|
|
104
|
+
const _arialabelledby = (parentElement, element) => {
|
|
105
|
+
return (element.getAttribute("aria-labelledby") !== null) ? ((element.getAttribute("aria-labelledby") || "").split(" ").map(e => parentElement.subelements(`#${e}`).map(_e => _e.innerHTML)).join(" ")) : (null);
|
|
106
|
+
};
|
|
107
|
+
return (_arialabelledby(parentElement, element)
|
|
108
|
+
|| element.getAttribute("aria-label")
|
|
109
|
+
|| element.getAttribute("placeholder")
|
|
110
|
+
|| element.getAttribute("name")
|
|
111
|
+
|| element.getAttribute("data-field"));
|
|
112
|
+
};
|
|
113
|
+
const _ariatitle = function (element) {
|
|
114
|
+
return (element.getAttribute("title") || element.getAttribute("aria-title") || "");
|
|
115
|
+
};
|
|
116
|
+
const invalidFields = fieldsToValidate.filter(f => this.isInvalid(f));
|
|
117
|
+
if (invalidFields.length > 0) {
|
|
118
|
+
const validationMessage = `
|
|
119
|
+
<details>
|
|
120
|
+
<summary>Please verify the following incorrect fields:</summary>
|
|
121
|
+
<ul>
|
|
122
|
+
<div>
|
|
123
|
+
${invalidFields.map(element => "<li><div>" + _labelledby(_componentRoot_, element) + "</div><div>" + _ariatitle(element) + "</div></li>").join("")}
|
|
124
|
+
</div>
|
|
125
|
+
</ul>
|
|
126
|
+
</details>
|
|
127
|
+
`;
|
|
128
|
+
this.formValidatorModal.body.subelements(".validationMessage")[0].innerHTML = validationMessage;
|
|
129
|
+
this.formValidatorModal.modal();
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
this.save();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
qcobjects_1.logger.debug("Unable to find the modal validator...");
|
|
137
|
+
qcobjects_1.logger.debug("Saving data...");
|
|
138
|
+
this.save();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
constructor(o) {
|
|
142
|
+
super(o);
|
|
143
|
+
this.validations = [];
|
|
144
|
+
this.serviceClass = "";
|
|
145
|
+
this.formSettings = {
|
|
146
|
+
backRouting: "#",
|
|
147
|
+
loadingRouting: "#loading",
|
|
148
|
+
nextRouting: "#signupsuccessful"
|
|
149
|
+
};
|
|
150
|
+
this.component = o.component;
|
|
151
|
+
this.component = this.component.Cast(org_qcobjects_components_1.FormField);
|
|
152
|
+
}
|
|
153
|
+
done() {
|
|
154
|
+
qcobjects_1.logger.debugEnabled = true;
|
|
155
|
+
try {
|
|
156
|
+
this.component.createBindingEvents();
|
|
157
|
+
const modalBody = (0, qcobjects_1._DOMCreateElement)("div");
|
|
158
|
+
modalBody.className = "modal_body";
|
|
159
|
+
this.formValidatorModal = (0, qcobjects_1.New)(org_qcobjects_components_1.ModalComponent, {
|
|
160
|
+
body: modalBody,
|
|
161
|
+
subcomponents: [],
|
|
162
|
+
data: {
|
|
163
|
+
content: "<div class=\"validationMessage\"></div>"
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
(0, qcobjects_1.Tag)(".modal_body").map(e => document.body.removeChild(e));
|
|
167
|
+
document.body.append(this.formValidatorModal);
|
|
168
|
+
}
|
|
169
|
+
catch (e) {
|
|
170
|
+
qcobjects_1.logger.debug("Unable to create the modal");
|
|
171
|
+
}
|
|
172
|
+
this.onpress(".submit", () => {
|
|
173
|
+
this.formSaveTouchHandler();
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
]);
|
|
178
|
+
})();
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const qcobjects_1 = require("qcobjects");
|
|
4
|
+
/**
|
|
5
|
+
* QCObjects SDK 2.4
|
|
6
|
+
* ________________
|
|
7
|
+
*
|
|
8
|
+
* Author: Jean Machuca <correojean@gmail.com>
|
|
9
|
+
*
|
|
10
|
+
* Cross Browser Javascript Framework for MVC Patterns
|
|
11
|
+
* QuickCorp/QCObjects is licensed under the
|
|
12
|
+
* GNU Lesser General Public License v3.0
|
|
13
|
+
* [LICENSE] (https://github.com/QuickCorp/QCObjects/blob/master/LICENSE.txt)
|
|
14
|
+
*
|
|
15
|
+
* Permissions of this copyleft license are conditioned on making available
|
|
16
|
+
* complete source code of licensed works and modifications under the same
|
|
17
|
+
* license or the GNU GPLv3. Copyright and license notices must be preserved.
|
|
18
|
+
* Contributors provide an express grant of patent rights. However, a larger
|
|
19
|
+
* work using the licensed work through interfaces provided by the licensed
|
|
20
|
+
* work may be distributed under different terms and without source code for
|
|
21
|
+
* the larger work.
|
|
22
|
+
*
|
|
23
|
+
* Copyright (C) 2015 Jean Machuca,<correojean@gmail.com>
|
|
24
|
+
*
|
|
25
|
+
* Everyone is permitted to copy and distribute verbatim copies of this
|
|
26
|
+
* license document, but changing it is not allowed.
|
|
27
|
+
*/
|
|
28
|
+
(function () {
|
|
29
|
+
"use strict";
|
|
30
|
+
(0, qcobjects_1.Package)("org.qcobjects.controllers.grid", [
|
|
31
|
+
class GridController extends qcobjects_1.Controller {
|
|
32
|
+
constructor(controller) {
|
|
33
|
+
super(controller);
|
|
34
|
+
this.rows = this.component.body.getAttribute("rows");
|
|
35
|
+
this.rows = (this.rows !== null) ? (this.rows) : (this.component.rows);
|
|
36
|
+
this.cols = this.component.body.getAttribute("cols");
|
|
37
|
+
this.cols = (this.cols !== null) ? (this.cols) : (this.component.cols);
|
|
38
|
+
}
|
|
39
|
+
cssGrid() {
|
|
40
|
+
const component = this.component;
|
|
41
|
+
const _componentRoot = (component.shadowed) ? (component.shadowRoot) : (component.body);
|
|
42
|
+
if (typeof this.rows !== "undefined" && typeof this.cols !== "undefined") {
|
|
43
|
+
const s = (0, qcobjects_1._DOMCreateElement)("style");
|
|
44
|
+
const templateRows = "auto ".repeat(this.rows);
|
|
45
|
+
const templateCols = "auto ".repeat(this.cols);
|
|
46
|
+
const className = "grid" + this.__instanceID.toString();
|
|
47
|
+
s.innerHTML = `.${className}{
|
|
48
|
+
display: grid; \
|
|
49
|
+
grid-template-rows: ${templateRows}; \
|
|
50
|
+
grid-template-columns: ${templateCols}; \
|
|
51
|
+
margin:0 auto; \
|
|
52
|
+
}`;
|
|
53
|
+
_componentRoot?.append(s);
|
|
54
|
+
if (component.shadowed) {
|
|
55
|
+
_componentRoot?.host.classList.add(className);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
(_componentRoot.classList).add(className);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
done() {
|
|
63
|
+
this.cssGrid();
|
|
64
|
+
qcobjects_1.logger.debug("GridComponent built");
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
class DataGridController extends qcobjects_1.Controller {
|
|
68
|
+
constructor(controller) {
|
|
69
|
+
super(controller);
|
|
70
|
+
this._componentRoot = (controller.component.shadowed) ? (controller.component.shadowRoot) : (controller.component.body);
|
|
71
|
+
this.rows = controller.component.body.getAttribute("rows");
|
|
72
|
+
this.rows = (controller.rows !== null) ? (controller.rows) : (controller.component.rows);
|
|
73
|
+
this.cols = controller.component.body.getAttribute("cols");
|
|
74
|
+
this.cols = (controller.cols !== null) ? (controller.cols) : (controller.component.cols);
|
|
75
|
+
qcobjects_1.logger.debug("DataGridController INIT");
|
|
76
|
+
}
|
|
77
|
+
getPageIndex(page, totalPage, totalElements) {
|
|
78
|
+
page = (page > 0) ? (page - 1) : (0);
|
|
79
|
+
return [totalElements * page / totalPage, (totalElements * page / totalPage) + totalElements / totalPage];
|
|
80
|
+
}
|
|
81
|
+
addSubcomponents() {
|
|
82
|
+
this.component.subcomponents = [];
|
|
83
|
+
if (typeof this._componentRoot !== "undefined") {
|
|
84
|
+
this._componentRoot.innerHTML = "";
|
|
85
|
+
}
|
|
86
|
+
this.cssGrid();
|
|
87
|
+
qcobjects_1.logger.debug((0, qcobjects_1._DataStringify)(this.component.data));
|
|
88
|
+
try {
|
|
89
|
+
const subcomponentClass = this.component.body.getAttribute("subcomponentClass");
|
|
90
|
+
if (subcomponentClass != null) {
|
|
91
|
+
let offset;
|
|
92
|
+
let limit;
|
|
93
|
+
let pagesNumber;
|
|
94
|
+
let list = [...this.component.data];
|
|
95
|
+
let paginateIn = this.component.body.getAttribute("paginate-in");
|
|
96
|
+
let page;
|
|
97
|
+
paginateIn = (paginateIn !== null) ? (paginateIn) : ("client");
|
|
98
|
+
if (paginateIn === "client") {
|
|
99
|
+
page = this.component.body.getAttribute("page-number");
|
|
100
|
+
page = (isNaN(page) || page === null) ? (-1) : (page);
|
|
101
|
+
if (page !== -1) {
|
|
102
|
+
pagesNumber = this.component.body.getAttribute("total-pages");
|
|
103
|
+
pagesNumber = (isNaN(pagesNumber)) ? (1) : (pagesNumber);
|
|
104
|
+
offset = this.getPageIndex(page, pagesNumber, list.length)[0];
|
|
105
|
+
limit = this.getPageIndex(page, pagesNumber, list.length)[1];
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
offset = 0;
|
|
109
|
+
limit = list.length;
|
|
110
|
+
pagesNumber = 1;
|
|
111
|
+
}
|
|
112
|
+
list = list.slice(offset, limit);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
offset = 0;
|
|
116
|
+
limit = list.length;
|
|
117
|
+
pagesNumber = 1;
|
|
118
|
+
}
|
|
119
|
+
list.map((record, dataIndex, list) => {
|
|
120
|
+
const _ret_ = undefined;
|
|
121
|
+
try {
|
|
122
|
+
const _body = (0, qcobjects_1._DOMCreateElement)("component");
|
|
123
|
+
_body.setAttribute("name", (0, qcobjects_1.ClassFactory)(subcomponentClass).name);
|
|
124
|
+
_body.setAttribute("shadowed", (0, qcobjects_1.ClassFactory)(subcomponentClass).shadowed);
|
|
125
|
+
_body.setAttribute("cached", (0, qcobjects_1.ClassFactory)(subcomponentClass).cached);
|
|
126
|
+
record = Object.assign(record, {
|
|
127
|
+
__dataIndex: dataIndex,
|
|
128
|
+
__dataLength: list.length,
|
|
129
|
+
__page: page,
|
|
130
|
+
__totalPages: pagesNumber,
|
|
131
|
+
__limit: limit,
|
|
132
|
+
__offset: offset
|
|
133
|
+
});
|
|
134
|
+
const subcomponent = (0, qcobjects_1.New)((0, qcobjects_1.ClassFactory)(subcomponentClass), {
|
|
135
|
+
name: "item",
|
|
136
|
+
data: record,
|
|
137
|
+
templateURI: (0, qcobjects_1.ComponentURI)({
|
|
138
|
+
"COMPONENTS_BASE_PATH": qcobjects_1.CONFIG.get("componentsBasePath", ""),
|
|
139
|
+
"COMPONENT_NAME": (0, qcobjects_1.ClassFactory)(subcomponentClass).name,
|
|
140
|
+
"TPLEXTENSION": qcobjects_1.CONFIG.get("tplextension", ""),
|
|
141
|
+
"TPL_SOURCE": (0, qcobjects_1.ClassFactory)(subcomponentClass).tplsource
|
|
142
|
+
}),
|
|
143
|
+
body: _body,
|
|
144
|
+
template: (0, qcobjects_1.ClassFactory)(subcomponentClass).template
|
|
145
|
+
});
|
|
146
|
+
subcomponent.done = this.component.done.bind(subcomponent);
|
|
147
|
+
try {
|
|
148
|
+
if (subcomponent) {
|
|
149
|
+
subcomponent.data.__dataIndex = dataIndex;
|
|
150
|
+
if (Object.hasOwnProperty.call(this.component.data, "length")) {
|
|
151
|
+
subcomponent.data.__dataLength = this.component.data.length;
|
|
152
|
+
}
|
|
153
|
+
qcobjects_1.logger.debug("adding subcomponent to body");
|
|
154
|
+
this._componentRoot?.append(subcomponent.body);
|
|
155
|
+
try {
|
|
156
|
+
this.component.subcomponents.push(subcomponent);
|
|
157
|
+
}
|
|
158
|
+
catch (e) {
|
|
159
|
+
qcobjects_1.logger.debug("ERROR LOADING SUBCOMPONENT IN DATAGRID");
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
qcobjects_1.logger.debug("ERROR LOADING SUBCOMPONENT IN DATAGRID");
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
catch (e) {
|
|
167
|
+
qcobjects_1.logger.debug("ERROR LOADING SUBCOMPONENT IN DATAGRID");
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
catch (e) {
|
|
171
|
+
qcobjects_1.logger.debug("ERROR LOADING SUBCOMPONENT IN DATAGRID");
|
|
172
|
+
}
|
|
173
|
+
return _ret_;
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
qcobjects_1.logger.debug("NO SUBCOMPONENT CLASS IN COMPONENT");
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
catch (e) {
|
|
181
|
+
qcobjects_1.logger.debug("No data for component");
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
cssGrid() {
|
|
185
|
+
const component = this.component;
|
|
186
|
+
const _componentRoot = (component.shadowed) ? (component.shadowRoot) : (component.body);
|
|
187
|
+
if (typeof this.rows !== "undefined" && typeof this.cols !== "undefined") {
|
|
188
|
+
const s = (0, qcobjects_1._DOMCreateElement)("style");
|
|
189
|
+
const templateRows = "auto ".repeat(this.rows);
|
|
190
|
+
const templateCols = "auto ".repeat(this.cols);
|
|
191
|
+
const className = "grid" + this.__instanceID.toString();
|
|
192
|
+
s.innerHTML = `.${className}{
|
|
193
|
+
display: grid; \
|
|
194
|
+
grid-template-rows: ${templateRows}; \
|
|
195
|
+
grid-template-columns: ${templateCols}; \
|
|
196
|
+
margin:0 auto; \
|
|
197
|
+
}`;
|
|
198
|
+
if (component.shadowed) {
|
|
199
|
+
component.body.append(s);
|
|
200
|
+
_componentRoot.host.classList.add(className);
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
_componentRoot?.append(s);
|
|
204
|
+
_componentRoot.classList.add(className);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
done() {
|
|
209
|
+
const componentInstance = this.component;
|
|
210
|
+
qcobjects_1.logger.debug("DataGridController DONE");
|
|
211
|
+
const serviceClass = this.component.body.getAttribute("serviceClass");
|
|
212
|
+
if (serviceClass != null) {
|
|
213
|
+
let offset;
|
|
214
|
+
let limit;
|
|
215
|
+
let paginateIn = componentInstance.body.getAttribute("paginate-in");
|
|
216
|
+
paginateIn = (paginateIn !== null) ? (paginateIn) : ("client");
|
|
217
|
+
if (paginateIn === "server") {
|
|
218
|
+
let page = componentInstance.body.getAttribute("page-number");
|
|
219
|
+
page = (isNaN(page) || page === null) ? (-1) : (page);
|
|
220
|
+
let pagesNumber;
|
|
221
|
+
if (page !== -1) {
|
|
222
|
+
const serverDataCount = (this.component.body.getAttribute("server-data-count") !== null) ? this.component.body.getAttribute("server-data-count") : (1);
|
|
223
|
+
pagesNumber = this.component.body.getAttribute("total-pages");
|
|
224
|
+
pagesNumber = (isNaN(pagesNumber)) ? (1) : (pagesNumber);
|
|
225
|
+
offset = this.getPageIndex(page, pagesNumber, serverDataCount)[0];
|
|
226
|
+
limit = this.getPageIndex(page, pagesNumber, serverDataCount)[1];
|
|
227
|
+
// send params in jsonrpc 2.0 style
|
|
228
|
+
componentInstance.serviceData = (typeof componentInstance.serviceData !== "undefined") ? (componentInstance.serviceData) : ({});
|
|
229
|
+
componentInstance.serviceData.params = (typeof componentInstance.serviceData.params !== "undefined") ? (componentInstance.serviceData.params) : ({});
|
|
230
|
+
componentInstance.serviceData.params.offset = offset;
|
|
231
|
+
componentInstance.serviceData.params.limit = limit;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
(0, qcobjects_1.serviceLoader)((0, qcobjects_1.New)((0, qcobjects_1.ClassFactory)(serviceClass), {
|
|
235
|
+
data: componentInstance.serviceData
|
|
236
|
+
}), false).then((successfulResponse) => {
|
|
237
|
+
// This will show the service response as a plain text
|
|
238
|
+
qcobjects_1.logger.debug("DONE SERVICE COMPONENT");
|
|
239
|
+
successfulResponse.service.JSONresponse = JSON.parse(successfulResponse.service.template);
|
|
240
|
+
if (typeof successfulResponse.service.JSONresponse.result !== "undefined") {
|
|
241
|
+
qcobjects_1.logger.debug((0, qcobjects_1._DataStringify)(successfulResponse.service.JSONresponse.result));
|
|
242
|
+
componentInstance.data = successfulResponse.service.JSONresponse.result;
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
componentInstance.data = successfulResponse.service.JSONresponse;
|
|
246
|
+
}
|
|
247
|
+
this.addSubcomponents();
|
|
248
|
+
}, (failedResponse) => {
|
|
249
|
+
qcobjects_1.logger.debug(failedResponse);
|
|
250
|
+
}).catch((e) => {
|
|
251
|
+
qcobjects_1.logger.debug("Something went wrong when calling the service from: " + serviceClass);
|
|
252
|
+
qcobjects_1.logger.debug(e.message);
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
]);
|
|
258
|
+
})();
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const qcobjects_1 = require("qcobjects");
|
|
4
|
+
/**
|
|
5
|
+
* QCObjects SDK 2.4
|
|
6
|
+
* ________________
|
|
7
|
+
*
|
|
8
|
+
* Author: Jean Machuca <correojean@gmail.com>
|
|
9
|
+
*
|
|
10
|
+
* Cross Browser Javascript Framework for MVC Patterns
|
|
11
|
+
* QuickCorp/QCObjects is licensed under the
|
|
12
|
+
* GNU Lesser General Public License v3.0
|
|
13
|
+
* [LICENSE] (https://github.com/QuickCorp/QCObjects/blob/master/LICENSE.txt)
|
|
14
|
+
*
|
|
15
|
+
* Permissions of this copyleft license are conditioned on making available
|
|
16
|
+
* complete source code of licensed works and modifications under the same
|
|
17
|
+
* license or the GNU GPLv3. Copyright and license notices must be preserved.
|
|
18
|
+
* Contributors provide an express grant of patent rights. However, a larger
|
|
19
|
+
* work using the licensed work through interfaces provided by the licensed
|
|
20
|
+
* work may be distributed under different terms and without source code for
|
|
21
|
+
* the larger work.
|
|
22
|
+
*
|
|
23
|
+
* Copyright (C) 2015 Jean Machuca,<correojean@gmail.com>
|
|
24
|
+
*
|
|
25
|
+
* Everyone is permitted to copy and distribute verbatim copies of this
|
|
26
|
+
* license document, but changing it is not allowed.
|
|
27
|
+
*/
|
|
28
|
+
(function () {
|
|
29
|
+
"use strict";
|
|
30
|
+
(0, qcobjects_1.Package)("org.qcobjects.controllers", [
|
|
31
|
+
class GenericController extends qcobjects_1.Controller {
|
|
32
|
+
}
|
|
33
|
+
]);
|
|
34
|
+
})();
|