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