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
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QCObjects SDK 2.5
|
|
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
|
+
import { Package, Controller, logger, CONFIG, _DataStringify, _DOMCreateElement, New, ClassFactory, ComponentURI, serviceLoader } from "qcobjects";
|
|
27
|
+
import { ListComponent } from "./org.qcobjects.components.list";
|
|
28
|
+
export type ListControllerParams = {
|
|
29
|
+
component: ListComponent;
|
|
30
|
+
valueField: string | undefined;
|
|
31
|
+
labelField: string | undefined;
|
|
32
|
+
dependencies: any[];
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export class ListController extends Controller {
|
|
36
|
+
__instanceID!: number;
|
|
37
|
+
component: ListComponent;
|
|
38
|
+
valueField: string | undefined;
|
|
39
|
+
labelField: string | undefined;
|
|
40
|
+
rows: number | string | null;
|
|
41
|
+
cols: number;
|
|
42
|
+
_componentRoot: HTMLElement | undefined;
|
|
43
|
+
|
|
44
|
+
constructor({ component, dependencies = [], valueField = undefined, labelField = undefined }: ListControllerParams) {
|
|
45
|
+
super({ component, dependencies, valueField, labelField } as ListControllerParams);
|
|
46
|
+
this.component = component;
|
|
47
|
+
this._componentRoot = (this.component.shadowed) ? (this.component.shadowRoot) : (this.component.body);
|
|
48
|
+
|
|
49
|
+
this.labelField = this.component.body.getAttribute("label-field") as string;
|
|
50
|
+
this.valueField = this.component.body.getAttribute("value-field") as string;
|
|
51
|
+
this.rows = this.component.body.getAttribute("rows");
|
|
52
|
+
this.rows = (this.rows !== null) ? (this.rows) : (this.component.rows);
|
|
53
|
+
this.cols = 1;
|
|
54
|
+
logger.debug("ListController INIT");
|
|
55
|
+
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
getPageIndex(page: number, totalPage: number, totalElements: number) {
|
|
59
|
+
page = (page > 0) ? (page - 1) : (0);
|
|
60
|
+
return [totalElements * page / totalPage, (totalElements * page / totalPage) + totalElements / totalPage];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
addSubcomponents() {
|
|
64
|
+
this.component.subcomponents = [];
|
|
65
|
+
const layout = this.component.body.getAttribute("layout");
|
|
66
|
+
const basePath = CONFIG.get("listBasePath", CONFIG.get("remoteSDKPath", ""));
|
|
67
|
+
let cssLayout = "";
|
|
68
|
+
this.labelField = this.component.body.getAttribute("label-field");
|
|
69
|
+
this.valueField = this.component.body.getAttribute("value-field");
|
|
70
|
+
|
|
71
|
+
if (layout === "horizontal") {
|
|
72
|
+
cssLayout = `@import url("${basePath}css/components/horizontal-list.css");`;
|
|
73
|
+
} else {
|
|
74
|
+
cssLayout = `@import url("${basePath}css/components/list.css");`;
|
|
75
|
+
}
|
|
76
|
+
if (typeof this._componentRoot !== "undefined") {
|
|
77
|
+
this._componentRoot.innerHTML = `<style>${cssLayout}</style><ul></ul>`;
|
|
78
|
+
}
|
|
79
|
+
logger.debug(_DataStringify(this.component.data));
|
|
80
|
+
try {
|
|
81
|
+
const subcomponentClass = this.component.body.getAttribute("subcomponentClass");
|
|
82
|
+
if (subcomponentClass != null) {
|
|
83
|
+
let offset: number;
|
|
84
|
+
let limit: number;
|
|
85
|
+
let pagesNumber: number;
|
|
86
|
+
let list = [...this.component.data];
|
|
87
|
+
let paginateIn = this.component.body.getAttribute("paginate-in");
|
|
88
|
+
paginateIn = (paginateIn !== null) ? (paginateIn) : ("client");
|
|
89
|
+
let page: number;
|
|
90
|
+
if (paginateIn === "client") {
|
|
91
|
+
page = this.component.body.getAttribute("page-number");
|
|
92
|
+
page = (isNaN(page) || page === null) ? (-1) : (page);
|
|
93
|
+
if (page !== -1) {
|
|
94
|
+
pagesNumber = this.component.body.getAttribute("total-pages");
|
|
95
|
+
pagesNumber = (isNaN(pagesNumber)) ? (1) : (pagesNumber);
|
|
96
|
+
offset = this.getPageIndex(page, pagesNumber, list.length)[0];
|
|
97
|
+
limit = this.getPageIndex(page, pagesNumber, list.length)[1];
|
|
98
|
+
} else {
|
|
99
|
+
offset = 0;
|
|
100
|
+
limit = list.length;
|
|
101
|
+
pagesNumber = 1;
|
|
102
|
+
}
|
|
103
|
+
list = list.slice(offset, limit);
|
|
104
|
+
} else {
|
|
105
|
+
offset = 0;
|
|
106
|
+
limit = list.length;
|
|
107
|
+
pagesNumber = 1;
|
|
108
|
+
}
|
|
109
|
+
list.map(
|
|
110
|
+
(record, dataIndex) => {
|
|
111
|
+
const _ret_ = undefined;
|
|
112
|
+
try {
|
|
113
|
+
const _body = _DOMCreateElement("li");
|
|
114
|
+
record.label = record[this.labelField as string];
|
|
115
|
+
record.value = record[this.valueField as string];
|
|
116
|
+
const subcomponent = New(ClassFactory(subcomponentClass), {
|
|
117
|
+
name: "list-item",
|
|
118
|
+
data: {
|
|
119
|
+
label: record[this.labelField as string],
|
|
120
|
+
value: record[this.valueField as string],
|
|
121
|
+
__dataIndex: dataIndex,
|
|
122
|
+
__page: page,
|
|
123
|
+
__totalPages: pagesNumber,
|
|
124
|
+
__limit: limit,
|
|
125
|
+
__offset: offset
|
|
126
|
+
},
|
|
127
|
+
templateURI: ComponentURI({
|
|
128
|
+
"COMPONENTS_BASE_PATH": CONFIG.get("componentsBasePath", ""),
|
|
129
|
+
"COMPONENT_NAME": ClassFactory(subcomponentClass).name,
|
|
130
|
+
"TPLEXTENSION": CONFIG.get("tplextension", ""),
|
|
131
|
+
"TPL_SOURCE": ClassFactory(subcomponentClass).tplsource
|
|
132
|
+
}),
|
|
133
|
+
body: _body,
|
|
134
|
+
template: ClassFactory(subcomponentClass).template
|
|
135
|
+
});
|
|
136
|
+
subcomponent.done = this.component.done.bind(subcomponent);
|
|
137
|
+
try {
|
|
138
|
+
if (subcomponent) {
|
|
139
|
+
subcomponent.data.__dataIndex = dataIndex;
|
|
140
|
+
if (Object.hasOwnProperty.call(this.component.data, "length")) {
|
|
141
|
+
subcomponent.data.__dataLength = this.component.data.length;
|
|
142
|
+
}
|
|
143
|
+
logger.debug("adding subcomponent to body");
|
|
144
|
+
|
|
145
|
+
(this._componentRoot as any).subelements("ul").map((ul: HTMLElement) => ul.append(subcomponent));
|
|
146
|
+
try {
|
|
147
|
+
this.component.subcomponents.push(subcomponent as never);
|
|
148
|
+
} catch (e: any) {
|
|
149
|
+
logger.debug(`ERROR LOADING SUBCOMPONENT IN DATAGRID: ${e}`);
|
|
150
|
+
}
|
|
151
|
+
} else {
|
|
152
|
+
logger.debug("ERROR LOADING SUBCOMPONENT IN DATAGRID");
|
|
153
|
+
}
|
|
154
|
+
} catch (e: any) {
|
|
155
|
+
logger.debug(`ERROR LOADING SUBCOMPONENT IN DATAGRID: ${e}`);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
} catch (e: any) {
|
|
159
|
+
logger.debug(`ERROR LOADING SUBCOMPONENT IN DATAGRID: ${e}`);
|
|
160
|
+
}
|
|
161
|
+
return _ret_;
|
|
162
|
+
}
|
|
163
|
+
);
|
|
164
|
+
} else {
|
|
165
|
+
logger.debug("NO SUBCOMPONENT CLASS IN COMPONENT");
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
} catch (e: any) {
|
|
169
|
+
logger.debug(`No data for component: ${e}`);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
cssGrid() {
|
|
174
|
+
const component = this.component;
|
|
175
|
+
const _componentRoot = (component.shadowed) ? (component.shadowRoot) : (component.body);
|
|
176
|
+
if (typeof this.rows !== "undefined" && typeof this.cols !== "undefined") {
|
|
177
|
+
const s = _DOMCreateElement("style");
|
|
178
|
+
const templateRows = "auto ".repeat(this.rows as number);
|
|
179
|
+
const templateCols = "auto ".repeat(this.cols);
|
|
180
|
+
const className = "grid" + this.__instanceID.toString();
|
|
181
|
+
s.innerHTML = `.${className}{
|
|
182
|
+
display: grid; \
|
|
183
|
+
grid-template-rows: ${templateRows}; \
|
|
184
|
+
grid-template-columns: ${templateCols}; \
|
|
185
|
+
margin:0 auto; \
|
|
186
|
+
}`;
|
|
187
|
+
_componentRoot.append(s);
|
|
188
|
+
_componentRoot.classList.add(className);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
done() {
|
|
193
|
+
this.cssGrid();
|
|
194
|
+
|
|
195
|
+
const componentInstance = this.component;
|
|
196
|
+
logger.debug("ListController DONE");
|
|
197
|
+
const serviceClass = this.component.body.getAttribute("serviceClass");
|
|
198
|
+
if (serviceClass != null) {
|
|
199
|
+
let offset;
|
|
200
|
+
let limit;
|
|
201
|
+
let paginateIn = componentInstance.body.getAttribute("paginate-in");
|
|
202
|
+
paginateIn = (paginateIn !== null) ? (paginateIn) : ("client");
|
|
203
|
+
if (paginateIn === "server") {
|
|
204
|
+
let page = componentInstance.body.getAttribute("page-number");
|
|
205
|
+
page = (isNaN(page) || page === null) ? (-1) : (page);
|
|
206
|
+
let pagesNumber;
|
|
207
|
+
if (page !== -1) {
|
|
208
|
+
const serverDataCount = (this.component.body.getAttribute("server-data-count") !== null) ? (this.component.body.getAttribute("server-data-count")) : (1);
|
|
209
|
+
pagesNumber = this.component.body.getAttribute("total-pages");
|
|
210
|
+
pagesNumber = (isNaN(pagesNumber)) ? (1) : (pagesNumber);
|
|
211
|
+
offset = this.getPageIndex(page, pagesNumber, serverDataCount)[0];
|
|
212
|
+
limit = this.getPageIndex(page, pagesNumber, serverDataCount)[1];
|
|
213
|
+
// send params in jsonrpc 2.0 style
|
|
214
|
+
componentInstance.serviceData = (typeof componentInstance.serviceData !== "undefined") ? (componentInstance.serviceData) : ({});
|
|
215
|
+
componentInstance.serviceData.params = (typeof componentInstance.serviceData.params !== "undefined") ? (componentInstance.serviceData.params) : ({});
|
|
216
|
+
componentInstance.serviceData.params.offset = offset;
|
|
217
|
+
componentInstance.serviceData.params.limit = limit;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
serviceLoader(New(ClassFactory(serviceClass), {
|
|
222
|
+
data: componentInstance.serviceData
|
|
223
|
+
}), false).then(
|
|
224
|
+
(successfulResponse: { service: any }) => {
|
|
225
|
+
// This will show the service response as a plain text
|
|
226
|
+
logger.debug("DONE SERVICE COMPONENT");
|
|
227
|
+
successfulResponse.service.JSONresponse = JSON.parse(successfulResponse.service.template);
|
|
228
|
+
if (typeof successfulResponse.service.JSONresponse.result !== "undefined") {
|
|
229
|
+
logger.debug(_DataStringify(successfulResponse.service.JSONresponse.result));
|
|
230
|
+
componentInstance.data = successfulResponse.service.JSONresponse.result;
|
|
231
|
+
} else {
|
|
232
|
+
componentInstance.data = successfulResponse.service.JSONresponse;
|
|
233
|
+
}
|
|
234
|
+
this.addSubcomponents();
|
|
235
|
+
|
|
236
|
+
},
|
|
237
|
+
(failedResponse: string) => {
|
|
238
|
+
logger.debug(failedResponse);
|
|
239
|
+
}).catch((e: any) => {
|
|
240
|
+
logger.debug("Something went wrong when calling the service from: " + serviceClass);
|
|
241
|
+
logger.debug(e.message);
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
Package("org.qcobjects.controllers.list", [
|
|
253
|
+
ListController
|
|
254
|
+
|
|
255
|
+
]);
|
|
256
|
+
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QCObjects SDK 2.5
|
|
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
|
+
import { ClassFactory, Controller, New, Package, logger, Component } from "qcobjects";
|
|
27
|
+
|
|
28
|
+
type SliderParams = {
|
|
29
|
+
dependencies: any[];
|
|
30
|
+
component: Component;
|
|
31
|
+
duration: number;
|
|
32
|
+
slideIndex: number;
|
|
33
|
+
interval: number | null;
|
|
34
|
+
sliderHandlerName: string | null;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export class SliderController extends Controller {
|
|
38
|
+
slideIndex = 0;
|
|
39
|
+
duration = 7100;
|
|
40
|
+
interval: any = null;
|
|
41
|
+
sliderHandlerName = "";
|
|
42
|
+
_componentRoot: HTMLElement | ShadowRoot | undefined;
|
|
43
|
+
component: Component;
|
|
44
|
+
|
|
45
|
+
constructor({ component, dependencies = [], duration = 7100, slideIndex = 0, interval = null, sliderHandlerName = null }: SliderParams) {
|
|
46
|
+
super({ component, dependencies, duration, slideIndex, interval, sliderHandlerName } as SliderParams);
|
|
47
|
+
this.component = component;
|
|
48
|
+
this._componentRoot = (component.shadowed) ? (component.shadowRoot) : (component.body);
|
|
49
|
+
this.sliderHandlerName = "slider_" + this.component.__instanceID.toString();
|
|
50
|
+
(global as any).set(this.sliderHandlerName, this);
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
stop() {
|
|
56
|
+
if (this.interval != null) {
|
|
57
|
+
clearInterval(this.interval);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
plusSlidesAndStop(n: number) {
|
|
62
|
+
this.stop();
|
|
63
|
+
this.plusSlides(n);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
plusSlides(n: number) {
|
|
67
|
+
this.showSlides(this.slideIndex += n);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
currentSlide(n: number) {
|
|
71
|
+
this.stop();
|
|
72
|
+
this.showSlides(this.slideIndex = n);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
automate() {
|
|
76
|
+
this.interval = setInterval(() => {
|
|
77
|
+
this.plusSlides(1);
|
|
78
|
+
}, this.duration);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
showSlides(n: number) {
|
|
82
|
+
const slides = (this._componentRoot as any)?.subelements(".qcoSlides");
|
|
83
|
+
const dots = (this._componentRoot as any)?.subelements(".qcoSlider__dots--dot");
|
|
84
|
+
|
|
85
|
+
if (n > (slides.length - 1)) {
|
|
86
|
+
this.slideIndex = 0;
|
|
87
|
+
}
|
|
88
|
+
if (n < 0) {
|
|
89
|
+
this.slideIndex = 0;
|
|
90
|
+
}
|
|
91
|
+
slides.filter((slide: any, index: number) => { return index !== this.slideIndex; }).map((slide: any) => {
|
|
92
|
+
|
|
93
|
+
return (New(ClassFactory("Fade"), {})).apply(slide, 1, 0);
|
|
94
|
+
});
|
|
95
|
+
// eslint-disable-next-line no-unused-vars
|
|
96
|
+
dots.filter((dot: any, index: number) => { return index !== this.slideIndex; }).map((dot: { classList: { remove: (arg0: string) => any; }; }) => {
|
|
97
|
+
|
|
98
|
+
return dot.classList.remove("active");
|
|
99
|
+
});
|
|
100
|
+
try {
|
|
101
|
+
dots[this.slideIndex].classList.add("active");
|
|
102
|
+
} catch (e: any) {
|
|
103
|
+
logger.debug(`Something went wrong when trying to activate a slide: ${this.slideIndex} - ${e.message}`);
|
|
104
|
+
}
|
|
105
|
+
setTimeout(() => {
|
|
106
|
+
slides.filter((slide: any, index: number) => { return index !== this.slideIndex; }).map((slide: { style: { display: string; }; }) => {
|
|
107
|
+
slide.style.display = "none";
|
|
108
|
+
return slide.style.display;
|
|
109
|
+
});
|
|
110
|
+
try {
|
|
111
|
+
slides[this.slideIndex].style.display = "block";
|
|
112
|
+
(New(ClassFactory("Fade"), {})).apply(slides[this.slideIndex], 0, 1);
|
|
113
|
+
|
|
114
|
+
} catch (e: any) {
|
|
115
|
+
logger.debug(`Something went wrong when trying to show a slide: ${this.slideIndex} - ${e.message}`);
|
|
116
|
+
}
|
|
117
|
+
}, 700);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
fillDots() {
|
|
121
|
+
const slides = (this._componentRoot as any)?.subelements(".qcoSlides");
|
|
122
|
+
slides.map((slide: HTMLElement, index: number) => {
|
|
123
|
+
const dotHTML = document.createElement("span");
|
|
124
|
+
const dotContent = `<span class="qcoSlider__dots--dot" onclick="global.get('${this.sliderHandlerName}').currentSlide(${index})"></span>`;
|
|
125
|
+
dotHTML.innerHTML = dotContent;
|
|
126
|
+
|
|
127
|
+
return (this._componentRoot as any)?.subelements(".qcoSlider__dots")[0].append(dotHTML);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
done() {
|
|
133
|
+
const slides = (this._componentRoot as any)?.subelements(".qcoSlides");
|
|
134
|
+
slides.filter((slide: HTMLElement, index: number) => { return index !== this.slideIndex; }).map((slide: { style: { display: string; }; }) => {
|
|
135
|
+
slide.style.display = "none";
|
|
136
|
+
return slide.style.display;
|
|
137
|
+
});
|
|
138
|
+
setTimeout(() => {
|
|
139
|
+
this.fillDots();
|
|
140
|
+
this.slideIndex = 0;
|
|
141
|
+
this.showSlides(this.slideIndex);
|
|
142
|
+
this.automate();
|
|
143
|
+
}, 3000);
|
|
144
|
+
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
Package("org.qcobjects.controllers.slider", [
|
|
151
|
+
|
|
152
|
+
SliderController
|
|
153
|
+
]);
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QCObjects SDK 2.5
|
|
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
|
+
import { CONFIG, Controller, New, Package, SourceCSS, SourceJS } from "qcobjects";
|
|
27
|
+
declare let SwaggerUIBundle: any;
|
|
28
|
+
declare let SwaggerUIStandalonePreset: any;
|
|
29
|
+
export class SwaggerUIController extends Controller {
|
|
30
|
+
component: any;
|
|
31
|
+
dependencies: any;
|
|
32
|
+
|
|
33
|
+
startSwaggerUI() {
|
|
34
|
+
// Begin Swagger UI call region
|
|
35
|
+
if (typeof SwaggerUIBundle !== "undefined") {
|
|
36
|
+
|
|
37
|
+
const ui = SwaggerUIBundle({
|
|
38
|
+
url: CONFIG.get("swagger-ui-url", "https://petstore.swagger.io/v2/swagger.json"),
|
|
39
|
+
dom_id: "#" + CONFIG.get("swagger-ui-dom_id", "swagger-ui"),
|
|
40
|
+
deepLinking: true,
|
|
41
|
+
presets: [
|
|
42
|
+
SwaggerUIBundle.presets.apis,
|
|
43
|
+
SwaggerUIStandalonePreset
|
|
44
|
+
],
|
|
45
|
+
plugins: [
|
|
46
|
+
SwaggerUIBundle.plugins.DownloadUrl
|
|
47
|
+
],
|
|
48
|
+
layout: "StandaloneLayout"
|
|
49
|
+
});
|
|
50
|
+
// End Swagger UI call region
|
|
51
|
+
(window as any).ui = ui;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
done() {
|
|
57
|
+
this.component.body.innerHTML = "<div id=\"" + CONFIG.get("swagger-ui-dom_id", "swagger-ui") + "\"></div>";
|
|
58
|
+
const swaggerUIPackagePath = CONFIG.get("swagger-ui-package-path", "node_modules/swagger-ui-dist/");
|
|
59
|
+
|
|
60
|
+
this.dependencies?.push(New(SourceJS, {
|
|
61
|
+
url: swaggerUIPackagePath + "swagger-ui-standalone-preset.js",
|
|
62
|
+
external: CONFIG.get("swagger-ui-external", false)
|
|
63
|
+
}));
|
|
64
|
+
this.dependencies?.push(New(SourceCSS, {
|
|
65
|
+
url: swaggerUIPackagePath + "swagger-ui.css",
|
|
66
|
+
external: CONFIG.get("swagger-ui-external", false)
|
|
67
|
+
}));
|
|
68
|
+
this.dependencies?.push(New(SourceJS, {
|
|
69
|
+
url: swaggerUIPackagePath + "swagger-ui-bundle.js",
|
|
70
|
+
external: CONFIG.get("swagger-ui-external", false),
|
|
71
|
+
done: () => {
|
|
72
|
+
this.startSwaggerUI();
|
|
73
|
+
}
|
|
74
|
+
}));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
Package("org.qcobjects.controllers.swagger", [
|
|
80
|
+
SwaggerUIController
|
|
81
|
+
|
|
82
|
+
]);
|
|
83
|
+
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { Controller, Package } from "qcobjects";
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
|
-
* QCObjects SDK 2.
|
|
2
|
+
* QCObjects SDK 2.5
|
|
5
3
|
* ________________
|
|
6
4
|
*
|
|
7
5
|
* Author: Jean Machuca <correojean@gmail.com>
|
|
@@ -24,14 +22,14 @@ import { Controller, Package } from "qcobjects";
|
|
|
24
22
|
* Everyone is permitted to copy and distribute verbatim copies of this
|
|
25
23
|
* license document, but changing it is not allowed.
|
|
26
24
|
*/
|
|
27
|
-
(function() {
|
|
28
25
|
"use strict";
|
|
29
|
-
Package
|
|
26
|
+
import { Controller, Package } from "qcobjects";
|
|
30
27
|
|
|
31
|
-
|
|
28
|
+
export class GenericController extends Controller {
|
|
32
29
|
|
|
33
|
-
|
|
30
|
+
}
|
|
34
31
|
|
|
35
|
-
|
|
32
|
+
Package("org.qcobjects.controllers", [
|
|
33
|
+
GenericController
|
|
36
34
|
|
|
37
|
-
|
|
35
|
+
]);
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Package, Effect, logger } from "qcobjects";
|
|
2
|
+
|
|
3
|
+
export type MoveElement = HTMLElement & {
|
|
4
|
+
width?:number;
|
|
5
|
+
height?:number;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export class Fade extends Effect {
|
|
9
|
+
duration = 1000;
|
|
10
|
+
static duration: any;
|
|
11
|
+
|
|
12
|
+
constructor(o?:{duration:number}){
|
|
13
|
+
super(o);
|
|
14
|
+
this.duration = o?.duration as number;
|
|
15
|
+
}
|
|
16
|
+
apply(element:HTMLElement, alphaFrom:number, alphaTo:number) {
|
|
17
|
+
const da = alphaTo - alphaFrom;
|
|
18
|
+
super.animate({
|
|
19
|
+
duration: this.duration,
|
|
20
|
+
timing(timeFraction: number) {
|
|
21
|
+
|
|
22
|
+
return timeFraction;
|
|
23
|
+
},
|
|
24
|
+
draw(progress: number) {
|
|
25
|
+
logger.debug("animation progress: " + progress.toString());
|
|
26
|
+
const alpha = alphaFrom + (progress * da / 100);
|
|
27
|
+
logger.debug("alpha: " + alpha.toString());
|
|
28
|
+
element.style.opacity = alpha.toString();
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static apply(element:HTMLElement, alphaFrom:number, alphaTo:number) {
|
|
35
|
+
const da = alphaTo - alphaFrom;
|
|
36
|
+
super.animate({
|
|
37
|
+
duration: this.duration,
|
|
38
|
+
timing(timeFraction: number) {
|
|
39
|
+
|
|
40
|
+
return timeFraction;
|
|
41
|
+
},
|
|
42
|
+
draw(progress: number) {
|
|
43
|
+
logger.debug("animation progress: " + progress.toString());
|
|
44
|
+
const alpha = alphaFrom + (progress * da / 100);
|
|
45
|
+
logger.debug("alpha: " + alpha.toString());
|
|
46
|
+
element.style.opacity = alpha.toString();
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export class Move extends Effect {
|
|
53
|
+
duration = 1000;
|
|
54
|
+
static duration: any;
|
|
55
|
+
|
|
56
|
+
static apply(element:MoveElement, xfrom:number, yfrom:number, xto:number, yto:number) {
|
|
57
|
+
const dx = xto - xfrom;
|
|
58
|
+
const dy = yto - yfrom;
|
|
59
|
+
element.style.transform = "translate(" + xfrom + "px," + yfrom + "px)";
|
|
60
|
+
super.animate({
|
|
61
|
+
duration: this.duration,
|
|
62
|
+
timing(timeFraction: number) {
|
|
63
|
+
|
|
64
|
+
return timeFraction;
|
|
65
|
+
},
|
|
66
|
+
draw(progress: number) {
|
|
67
|
+
logger.debug("animation progress: " + progress.toString());
|
|
68
|
+
const y = yfrom + (progress * dy / 100);
|
|
69
|
+
const x = xfrom + (progress * dx / 100);
|
|
70
|
+
logger.debug("x: " + x.toString() + " y:" + y.toString());
|
|
71
|
+
element.style.transform = "translate(" + x + "px," + y + "px)";
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
Package("org.qcobjects.effects.base", [
|
|
79
|
+
Fade,
|
|
80
|
+
Move
|
|
81
|
+
]);
|