@sankhyalabs/sankhyablocks 1.1.28 → 1.3.1
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/LICENSE +21 -21
- package/README.md +75 -75
- package/dist/cjs/index-4720dab8.js +735 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/sankhyablocks.cjs.js +2 -2
- package/dist/cjs/snk-application.cjs.entry.js +668 -653
- package/dist/collection/collection-manifest.json +5 -34
- package/dist/collection/components/snk-application/snk-application.css +5 -5
- package/dist/collection/components/snk-application/snk-application.js +492 -492
- package/dist/collection/index.js +1 -1
- package/dist/collection/lib/http/data-fetcher/DataFetcher.js +158 -158
- package/dist/collection/lib/http/data-fetcher/fetchers/application-config-fetcher.js +23 -23
- package/dist/collection/lib/http/data-fetcher/fetchers/dataunit-fetcher.js +188 -188
- package/dist/collection/lib/http/data-fetcher/fetchers/form-config-fetcher.js +25 -25
- package/dist/collection/lib/http/data-fetcher/fetchers/grid-config-fetcher.js +2 -2
- package/dist/collection/lib/http/data-fetcher/fetchers/parameters-fecher.js +59 -59
- package/dist/collection/lib/http/data-fetcher/fetchers/resource-fetcher.js +30 -30
- package/dist/collection/lib/http/data-fetcher/state/LoadStateManager.js +66 -66
- package/dist/collection/lib/utils/pesquisa.js +16 -16
- package/dist/collection/lib/utils/urlutils.js +23 -23
- package/dist/collection/lib/workspace/workspace.js +7 -7
- package/dist/components/snk-application.js +655 -640
- package/dist/esm/index-72d4e2e0.js +709 -0
- package/dist/esm/loader.js +2 -2
- package/dist/esm/polyfills/core-js.js +0 -0
- package/dist/esm/polyfills/dom.js +0 -0
- package/dist/esm/polyfills/es5-html-element.js +0 -0
- package/dist/esm/polyfills/index.js +0 -0
- package/dist/esm/polyfills/system.js +0 -0
- package/dist/esm/sankhyablocks.js +2 -2
- package/dist/esm/snk-application.entry.js +626 -611
- package/dist/sankhyablocks/p-5d8ddbda.entry.js +57 -0
- package/dist/sankhyablocks/p-a33afc3b.js +2 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-application/snk-application.d.ts +44 -44
- package/dist/types/index.d.ts +1 -1
- package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +15 -15
- package/dist/types/lib/http/data-fetcher/fetchers/application-config-fetcher.d.ts +6 -6
- package/dist/types/lib/http/data-fetcher/fetchers/dataunit-fetcher.d.ts +12 -12
- package/dist/types/lib/http/data-fetcher/fetchers/form-config-fetcher.d.ts +5 -5
- package/dist/types/lib/http/data-fetcher/fetchers/grid-config-fetcher.d.ts +2 -2
- package/dist/types/lib/http/data-fetcher/fetchers/parameters-fecher.d.ts +13 -13
- package/dist/types/lib/http/data-fetcher/fetchers/resource-fetcher.d.ts +6 -6
- package/dist/types/lib/http/data-fetcher/state/LoadStateManager.d.ts +23 -23
- package/dist/types/lib/utils/pesquisa.d.ts +2 -2
- package/dist/types/lib/utils/urlutils.d.ts +4 -4
- package/dist/types/lib/workspace/workspace.d.ts +4 -4
- package/package.json +63 -52
- package/react/.keepfolder +1 -0
- package/react/components.d.ts +3 -32
- package/react/components.js +5 -34
- package/react/components.js.map +1 -1
- package/react/react-component-lib/createComponent.d.ts +10 -10
- package/react/react-component-lib/createComponent.js +58 -74
- package/react/react-component-lib/createComponent.js.map +1 -1
- package/react/react-component-lib/createOverlayComponent.d.ts +20 -21
- package/react/react-component-lib/createOverlayComponent.js +88 -108
- package/react/react-component-lib/createOverlayComponent.js.map +1 -1
- package/react/react-component-lib/index.d.ts +2 -2
- package/react/react-component-lib/index.js +2 -2
- package/react/react-component-lib/interfaces.d.ts +29 -29
- package/react/react-component-lib/utils/attachProps.d.ts +12 -12
- package/react/react-component-lib/utils/attachProps.js +95 -97
- package/react/react-component-lib/utils/attachProps.js.map +1 -1
- package/react/react-component-lib/utils/case.d.ts +2 -2
- package/react/react-component-lib/utils/case.js +6 -6
- package/react/react-component-lib/utils/dev.d.ts +2 -2
- package/react/react-component-lib/utils/dev.js +12 -12
- package/react/react-component-lib/utils/index.d.ts +7 -10
- package/react/react-component-lib/utils/index.js +20 -33
- package/react/react-component-lib/utils/index.js.map +1 -1
- package/dist/cjs/ApplicationUtils-05b74ee9.js +0 -39
- package/dist/cjs/AssetsUtils-7e3c38f9.js +0 -24
- package/dist/cjs/CSSVarsUtils-75ca9c64.js +0 -19
- package/dist/cjs/_commonjsHelpers-537d719a.js +0 -20
- package/dist/cjs/ez-action-chip.cjs.entry.js +0 -27
- package/dist/cjs/ez-application.cjs.entry.js +0 -26
- package/dist/cjs/ez-button_4.cjs.entry.js +0 -660
- package/dist/cjs/ez-calendar.cjs.entry.js +0 -223
- package/dist/cjs/ez-collapsible-box.cjs.entry.js +0 -47
- package/dist/cjs/ez-combo-box.cjs.entry.js +0 -278
- package/dist/cjs/ez-date-input.cjs.entry.js +0 -102
- package/dist/cjs/ez-date-time-input.cjs.entry.js +0 -145
- package/dist/cjs/ez-dialog.cjs.entry.js +0 -89
- package/dist/cjs/ez-form.cjs.entry.js +0 -785
- package/dist/cjs/ez-grid.cjs.entry.js +0 -110485
- package/dist/cjs/ez-icon.cjs.entry.js +0 -41
- package/dist/cjs/ez-label-chip.cjs.entry.js +0 -104
- package/dist/cjs/ez-modal_2.cjs.entry.js +0 -316
- package/dist/cjs/ez-number-input.cjs.entry.js +0 -86
- package/dist/cjs/ez-popover.cjs.entry.js +0 -120
- package/dist/cjs/ez-popup.cjs.entry.js +0 -48
- package/dist/cjs/ez-search.cjs.entry.js +0 -64
- package/dist/cjs/ez-tabselector.cjs.entry.js +0 -198
- package/dist/cjs/ez-text-area.cjs.entry.js +0 -114
- package/dist/cjs/ez-text-input.cjs.entry.js +0 -201
- package/dist/cjs/ez-time-input.cjs.entry.js +0 -118
- package/dist/cjs/ez-toast.cjs.entry.js +0 -44
- package/dist/cjs/ez-upload.cjs.entry.js +0 -356
- package/dist/cjs/index-682c98b2.js +0 -1771
- package/dist/cjs/test-du.cjs.entry.js +0 -76
- package/dist/components/ApplicationUtils.js +0 -37
- package/dist/components/AssetsUtils.js +0 -22
- package/dist/components/CSSVarsUtils.js +0 -17
- package/dist/components/_commonjsHelpers.js +0 -17
- package/dist/components/ez-action-chip.js +0 -44
- package/dist/components/ez-application.js +0 -39
- package/dist/components/ez-button.js +0 -6
- package/dist/components/ez-button2.js +0 -105
- package/dist/components/ez-calendar.js +0 -6
- package/dist/components/ez-calendar2.js +0 -242
- package/dist/components/ez-check.js +0 -6
- package/dist/components/ez-check2.js +0 -94
- package/dist/components/ez-collapsible-box.js +0 -67
- package/dist/components/ez-combo-box.js +0 -6
- package/dist/components/ez-combo-box2.js +0 -311
- package/dist/components/ez-date-input.js +0 -135
- package/dist/components/ez-date-time-input.js +0 -179
- package/dist/components/ez-dialog.js +0 -124
- package/dist/components/ez-form.js +0 -6
- package/dist/components/ez-form2.js +0 -807
- package/dist/components/ez-grid.js +0 -110576
- package/dist/components/ez-icon.js +0 -6
- package/dist/components/ez-icon2.js +0 -56
- package/dist/components/ez-label-chip.js +0 -125
- package/dist/components/ez-list.js +0 -6
- package/dist/components/ez-list2.js +0 -523
- package/dist/components/ez-modal.js +0 -6
- package/dist/components/ez-modal2.js +0 -82
- package/dist/components/ez-number-input.js +0 -115
- package/dist/components/ez-popover.js +0 -145
- package/dist/components/ez-popup.js +0 -67
- package/dist/components/ez-search.js +0 -100
- package/dist/components/ez-tabselector.js +0 -6
- package/dist/components/ez-tabselector2.js +0 -213
- package/dist/components/ez-text-area.js +0 -137
- package/dist/components/ez-text-input.js +0 -6
- package/dist/components/ez-text-input2.js +0 -223
- package/dist/components/ez-time-input.js +0 -153
- package/dist/components/ez-toast.js +0 -64
- package/dist/components/ez-upload.js +0 -382
- package/dist/components/grid-config.js +0 -6
- package/dist/components/grid-config2.js +0 -318
- package/dist/components/select-box.js +0 -6
- package/dist/components/select-box2.js +0 -47
- package/dist/components/test-du.js +0 -101
- package/dist/esm/ApplicationUtils-e0b6d857.js +0 -37
- package/dist/esm/AssetsUtils-6e6624dc.js +0 -22
- package/dist/esm/CSSVarsUtils-0787c3f3.js +0 -17
- package/dist/esm/_commonjsHelpers-9943807e.js +0 -17
- package/dist/esm/ez-action-chip.entry.js +0 -23
- package/dist/esm/ez-application.entry.js +0 -22
- package/dist/esm/ez-button_4.entry.js +0 -653
- package/dist/esm/ez-calendar.entry.js +0 -219
- package/dist/esm/ez-collapsible-box.entry.js +0 -43
- package/dist/esm/ez-combo-box.entry.js +0 -274
- package/dist/esm/ez-date-input.entry.js +0 -98
- package/dist/esm/ez-date-time-input.entry.js +0 -141
- package/dist/esm/ez-dialog.entry.js +0 -85
- package/dist/esm/ez-form.entry.js +0 -781
- package/dist/esm/ez-grid.entry.js +0 -110481
- package/dist/esm/ez-icon.entry.js +0 -37
- package/dist/esm/ez-label-chip.entry.js +0 -100
- package/dist/esm/ez-modal_2.entry.js +0 -311
- package/dist/esm/ez-number-input.entry.js +0 -82
- package/dist/esm/ez-popover.entry.js +0 -116
- package/dist/esm/ez-popup.entry.js +0 -44
- package/dist/esm/ez-search.entry.js +0 -60
- package/dist/esm/ez-tabselector.entry.js +0 -194
- package/dist/esm/ez-text-area.entry.js +0 -110
- package/dist/esm/ez-text-input.entry.js +0 -197
- package/dist/esm/ez-time-input.entry.js +0 -114
- package/dist/esm/ez-toast.entry.js +0 -40
- package/dist/esm/ez-upload.entry.js +0 -352
- package/dist/esm/index-35088a3f.js +0 -1740
- package/dist/esm/test-du.entry.js +0 -72
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-action-chip/ez-action-chip.css +0 -67
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-application/ez-application.css +0 -3
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-button/ez-button.css +0 -180
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-calendar/ez-calendar.css +0 -319
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-check/ez-check.css +0 -327
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-collapsible-box/ez-collapsible-box.css +0 -162
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-combo-box/ez-combo-box.css +0 -217
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-date-input/ez-date-input.css +0 -49
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-date-time-input/ez-date-time-input.css +0 -44
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-dialog/ez-dialog.css +0 -527
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-form/ez-form.css +0 -5
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-grid/ez-grid.css +0 -31
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-grid/subcomponents/gridconfig/grid-config.css +0 -129
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-grid/subcomponents/select-box/select-box.css +0 -10
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-icon/ez-icon.css +0 -176
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-label-chip/ez-label-chip.css +0 -139
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-list/ez-list.css +0 -335
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-modal/ez-modal.css +0 -358
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-number-input/ez-number-input.css +0 -4
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-popover/ez-popover.css +0 -44
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-popup/ez-popup.css +0 -405
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-search/ez-search.css +0 -3
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-tabselector/ez-tabselector.css +0 -138
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-text-area/ez-text-area.css +0 -165
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-text-input/ez-text-input.css +0 -196
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-time-input/ez-time-input.css +0 -10
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-toast/ez-toast.css +0 -127
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-upload/ez-upload.css +0 -568
- package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/test-du/test-du.css +0 -3
- package/dist/sankhyablocks/p-0183d259.entry.js +0 -1
- package/dist/sankhyablocks/p-01f23a70.entry.js +0 -1
- package/dist/sankhyablocks/p-07c32f68.entry.js +0 -1
- package/dist/sankhyablocks/p-0f90499d.entry.js +0 -1
- package/dist/sankhyablocks/p-105724a3.entry.js +0 -1
- package/dist/sankhyablocks/p-112455b1.js +0 -1
- package/dist/sankhyablocks/p-2ac02d48.entry.js +0 -1
- package/dist/sankhyablocks/p-35364a97.entry.js +0 -1
- package/dist/sankhyablocks/p-3f6aa9a7.entry.js +0 -1
- package/dist/sankhyablocks/p-4811bc0a.entry.js +0 -369
- package/dist/sankhyablocks/p-5f9af495.entry.js +0 -1
- package/dist/sankhyablocks/p-60967cf0.js +0 -1
- package/dist/sankhyablocks/p-70ad6c16.entry.js +0 -1
- package/dist/sankhyablocks/p-710bfffe.entry.js +0 -1
- package/dist/sankhyablocks/p-73397a0f.entry.js +0 -57
- package/dist/sankhyablocks/p-811b4b9d.js +0 -1
- package/dist/sankhyablocks/p-813fe4f7.js +0 -1
- package/dist/sankhyablocks/p-85a9446b.js +0 -2
- package/dist/sankhyablocks/p-89a1100f.entry.js +0 -1
- package/dist/sankhyablocks/p-8b543003.entry.js +0 -1
- package/dist/sankhyablocks/p-9750632b.entry.js +0 -1
- package/dist/sankhyablocks/p-a96272f7.entry.js +0 -1
- package/dist/sankhyablocks/p-ac8842e5.entry.js +0 -1
- package/dist/sankhyablocks/p-ba64cc41.entry.js +0 -1
- package/dist/sankhyablocks/p-c1ede043.entry.js +0 -1
- package/dist/sankhyablocks/p-d90ebb85.entry.js +0 -1
- package/dist/sankhyablocks/p-e5355a29.entry.js +0 -1
- package/dist/sankhyablocks/p-ef04b633.entry.js +0 -1
- package/dist/sankhyablocks/p-f6db07fb.entry.js +0 -1
- package/dist/sankhyablocks/p-f80cabc7.entry.js +0 -1
- package/dist/sankhyablocks/p-fcd9bd92.entry.js +0 -1
|
@@ -1,8 +1,23 @@
|
|
|
1
|
-
import { r as registerInstance, c as createEvent, h } from './index-
|
|
1
|
+
import { r as registerInstance, c as createEvent, h } from './index-72d4e2e0.js';
|
|
2
2
|
import { DataUnit, ChangeOperation, DateUtils, StringUtils, ApplicationContext } from '@sankhyalabs/core';
|
|
3
|
-
import { c as createCommonjsModule, a as commonjsGlobal } from './_commonjsHelpers-9943807e.js';
|
|
4
3
|
import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
|
|
5
4
|
|
|
5
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
6
|
+
|
|
7
|
+
function createCommonjsModule(fn, basedir, module) {
|
|
8
|
+
return module = {
|
|
9
|
+
path: basedir,
|
|
10
|
+
exports: {},
|
|
11
|
+
require: function (path, base) {
|
|
12
|
+
return commonjsRequire();
|
|
13
|
+
}
|
|
14
|
+
}, fn(module, module.exports), module.exports;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function commonjsRequire () {
|
|
18
|
+
throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
|
|
19
|
+
}
|
|
20
|
+
|
|
6
21
|
var browserPonyfill = createCommonjsModule(function (module, exports) {
|
|
7
22
|
var global = typeof self !== 'undefined' ? self : commonjsGlobal;
|
|
8
23
|
var __self__ = (function () {
|
|
@@ -6414,633 +6429,633 @@ Object.defineProperty(exports, "GraphQLWebSocketClient", { enumerable: true, get
|
|
|
6414
6429
|
//# sourceMappingURL=index.js.map
|
|
6415
6430
|
});
|
|
6416
6431
|
|
|
6417
|
-
class HttpFetcher {
|
|
6418
|
-
constructor() {
|
|
6419
|
-
this.watingRequestsById = new Map();
|
|
6420
|
-
}
|
|
6421
|
-
static get() {
|
|
6422
|
-
if (!HttpFetcher.instance) {
|
|
6423
|
-
HttpFetcher.instance = new HttpFetcher();
|
|
6424
|
-
const application = document.querySelector(this.appTagName);
|
|
6425
|
-
if (application === null) {
|
|
6426
|
-
HttpFetcher.instance.resume();
|
|
6427
|
-
}
|
|
6428
|
-
else {
|
|
6429
|
-
application.addEventListener('applicationLoading', () => HttpFetcher.instance.pause());
|
|
6430
|
-
application.addEventListener('applicationLoaded', () => HttpFetcher.instance.resume());
|
|
6431
|
-
}
|
|
6432
|
-
}
|
|
6433
|
-
return this.instance;
|
|
6434
|
-
}
|
|
6435
|
-
async callGraphQL(req) {
|
|
6436
|
-
var _a;
|
|
6437
|
-
const reqKey = this.getReqKey(req);
|
|
6438
|
-
req.queryID = reqKey;
|
|
6439
|
-
req.values.queryID = reqKey;
|
|
6440
|
-
if (this.ready) {
|
|
6441
|
-
return new Promise(async (resolve, reject) => {
|
|
6442
|
-
let query = this.getQueryTemplate(req);
|
|
6443
|
-
const res = await this.fecthGrapql([{ document: query, variables: req.values }]);
|
|
6444
|
-
if (res.errors.length > 0) {
|
|
6445
|
-
reject(res);
|
|
6446
|
-
}
|
|
6447
|
-
else {
|
|
6448
|
-
//resolve(res);
|
|
6449
|
-
//FIXME: Precisamos trabalhar melhor a resposta, quem chamou
|
|
6450
|
-
//a API não pode ficar responsavel por desempacotar... fiz uma
|
|
6451
|
-
//gambiarra aqui...
|
|
6452
|
-
resolve(res.data[0][reqKey]);
|
|
6453
|
-
}
|
|
6454
|
-
});
|
|
6455
|
-
}
|
|
6456
|
-
else {
|
|
6457
|
-
if (!this.watingRequestsById.has(reqKey)) {
|
|
6458
|
-
this.watingRequestsById.set(reqKey, new WaitingRequest(req));
|
|
6459
|
-
}
|
|
6460
|
-
return (_a = this.getWatingRequest(reqKey)) === null || _a === void 0 ? void 0 : _a.promise;
|
|
6461
|
-
}
|
|
6462
|
-
}
|
|
6463
|
-
getReqKey(req) {
|
|
6464
|
-
return window.btoa(this.hashCode(`${req.query}${JSON.stringify(req.values || "")}`)).replace(/=/g, "");
|
|
6465
|
-
}
|
|
6466
|
-
getQueryTemplate(re) {
|
|
6467
|
-
return (re.query || "").replaceAll("$queryAlias$", re.queryID);
|
|
6468
|
-
}
|
|
6469
|
-
getWatingRequest(reqID) {
|
|
6470
|
-
return this.watingRequestsById.get(reqID);
|
|
6471
|
-
}
|
|
6472
|
-
pause() {
|
|
6473
|
-
this.ready = false;
|
|
6474
|
-
}
|
|
6475
|
-
async resume() {
|
|
6476
|
-
this.ready = true;
|
|
6477
|
-
if (this.watingRequestsById.size > 0) {
|
|
6478
|
-
const requestsBatch = [];
|
|
6479
|
-
this.watingRequestsById.forEach(async (waitingReq) => {
|
|
6480
|
-
let query = this.getQueryTemplate(waitingReq.request);
|
|
6481
|
-
requestsBatch.push({ document: query, variables: Object.assign({}, waitingReq.request.values) });
|
|
6482
|
-
});
|
|
6483
|
-
let res = undefined;
|
|
6484
|
-
let dataResponse = [];
|
|
6485
|
-
let errorsResponse = [];
|
|
6486
|
-
res = await this.fecthGrapql(requestsBatch);
|
|
6487
|
-
dataResponse = res.data;
|
|
6488
|
-
errorsResponse = res.errors;
|
|
6489
|
-
//Reject promises with errors from query
|
|
6490
|
-
errorsResponse.forEach((errorResponse) => {
|
|
6491
|
-
Object.entries(errorResponse).forEach(([_key, val]) => {
|
|
6492
|
-
var _a;
|
|
6493
|
-
(((_a = this.getWatingRequest(val.request.variables[val.index].queryID)) === null || _a === void 0 ? void 0 : _a.reject) || Promise.reject)(val);
|
|
6494
|
-
});
|
|
6495
|
-
});
|
|
6496
|
-
//Resolve promises with data from query
|
|
6497
|
-
dataResponse.forEach((data) => {
|
|
6498
|
-
Object.entries(data).forEach(([key, val]) => {
|
|
6499
|
-
var _a;
|
|
6500
|
-
(((_a = this.getWatingRequest(key)) === null || _a === void 0 ? void 0 : _a.resolve) || Promise.resolve)(val);
|
|
6501
|
-
});
|
|
6502
|
-
});
|
|
6503
|
-
this.watingRequestsById.clear();
|
|
6504
|
-
}
|
|
6505
|
-
}
|
|
6506
|
-
async fecthGrapql(request) {
|
|
6507
|
-
let res = undefined;
|
|
6508
|
-
let dataResponse = [];
|
|
6509
|
-
let errorsResponse = [];
|
|
6510
|
-
try {
|
|
6511
|
-
res = await dist.batchRequests('http://localhost:8082/', request);
|
|
6512
|
-
res.forEach((resItem) => {
|
|
6513
|
-
dataResponse.push(resItem.data);
|
|
6514
|
-
});
|
|
6515
|
-
}
|
|
6516
|
-
catch (err) {
|
|
6517
|
-
//TODO: Tratar erro quando não existir err.response
|
|
6518
|
-
res = err.response;
|
|
6519
|
-
const req = err.request;
|
|
6520
|
-
Object.entries(res).forEach(([key, val]) => {
|
|
6521
|
-
if (val.errors) {
|
|
6522
|
-
errorsResponse.push(val.errors.map((item) => {
|
|
6523
|
-
item.request = req;
|
|
6524
|
-
item.index = Number(key);
|
|
6525
|
-
return item;
|
|
6526
|
-
}));
|
|
6527
|
-
}
|
|
6528
|
-
else if (val.data) {
|
|
6529
|
-
dataResponse.push(val.data);
|
|
6530
|
-
}
|
|
6531
|
-
});
|
|
6532
|
-
}
|
|
6533
|
-
return { data: dataResponse, errors: errorsResponse };
|
|
6534
|
-
}
|
|
6535
|
-
//TODO: Mover este metodo para o @sankhyalabs/core classe string utils.
|
|
6536
|
-
hashCode(txt) {
|
|
6537
|
-
var hash = 0, i, chr;
|
|
6538
|
-
if (txt.length === 0)
|
|
6539
|
-
return hash.toString();
|
|
6540
|
-
for (i = 0; i < txt.length; i++) {
|
|
6541
|
-
chr = txt.charCodeAt(i);
|
|
6542
|
-
hash = ((hash << 5) - hash) + chr;
|
|
6543
|
-
hash |= 0; // Convert to 32bit integer
|
|
6544
|
-
}
|
|
6545
|
-
return hash.toString();
|
|
6546
|
-
}
|
|
6547
|
-
;
|
|
6548
|
-
}
|
|
6549
|
-
HttpFetcher.appTagName = "snk-application";
|
|
6550
|
-
class WaitingRequest {
|
|
6551
|
-
constructor(req) {
|
|
6552
|
-
this._resolve = () => { };
|
|
6553
|
-
this._reject = () => { };
|
|
6554
|
-
this._request = undefined;
|
|
6555
|
-
this._request = req;
|
|
6556
|
-
this._promisse = new Promise((resolve, reject) => {
|
|
6557
|
-
this._resolve = resolve;
|
|
6558
|
-
this._reject = reject;
|
|
6559
|
-
});
|
|
6560
|
-
}
|
|
6561
|
-
get resolve() {
|
|
6562
|
-
return this._resolve;
|
|
6563
|
-
}
|
|
6564
|
-
get reject() {
|
|
6565
|
-
return this._reject;
|
|
6566
|
-
}
|
|
6567
|
-
get promise() {
|
|
6568
|
-
return this._promisse;
|
|
6569
|
-
}
|
|
6570
|
-
get request() {
|
|
6571
|
-
return this._request;
|
|
6572
|
-
}
|
|
6432
|
+
class HttpFetcher {
|
|
6433
|
+
constructor() {
|
|
6434
|
+
this.watingRequestsById = new Map();
|
|
6435
|
+
}
|
|
6436
|
+
static get() {
|
|
6437
|
+
if (!HttpFetcher.instance) {
|
|
6438
|
+
HttpFetcher.instance = new HttpFetcher();
|
|
6439
|
+
const application = document.querySelector(this.appTagName);
|
|
6440
|
+
if (application === null) {
|
|
6441
|
+
HttpFetcher.instance.resume();
|
|
6442
|
+
}
|
|
6443
|
+
else {
|
|
6444
|
+
application.addEventListener('applicationLoading', () => HttpFetcher.instance.pause());
|
|
6445
|
+
application.addEventListener('applicationLoaded', () => HttpFetcher.instance.resume());
|
|
6446
|
+
}
|
|
6447
|
+
}
|
|
6448
|
+
return this.instance;
|
|
6449
|
+
}
|
|
6450
|
+
async callGraphQL(req) {
|
|
6451
|
+
var _a;
|
|
6452
|
+
const reqKey = this.getReqKey(req);
|
|
6453
|
+
req.queryID = reqKey;
|
|
6454
|
+
req.values.queryID = reqKey;
|
|
6455
|
+
if (this.ready) {
|
|
6456
|
+
return new Promise(async (resolve, reject) => {
|
|
6457
|
+
let query = this.getQueryTemplate(req);
|
|
6458
|
+
const res = await this.fecthGrapql([{ document: query, variables: req.values }]);
|
|
6459
|
+
if (res.errors.length > 0) {
|
|
6460
|
+
reject(res);
|
|
6461
|
+
}
|
|
6462
|
+
else {
|
|
6463
|
+
//resolve(res);
|
|
6464
|
+
//FIXME: Precisamos trabalhar melhor a resposta, quem chamou
|
|
6465
|
+
//a API não pode ficar responsavel por desempacotar... fiz uma
|
|
6466
|
+
//gambiarra aqui...
|
|
6467
|
+
resolve(res.data[0][reqKey]);
|
|
6468
|
+
}
|
|
6469
|
+
});
|
|
6470
|
+
}
|
|
6471
|
+
else {
|
|
6472
|
+
if (!this.watingRequestsById.has(reqKey)) {
|
|
6473
|
+
this.watingRequestsById.set(reqKey, new WaitingRequest(req));
|
|
6474
|
+
}
|
|
6475
|
+
return (_a = this.getWatingRequest(reqKey)) === null || _a === void 0 ? void 0 : _a.promise;
|
|
6476
|
+
}
|
|
6477
|
+
}
|
|
6478
|
+
getReqKey(req) {
|
|
6479
|
+
return window.btoa(this.hashCode(`${req.query}${JSON.stringify(req.values || "")}`)).replace(/=/g, "");
|
|
6480
|
+
}
|
|
6481
|
+
getQueryTemplate(re) {
|
|
6482
|
+
return (re.query || "").replaceAll("$queryAlias$", re.queryID);
|
|
6483
|
+
}
|
|
6484
|
+
getWatingRequest(reqID) {
|
|
6485
|
+
return this.watingRequestsById.get(reqID);
|
|
6486
|
+
}
|
|
6487
|
+
pause() {
|
|
6488
|
+
this.ready = false;
|
|
6489
|
+
}
|
|
6490
|
+
async resume() {
|
|
6491
|
+
this.ready = true;
|
|
6492
|
+
if (this.watingRequestsById.size > 0) {
|
|
6493
|
+
const requestsBatch = [];
|
|
6494
|
+
this.watingRequestsById.forEach(async (waitingReq) => {
|
|
6495
|
+
let query = this.getQueryTemplate(waitingReq.request);
|
|
6496
|
+
requestsBatch.push({ document: query, variables: Object.assign({}, waitingReq.request.values) });
|
|
6497
|
+
});
|
|
6498
|
+
let res = undefined;
|
|
6499
|
+
let dataResponse = [];
|
|
6500
|
+
let errorsResponse = [];
|
|
6501
|
+
res = await this.fecthGrapql(requestsBatch);
|
|
6502
|
+
dataResponse = res.data;
|
|
6503
|
+
errorsResponse = res.errors;
|
|
6504
|
+
//Reject promises with errors from query
|
|
6505
|
+
errorsResponse.forEach((errorResponse) => {
|
|
6506
|
+
Object.entries(errorResponse).forEach(([_key, val]) => {
|
|
6507
|
+
var _a;
|
|
6508
|
+
(((_a = this.getWatingRequest(val.request.variables[val.index].queryID)) === null || _a === void 0 ? void 0 : _a.reject) || Promise.reject)(val);
|
|
6509
|
+
});
|
|
6510
|
+
});
|
|
6511
|
+
//Resolve promises with data from query
|
|
6512
|
+
dataResponse.forEach((data) => {
|
|
6513
|
+
Object.entries(data).forEach(([key, val]) => {
|
|
6514
|
+
var _a;
|
|
6515
|
+
(((_a = this.getWatingRequest(key)) === null || _a === void 0 ? void 0 : _a.resolve) || Promise.resolve)(val);
|
|
6516
|
+
});
|
|
6517
|
+
});
|
|
6518
|
+
this.watingRequestsById.clear();
|
|
6519
|
+
}
|
|
6520
|
+
}
|
|
6521
|
+
async fecthGrapql(request) {
|
|
6522
|
+
let res = undefined;
|
|
6523
|
+
let dataResponse = [];
|
|
6524
|
+
let errorsResponse = [];
|
|
6525
|
+
try {
|
|
6526
|
+
res = await dist.batchRequests('http://localhost:8082/', request);
|
|
6527
|
+
res.forEach((resItem) => {
|
|
6528
|
+
dataResponse.push(resItem.data);
|
|
6529
|
+
});
|
|
6530
|
+
}
|
|
6531
|
+
catch (err) {
|
|
6532
|
+
//TODO: Tratar erro quando não existir err.response
|
|
6533
|
+
res = err.response;
|
|
6534
|
+
const req = err.request;
|
|
6535
|
+
Object.entries(res).forEach(([key, val]) => {
|
|
6536
|
+
if (val.errors) {
|
|
6537
|
+
errorsResponse.push(val.errors.map((item) => {
|
|
6538
|
+
item.request = req;
|
|
6539
|
+
item.index = Number(key);
|
|
6540
|
+
return item;
|
|
6541
|
+
}));
|
|
6542
|
+
}
|
|
6543
|
+
else if (val.data) {
|
|
6544
|
+
dataResponse.push(val.data);
|
|
6545
|
+
}
|
|
6546
|
+
});
|
|
6547
|
+
}
|
|
6548
|
+
return { data: dataResponse, errors: errorsResponse };
|
|
6549
|
+
}
|
|
6550
|
+
//TODO: Mover este metodo para o @sankhyalabs/core classe string utils.
|
|
6551
|
+
hashCode(txt) {
|
|
6552
|
+
var hash = 0, i, chr;
|
|
6553
|
+
if (txt.length === 0)
|
|
6554
|
+
return hash.toString();
|
|
6555
|
+
for (i = 0; i < txt.length; i++) {
|
|
6556
|
+
chr = txt.charCodeAt(i);
|
|
6557
|
+
hash = ((hash << 5) - hash) + chr;
|
|
6558
|
+
hash |= 0; // Convert to 32bit integer
|
|
6559
|
+
}
|
|
6560
|
+
return hash.toString();
|
|
6561
|
+
}
|
|
6562
|
+
;
|
|
6563
|
+
}
|
|
6564
|
+
HttpFetcher.appTagName = "snk-application";
|
|
6565
|
+
class WaitingRequest {
|
|
6566
|
+
constructor(req) {
|
|
6567
|
+
this._resolve = () => { };
|
|
6568
|
+
this._reject = () => { };
|
|
6569
|
+
this._request = undefined;
|
|
6570
|
+
this._request = req;
|
|
6571
|
+
this._promisse = new Promise((resolve, reject) => {
|
|
6572
|
+
this._resolve = resolve;
|
|
6573
|
+
this._reject = reject;
|
|
6574
|
+
});
|
|
6575
|
+
}
|
|
6576
|
+
get resolve() {
|
|
6577
|
+
return this._resolve;
|
|
6578
|
+
}
|
|
6579
|
+
get reject() {
|
|
6580
|
+
return this._reject;
|
|
6581
|
+
}
|
|
6582
|
+
get promise() {
|
|
6583
|
+
return this._promisse;
|
|
6584
|
+
}
|
|
6585
|
+
get request() {
|
|
6586
|
+
return this._request;
|
|
6587
|
+
}
|
|
6573
6588
|
}
|
|
6574
6589
|
|
|
6575
|
-
class DataUnitFetcher {
|
|
6576
|
-
constructor() {
|
|
6577
|
-
this.templateByQuery = new Map();
|
|
6578
|
-
this.buldTemplates();
|
|
6579
|
-
}
|
|
6580
|
-
buldTemplates() {
|
|
6581
|
-
this.templateByQuery.set("fetchDataUnit", dist.gql `query($name: String!) {
|
|
6582
|
-
$queryAlias$: fetchDataUnit(name: $name){
|
|
6583
|
-
name
|
|
6584
|
-
fields{
|
|
6585
|
-
name
|
|
6586
|
-
defaultValue
|
|
6587
|
-
label
|
|
6588
|
-
readOnly
|
|
6589
|
-
required
|
|
6590
|
-
dataType
|
|
6591
|
-
userInterface
|
|
6592
|
-
properties{
|
|
6593
|
-
name
|
|
6594
|
-
value
|
|
6595
|
-
}
|
|
6596
|
-
dependencies{
|
|
6597
|
-
masterFields
|
|
6598
|
-
type
|
|
6599
|
-
expression
|
|
6600
|
-
}
|
|
6601
|
-
}
|
|
6602
|
-
}
|
|
6603
|
-
}`);
|
|
6604
|
-
this.templateByQuery.set("fetchData", dist.gql `query($dataunit: String! $first: Int $offset:Int $filter: [Filter!] $sort: [Sort!]) {
|
|
6605
|
-
$queryAlias$: fetchDataUnit(name: $dataunit){
|
|
6606
|
-
data(first: $first offset: $offset filters: $filter sort: $sort){
|
|
6607
|
-
first
|
|
6608
|
-
offset
|
|
6609
|
-
total
|
|
6610
|
-
hasMore
|
|
6611
|
-
records{
|
|
6612
|
-
id
|
|
6613
|
-
fields {
|
|
6614
|
-
name
|
|
6615
|
-
value
|
|
6616
|
-
}
|
|
6617
|
-
}
|
|
6618
|
-
}
|
|
6619
|
-
}
|
|
6620
|
-
}`);
|
|
6621
|
-
this.templateByQuery.set("saveData", dist.gql `mutation($changes: [Change!]!) {
|
|
6622
|
-
$queryAlias$: saveDataUnitChanges(changes: $changes){
|
|
6623
|
-
oldId
|
|
6624
|
-
id
|
|
6625
|
-
fields {
|
|
6626
|
-
name
|
|
6627
|
-
value
|
|
6628
|
-
}
|
|
6629
|
-
}
|
|
6630
|
-
}`);
|
|
6631
|
-
}
|
|
6632
|
-
getDataUnit(entityName, resourceID) {
|
|
6633
|
-
const dataUnit = new DataUnit(`dd://${entityName}/${resourceID}`);
|
|
6634
|
-
dataUnit.metadataLoader = (dataUnit) => this.loadMetadata(dataUnit);
|
|
6635
|
-
dataUnit.dataLoader = (dataUnit, sort, filters) => this.loadData(dataUnit, sort, filters);
|
|
6636
|
-
dataUnit.saveLoader = (dataUnit, changes) => this.saveData(dataUnit, changes);
|
|
6637
|
-
dataUnit.removeLoader = (dataUnit, recordIds) => this.removeRecords(dataUnit, recordIds);
|
|
6638
|
-
return dataUnit;
|
|
6639
|
-
}
|
|
6640
|
-
loadMetadata(dataUnit) {
|
|
6641
|
-
return new Promise((resolve, reject) => {
|
|
6642
|
-
HttpFetcher.get()
|
|
6643
|
-
.callGraphQL({
|
|
6644
|
-
values: { name: dataUnit.name },
|
|
6645
|
-
query: this.templateByQuery.get("fetchDataUnit"),
|
|
6646
|
-
})
|
|
6647
|
-
.then((resp) => {
|
|
6648
|
-
var _a;
|
|
6649
|
-
const metadata = {
|
|
6650
|
-
name: resp.name,
|
|
6651
|
-
label: resp.name,
|
|
6652
|
-
fields: [],
|
|
6653
|
-
};
|
|
6654
|
-
(_a = resp.fields) === null || _a === void 0 ? void 0 : _a.forEach((source) => {
|
|
6655
|
-
let properties = undefined;
|
|
6656
|
-
if (Array.isArray(source.properties)) {
|
|
6657
|
-
properties = {};
|
|
6658
|
-
source.properties.forEach((prop) => (properties[prop.name] = prop.value));
|
|
6659
|
-
}
|
|
6660
|
-
metadata.fields.push(Object.assign(Object.assign({}, source), { properties }));
|
|
6661
|
-
});
|
|
6662
|
-
resolve(metadata);
|
|
6663
|
-
})
|
|
6664
|
-
.catch((error) => {
|
|
6665
|
-
reject(error);
|
|
6666
|
-
});
|
|
6667
|
-
});
|
|
6668
|
-
}
|
|
6669
|
-
loadData(dataUnit, sort, filters) {
|
|
6670
|
-
return new Promise((resolve, reject) => {
|
|
6671
|
-
HttpFetcher.get()
|
|
6672
|
-
.callGraphQL({
|
|
6673
|
-
values: { dataunit: dataUnit.name, sort, filters },
|
|
6674
|
-
query: this.templateByQuery.get("fetchData"),
|
|
6675
|
-
})
|
|
6676
|
-
.then((resp) => {
|
|
6677
|
-
const result = resp.data;
|
|
6678
|
-
const dataUnitRecords = [];
|
|
6679
|
-
result.records.forEach((responseRecord) => {
|
|
6680
|
-
const duRecord = { __record__id__: responseRecord.id };
|
|
6681
|
-
responseRecord.fields.forEach(({ name, value }) => {
|
|
6682
|
-
duRecord[name] = dataUnit.valueFromString(name, value);
|
|
6683
|
-
});
|
|
6684
|
-
dataUnitRecords.push(duRecord);
|
|
6685
|
-
});
|
|
6686
|
-
resolve(dataUnitRecords);
|
|
6687
|
-
})
|
|
6688
|
-
.catch((error) => {
|
|
6689
|
-
reject(error);
|
|
6690
|
-
});
|
|
6691
|
-
});
|
|
6692
|
-
}
|
|
6693
|
-
saveData(dataUnit, duChanges) {
|
|
6694
|
-
const changes = duChanges.map((change) => {
|
|
6695
|
-
const { dataUnit: changeDU, record, updatingFields, operation } = change;
|
|
6696
|
-
const parsedUpdatingFields = Object.entries(updatingFields).map(([fieldName, value]) => {
|
|
6697
|
-
return { fieldName, value: this.formatValueToServer(value) };
|
|
6698
|
-
});
|
|
6699
|
-
return { dataUnit: changeDU, updatingFields: parsedUpdatingFields, operation, recordId: record.__record__id__ };
|
|
6700
|
-
});
|
|
6701
|
-
return new Promise((resolve, reject) => {
|
|
6702
|
-
HttpFetcher.get()
|
|
6703
|
-
.callGraphQL({
|
|
6704
|
-
values: { changes: changes },
|
|
6705
|
-
query: this.templateByQuery.get("saveData"),
|
|
6706
|
-
})
|
|
6707
|
-
.then((resp) => {
|
|
6708
|
-
const dataUnitRecords = [];
|
|
6709
|
-
resp === null || resp === void 0 ? void 0 : resp.forEach((responseRecord) => {
|
|
6710
|
-
const duRecord = { __record__id__: responseRecord.id };
|
|
6711
|
-
if (responseRecord.oldId) {
|
|
6712
|
-
duRecord.__old__id__ = responseRecord.oldId;
|
|
6713
|
-
}
|
|
6714
|
-
responseRecord.fields.forEach(({ name, value }) => {
|
|
6715
|
-
duRecord[name] = dataUnit.valueFromString(name, value);
|
|
6716
|
-
});
|
|
6717
|
-
dataUnitRecords.push(duRecord);
|
|
6718
|
-
});
|
|
6719
|
-
resolve(dataUnitRecords);
|
|
6720
|
-
})
|
|
6721
|
-
.catch((error) => {
|
|
6722
|
-
reject(error);
|
|
6723
|
-
});
|
|
6724
|
-
});
|
|
6725
|
-
}
|
|
6726
|
-
formatValueToServer(value) {
|
|
6727
|
-
if (value === undefined)
|
|
6728
|
-
return value;
|
|
6729
|
-
try {
|
|
6730
|
-
if (value instanceof Date) {
|
|
6731
|
-
return value.toString();
|
|
6732
|
-
}
|
|
6733
|
-
//Any others objects
|
|
6734
|
-
value = JSON.stringify(value);
|
|
6735
|
-
}
|
|
6736
|
-
catch (_a) {
|
|
6737
|
-
value = value.toString();
|
|
6738
|
-
}
|
|
6739
|
-
return value;
|
|
6740
|
-
}
|
|
6741
|
-
removeRecords(dataUnit, recordIds) {
|
|
6742
|
-
const changes = recordIds.map((recordId) => {
|
|
6743
|
-
return { dataUnit: dataUnit.name, operation: ChangeOperation.DELETE, recordId };
|
|
6744
|
-
});
|
|
6745
|
-
return new Promise((resolve, reject) => {
|
|
6746
|
-
HttpFetcher.get()
|
|
6747
|
-
.callGraphQL({
|
|
6748
|
-
values: { changes: changes },
|
|
6749
|
-
query: this.templateByQuery.get("saveData"),
|
|
6750
|
-
})
|
|
6751
|
-
.then((_resp) => {
|
|
6752
|
-
resolve(recordIds);
|
|
6753
|
-
})
|
|
6754
|
-
.catch((error) => {
|
|
6755
|
-
reject(error);
|
|
6756
|
-
});
|
|
6757
|
-
});
|
|
6758
|
-
}
|
|
6590
|
+
class DataUnitFetcher {
|
|
6591
|
+
constructor() {
|
|
6592
|
+
this.templateByQuery = new Map();
|
|
6593
|
+
this.buldTemplates();
|
|
6594
|
+
}
|
|
6595
|
+
buldTemplates() {
|
|
6596
|
+
this.templateByQuery.set("fetchDataUnit", dist.gql `query($name: String!) {
|
|
6597
|
+
$queryAlias$: fetchDataUnit(name: $name){
|
|
6598
|
+
name
|
|
6599
|
+
fields{
|
|
6600
|
+
name
|
|
6601
|
+
defaultValue
|
|
6602
|
+
label
|
|
6603
|
+
readOnly
|
|
6604
|
+
required
|
|
6605
|
+
dataType
|
|
6606
|
+
userInterface
|
|
6607
|
+
properties{
|
|
6608
|
+
name
|
|
6609
|
+
value
|
|
6610
|
+
}
|
|
6611
|
+
dependencies{
|
|
6612
|
+
masterFields
|
|
6613
|
+
type
|
|
6614
|
+
expression
|
|
6615
|
+
}
|
|
6616
|
+
}
|
|
6617
|
+
}
|
|
6618
|
+
}`);
|
|
6619
|
+
this.templateByQuery.set("fetchData", dist.gql `query($dataunit: String! $first: Int $offset:Int $filter: [Filter!] $sort: [Sort!]) {
|
|
6620
|
+
$queryAlias$: fetchDataUnit(name: $dataunit){
|
|
6621
|
+
data(first: $first offset: $offset filters: $filter sort: $sort){
|
|
6622
|
+
first
|
|
6623
|
+
offset
|
|
6624
|
+
total
|
|
6625
|
+
hasMore
|
|
6626
|
+
records{
|
|
6627
|
+
id
|
|
6628
|
+
fields {
|
|
6629
|
+
name
|
|
6630
|
+
value
|
|
6631
|
+
}
|
|
6632
|
+
}
|
|
6633
|
+
}
|
|
6634
|
+
}
|
|
6635
|
+
}`);
|
|
6636
|
+
this.templateByQuery.set("saveData", dist.gql `mutation($changes: [Change!]!) {
|
|
6637
|
+
$queryAlias$: saveDataUnitChanges(changes: $changes){
|
|
6638
|
+
oldId
|
|
6639
|
+
id
|
|
6640
|
+
fields {
|
|
6641
|
+
name
|
|
6642
|
+
value
|
|
6643
|
+
}
|
|
6644
|
+
}
|
|
6645
|
+
}`);
|
|
6646
|
+
}
|
|
6647
|
+
getDataUnit(entityName, resourceID) {
|
|
6648
|
+
const dataUnit = new DataUnit(`dd://${entityName}/${resourceID}`);
|
|
6649
|
+
dataUnit.metadataLoader = (dataUnit) => this.loadMetadata(dataUnit);
|
|
6650
|
+
dataUnit.dataLoader = (dataUnit, sort, filters) => this.loadData(dataUnit, sort, filters);
|
|
6651
|
+
dataUnit.saveLoader = (dataUnit, changes) => this.saveData(dataUnit, changes);
|
|
6652
|
+
dataUnit.removeLoader = (dataUnit, recordIds) => this.removeRecords(dataUnit, recordIds);
|
|
6653
|
+
return dataUnit;
|
|
6654
|
+
}
|
|
6655
|
+
loadMetadata(dataUnit) {
|
|
6656
|
+
return new Promise((resolve, reject) => {
|
|
6657
|
+
HttpFetcher.get()
|
|
6658
|
+
.callGraphQL({
|
|
6659
|
+
values: { name: dataUnit.name },
|
|
6660
|
+
query: this.templateByQuery.get("fetchDataUnit"),
|
|
6661
|
+
})
|
|
6662
|
+
.then((resp) => {
|
|
6663
|
+
var _a;
|
|
6664
|
+
const metadata = {
|
|
6665
|
+
name: resp.name,
|
|
6666
|
+
label: resp.name,
|
|
6667
|
+
fields: [],
|
|
6668
|
+
};
|
|
6669
|
+
(_a = resp.fields) === null || _a === void 0 ? void 0 : _a.forEach((source) => {
|
|
6670
|
+
let properties = undefined;
|
|
6671
|
+
if (Array.isArray(source.properties)) {
|
|
6672
|
+
properties = {};
|
|
6673
|
+
source.properties.forEach((prop) => (properties[prop.name] = prop.value));
|
|
6674
|
+
}
|
|
6675
|
+
metadata.fields.push(Object.assign(Object.assign({}, source), { properties }));
|
|
6676
|
+
});
|
|
6677
|
+
resolve(metadata);
|
|
6678
|
+
})
|
|
6679
|
+
.catch((error) => {
|
|
6680
|
+
reject(error);
|
|
6681
|
+
});
|
|
6682
|
+
});
|
|
6683
|
+
}
|
|
6684
|
+
loadData(dataUnit, sort, filters) {
|
|
6685
|
+
return new Promise((resolve, reject) => {
|
|
6686
|
+
HttpFetcher.get()
|
|
6687
|
+
.callGraphQL({
|
|
6688
|
+
values: { dataunit: dataUnit.name, sort, filters },
|
|
6689
|
+
query: this.templateByQuery.get("fetchData"),
|
|
6690
|
+
})
|
|
6691
|
+
.then((resp) => {
|
|
6692
|
+
const result = resp.data;
|
|
6693
|
+
const dataUnitRecords = [];
|
|
6694
|
+
result.records.forEach((responseRecord) => {
|
|
6695
|
+
const duRecord = { __record__id__: responseRecord.id };
|
|
6696
|
+
responseRecord.fields.forEach(({ name, value }) => {
|
|
6697
|
+
duRecord[name] = dataUnit.valueFromString(name, value);
|
|
6698
|
+
});
|
|
6699
|
+
dataUnitRecords.push(duRecord);
|
|
6700
|
+
});
|
|
6701
|
+
resolve(dataUnitRecords);
|
|
6702
|
+
})
|
|
6703
|
+
.catch((error) => {
|
|
6704
|
+
reject(error);
|
|
6705
|
+
});
|
|
6706
|
+
});
|
|
6707
|
+
}
|
|
6708
|
+
saveData(dataUnit, duChanges) {
|
|
6709
|
+
const changes = duChanges.map((change) => {
|
|
6710
|
+
const { dataUnit: changeDU, record, updatingFields, operation } = change;
|
|
6711
|
+
const parsedUpdatingFields = Object.entries(updatingFields).map(([fieldName, value]) => {
|
|
6712
|
+
return { fieldName, value: this.formatValueToServer(value) };
|
|
6713
|
+
});
|
|
6714
|
+
return { dataUnit: changeDU, updatingFields: parsedUpdatingFields, operation, recordId: record.__record__id__ };
|
|
6715
|
+
});
|
|
6716
|
+
return new Promise((resolve, reject) => {
|
|
6717
|
+
HttpFetcher.get()
|
|
6718
|
+
.callGraphQL({
|
|
6719
|
+
values: { changes: changes },
|
|
6720
|
+
query: this.templateByQuery.get("saveData"),
|
|
6721
|
+
})
|
|
6722
|
+
.then((resp) => {
|
|
6723
|
+
const dataUnitRecords = [];
|
|
6724
|
+
resp === null || resp === void 0 ? void 0 : resp.forEach((responseRecord) => {
|
|
6725
|
+
const duRecord = { __record__id__: responseRecord.id };
|
|
6726
|
+
if (responseRecord.oldId) {
|
|
6727
|
+
duRecord.__old__id__ = responseRecord.oldId;
|
|
6728
|
+
}
|
|
6729
|
+
responseRecord.fields.forEach(({ name, value }) => {
|
|
6730
|
+
duRecord[name] = dataUnit.valueFromString(name, value);
|
|
6731
|
+
});
|
|
6732
|
+
dataUnitRecords.push(duRecord);
|
|
6733
|
+
});
|
|
6734
|
+
resolve(dataUnitRecords);
|
|
6735
|
+
})
|
|
6736
|
+
.catch((error) => {
|
|
6737
|
+
reject(error);
|
|
6738
|
+
});
|
|
6739
|
+
});
|
|
6740
|
+
}
|
|
6741
|
+
formatValueToServer(value) {
|
|
6742
|
+
if (value === undefined)
|
|
6743
|
+
return value;
|
|
6744
|
+
try {
|
|
6745
|
+
if (value instanceof Date) {
|
|
6746
|
+
return value.toString();
|
|
6747
|
+
}
|
|
6748
|
+
//Any others objects
|
|
6749
|
+
value = JSON.stringify(value);
|
|
6750
|
+
}
|
|
6751
|
+
catch (_a) {
|
|
6752
|
+
value = value.toString();
|
|
6753
|
+
}
|
|
6754
|
+
return value;
|
|
6755
|
+
}
|
|
6756
|
+
removeRecords(dataUnit, recordIds) {
|
|
6757
|
+
const changes = recordIds.map((recordId) => {
|
|
6758
|
+
return { dataUnit: dataUnit.name, operation: ChangeOperation.DELETE, recordId };
|
|
6759
|
+
});
|
|
6760
|
+
return new Promise((resolve, reject) => {
|
|
6761
|
+
HttpFetcher.get()
|
|
6762
|
+
.callGraphQL({
|
|
6763
|
+
values: { changes: changes },
|
|
6764
|
+
query: this.templateByQuery.get("saveData"),
|
|
6765
|
+
})
|
|
6766
|
+
.then((_resp) => {
|
|
6767
|
+
resolve(recordIds);
|
|
6768
|
+
})
|
|
6769
|
+
.catch((error) => {
|
|
6770
|
+
reject(error);
|
|
6771
|
+
});
|
|
6772
|
+
});
|
|
6773
|
+
}
|
|
6759
6774
|
}
|
|
6760
6775
|
|
|
6761
|
-
class UrlUtils {
|
|
6762
|
-
static getQueryParams(queryString) {
|
|
6763
|
-
const params = new Map();
|
|
6764
|
-
const re = /[?&]?([^=]+)=([^&]*)/g;
|
|
6765
|
-
let tokens;
|
|
6766
|
-
//Necessário por causa da tela Histórico Padrão que possui resourceID com acento
|
|
6767
|
-
queryString = window.unescape(queryString);
|
|
6768
|
-
queryString = queryString.split("+").join(" ");
|
|
6769
|
-
while ((tokens = re.exec(queryString))) {
|
|
6770
|
-
params.set(window.decodeURIComponent(tokens[1]), tokens[2]);
|
|
6771
|
-
}
|
|
6772
|
-
//Inserimos a urlBase no params.
|
|
6773
|
-
params.set("urlBase", this.getUrlBase());
|
|
6774
|
-
if (window["moduleID"] && window["URIServiceBroker"]) {
|
|
6775
|
-
params.set("moduleID", window["moduleID"]);
|
|
6776
|
-
params.set("URIServiceBroker", window["URIServiceBroker"]);
|
|
6777
|
-
}
|
|
6778
|
-
return params;
|
|
6779
|
-
}
|
|
6780
|
-
static getUrlBase() {
|
|
6781
|
-
return `${location.protocol}"//"${location.hostname}${location.port ? ":" + location.port : ""}`;
|
|
6782
|
-
}
|
|
6776
|
+
class UrlUtils {
|
|
6777
|
+
static getQueryParams(queryString) {
|
|
6778
|
+
const params = new Map();
|
|
6779
|
+
const re = /[?&]?([^=]+)=([^&]*)/g;
|
|
6780
|
+
let tokens;
|
|
6781
|
+
//Necessário por causa da tela Histórico Padrão que possui resourceID com acento
|
|
6782
|
+
queryString = window.unescape(queryString);
|
|
6783
|
+
queryString = queryString.split("+").join(" ");
|
|
6784
|
+
while ((tokens = re.exec(queryString))) {
|
|
6785
|
+
params.set(window.decodeURIComponent(tokens[1]), tokens[2]);
|
|
6786
|
+
}
|
|
6787
|
+
//Inserimos a urlBase no params.
|
|
6788
|
+
params.set("urlBase", this.getUrlBase());
|
|
6789
|
+
if (window["moduleID"] && window["URIServiceBroker"]) {
|
|
6790
|
+
params.set("moduleID", window["moduleID"]);
|
|
6791
|
+
params.set("URIServiceBroker", window["URIServiceBroker"]);
|
|
6792
|
+
}
|
|
6793
|
+
return params;
|
|
6794
|
+
}
|
|
6795
|
+
static getUrlBase() {
|
|
6796
|
+
return `${location.protocol}"//"${location.hostname}${location.port ? ":" + location.port : ""}`;
|
|
6797
|
+
}
|
|
6783
6798
|
}
|
|
6784
6799
|
|
|
6785
|
-
class Workspace {
|
|
6786
|
-
static openAppActivity(resourceId, pkObject) {
|
|
6787
|
-
var _a;
|
|
6788
|
-
(_a = window["workspace"]) === null || _a === void 0 ? void 0 : _a.openAppActivity(resourceId, pkObject);
|
|
6789
|
-
}
|
|
6790
|
-
}
|
|
6800
|
+
class Workspace {
|
|
6801
|
+
static openAppActivity(resourceId, pkObject) {
|
|
6802
|
+
var _a;
|
|
6803
|
+
(_a = window["workspace"]) === null || _a === void 0 ? void 0 : _a.openAppActivity(resourceId, pkObject);
|
|
6804
|
+
}
|
|
6805
|
+
}
|
|
6791
6806
|
Workspace.resourceID = window["workspace"].resourceID;
|
|
6792
6807
|
|
|
6793
|
-
class ParametersFetcher {
|
|
6794
|
-
constructor() {
|
|
6795
|
-
this.templateByQuery = new Map();
|
|
6796
|
-
this.buldTemplates();
|
|
6797
|
-
}
|
|
6798
|
-
buldTemplates() {
|
|
6799
|
-
this.templateByQuery.set("fetchParam", dist.gql `query($name: String!) {
|
|
6800
|
-
$queryAlias$: fetchResource(name: $name){
|
|
6801
|
-
name
|
|
6802
|
-
resource
|
|
6803
|
-
}
|
|
6804
|
-
}`);
|
|
6805
|
-
}
|
|
6806
|
-
async getParam(name, resourceID) {
|
|
6807
|
-
const completPath = `param://${resourceID}?params=${window.btoa(name)}`;
|
|
6808
|
-
return HttpFetcher.get().callGraphQL({
|
|
6809
|
-
values: { name: completPath },
|
|
6810
|
-
query: this.templateByQuery.get("fetchParam"),
|
|
6811
|
-
});
|
|
6812
|
-
}
|
|
6813
|
-
async asString(name, resourceID) {
|
|
6814
|
-
const paramArr = await this.getParam(name, resourceID);
|
|
6815
|
-
return this.getValue(paramArr);
|
|
6816
|
-
}
|
|
6817
|
-
async asInteger(name, resourceID) {
|
|
6818
|
-
const paramArr = await this.getParam(name, resourceID);
|
|
6819
|
-
return parseInt(this.getValue(paramArr));
|
|
6820
|
-
}
|
|
6821
|
-
async asFloat(name, resourceID) {
|
|
6822
|
-
const paramArr = await this.getParam(name, resourceID);
|
|
6823
|
-
return parseFloat(this.getValue(paramArr));
|
|
6824
|
-
}
|
|
6825
|
-
async asBoolean(name, resourceID) {
|
|
6826
|
-
const paramArr = await this.getParam(name, resourceID);
|
|
6827
|
-
return this.getValue(paramArr) == "S";
|
|
6828
|
-
}
|
|
6829
|
-
async asDate(name, resourceID) {
|
|
6830
|
-
const paramArr = await this.getParam(name, resourceID);
|
|
6831
|
-
return DateUtils.strToDate(this.getValue(paramArr));
|
|
6832
|
-
}
|
|
6833
|
-
async getBatchParams(names, resourceID) {
|
|
6834
|
-
const paramArr = await this.getParam(names.join(","), resourceID);
|
|
6835
|
-
//TODO: try to typed params val?
|
|
6836
|
-
const response = {};
|
|
6837
|
-
paramArr.forEach((param) => (response[param.name] = param.resource));
|
|
6838
|
-
return response;
|
|
6839
|
-
}
|
|
6840
|
-
getValue(obj = {}) {
|
|
6841
|
-
if (Array.isArray(obj) && obj.length > 0) {
|
|
6842
|
-
obj = obj[0];
|
|
6843
|
-
}
|
|
6844
|
-
if (StringUtils.isEmpty(obj.resource))
|
|
6845
|
-
return "";
|
|
6846
|
-
return obj.resource;
|
|
6847
|
-
}
|
|
6808
|
+
class ParametersFetcher {
|
|
6809
|
+
constructor() {
|
|
6810
|
+
this.templateByQuery = new Map();
|
|
6811
|
+
this.buldTemplates();
|
|
6812
|
+
}
|
|
6813
|
+
buldTemplates() {
|
|
6814
|
+
this.templateByQuery.set("fetchParam", dist.gql `query($name: String!) {
|
|
6815
|
+
$queryAlias$: fetchResource(name: $name){
|
|
6816
|
+
name
|
|
6817
|
+
resource
|
|
6818
|
+
}
|
|
6819
|
+
}`);
|
|
6820
|
+
}
|
|
6821
|
+
async getParam(name, resourceID) {
|
|
6822
|
+
const completPath = `param://${resourceID}?params=${window.btoa(name)}`;
|
|
6823
|
+
return HttpFetcher.get().callGraphQL({
|
|
6824
|
+
values: { name: completPath },
|
|
6825
|
+
query: this.templateByQuery.get("fetchParam"),
|
|
6826
|
+
});
|
|
6827
|
+
}
|
|
6828
|
+
async asString(name, resourceID) {
|
|
6829
|
+
const paramArr = await this.getParam(name, resourceID);
|
|
6830
|
+
return this.getValue(paramArr);
|
|
6831
|
+
}
|
|
6832
|
+
async asInteger(name, resourceID) {
|
|
6833
|
+
const paramArr = await this.getParam(name, resourceID);
|
|
6834
|
+
return parseInt(this.getValue(paramArr));
|
|
6835
|
+
}
|
|
6836
|
+
async asFloat(name, resourceID) {
|
|
6837
|
+
const paramArr = await this.getParam(name, resourceID);
|
|
6838
|
+
return parseFloat(this.getValue(paramArr));
|
|
6839
|
+
}
|
|
6840
|
+
async asBoolean(name, resourceID) {
|
|
6841
|
+
const paramArr = await this.getParam(name, resourceID);
|
|
6842
|
+
return this.getValue(paramArr) == "S";
|
|
6843
|
+
}
|
|
6844
|
+
async asDate(name, resourceID) {
|
|
6845
|
+
const paramArr = await this.getParam(name, resourceID);
|
|
6846
|
+
return DateUtils.strToDate(this.getValue(paramArr));
|
|
6847
|
+
}
|
|
6848
|
+
async getBatchParams(names, resourceID) {
|
|
6849
|
+
const paramArr = await this.getParam(names.join(","), resourceID);
|
|
6850
|
+
//TODO: try to typed params val?
|
|
6851
|
+
const response = {};
|
|
6852
|
+
paramArr.forEach((param) => (response[param.name] = param.resource));
|
|
6853
|
+
return response;
|
|
6854
|
+
}
|
|
6855
|
+
getValue(obj = {}) {
|
|
6856
|
+
if (Array.isArray(obj) && obj.length > 0) {
|
|
6857
|
+
obj = obj[0];
|
|
6858
|
+
}
|
|
6859
|
+
if (StringUtils.isEmpty(obj.resource))
|
|
6860
|
+
return "";
|
|
6861
|
+
return obj.resource;
|
|
6862
|
+
}
|
|
6848
6863
|
}
|
|
6849
6864
|
|
|
6850
|
-
class ResourceFetcher {
|
|
6851
|
-
constructor() {
|
|
6852
|
-
this.templateByQuery = new Map();
|
|
6853
|
-
this.buldTemplates();
|
|
6854
|
-
}
|
|
6855
|
-
buldTemplates() {
|
|
6856
|
-
this.templateByQuery.set("fetchResource", dist.gql `query($name: String!) {
|
|
6857
|
-
$queryAlias$: fetchResource(name: $name){
|
|
6858
|
-
resource
|
|
6859
|
-
}
|
|
6860
|
-
}`);
|
|
6861
|
-
}
|
|
6862
|
-
loadResource(name) {
|
|
6863
|
-
return new Promise((resolve, reject) => {
|
|
6864
|
-
HttpFetcher.get()
|
|
6865
|
-
.callGraphQL({
|
|
6866
|
-
values: { name },
|
|
6867
|
-
query: this.templateByQuery.get("fetchResource"),
|
|
6868
|
-
})
|
|
6869
|
-
.then((result) => {
|
|
6870
|
-
resolve(result === null || result === void 0 ? void 0 : result.resource);
|
|
6871
|
-
})
|
|
6872
|
-
.catch((error) => {
|
|
6873
|
-
reject(error);
|
|
6874
|
-
});
|
|
6875
|
-
});
|
|
6876
|
-
}
|
|
6865
|
+
class ResourceFetcher {
|
|
6866
|
+
constructor() {
|
|
6867
|
+
this.templateByQuery = new Map();
|
|
6868
|
+
this.buldTemplates();
|
|
6869
|
+
}
|
|
6870
|
+
buldTemplates() {
|
|
6871
|
+
this.templateByQuery.set("fetchResource", dist.gql `query($name: String!) {
|
|
6872
|
+
$queryAlias$: fetchResource(name: $name){
|
|
6873
|
+
resource
|
|
6874
|
+
}
|
|
6875
|
+
}`);
|
|
6876
|
+
}
|
|
6877
|
+
loadResource(name) {
|
|
6878
|
+
return new Promise((resolve, reject) => {
|
|
6879
|
+
HttpFetcher.get()
|
|
6880
|
+
.callGraphQL({
|
|
6881
|
+
values: { name },
|
|
6882
|
+
query: this.templateByQuery.get("fetchResource"),
|
|
6883
|
+
})
|
|
6884
|
+
.then((result) => {
|
|
6885
|
+
resolve(result === null || result === void 0 ? void 0 : result.resource);
|
|
6886
|
+
})
|
|
6887
|
+
.catch((error) => {
|
|
6888
|
+
reject(error);
|
|
6889
|
+
});
|
|
6890
|
+
});
|
|
6891
|
+
}
|
|
6877
6892
|
}
|
|
6878
6893
|
|
|
6879
|
-
class FormConfigFetcher extends ResourceFetcher {
|
|
6880
|
-
loadFormConfig(formName, resourceID) {
|
|
6881
|
-
return new Promise((accept, reject) => {
|
|
6882
|
-
this.loadResource(`cfg://form/${resourceID}/${formName}`)
|
|
6883
|
-
.then((configAsString) => {
|
|
6884
|
-
if (configAsString) {
|
|
6885
|
-
const config = JSON.parse(configAsString);
|
|
6886
|
-
const { tabs, fields } = config;
|
|
6887
|
-
if (tabs) {
|
|
6888
|
-
const allTabs = new Map(tabs.map(t => [t.label, t]));
|
|
6889
|
-
fields.forEach(f => f.tab = allTabs.get(f.tab));
|
|
6890
|
-
}
|
|
6891
|
-
accept(fields);
|
|
6892
|
-
}
|
|
6893
|
-
else {
|
|
6894
|
-
reject(`Sem configuração pro formulário "${formName}".`);
|
|
6895
|
-
}
|
|
6896
|
-
})
|
|
6897
|
-
.catch((error) => {
|
|
6898
|
-
reject(error);
|
|
6899
|
-
});
|
|
6900
|
-
});
|
|
6901
|
-
}
|
|
6894
|
+
class FormConfigFetcher extends ResourceFetcher {
|
|
6895
|
+
loadFormConfig(formName, resourceID) {
|
|
6896
|
+
return new Promise((accept, reject) => {
|
|
6897
|
+
this.loadResource(`cfg://form/${resourceID}/${formName}`)
|
|
6898
|
+
.then((configAsString) => {
|
|
6899
|
+
if (configAsString) {
|
|
6900
|
+
const config = JSON.parse(configAsString);
|
|
6901
|
+
const { tabs, fields } = config;
|
|
6902
|
+
if (tabs) {
|
|
6903
|
+
const allTabs = new Map(tabs.map(t => [t.label, t]));
|
|
6904
|
+
fields.forEach(f => f.tab = allTabs.get(f.tab));
|
|
6905
|
+
}
|
|
6906
|
+
accept(fields);
|
|
6907
|
+
}
|
|
6908
|
+
else {
|
|
6909
|
+
reject(`Sem configuração pro formulário "${formName}".`);
|
|
6910
|
+
}
|
|
6911
|
+
})
|
|
6912
|
+
.catch((error) => {
|
|
6913
|
+
reject(error);
|
|
6914
|
+
});
|
|
6915
|
+
});
|
|
6916
|
+
}
|
|
6902
6917
|
}
|
|
6903
6918
|
|
|
6904
|
-
const mockByEntity = {
|
|
6905
|
-
"ImplantacaoSaldoConta": [{ "value": 6, "label": "Conta Financeiro" }, { "value": 7, "label": "Conta Banco do Brasil" }],
|
|
6906
|
-
"HistoricoBancario": [{ "value": 9, "label": "Lanç. Origem" }, { "value": 8, "label": "Lanç. Origem 2" }],
|
|
6907
|
-
"ContaDestino": [{ "value": 10, "label": "Conta BB" }, { "value": 7, "label": "Conta Santander" }],
|
|
6908
|
-
"HistoricoBancarioDestino": [{ "value": 11, "label": "Contra Bradesco" }, { "value": 13, "label": "Contra Destino" }],
|
|
6909
|
-
"Usuario": [{ "value": 0, "label": "SUP" }],
|
|
6910
|
-
"ContaBancaria": [{ "value": 10, "label": "Conta 10" }, { "value": 17, "label": "Conta 17" }],
|
|
6911
|
-
"TipoOperacao": [{ "value": 4, "label": "Entrada NFse" }, { "value": 5, "label": "Outra top" }, { "value": 6, "label": "Top 6" }]
|
|
6912
|
-
};
|
|
6913
|
-
const pesquisaLoadOptions = (searchArgument, fieldName, dataUnit) => {
|
|
6914
|
-
var _a;
|
|
6915
|
-
console.log(searchArgument);
|
|
6916
|
-
const field = dataUnit.getField(fieldName);
|
|
6917
|
-
const entityName = (_a = field.properties) === null || _a === void 0 ? void 0 : _a.ENTITYNAME;
|
|
6918
|
-
return (mockByEntity[entityName] || []);
|
|
6919
|
+
const mockByEntity = {
|
|
6920
|
+
"ImplantacaoSaldoConta": [{ "value": 6, "label": "Conta Financeiro" }, { "value": 7, "label": "Conta Banco do Brasil" }],
|
|
6921
|
+
"HistoricoBancario": [{ "value": 9, "label": "Lanç. Origem" }, { "value": 8, "label": "Lanç. Origem 2" }],
|
|
6922
|
+
"ContaDestino": [{ "value": 10, "label": "Conta BB" }, { "value": 7, "label": "Conta Santander" }],
|
|
6923
|
+
"HistoricoBancarioDestino": [{ "value": 11, "label": "Contra Bradesco" }, { "value": 13, "label": "Contra Destino" }],
|
|
6924
|
+
"Usuario": [{ "value": 0, "label": "SUP" }],
|
|
6925
|
+
"ContaBancaria": [{ "value": 10, "label": "Conta 10" }, { "value": 17, "label": "Conta 17" }],
|
|
6926
|
+
"TipoOperacao": [{ "value": 4, "label": "Entrada NFse" }, { "value": 5, "label": "Outra top" }, { "value": 6, "label": "Top 6" }]
|
|
6927
|
+
};
|
|
6928
|
+
const pesquisaLoadOptions = (searchArgument, fieldName, dataUnit) => {
|
|
6929
|
+
var _a;
|
|
6930
|
+
console.log(searchArgument);
|
|
6931
|
+
const field = dataUnit.getField(fieldName);
|
|
6932
|
+
const entityName = (_a = field.properties) === null || _a === void 0 ? void 0 : _a.ENTITYNAME;
|
|
6933
|
+
return (mockByEntity[entityName] || []);
|
|
6919
6934
|
};
|
|
6920
6935
|
|
|
6921
6936
|
const snkApplicationCss = ".sc-snk-application-h{display:flex;flex-direction:column;height:100%}";
|
|
6922
6937
|
|
|
6923
|
-
const SnkApplication = class {
|
|
6924
|
-
constructor(hostRef) {
|
|
6925
|
-
registerInstance(this, hostRef);
|
|
6926
|
-
this.applicationLoaded = createEvent(this, "applicationLoaded", 7);
|
|
6927
|
-
this.applicationLoading = createEvent(this, "applicationLoading", 7);
|
|
6928
|
-
}
|
|
6929
|
-
get parameters() {
|
|
6930
|
-
if (!this._parameters) {
|
|
6931
|
-
this._parameters = new ParametersFetcher();
|
|
6932
|
-
}
|
|
6933
|
-
return this._parameters;
|
|
6934
|
-
}
|
|
6935
|
-
get resourceID() {
|
|
6936
|
-
if (!this._resourceID) {
|
|
6937
|
-
this._resourceID = this.urlParams.get("workspaceResourceID") ||
|
|
6938
|
-
this.urlParams.get("resourceID") ||
|
|
6939
|
-
Workspace.resourceID ||
|
|
6940
|
-
"unknown.resource.id";
|
|
6941
|
-
}
|
|
6942
|
-
return this._resourceID;
|
|
6943
|
-
}
|
|
6944
|
-
async getStringParam(name) {
|
|
6945
|
-
return this.parameters.asString(name, this.resourceID);
|
|
6946
|
-
}
|
|
6947
|
-
async getIntParam(name) {
|
|
6948
|
-
return this.parameters.asInteger(name, this.resourceID);
|
|
6949
|
-
}
|
|
6950
|
-
async getFloatParam(name) {
|
|
6951
|
-
return this.parameters.asFloat(name, this.resourceID);
|
|
6952
|
-
}
|
|
6953
|
-
async getBooleanParam(name) {
|
|
6954
|
-
return this.parameters.asBoolean(name, this.resourceID);
|
|
6955
|
-
}
|
|
6956
|
-
async getDateParam(name) {
|
|
6957
|
-
return this.parameters.asDate(name, this.resourceID);
|
|
6958
|
-
}
|
|
6959
|
-
async temOpcional(opcional) {
|
|
6960
|
-
const opts = opcional.split(",");
|
|
6961
|
-
return new Promise((resolve, reject) => {
|
|
6962
|
-
this.getAttributeFromHTMLWrapper("opc0009")
|
|
6963
|
-
.then(value => {
|
|
6964
|
-
if (value === "1") {
|
|
6965
|
-
resolve(true);
|
|
6966
|
-
}
|
|
6967
|
-
else {
|
|
6968
|
-
Promise.all(opts.map(opt => this.getAttributeFromHTMLWrapper("opc" + opt)))
|
|
6969
|
-
.then(result => {
|
|
6970
|
-
resolve(result.includes("1"));
|
|
6971
|
-
})
|
|
6972
|
-
.catch(error => {
|
|
6973
|
-
reject(error);
|
|
6974
|
-
});
|
|
6975
|
-
}
|
|
6976
|
-
})
|
|
6977
|
-
.catch(error => {
|
|
6978
|
-
reject(error);
|
|
6979
|
-
});
|
|
6980
|
-
});
|
|
6981
|
-
}
|
|
6982
|
-
async getAttributeFromHTMLWrapper(attribName) {
|
|
6983
|
-
return Promise.resolve(window[attribName]);
|
|
6984
|
-
}
|
|
6985
|
-
async openApp(resourceId, pkObject) {
|
|
6986
|
-
Workspace.openAppActivity(resourceId, pkObject);
|
|
6987
|
-
}
|
|
6988
|
-
async createDataunit(entityName) {
|
|
6989
|
-
return new Promise(resolve => {
|
|
6990
|
-
const dataUnit = this.dataUnitFetcher.getDataUnit(entityName, this.resourceID);
|
|
6991
|
-
dataUnit.loadMetadata();
|
|
6992
|
-
resolve(dataUnit);
|
|
6993
|
-
});
|
|
6994
|
-
}
|
|
6995
|
-
async getResourceID() {
|
|
6996
|
-
return Promise.resolve(this.resourceID);
|
|
6997
|
-
}
|
|
6998
|
-
async alert(title, message, icon) {
|
|
6999
|
-
return ApplicationUtils.alert(title, message, icon);
|
|
7000
|
-
}
|
|
7001
|
-
async error(title, message, icon) {
|
|
7002
|
-
return ApplicationUtils.error(title, message, icon);
|
|
7003
|
-
}
|
|
7004
|
-
async confirm(title, message, icon, critical) {
|
|
7005
|
-
return ApplicationUtils.confirm(title, message, icon, critical);
|
|
7006
|
-
}
|
|
7007
|
-
async info(message, options = undefined) {
|
|
7008
|
-
return ApplicationUtils.info(message, options);
|
|
7009
|
-
}
|
|
7010
|
-
async loadFormConfig(name) {
|
|
7011
|
-
return this.formConfigFetcher.loadFormConfig(name, this.resourceID);
|
|
7012
|
-
}
|
|
7013
|
-
get urlParams() {
|
|
7014
|
-
if (!this._urlParams) {
|
|
7015
|
-
this._urlParams = UrlUtils.getQueryParams(location.search);
|
|
7016
|
-
}
|
|
7017
|
-
return this._urlParams;
|
|
7018
|
-
}
|
|
7019
|
-
get dataUnitFetcher() {
|
|
7020
|
-
if (!this._dataUnitFetcher) {
|
|
7021
|
-
this._dataUnitFetcher = new DataUnitFetcher();
|
|
7022
|
-
}
|
|
7023
|
-
return this._dataUnitFetcher;
|
|
7024
|
-
}
|
|
7025
|
-
get formConfigFetcher() {
|
|
7026
|
-
if (!this._formConfigFetcher) {
|
|
7027
|
-
this._formConfigFetcher = new FormConfigFetcher();
|
|
7028
|
-
}
|
|
7029
|
-
return this._formConfigFetcher;
|
|
7030
|
-
}
|
|
7031
|
-
componentWillLoad() {
|
|
7032
|
-
ApplicationContext.setContextValue("__EZUI__SEARCH__OPTION__LOADER__", pesquisaLoadOptions);
|
|
7033
|
-
}
|
|
7034
|
-
componentDidLoad() {
|
|
7035
|
-
this.applicationLoading.emit(true);
|
|
7036
|
-
window.requestAnimationFrame(() => {
|
|
7037
|
-
this.applicationLoaded.emit(true);
|
|
7038
|
-
});
|
|
7039
|
-
}
|
|
7040
|
-
render() {
|
|
7041
|
-
return (h("div", null));
|
|
7042
|
-
}
|
|
7043
|
-
};
|
|
6938
|
+
const SnkApplication = class {
|
|
6939
|
+
constructor(hostRef) {
|
|
6940
|
+
registerInstance(this, hostRef);
|
|
6941
|
+
this.applicationLoaded = createEvent(this, "applicationLoaded", 7);
|
|
6942
|
+
this.applicationLoading = createEvent(this, "applicationLoading", 7);
|
|
6943
|
+
}
|
|
6944
|
+
get parameters() {
|
|
6945
|
+
if (!this._parameters) {
|
|
6946
|
+
this._parameters = new ParametersFetcher();
|
|
6947
|
+
}
|
|
6948
|
+
return this._parameters;
|
|
6949
|
+
}
|
|
6950
|
+
get resourceID() {
|
|
6951
|
+
if (!this._resourceID) {
|
|
6952
|
+
this._resourceID = this.urlParams.get("workspaceResourceID") ||
|
|
6953
|
+
this.urlParams.get("resourceID") ||
|
|
6954
|
+
Workspace.resourceID ||
|
|
6955
|
+
"unknown.resource.id";
|
|
6956
|
+
}
|
|
6957
|
+
return this._resourceID;
|
|
6958
|
+
}
|
|
6959
|
+
async getStringParam(name) {
|
|
6960
|
+
return this.parameters.asString(name, this.resourceID);
|
|
6961
|
+
}
|
|
6962
|
+
async getIntParam(name) {
|
|
6963
|
+
return this.parameters.asInteger(name, this.resourceID);
|
|
6964
|
+
}
|
|
6965
|
+
async getFloatParam(name) {
|
|
6966
|
+
return this.parameters.asFloat(name, this.resourceID);
|
|
6967
|
+
}
|
|
6968
|
+
async getBooleanParam(name) {
|
|
6969
|
+
return this.parameters.asBoolean(name, this.resourceID);
|
|
6970
|
+
}
|
|
6971
|
+
async getDateParam(name) {
|
|
6972
|
+
return this.parameters.asDate(name, this.resourceID);
|
|
6973
|
+
}
|
|
6974
|
+
async temOpcional(opcional) {
|
|
6975
|
+
const opts = opcional.split(",");
|
|
6976
|
+
return new Promise((resolve, reject) => {
|
|
6977
|
+
this.getAttributeFromHTMLWrapper("opc0009")
|
|
6978
|
+
.then(value => {
|
|
6979
|
+
if (value === "1") {
|
|
6980
|
+
resolve(true);
|
|
6981
|
+
}
|
|
6982
|
+
else {
|
|
6983
|
+
Promise.all(opts.map(opt => this.getAttributeFromHTMLWrapper("opc" + opt)))
|
|
6984
|
+
.then(result => {
|
|
6985
|
+
resolve(result.includes("1"));
|
|
6986
|
+
})
|
|
6987
|
+
.catch(error => {
|
|
6988
|
+
reject(error);
|
|
6989
|
+
});
|
|
6990
|
+
}
|
|
6991
|
+
})
|
|
6992
|
+
.catch(error => {
|
|
6993
|
+
reject(error);
|
|
6994
|
+
});
|
|
6995
|
+
});
|
|
6996
|
+
}
|
|
6997
|
+
async getAttributeFromHTMLWrapper(attribName) {
|
|
6998
|
+
return Promise.resolve(window[attribName]);
|
|
6999
|
+
}
|
|
7000
|
+
async openApp(resourceId, pkObject) {
|
|
7001
|
+
Workspace.openAppActivity(resourceId, pkObject);
|
|
7002
|
+
}
|
|
7003
|
+
async createDataunit(entityName) {
|
|
7004
|
+
return new Promise(resolve => {
|
|
7005
|
+
const dataUnit = this.dataUnitFetcher.getDataUnit(entityName, this.resourceID);
|
|
7006
|
+
dataUnit.loadMetadata();
|
|
7007
|
+
resolve(dataUnit);
|
|
7008
|
+
});
|
|
7009
|
+
}
|
|
7010
|
+
async getResourceID() {
|
|
7011
|
+
return Promise.resolve(this.resourceID);
|
|
7012
|
+
}
|
|
7013
|
+
async alert(title, message, icon) {
|
|
7014
|
+
return ApplicationUtils.alert(title, message, icon);
|
|
7015
|
+
}
|
|
7016
|
+
async error(title, message, icon) {
|
|
7017
|
+
return ApplicationUtils.error(title, message, icon);
|
|
7018
|
+
}
|
|
7019
|
+
async confirm(title, message, icon, critical) {
|
|
7020
|
+
return ApplicationUtils.confirm(title, message, icon, critical);
|
|
7021
|
+
}
|
|
7022
|
+
async info(message, options = undefined) {
|
|
7023
|
+
return ApplicationUtils.info(message, options);
|
|
7024
|
+
}
|
|
7025
|
+
async loadFormConfig(name) {
|
|
7026
|
+
return this.formConfigFetcher.loadFormConfig(name, this.resourceID);
|
|
7027
|
+
}
|
|
7028
|
+
get urlParams() {
|
|
7029
|
+
if (!this._urlParams) {
|
|
7030
|
+
this._urlParams = UrlUtils.getQueryParams(location.search);
|
|
7031
|
+
}
|
|
7032
|
+
return this._urlParams;
|
|
7033
|
+
}
|
|
7034
|
+
get dataUnitFetcher() {
|
|
7035
|
+
if (!this._dataUnitFetcher) {
|
|
7036
|
+
this._dataUnitFetcher = new DataUnitFetcher();
|
|
7037
|
+
}
|
|
7038
|
+
return this._dataUnitFetcher;
|
|
7039
|
+
}
|
|
7040
|
+
get formConfigFetcher() {
|
|
7041
|
+
if (!this._formConfigFetcher) {
|
|
7042
|
+
this._formConfigFetcher = new FormConfigFetcher();
|
|
7043
|
+
}
|
|
7044
|
+
return this._formConfigFetcher;
|
|
7045
|
+
}
|
|
7046
|
+
componentWillLoad() {
|
|
7047
|
+
ApplicationContext.setContextValue("__EZUI__SEARCH__OPTION__LOADER__", pesquisaLoadOptions);
|
|
7048
|
+
}
|
|
7049
|
+
componentDidLoad() {
|
|
7050
|
+
this.applicationLoading.emit(true);
|
|
7051
|
+
window.requestAnimationFrame(() => {
|
|
7052
|
+
this.applicationLoaded.emit(true);
|
|
7053
|
+
});
|
|
7054
|
+
}
|
|
7055
|
+
render() {
|
|
7056
|
+
return (h("div", null));
|
|
7057
|
+
}
|
|
7058
|
+
};
|
|
7044
7059
|
SnkApplication.style = snkApplicationCss;
|
|
7045
7060
|
|
|
7046
7061
|
export { SnkApplication as snk_application };
|