qcobjects-sdk 2.4.66 → 2.5.105
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/.github/workflows/npmpublish.yml +47 -0
- package/README.md +0 -1
- package/VERSION +1 -1
- package/build/index.js +137 -25
- package/build/ts/org.qcobjects.base.components.js +75 -0
- package/build/ts/org.qcobjects.cloud.auth.session.data.js +122 -0
- package/build/ts/org.qcobjects.cloud.auth.session.usertoken.js +97 -0
- package/build/ts/org.qcobjects.components.grid.js +63 -0
- package/build/ts/org.qcobjects.components.js +200 -0
- package/build/{js/org.qcobjects.modal.effects.js → ts/org.qcobjects.components.list.js} +40 -29
- package/build/ts/org.qcobjects.components.notifications.js +180 -0
- package/build/ts/org.qcobjects.components.slider.js +207 -0
- package/build/{js → ts}/org.qcobjects.components.splashscreen.js +123 -130
- package/build/ts/org.qcobjects.controllers.form.js +180 -0
- package/build/ts/org.qcobjects.controllers.grid.js +269 -0
- package/build/{js → ts}/org.qcobjects.controllers.js +11 -11
- package/build/ts/org.qcobjects.controllers.list.js +235 -0
- package/build/ts/org.qcobjects.controllers.slider.js +126 -0
- package/build/ts/org.qcobjects.controllers.swagger.js +75 -0
- package/build/ts/org.qcobjects.effects.base.js +70 -0
- package/build/ts/org.qcobjects.effects.extended.js +270 -0
- package/build/ts/org.qcobjects.effects.js +49 -0
- package/build/ts/org.qcobjects.i18n_messages.js +59 -0
- package/build/{js → ts}/org.qcobjects.modal.controllers.js +16 -15
- package/build/ts/org.qcobjects.modal.effects.js +46 -0
- package/build/{js → ts}/org.qcobjects.models.js +11 -11
- package/{src/js/org.qcobjects.tools.canvas.ts → build/ts/org.qcobjects.tools.canvas.js} +16 -21
- package/build/{js → ts}/org.qcobjects.tools.js +10 -3
- package/build/ts/org.qcobjects.tools.layouts.js +74 -0
- package/build/{js → ts}/org.qcobjects.views.js +11 -11
- package/build-esbuild.js +72 -0
- package/eslint.config.mjs +88 -0
- package/package.json +67 -63
- package/postbuild.js +10 -0
- package/public/browser/index.js +9829 -0
- package/public/browser/index.js.map +7 -0
- package/public/cjs/index.cjs +9879 -0
- package/public/cjs/index.cjs.map +7 -0
- package/public/esm/index.mjs +9819 -0
- package/public/esm/index.mjs.map +7 -0
- package/public/types/index.d.ts +614 -0
- package/spec/helpers/mock-sdk.helper.ts +2 -0
- package/spec/mocks/qcobjects-sdk.mock.ts +1 -0
- package/spec/support/jasmine.json +7 -4
- package/src/index.ts +127 -2
- package/src/ts/org.qcobjects.base.components.ts +83 -0
- package/src/ts/org.qcobjects.cloud.auth.session.data.ts +134 -0
- package/src/ts/org.qcobjects.cloud.auth.session.usertoken.ts +108 -0
- package/src/ts/org.qcobjects.components.grid.ts +68 -0
- package/src/{js → ts}/org.qcobjects.components.list.ts +15 -31
- package/src/{js → ts}/org.qcobjects.components.notifications.ts +12 -12
- package/src/ts/org.qcobjects.components.slider.ts +216 -0
- package/src/{js → ts}/org.qcobjects.components.splashscreen.ts +31 -39
- package/src/ts/org.qcobjects.components.ts +226 -0
- package/src/ts/org.qcobjects.controllers.form.ts +209 -0
- package/src/ts/org.qcobjects.controllers.grid.ts +291 -0
- package/src/ts/org.qcobjects.controllers.list.ts +256 -0
- package/src/ts/org.qcobjects.controllers.slider.ts +153 -0
- package/src/ts/org.qcobjects.controllers.swagger.ts +83 -0
- package/src/{js → ts}/org.qcobjects.controllers.ts +7 -9
- package/src/ts/org.qcobjects.effects.base.ts +81 -0
- package/src/{js/org.qcobjects.effects.ts → ts/org.qcobjects.effects.extended.ts} +70 -198
- package/src/ts/org.qcobjects.effects.ts +42 -0
- package/src/ts/org.qcobjects.i18n_messages.ts +68 -0
- package/src/{js → ts}/org.qcobjects.modal.controllers.ts +12 -14
- package/src/{js → ts}/org.qcobjects.modal.effects.ts +22 -18
- package/src/{js → ts}/org.qcobjects.models.ts +8 -11
- package/src/ts/org.qcobjects.tools.canvas.ts +57 -0
- package/src/ts/org.qcobjects.tools.layouts.ts +82 -0
- package/src/{js → ts}/org.qcobjects.tools.ts +7 -1
- package/src/{js → ts}/org.qcobjects.views.ts +9 -8
- package/src/types/global/index.d.ts +181 -0
- package/transpile.js +65 -0
- package/tsconfig.d.json +65 -3
- package/tsconfig.jasmine.json +64 -0
- package/tsconfig.json +71 -7
- package/.eslintignore +0 -4
- package/.eslintrc.cjs +0 -6
- package/.github/workflows/npmpublish-beta.yml +0 -38
- package/.github/workflows/npmpublish-lts.yml +0 -38
- package/.github/workflows/npmpublish-main.yml +0 -40
- package/.gitmodules +0 -4
- package/build/QCObjects-SDK.js +0 -97
- package/build/css/base-modal.css +0 -43
- package/build/css/basic-layout-embedded-nav.css +0 -14
- package/build/css/basic-layout.css +0 -76
- package/build/css/components/horizontal-list.css +0 -64
- package/build/css/components/list.css +0 -57
- package/build/css/components/splashscreen.css +0 -111
- package/build/css/modal.css +0 -46
- package/build/index.cjs +0 -4
- package/build/index.mjs +0 -2
- package/build/js/org.qcobjects.cloud.auth.session.data.js +0 -125
- package/build/js/org.qcobjects.cloud.auth.session.usertoken.js +0 -109
- package/build/js/org.qcobjects.components.grid.js +0 -81
- package/build/js/org.qcobjects.components.js +0 -292
- package/build/js/org.qcobjects.components.list.js +0 -71
- package/build/js/org.qcobjects.components.notifications.js +0 -179
- package/build/js/org.qcobjects.components.slider.js +0 -193
- package/build/js/org.qcobjects.controllers.form.js +0 -178
- package/build/js/org.qcobjects.controllers.grid.js +0 -258
- package/build/js/org.qcobjects.controllers.list.js +0 -228
- package/build/js/org.qcobjects.controllers.slider.js +0 -131
- package/build/js/org.qcobjects.controllers.swagger.js +0 -50
- package/build/js/org.qcobjects.effects.js +0 -417
- package/build/js/org.qcobjects.i18n_messages.js +0 -72
- package/build/js/org.qcobjects.tools.canvas.js +0 -53
- package/build/js/org.qcobjects.tools.layouts.js +0 -73
- package/build/templates/components/modalyoulose.tpl.html +0 -3
- package/build/templates/components/modalyouwin.tpl.html +0 -4
- package/build/templates/components/splashscreen.tpl.html +0 -128
- package/build/templates/components/swagger-ui.tpl.html +0 -22
- package/docs/CNAME +0 -1
- package/public/QCObjects-SDK.js +0 -696
- package/public/QCObjects-SDK.js.map +0 -7
- package/public/css/base-modal.css +0 -2
- package/public/css/base-modal.css.map +0 -7
- package/public/css/basic-layout-embedded-nav.css +0 -2
- package/public/css/basic-layout-embedded-nav.css.map +0 -7
- package/public/css/basic-layout.css +0 -2
- package/public/css/basic-layout.css.map +0 -7
- package/public/css/components/horizontal-list.css +0 -2
- package/public/css/components/horizontal-list.css.map +0 -7
- package/public/css/components/list.css +0 -2
- package/public/css/components/list.css.map +0 -7
- package/public/css/components/splashscreen.css +0 -2
- package/public/css/components/splashscreen.css.map +0 -7
- package/public/css/modal.css +0 -2
- package/public/css/modal.css.map +0 -7
- package/public/index.cjs +0 -4
- package/public/index.js +0 -27
- package/public/index.mjs +0 -2
- package/public/templates/components/modalyoulose.tpl.html +0 -3
- package/public/templates/components/modalyouwin.tpl.html +0 -4
- package/public/templates/components/splashscreen.tpl.html +0 -128
- package/public/templates/components/swagger-ui.tpl.html +0 -22
- package/src/QCObjects-SDK.d.ts +0 -26
- package/src/QCObjects-SDK.ts +0 -108
- package/src/index.cts +0 -2
- package/src/index.d.ts +0 -2
- package/src/index.mts +0 -2
- package/src/js/org.qcobjects.cloud.auth.session.data.d.ts +0 -1
- package/src/js/org.qcobjects.cloud.auth.session.data.ts +0 -135
- package/src/js/org.qcobjects.cloud.auth.session.usertoken.d.ts +0 -2
- package/src/js/org.qcobjects.cloud.auth.session.usertoken.ts +0 -128
- package/src/js/org.qcobjects.components.d.ts +0 -10
- package/src/js/org.qcobjects.components.grid.d.ts +0 -3
- package/src/js/org.qcobjects.components.grid.ts +0 -95
- package/src/js/org.qcobjects.components.list.d.ts +0 -3
- package/src/js/org.qcobjects.components.notifications.d.ts +0 -1
- package/src/js/org.qcobjects.components.slider.d.ts +0 -1
- package/src/js/org.qcobjects.components.slider.ts +0 -205
- package/src/js/org.qcobjects.components.splashscreen.d.ts +0 -28
- package/src/js/org.qcobjects.components.ts +0 -336
- package/src/js/org.qcobjects.controllers.d.ts +0 -1
- package/src/js/org.qcobjects.controllers.form.d.ts +0 -1
- package/src/js/org.qcobjects.controllers.form.ts +0 -206
- package/src/js/org.qcobjects.controllers.grid.d.ts +0 -1
- package/src/js/org.qcobjects.controllers.grid.ts +0 -287
- package/src/js/org.qcobjects.controllers.list.d.ts +0 -1
- package/src/js/org.qcobjects.controllers.list.ts +0 -254
- package/src/js/org.qcobjects.controllers.slider.d.ts +0 -1
- package/src/js/org.qcobjects.controllers.slider.ts +0 -158
- package/src/js/org.qcobjects.controllers.swagger.d.ts +0 -1
- package/src/js/org.qcobjects.controllers.swagger.ts +0 -83
- package/src/js/org.qcobjects.effects.d.ts +0 -20
- package/src/js/org.qcobjects.i18n_messages.d.ts +0 -1
- package/src/js/org.qcobjects.i18n_messages.ts +0 -82
- package/src/js/org.qcobjects.modal.controllers.d.ts +0 -1
- package/src/js/org.qcobjects.modal.effects.d.ts +0 -1
- package/src/js/org.qcobjects.models.d.ts +0 -1
- package/src/js/org.qcobjects.tools.canvas.d.ts +0 -1
- package/src/js/org.qcobjects.tools.d.ts +0 -1
- package/src/js/org.qcobjects.tools.layouts.d.ts +0 -1
- package/src/js/org.qcobjects.tools.layouts.ts +0 -85
- package/src/js/org.qcobjects.views.d.ts +0 -1
- /package/spec/{testsSpec.js → testsSpec.ts} +0 -0
|
@@ -1,336 +0,0 @@
|
|
|
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
|
-
"use strict";
|
|
26
|
-
|
|
27
|
-
import { Package, Component, logger, _DOMCreateElement, CONFIG, New, ClassFactory, Tag, ComponentURI, QCObjectsElement, ComponentDoneResponse, ComponentParams } from "qcobjects";
|
|
28
|
-
import { ModalFade, ModalMoveDown, ModalMoveUp } from "./org.qcobjects.effects";
|
|
29
|
-
const _top:any = (typeof module === "object" && typeof module.exports === "object") ? (
|
|
30
|
-
module.exports = (typeof globalThis !== "undefined"
|
|
31
|
-
? globalThis
|
|
32
|
-
: typeof self !== "undefined"
|
|
33
|
-
? self
|
|
34
|
-
: typeof window !== "undefined"
|
|
35
|
-
? window
|
|
36
|
-
: typeof global !== "undefined"
|
|
37
|
-
? global
|
|
38
|
-
: {})
|
|
39
|
-
) : ((typeof global === "object") ? (global) : (
|
|
40
|
-
(typeof window === "object") ? (window) : ({})
|
|
41
|
-
));
|
|
42
|
-
(function (global:any) {
|
|
43
|
-
|
|
44
|
-
type FieldComponentParams = ComponentParams & {
|
|
45
|
-
basePath?:string;
|
|
46
|
-
fieldType:string;
|
|
47
|
-
}
|
|
48
|
-
class FormField extends Component {
|
|
49
|
-
fieldType!:string;
|
|
50
|
-
cached = false;
|
|
51
|
-
reload = true;
|
|
52
|
-
constructor (o:FieldComponentParams){
|
|
53
|
-
o.name = (typeof o.name !== "undefined")?(o.name):("form-field");
|
|
54
|
-
super(o);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
createBindingEvents() {
|
|
58
|
-
let _objList;
|
|
59
|
-
if (typeof this.fieldType === "undefined" || this.fieldType == null) {
|
|
60
|
-
_objList = (this.body as QCObjectsElement).subelements("*[data-field]"); // every child with data-field set
|
|
61
|
-
} else {
|
|
62
|
-
_objList = (this.body as QCObjectsElement).subelements(this.fieldType + "[data-field]"); // every child with data-field set and tagname is equal to fieldType property
|
|
63
|
-
}
|
|
64
|
-
for (let _datak = 0; _datak < _objList.length; _datak++) {
|
|
65
|
-
const _obj = _objList[_datak];
|
|
66
|
-
_obj.addEventListener("change", () => {
|
|
67
|
-
logger.debug("Executing change event binding");
|
|
68
|
-
this.executeBindings();
|
|
69
|
-
});
|
|
70
|
-
_obj.addEventListener("blur", () => {
|
|
71
|
-
logger.debug("Executing change event binding");
|
|
72
|
-
this.executeBindings();
|
|
73
|
-
});
|
|
74
|
-
_obj.addEventListener("focus", () => {
|
|
75
|
-
logger.debug("Executing change event binding");
|
|
76
|
-
this.executeBindings();
|
|
77
|
-
});
|
|
78
|
-
_obj.addEventListener("keydown", () =>{
|
|
79
|
-
logger.debug("Executing keydown event binding");
|
|
80
|
-
this.executeBindings();
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
executeBinding(_obj:HTMLElement & {value:any}) {
|
|
86
|
-
const _datamodel = _obj.getAttribute("data-field");
|
|
87
|
-
logger.debug("Binding " + _datamodel + " for " + this.name);
|
|
88
|
-
this.data[_datamodel as keyof typeof this.data] = _obj.value;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
executeBindings() {
|
|
92
|
-
let _objList;
|
|
93
|
-
if (typeof this.fieldType === "undefined" || this.fieldType == null) {
|
|
94
|
-
_objList = (this.body as QCObjectsElement).subelements("*[data-field]"); // every child with data-field set
|
|
95
|
-
} else {
|
|
96
|
-
_objList = (this.body as QCObjectsElement).subelements(this.fieldType + "[data-field]"); // every child with data-field set and tagname is equal to fieldType property
|
|
97
|
-
}
|
|
98
|
-
for (let _datak = 0; _datak < _objList.length; _datak++) {
|
|
99
|
-
const _obj = _objList[_datak] as HTMLElement & {value:any};
|
|
100
|
-
const _datamodel = _obj.getAttribute("data-field");
|
|
101
|
-
logger.debug("Binding " + _datamodel + " for " + this.name);
|
|
102
|
-
this.data[_datamodel as keyof typeof this.data] = _obj.value;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
done(standardResponse:ComponentDoneResponse):Promise<ComponentDoneResponse> {
|
|
107
|
-
const _ret_ = super.done(standardResponse);
|
|
108
|
-
this.executeBindings();
|
|
109
|
-
this.createBindingEvents();
|
|
110
|
-
logger.debug("Field loaded: " + this.fieldType + "[name=" + this.name + "]");
|
|
111
|
-
return _ret_;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
Package("org.qcobjects.base.components", [
|
|
118
|
-
FormField
|
|
119
|
-
]);
|
|
120
|
-
|
|
121
|
-
class ShadowedComponent extends Component {
|
|
122
|
-
container = null;
|
|
123
|
-
shadowed = true;
|
|
124
|
-
cached = false;
|
|
125
|
-
controller = null;
|
|
126
|
-
view = null;
|
|
127
|
-
data = {};
|
|
128
|
-
|
|
129
|
-
constructor (o:FieldComponentParams){
|
|
130
|
-
o.body = _DOMCreateElement("div") as QCObjectsElement;
|
|
131
|
-
super(o);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
class ButtonField extends FormField {
|
|
138
|
-
constructor(o:FieldComponentParams) {
|
|
139
|
-
o.fieldType = "button";
|
|
140
|
-
super(o);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
class InputField extends FormField {
|
|
145
|
-
constructor(o:FieldComponentParams) {
|
|
146
|
-
o.fieldType = "input";
|
|
147
|
-
super(o);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
class TextField extends FormField {
|
|
153
|
-
constructor(o:FieldComponentParams) {
|
|
154
|
-
o.fieldType = "textarea";
|
|
155
|
-
super(o);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
class EmailField extends FormField {
|
|
161
|
-
constructor(o:FieldComponentParams) {
|
|
162
|
-
o.fieldType = "input";
|
|
163
|
-
super(o);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
class ModalEnclosureComponent extends Component {
|
|
169
|
-
name = "modalenclosure";
|
|
170
|
-
tplsource = "inline";
|
|
171
|
-
cached = false;
|
|
172
|
-
basePath = CONFIG.get("modalBasePath", CONFIG.get("remoteSDKPath", ""));
|
|
173
|
-
template = `
|
|
174
|
-
<!-- The Modal -->
|
|
175
|
-
<style>
|
|
176
|
-
@import url('https://sdk.qcobjects.dev/css/modal.css');
|
|
177
|
-
</style>
|
|
178
|
-
<div id="modalInstance_{{modalId}}" class="modal">
|
|
179
|
-
|
|
180
|
-
<!-- Modal content -->
|
|
181
|
-
<div class="modal-content">
|
|
182
|
-
<span class="close">×</span>
|
|
183
|
-
{{content}}
|
|
184
|
-
</div>
|
|
185
|
-
|
|
186
|
-
</div>
|
|
187
|
-
`;
|
|
188
|
-
|
|
189
|
-
data = {};
|
|
190
|
-
constructor(o:FieldComponentParams) {
|
|
191
|
-
o.body = _DOMCreateElement("div") as QCObjectsElement;
|
|
192
|
-
super(o);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
class ModalComponent extends Component {
|
|
198
|
-
name = "modal";
|
|
199
|
-
cached = false;
|
|
200
|
-
modalEnclosureComponentClass = "ModalEnclosureComponent";
|
|
201
|
-
controller = null;
|
|
202
|
-
view = null;
|
|
203
|
-
tplsource = "none";
|
|
204
|
-
closeOnClickOutside = false;
|
|
205
|
-
data = {
|
|
206
|
-
content: "",
|
|
207
|
-
modalId: 0
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
submodal = null;
|
|
211
|
-
|
|
212
|
-
constructor(o:FieldComponentParams) {
|
|
213
|
-
o.basePath = CONFIG.get("modalBasePath", CONFIG.get("remoteSDKPath", ""));
|
|
214
|
-
super(o);
|
|
215
|
-
this.data.modalId = this.__instanceID;
|
|
216
|
-
const submodal = New(ClassFactory(this.modalEnclosureComponentClass), {
|
|
217
|
-
name: this.name,
|
|
218
|
-
basePath: this.basePath,
|
|
219
|
-
data: this.data
|
|
220
|
-
});
|
|
221
|
-
this.subcomponents.push(submodal);
|
|
222
|
-
this.submodal = submodal;
|
|
223
|
-
if (submodal.tplsource === "none") {
|
|
224
|
-
this.body.innerHTML = submodal.parsedAssignmentText;
|
|
225
|
-
} else {
|
|
226
|
-
this.body.append(submodal.body);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
modal() {
|
|
232
|
-
const modalId = this.data.modalId;
|
|
233
|
-
|
|
234
|
-
Tag("#modalInstance_" + modalId + ".modal").map( (modal) => {
|
|
235
|
-
modal.style.display = "block";
|
|
236
|
-
return (new ModalFade({})).apply(modal, 0, 1);
|
|
237
|
-
});
|
|
238
|
-
Tag("#modalInstance_" + modalId + ".modal .modal-content").map( (modalcontent) => {
|
|
239
|
-
return (new ModalMoveDown({})).apply(modalcontent, 0, -document.body.clientHeight, 0, 0);
|
|
240
|
-
});
|
|
241
|
-
Tag("#modalInstance_" + modalId + ".modal .modal-content .close").map( (closebtn) => {
|
|
242
|
-
return closebtn.addEventListener("click", () => {
|
|
243
|
-
this.close();
|
|
244
|
-
}, false);
|
|
245
|
-
});
|
|
246
|
-
if (this.closeOnClickOutside) {
|
|
247
|
-
window.addEventListener("click", () => {
|
|
248
|
-
this.close();
|
|
249
|
-
}, false);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
close() {
|
|
254
|
-
const modalId = this.data.modalId;
|
|
255
|
-
Tag("#modalInstance_" + modalId + ".modal").map( (modal) => {
|
|
256
|
-
modal.style.display = "block";
|
|
257
|
-
return (new ModalFade({})).apply(modal, 1, 0);
|
|
258
|
-
});
|
|
259
|
-
Tag("#modalInstance_" + modalId + ".modal .modal-content").map(function (modalcontent) {
|
|
260
|
-
return (new ModalMoveUp({})).apply(modalcontent, 0, 0, 0, -document.body.clientHeight);
|
|
261
|
-
});
|
|
262
|
-
setTimeout(function () {
|
|
263
|
-
Tag("#modalInstance_" + modalId + ".modal").map((modal) => {
|
|
264
|
-
modal.style.display = "none";
|
|
265
|
-
return true;
|
|
266
|
-
});
|
|
267
|
-
}, 900);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
rebuild() {
|
|
271
|
-
const _ret_ = super.rebuild();
|
|
272
|
-
this.templateURI = ComponentURI({
|
|
273
|
-
"COMPONENTS_BASE_PATH": CONFIG.get("componentsBasePath", ""),
|
|
274
|
-
"COMPONENT_NAME": "modal",
|
|
275
|
-
"TPLEXTENSION": CONFIG.get("tplextension", ""),
|
|
276
|
-
"TPL_SOURCE": "default" // here is always default in order to get the right uri
|
|
277
|
-
});
|
|
278
|
-
return _ret_; // parent call
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
class SwaggerUIComponent extends Component {
|
|
285
|
-
cached = false;
|
|
286
|
-
basePath = CONFIG.get("remoteSDKPath", "");
|
|
287
|
-
tplextension = "tpl.html";
|
|
288
|
-
name = "swagger-ui";
|
|
289
|
-
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
Package("org.qcobjects.form.components", [
|
|
294
|
-
ShadowedComponent,
|
|
295
|
-
ButtonField,
|
|
296
|
-
InputField,
|
|
297
|
-
TextField,
|
|
298
|
-
EmailField,
|
|
299
|
-
ModalEnclosureComponent,
|
|
300
|
-
ModalComponent,
|
|
301
|
-
SwaggerUIComponent
|
|
302
|
-
]);
|
|
303
|
-
|
|
304
|
-
global.FormField = FormField;
|
|
305
|
-
global.ShadowedComponent = ShadowedComponent;
|
|
306
|
-
global.ButtonField = ButtonField;
|
|
307
|
-
global.InputField = InputField;
|
|
308
|
-
global.TextField = TextField;
|
|
309
|
-
global.EmailField = EmailField;
|
|
310
|
-
global.ModalEnclosureComponent = ModalEnclosureComponent;
|
|
311
|
-
global.ModalComponent = ModalComponent;
|
|
312
|
-
global.SwaggerUIComponent = SwaggerUIComponent;
|
|
313
|
-
|
|
314
|
-
})(_top);
|
|
315
|
-
|
|
316
|
-
const FormField = _top.FormField;
|
|
317
|
-
const ShadowedComponent = _top.ShadowedComponent;
|
|
318
|
-
const ButtonField = _top.ButtonField;
|
|
319
|
-
const InputField = _top.InputField;
|
|
320
|
-
const TextField = _top.TextField;
|
|
321
|
-
const EmailField = _top.EmailField;
|
|
322
|
-
const ModalEnclosureComponent = _top.ModalEnclosureComponent;
|
|
323
|
-
const ModalComponent = _top.ModalComponent;
|
|
324
|
-
const SwaggerUIComponent = _top.SwaggerUIComponent;
|
|
325
|
-
|
|
326
|
-
export {
|
|
327
|
-
FormField,
|
|
328
|
-
ShadowedComponent,
|
|
329
|
-
ButtonField,
|
|
330
|
-
InputField,
|
|
331
|
-
TextField,
|
|
332
|
-
EmailField,
|
|
333
|
-
ModalComponent,
|
|
334
|
-
ModalEnclosureComponent,
|
|
335
|
-
SwaggerUIComponent
|
|
336
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
import { Package, Controller, serviceLoader, New, ClassFactory, logger, _DOMCreateElement, Tag, QCObjectsElement, ControllerParams } from "qcobjects";
|
|
2
|
-
import { FormField, ModalComponent } from "./org.qcobjects.components";
|
|
3
|
-
|
|
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
|
-
Package("org.qcobjects.controllers.form",[
|
|
31
|
-
|
|
32
|
-
class FormValidations extends Controller {
|
|
33
|
-
getDefault (){
|
|
34
|
-
return function (fieldName:string, dataValue:any, element:HTMLElement){
|
|
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 as keyof typeof _regex]);
|
|
40
|
-
const pattern = new RegExp(_pattern_);
|
|
41
|
-
return pattern.test(dataValue);
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
class FormController extends Controller {
|
|
48
|
-
validations:any[]=[];
|
|
49
|
-
formValidatorModal:typeof ModalComponent;
|
|
50
|
-
serviceClass="";
|
|
51
|
-
formSettings={
|
|
52
|
-
backRouting:"#",
|
|
53
|
-
loadingRouting:"#loading",
|
|
54
|
-
nextRouting:"#signupsuccessful"
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
hasValidation (element:HTMLElement){
|
|
58
|
-
const fieldName = element.getAttribute("data-field") as string;
|
|
59
|
-
let _hasValidation = false;
|
|
60
|
-
if (typeof this.validations !== "undefined"
|
|
61
|
-
&& Object.hasOwnProperty.call(this.validations,fieldName)){
|
|
62
|
-
_hasValidation = true;
|
|
63
|
-
}
|
|
64
|
-
return _hasValidation;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
isInvalid (element:HTMLElement){
|
|
68
|
-
let _isInvalid = false;
|
|
69
|
-
const fieldName = element.getAttribute("data-field");
|
|
70
|
-
const dataValue = this.component.data[fieldName as string];
|
|
71
|
-
|
|
72
|
-
const _execValidation = (fieldName:string, dataValue:any, element:HTMLElement) => {
|
|
73
|
-
return (typeof this.validations !== "undefined"
|
|
74
|
-
&& Object.hasOwnProperty.call(this.validations,fieldName as string)
|
|
75
|
-
&& this.validations[fieldName as keyof typeof this.validations].call(null,fieldName,dataValue, element));
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
if (typeof this.validations !== "undefined" && (
|
|
79
|
-
!_execValidation(fieldName as string, dataValue, element)
|
|
80
|
-
)){
|
|
81
|
-
_isInvalid = true;
|
|
82
|
-
}
|
|
83
|
-
return _isInvalid;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
isValid (element:HTMLElement){
|
|
87
|
-
return !this.isInvalid(element);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
save (){
|
|
91
|
-
if (this.serviceClass !== ""){
|
|
92
|
-
location.href=this.formSettings.loadingRouting;
|
|
93
|
-
serviceLoader(New(ClassFactory(this.serviceClass),{
|
|
94
|
-
data:this.component.data
|
|
95
|
-
}), false).then(
|
|
96
|
-
(successfulResponse)=>{
|
|
97
|
-
// This will show the service response as a plain text
|
|
98
|
-
console.log("DONE SERVICE COMPONENT");
|
|
99
|
-
try{
|
|
100
|
-
console.log(successfulResponse.service.JSONresponse);
|
|
101
|
-
}catch (e){
|
|
102
|
-
// no json
|
|
103
|
-
}
|
|
104
|
-
location.href=this.formSettings.nextRouting;
|
|
105
|
-
|
|
106
|
-
},
|
|
107
|
-
(failedResponse)=>{
|
|
108
|
-
logger.debug(failedResponse);
|
|
109
|
-
location.href=this.formSettings.backRouting;
|
|
110
|
-
});
|
|
111
|
-
} else {
|
|
112
|
-
logger.debug("No service name declared on serviceClass property");
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
formSaveTouchHandler (){
|
|
118
|
-
logger.debug("Saving data...");
|
|
119
|
-
const _componentRoot_ = (this.component.shadowed)?((this.component?.shadowRoot as ShadowRoot).host):(this.component.body);
|
|
120
|
-
(this.component as typeof FormField).executeBindings();
|
|
121
|
-
if (this.formValidatorModal!=null){
|
|
122
|
-
const componentElementFields = (_componentRoot_ as QCObjectsElement).subelements("*[data-field]");
|
|
123
|
-
const fieldsToValidate = componentElementFields.filter(
|
|
124
|
-
f => this.hasValidation(f)
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
const _labelledby = function (parentElement:HTMLElement, element:HTMLElement){
|
|
128
|
-
const _arialabelledby = (parentElement:HTMLElement, element:HTMLElement) => {
|
|
129
|
-
return (element.getAttribute("aria-labelledby") !== null)?((element.getAttribute("aria-labelledby") || "").split(" ").map(
|
|
130
|
-
e => (parentElement as QCObjectsElement).subelements(`#${e}`).map(_e => _e.innerHTML)
|
|
131
|
-
).join(" ")):(null);
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
return (_arialabelledby(parentElement, element)
|
|
135
|
-
|| element.getAttribute("aria-label")
|
|
136
|
-
|| element.getAttribute("placeholder")
|
|
137
|
-
|| element.getAttribute("name")
|
|
138
|
-
|| element.getAttribute("data-field") );
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
const _ariatitle = function (element:HTMLElement){
|
|
142
|
-
return (element.getAttribute("title") || element.getAttribute("aria-title") || "");
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
const invalidFields = fieldsToValidate.filter(f=>this.isInvalid(f));
|
|
146
|
-
if (invalidFields.length>0){
|
|
147
|
-
const validationMessage = `
|
|
148
|
-
<details>
|
|
149
|
-
<summary>Please verify the following incorrect fields:</summary>
|
|
150
|
-
<ul>
|
|
151
|
-
<div>
|
|
152
|
-
${invalidFields.map(element => "<li><div>"+_labelledby(_componentRoot_ as HTMLElement,element)+"</div><div>"+_ariatitle(element)+"</div></li>").join("")}
|
|
153
|
-
</div>
|
|
154
|
-
</ul>
|
|
155
|
-
</details>
|
|
156
|
-
`;
|
|
157
|
-
this.formValidatorModal.body.subelements(".validationMessage")[0].innerHTML=validationMessage;
|
|
158
|
-
this.formValidatorModal.modal();
|
|
159
|
-
} else {
|
|
160
|
-
this.save();
|
|
161
|
-
}
|
|
162
|
-
} else {
|
|
163
|
-
logger.debug("Unable to find the modal validator...");
|
|
164
|
-
logger.debug("Saving data...");
|
|
165
|
-
this.save();
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
constructor (o:ControllerParams){
|
|
170
|
-
super(o);
|
|
171
|
-
this.component = o.component;
|
|
172
|
-
this.component = this.component.Cast(FormField);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
done (){
|
|
176
|
-
logger.debugEnabled=true;
|
|
177
|
-
try {
|
|
178
|
-
(this.component as typeof FormField).createBindingEvents();
|
|
179
|
-
const modalBody = _DOMCreateElement("div");
|
|
180
|
-
modalBody.className="modal_body";
|
|
181
|
-
this.formValidatorModal = New(ModalComponent,{
|
|
182
|
-
body:modalBody,
|
|
183
|
-
subcomponents:[],
|
|
184
|
-
data:{
|
|
185
|
-
content:"<div class=\"validationMessage\"></div>"
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
Tag(".modal_body").map(e=>document.body.removeChild(e));
|
|
190
|
-
document.body.append(this.formValidatorModal);
|
|
191
|
-
|
|
192
|
-
} catch (e){
|
|
193
|
-
logger.debug("Unable to create the modal");
|
|
194
|
-
}
|
|
195
|
-
this.onpress(".submit", () => {
|
|
196
|
-
this.formSaveTouchHandler();
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
]);
|
|
205
|
-
|
|
206
|
-
})();
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|