qcobjects-sdk 2.4.64 → 2.5.105-beta
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-beta.yml +4 -2
- package/.github/workflows/npmpublish-lts.yml +4 -2
- package/.github/workflows/npmpublish-main.yml +5 -3
- package/VERSION +1 -1
- package/build/QCObjects-SDK.js +83 -41
- package/build/index.js +17 -7
- package/build/js/org.qcobjects.base.components.js +75 -0
- package/build/js/org.qcobjects.cloud.auth.session.data.js +98 -101
- package/build/js/org.qcobjects.cloud.auth.session.usertoken.js +68 -80
- package/build/js/org.qcobjects.components.grid.js +35 -53
- package/build/js/org.qcobjects.components.js +145 -237
- package/build/js/org.qcobjects.components.list.js +36 -45
- package/build/js/org.qcobjects.components.notifications.js +107 -106
- package/build/js/org.qcobjects.components.slider.js +183 -169
- package/build/js/org.qcobjects.components.splashscreen.js +123 -130
- package/build/js/org.qcobjects.controllers.form.js +149 -147
- package/build/js/org.qcobjects.controllers.grid.js +226 -215
- package/build/js/org.qcobjects.controllers.js +11 -11
- package/build/js/org.qcobjects.controllers.list.js +195 -188
- package/build/js/org.qcobjects.controllers.slider.js +101 -106
- package/build/js/org.qcobjects.controllers.swagger.js +71 -46
- package/build/js/org.qcobjects.effects.base.js +86 -0
- package/build/js/org.qcobjects.effects.extended.js +318 -0
- package/build/js/org.qcobjects.effects.js +26 -394
- package/build/js/org.qcobjects.i18n_messages.js +33 -46
- package/build/js/org.qcobjects.modal.controllers.js +16 -15
- package/build/js/org.qcobjects.modal.effects.js +23 -28
- package/build/js/org.qcobjects.models.js +11 -11
- package/build/js/org.qcobjects.tools.canvas.js +28 -27
- package/build/js/org.qcobjects.tools.js +10 -3
- package/build/js/org.qcobjects.tools.layouts.js +46 -45
- package/build/js/org.qcobjects.views.js +11 -11
- package/build-esbuild.js +72 -0
- package/eslint.config.mjs +88 -0
- package/package.json +66 -59
- package/postbuild.js +10 -0
- package/public/browser/index.js +9902 -0
- package/public/browser/index.js.map +7 -0
- package/public/cjs/index.cjs +9894 -0
- package/public/cjs/index.cjs.map +7 -0
- package/public/esm/index.mjs +9894 -0
- package/public/esm/index.mjs.map +7 -0
- package/public/types/index.d.ts +698 -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/QCObjects-SDK.ts +72 -53
- package/src/js/org.qcobjects.base.components.ts +83 -0
- package/src/js/org.qcobjects.cloud.auth.session.data.ts +98 -99
- package/src/js/org.qcobjects.cloud.auth.session.usertoken.ts +72 -92
- package/src/js/org.qcobjects.components.grid.ts +31 -58
- package/src/js/org.qcobjects.components.list.ts +15 -31
- package/src/js/org.qcobjects.components.notifications.ts +12 -12
- package/src/js/org.qcobjects.components.slider.ts +182 -171
- package/src/js/org.qcobjects.components.splashscreen.ts +31 -39
- package/src/js/org.qcobjects.components.ts +151 -261
- package/src/js/org.qcobjects.controllers.form.ts +151 -148
- package/src/js/org.qcobjects.controllers.grid.ts +226 -222
- package/src/js/org.qcobjects.controllers.list.ts +207 -205
- package/src/js/org.qcobjects.controllers.slider.ts +120 -125
- package/src/js/org.qcobjects.controllers.swagger.ts +51 -51
- package/src/js/org.qcobjects.controllers.ts +7 -9
- package/src/js/org.qcobjects.effects.base.ts +97 -0
- package/src/js/org.qcobjects.effects.extended.ts +350 -0
- package/src/js/org.qcobjects.effects.ts +6 -394
- package/src/js/org.qcobjects.i18n_messages.ts +37 -51
- package/src/js/org.qcobjects.modal.controllers.ts +12 -14
- package/src/js/org.qcobjects.modal.effects.ts +22 -18
- package/src/js/org.qcobjects.models.ts +8 -11
- package/src/js/org.qcobjects.tools.canvas.ts +26 -28
- package/src/js/org.qcobjects.tools.layouts.ts +44 -47
- package/src/js/org.qcobjects.tools.ts +7 -1
- package/src/js/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/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/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/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/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.usertoken.d.ts +0 -2
- 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.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.splashscreen.d.ts +0 -28
- 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.grid.d.ts +0 -1
- package/src/js/org.qcobjects.controllers.list.d.ts +0 -1
- package/src/js/org.qcobjects.controllers.slider.d.ts +0 -1
- package/src/js/org.qcobjects.controllers.swagger.d.ts +0 -1
- 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.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.views.d.ts +0 -1
- /package/spec/{testsSpec.js → testsSpec.ts} +0 -0
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
|
-
* QCObjects SDK 2.
|
|
2
|
+
* QCObjects SDK 2.5.0
|
|
4
3
|
* ________________
|
|
5
4
|
*
|
|
6
5
|
* Author: Jean Machuca <correojean@gmail.com>
|
|
@@ -23,125 +22,120 @@
|
|
|
23
22
|
* Everyone is permitted to copy and distribute verbatim copies of this
|
|
24
23
|
* license document, but changing it is not allowed.
|
|
25
24
|
*/
|
|
25
|
+
"use strict";
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
27
|
exports.CubeSplashScreenComponent = exports.VideoSplashScreenComponent = exports.SplashScreenComponent = void 0;
|
|
28
28
|
const qcobjects_1 = require("qcobjects");
|
|
29
29
|
const org_qcobjects_effects_1 = require("./org.qcobjects.effects");
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
30
|
+
class SplashScreenComponent extends qcobjects_1.Component {
|
|
31
|
+
_enabled_;
|
|
32
|
+
_bgcolor;
|
|
33
|
+
cached = false;
|
|
34
|
+
shadowed = true;
|
|
35
|
+
body;
|
|
36
|
+
shadowRoot;
|
|
37
|
+
constructor(component) {
|
|
38
|
+
component.name = (typeof component.name === "undefined") ? ("splashscreen") : (component.name);
|
|
39
|
+
const isBrowser = typeof window !== "undefined" && typeof window.self !== "undefined" && window === window.self;
|
|
40
|
+
const isStartURL = (location.hash === ""
|
|
41
|
+
&& location.pathname === "/" && location.search === "")
|
|
42
|
+
|| qcobjects_1.CONFIG.get("routingWay", "pathname") === "hash" && qcobjects_1.CONFIG.get("start_url", "/") === location.hash
|
|
43
|
+
|| qcobjects_1.CONFIG.get("routingWay", "pathname") === "pathname" && qcobjects_1.CONFIG.get("start_url", "/") === location.pathname
|
|
44
|
+
|| qcobjects_1.CONFIG.get("routingWay", "pathname") === "search" && qcobjects_1.CONFIG.get("start_url", "/") === location.search;
|
|
45
|
+
const _enabled_ = isBrowser && isStartURL;
|
|
46
|
+
if (_enabled_) {
|
|
47
|
+
component.basePath = qcobjects_1.CONFIG.get("splashscreenBasePath", qcobjects_1.CONFIG.get("remoteSDKPath", ""));
|
|
48
|
+
if (typeof component.data === "undefined") {
|
|
49
|
+
component.data = {};
|
|
50
|
+
}
|
|
51
|
+
component.data.basePath = component.basePath;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
if (typeof component !== "undefined" && typeof component.body !== "undefined") {
|
|
55
|
+
component.body.style.display = "none";
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
super(component);
|
|
59
|
+
this._bgcolor = "";
|
|
60
|
+
this._enabled_ = _enabled_;
|
|
61
|
+
if (this._enabled_) {
|
|
62
|
+
const displayEffectDuration = 1000;
|
|
63
|
+
let duration = this.body.getAttribute("duration");
|
|
64
|
+
if (duration === null) {
|
|
65
|
+
duration = displayEffectDuration;
|
|
58
66
|
}
|
|
59
67
|
else {
|
|
60
|
-
|
|
61
|
-
component.body.style.display = "none";
|
|
62
|
-
}
|
|
68
|
+
duration = parseInt(duration.toString());
|
|
63
69
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
setTimeout(() => {
|
|
81
|
-
if (!_helper_.executed) {
|
|
82
|
-
const _componentRoot = (this.shadowed) ? this.shadowRoot?.host : this.body;
|
|
83
|
-
if (typeof global.componentsStack !== "undefined") {
|
|
84
|
-
global.componentsStack.filter((c) => c.body.hasAttribute("splashscreen")).map((mainComponent) => {
|
|
85
|
-
qcobjects_1.logger.debug(`Splash Screen of Main Component: ${mainComponent.name}`);
|
|
86
|
-
mainComponent.splashScreenComponent = this;
|
|
87
|
-
const SplashScreenHandler = () => {
|
|
88
|
-
if (!SplashScreenHandler.executed) {
|
|
89
|
-
const component = mainComponent.splashScreenComponent;
|
|
90
|
-
const mainElement = (mainComponent.shadowed) ? mainComponent.shadowRoot?.host : mainComponent.body;
|
|
91
|
-
mainComponent._mainPosition = mainElement.style.position;
|
|
92
|
-
if (typeof mainElement !== "undefined") {
|
|
93
|
-
mainElement.style.position = "fixed";
|
|
94
|
-
}
|
|
95
|
-
mainComponent._mainOpacity = mainElement.style.opacity;
|
|
96
|
-
_componentRoot.style.width = "100%";
|
|
97
|
-
_componentRoot.style.height = "100%";
|
|
98
|
-
document.body.style.backgroundColor = "#111111";
|
|
99
|
-
mainElement.style.opacity = "0";
|
|
100
|
-
setTimeout(function () {
|
|
101
|
-
if (typeof _componentRoot !== "undefined") {
|
|
102
|
-
document.body.style.backgroundColor = component?._bgcolor;
|
|
103
|
-
_componentRoot.subelements("#slot-logo").map((slotlogo) => {
|
|
104
|
-
slotlogo.style.display = "block";
|
|
105
|
-
slotlogo.style.transformOrigin = "center";
|
|
106
|
-
return (new org_qcobjects_effects_1.Resize()).apply(slotlogo, 1, 0);
|
|
107
|
-
});
|
|
108
|
-
(new org_qcobjects_effects_1.Fade()).apply(_componentRoot, 1, 0);
|
|
109
|
-
}
|
|
110
|
-
}, (duration - displayEffectDuration));
|
|
111
|
-
setTimeout(function () {
|
|
112
|
-
(new org_qcobjects_effects_1.Fade()).apply(mainElement, 0, 1);
|
|
113
|
-
mainElement.style.position = mainComponent._mainPosition;
|
|
114
|
-
document.body.style.backgroundColor = component._bgcolor;
|
|
115
|
-
if (_componentRoot.parentElement !== null) {
|
|
116
|
-
_componentRoot.parentElement.remove();
|
|
117
|
-
}
|
|
118
|
-
}, duration);
|
|
70
|
+
this._bgcolor = this.body.style.backgroundColor;
|
|
71
|
+
const _helper_ = () => {
|
|
72
|
+
setTimeout(() => {
|
|
73
|
+
if (!_helper_.executed) {
|
|
74
|
+
const _componentRoot = (this.shadowed) ? this.shadowRoot?.host : this.body;
|
|
75
|
+
if (typeof qcobjects_1.global.componentsStack !== "undefined") {
|
|
76
|
+
qcobjects_1.global.componentsStack.filter((c) => c.body.hasAttribute("splashscreen")).map((mainComponent) => {
|
|
77
|
+
qcobjects_1.logger.debug(`Splash Screen of Main Component: ${mainComponent.name}`);
|
|
78
|
+
mainComponent.splashScreenComponent = this;
|
|
79
|
+
const SplashScreenHandler = () => {
|
|
80
|
+
if (!SplashScreenHandler.executed) {
|
|
81
|
+
const component = mainComponent.splashScreenComponent;
|
|
82
|
+
const mainElement = (mainComponent.shadowed) ? mainComponent.shadowRoot?.host : mainComponent.body;
|
|
83
|
+
mainComponent._mainPosition = mainElement.style.position;
|
|
84
|
+
if (typeof mainElement !== "undefined") {
|
|
85
|
+
mainElement.style.position = "fixed";
|
|
119
86
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
87
|
+
mainComponent._mainOpacity = mainElement.style.opacity;
|
|
88
|
+
_componentRoot.style.width = "100%";
|
|
89
|
+
_componentRoot.style.height = "100%";
|
|
90
|
+
document.body.style.backgroundColor = "#111111";
|
|
91
|
+
mainElement.style.opacity = "0";
|
|
92
|
+
setTimeout(function () {
|
|
93
|
+
if (typeof _componentRoot !== "undefined") {
|
|
94
|
+
document.body.style.backgroundColor = component?._bgcolor;
|
|
95
|
+
_componentRoot.subelements("#slot-logo").map((slotlogo) => {
|
|
96
|
+
slotlogo.style.display = "block";
|
|
97
|
+
slotlogo.style.transformOrigin = "center";
|
|
98
|
+
return (new org_qcobjects_effects_1.Resize()).apply(slotlogo, 1, 0);
|
|
99
|
+
});
|
|
100
|
+
(new org_qcobjects_effects_1.Fade()).apply(_componentRoot, 1, 0);
|
|
101
|
+
}
|
|
102
|
+
}, (duration - displayEffectDuration));
|
|
103
|
+
setTimeout(function () {
|
|
104
|
+
(new org_qcobjects_effects_1.Fade()).apply(mainElement, 0, 1);
|
|
105
|
+
mainElement.style.position = mainComponent._mainPosition;
|
|
106
|
+
document.body.style.backgroundColor = component._bgcolor;
|
|
107
|
+
if (_componentRoot.parentElement !== null) {
|
|
108
|
+
_componentRoot.parentElement.remove();
|
|
109
|
+
}
|
|
110
|
+
}, duration);
|
|
111
|
+
}
|
|
112
|
+
SplashScreenHandler.executed = true;
|
|
113
|
+
};
|
|
114
|
+
return mainComponent.addComponentHelper(SplashScreenHandler.bind(mainComponent));
|
|
115
|
+
});
|
|
126
116
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
117
|
+
_helper_.executed = true;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
_helper_.executed = false;
|
|
122
|
+
this.addComponentHelper(_helper_.bind(component));
|
|
132
123
|
}
|
|
133
124
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
125
|
+
// eslint-disable-next-line no-unused-vars
|
|
126
|
+
addComponentHelper(arg0) {
|
|
127
|
+
throw new Error("Method not implemented.");
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
exports.SplashScreenComponent = SplashScreenComponent;
|
|
131
|
+
(0, qcobjects_1.Package)("org.qcobjects.components.base", [
|
|
132
|
+
SplashScreenComponent
|
|
133
|
+
]);
|
|
134
|
+
class VideoSplashScreenComponent extends SplashScreenComponent {
|
|
135
|
+
cached = false;
|
|
136
|
+
shadowed = true;
|
|
137
|
+
tplsource = "inline";
|
|
138
|
+
template = `
|
|
145
139
|
<style>
|
|
146
140
|
:host * {
|
|
147
141
|
box-sizing: border-box;
|
|
@@ -305,16 +299,17 @@ const _top = (typeof module === "object" && typeof module.exports === "object")
|
|
|
305
299
|
</div>
|
|
306
300
|
|
|
307
301
|
`;
|
|
308
|
-
|
|
302
|
+
constructor(o) {
|
|
303
|
+
o.name = "videosplashscreen";
|
|
304
|
+
super(o);
|
|
309
305
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
this.template = `
|
|
306
|
+
}
|
|
307
|
+
exports.VideoSplashScreenComponent = VideoSplashScreenComponent;
|
|
308
|
+
class CubeSplashScreenComponent extends SplashScreenComponent {
|
|
309
|
+
cached = false;
|
|
310
|
+
shadowed = true;
|
|
311
|
+
tplsource = "inline";
|
|
312
|
+
template = `
|
|
318
313
|
<style>
|
|
319
314
|
@keyframes spin {
|
|
320
315
|
0% {
|
|
@@ -627,16 +622,14 @@ const _top = (typeof module === "object" && typeof module.exports === "object")
|
|
|
627
622
|
</div>
|
|
628
623
|
|
|
629
624
|
`;
|
|
630
|
-
|
|
625
|
+
constructor(o) {
|
|
626
|
+
o.name = "cubesplashscreen";
|
|
627
|
+
super(o);
|
|
631
628
|
}
|
|
632
|
-
|
|
633
|
-
VideoSplashScreenComponent,
|
|
634
|
-
CubeSplashScreenComponent
|
|
635
|
-
]);
|
|
636
|
-
})(_top);
|
|
637
|
-
const SplashScreenComponent = _top.SplashScreenComponent;
|
|
638
|
-
exports.SplashScreenComponent = SplashScreenComponent;
|
|
639
|
-
const VideoSplashScreenComponent = _top.VideoSplashScreenComponent;
|
|
640
|
-
exports.VideoSplashScreenComponent = VideoSplashScreenComponent;
|
|
641
|
-
const CubeSplashScreenComponent = _top.CubeSplashScreenComponent;
|
|
629
|
+
}
|
|
642
630
|
exports.CubeSplashScreenComponent = CubeSplashScreenComponent;
|
|
631
|
+
(0, qcobjects_1.Package)("org.qcobjects.components.splashscreen", [
|
|
632
|
+
SplashScreenComponent,
|
|
633
|
+
VideoSplashScreenComponent,
|
|
634
|
+
CubeSplashScreenComponent
|
|
635
|
+
]);
|
|
@@ -1,9 +1,5 @@
|
|
|
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
1
|
/**
|
|
6
|
-
* QCObjects SDK 2.
|
|
2
|
+
* QCObjects SDK 2.5
|
|
7
3
|
* ________________
|
|
8
4
|
*
|
|
9
5
|
* Author: Jean Machuca <correojean@gmail.com>
|
|
@@ -26,153 +22,159 @@ const org_qcobjects_components_1 = require("./org.qcobjects.components");
|
|
|
26
22
|
* Everyone is permitted to copy and distribute verbatim copies of this
|
|
27
23
|
* license document, but changing it is not allowed.
|
|
28
24
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
25
|
+
"use strict";
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.FormController = exports.FormValidations = void 0;
|
|
28
|
+
const qcobjects_1 = require("qcobjects");
|
|
29
|
+
const org_qcobjects_components_1 = require("./org.qcobjects.components");
|
|
30
|
+
class FormValidations extends qcobjects_1.Controller {
|
|
31
|
+
getDefault() {
|
|
32
|
+
return function (fieldName, dataValue, element) {
|
|
33
|
+
const _regex = {
|
|
34
|
+
name: "^[a-zA-Z]+(([',. -][a-zA-Z ])?[a-zA-Z]*)*$",
|
|
35
|
+
email: "^([A-Za-z0-9]+)@([A-Za-z0-9]+).([A-Za-z0-9]+)$"
|
|
36
|
+
};
|
|
37
|
+
const _pattern_ = (element.getAttribute("pattern") || _regex[fieldName]);
|
|
38
|
+
const pattern = new RegExp(_pattern_);
|
|
39
|
+
return pattern.test(dataValue);
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.FormValidations = FormValidations;
|
|
44
|
+
class FormController extends qcobjects_1.Controller {
|
|
45
|
+
validations = [];
|
|
46
|
+
formValidatorModal;
|
|
47
|
+
serviceClass = "";
|
|
48
|
+
formSettings = {
|
|
49
|
+
backRouting: "#",
|
|
50
|
+
loadingRouting: "#loading",
|
|
51
|
+
nextRouting: "#signupsuccessful"
|
|
52
|
+
};
|
|
53
|
+
component;
|
|
54
|
+
hasValidation(element) {
|
|
55
|
+
const fieldName = element.getAttribute("data-field");
|
|
56
|
+
let _hasValidation = false;
|
|
57
|
+
if (typeof this.validations !== "undefined"
|
|
58
|
+
&& Object.hasOwnProperty.call(this.validations, fieldName)) {
|
|
59
|
+
_hasValidation = true;
|
|
60
|
+
}
|
|
61
|
+
return _hasValidation;
|
|
62
|
+
}
|
|
63
|
+
isInvalid(element) {
|
|
64
|
+
let _isInvalid = false;
|
|
65
|
+
const fieldName = element.getAttribute("data-field");
|
|
66
|
+
const dataValue = this.component.data[fieldName];
|
|
67
|
+
const _execValidation = (fieldName, dataValue, element) => {
|
|
68
|
+
return (typeof this.validations !== "undefined"
|
|
69
|
+
&& Object.hasOwnProperty.call(this.validations, fieldName)
|
|
70
|
+
&& this.validations[fieldName].call(null, fieldName, dataValue, element));
|
|
71
|
+
};
|
|
72
|
+
if (typeof this.validations !== "undefined" && (!_execValidation(fieldName, dataValue, element))) {
|
|
73
|
+
_isInvalid = true;
|
|
74
|
+
}
|
|
75
|
+
return _isInvalid;
|
|
76
|
+
}
|
|
77
|
+
isValid(element) {
|
|
78
|
+
return !this.isInvalid(element);
|
|
79
|
+
}
|
|
80
|
+
save() {
|
|
81
|
+
if (this.serviceClass !== "") {
|
|
82
|
+
location.href = this.formSettings.loadingRouting;
|
|
83
|
+
(0, qcobjects_1.serviceLoader)((0, qcobjects_1.New)((0, qcobjects_1.ClassFactory)(this.serviceClass), {
|
|
84
|
+
data: this.component.data
|
|
85
|
+
}), false).then(() => {
|
|
86
|
+
// This will show the service response as a plain text
|
|
87
|
+
console.log("DONE SERVICE COMPONENT");
|
|
88
|
+
location.href = this.formSettings.nextRouting;
|
|
89
|
+
}, (failedResponse) => {
|
|
90
|
+
qcobjects_1.logger.debug(failedResponse);
|
|
91
|
+
location.href = this.formSettings.backRouting;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
qcobjects_1.logger.debug("No service name declared on serviceClass property");
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
formSaveTouchHandler() {
|
|
99
|
+
qcobjects_1.logger.debug("Saving data...");
|
|
100
|
+
const _componentRoot_ = (this.component.shadowed) ? ((this.component?.shadowRoot).host) : (this.component.body);
|
|
101
|
+
(this.component).executeBindings();
|
|
102
|
+
if (this.formValidatorModal != null) {
|
|
103
|
+
const componentElementFields = _componentRoot_.subelements("*[data-field]");
|
|
104
|
+
const fieldsToValidate = componentElementFields.filter((f) => this.hasValidation(f));
|
|
105
|
+
const _labelledby = function (parentElement, element) {
|
|
106
|
+
const _arialabelledby = (parentElement, element) => {
|
|
107
|
+
return (element.getAttribute("aria-labelledby") !== null) ? ((element.getAttribute("aria-labelledby") || "").split(" ").map(e => parentElement.subelements(`#${e}`).map((_e) => _e.innerHTML)).join(" ")) : (null);
|
|
63
108
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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 = `
|
|
109
|
+
return (_arialabelledby(parentElement, element)
|
|
110
|
+
|| element.getAttribute("aria-label")
|
|
111
|
+
|| element.getAttribute("placeholder")
|
|
112
|
+
|| element.getAttribute("name")
|
|
113
|
+
|| element.getAttribute("data-field"));
|
|
114
|
+
};
|
|
115
|
+
const _ariatitle = function (element) {
|
|
116
|
+
return (element.getAttribute("title") || element.getAttribute("aria-title") || "");
|
|
117
|
+
};
|
|
118
|
+
const invalidFields = fieldsToValidate.filter((f) => this.isInvalid(f));
|
|
119
|
+
if (invalidFields.length > 0) {
|
|
120
|
+
const validationMessage = `
|
|
119
121
|
<details>
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
122
|
+
<summary>Please verify the following incorrect fields:</summary>
|
|
123
|
+
<ul>
|
|
124
|
+
<div>
|
|
125
|
+
${invalidFields.map((element) => "<li><div>" + _labelledby(_componentRoot_, element) + "</div><div>" + _ariatitle(element) + "</div></li>").join("")}
|
|
126
|
+
</div>
|
|
127
|
+
</ul>
|
|
126
128
|
</details>
|
|
127
129
|
`;
|
|
128
|
-
|
|
129
|
-
|
|
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
|
-
}
|
|
130
|
+
this.formValidatorModal.body.subelements(".validationMessage")[0].innerHTML = validationMessage;
|
|
131
|
+
this.formValidatorModal.modal();
|
|
140
132
|
}
|
|
141
|
-
|
|
142
|
-
|
|
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);
|
|
133
|
+
else {
|
|
134
|
+
this.save();
|
|
152
135
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
qcobjects_1.logger.debug("Unable to find the modal validator...");
|
|
139
|
+
qcobjects_1.logger.debug("Saving data...");
|
|
140
|
+
this.save();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
constructor(o) {
|
|
144
|
+
super(o);
|
|
145
|
+
this.component = o.component;
|
|
146
|
+
this.component = this.component.Cast(org_qcobjects_components_1.FormField);
|
|
147
|
+
}
|
|
148
|
+
done() {
|
|
149
|
+
qcobjects_1.logger.debugEnabled = true;
|
|
150
|
+
try {
|
|
151
|
+
(this.component).createBindingEvents();
|
|
152
|
+
const modalBody = (0, qcobjects_1._DOMCreateElement)("div");
|
|
153
|
+
modalBody.className = "modal_body";
|
|
154
|
+
this.formValidatorModal = (0, qcobjects_1.New)(org_qcobjects_components_1.ModalComponent, {
|
|
155
|
+
body: modalBody,
|
|
156
|
+
subcomponents: [],
|
|
157
|
+
data: {
|
|
158
|
+
content: "<div class=\"validationMessage\"></div>"
|
|
171
159
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
160
|
+
});
|
|
161
|
+
(0, qcobjects_1.Tag)(".modal_body").map((e) => document.body.removeChild(e));
|
|
162
|
+
document.body.append(this.formValidatorModal.body);
|
|
163
|
+
}
|
|
164
|
+
catch (e) {
|
|
165
|
+
qcobjects_1.logger.debug(`Unable to create the modal: ${e}`);
|
|
176
166
|
}
|
|
177
|
-
|
|
178
|
-
|
|
167
|
+
this.onpress(".submit", () => {
|
|
168
|
+
this.formSaveTouchHandler();
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
// eslint-disable-next-line no-unused-vars
|
|
172
|
+
onpress(arg0, arg1) {
|
|
173
|
+
throw new Error("Method not implemented.");
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
exports.FormController = FormController;
|
|
177
|
+
(0, qcobjects_1.Package)("org.qcobjects.controllers.form", [
|
|
178
|
+
FormController,
|
|
179
|
+
FormValidations
|
|
180
|
+
]);
|