@sankhyalabs/sankhyablocks 1.3.0 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{index-4720dab8.js → index-8272993f.js} +439 -7
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/sankhyablocks.cjs.js +2 -2
- package/dist/cjs/snk-application.cjs.entry.js +227 -57
- package/dist/cjs/snk-pesquisa.cjs.entry.js +19 -0
- package/dist/cjs/teste-pesquisa.cjs.entry.js +37 -0
- package/dist/collection/collection-manifest.json +3 -1
- package/dist/collection/components/snk-application/snk-application.js +104 -3
- package/dist/collection/components/snk-pesquisa/snk-pesquisa.css +3 -0
- package/dist/collection/components/snk-pesquisa/snk-pesquisa.js +74 -0
- package/dist/collection/components/teste-pesquisa/teste-pesquisa.css +3 -0
- package/dist/collection/components/teste-pesquisa/teste-pesquisa.js +33 -0
- package/dist/collection/lib/http/data-fetcher/DataFetcher.js +47 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/dataunit-fetcher.js +17 -16
- package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +82 -0
- package/dist/collection/lib/workspace/workspace.js +2 -1
- package/dist/components/snk-application.js +1 -7089
- package/dist/components/snk-application2.js +7269 -0
- package/dist/components/snk-pesquisa.d.ts +11 -0
- package/dist/components/snk-pesquisa.js +6 -0
- package/dist/components/snk-pesquisa2.js +34 -0
- package/dist/components/teste-pesquisa.d.ts +11 -0
- package/dist/components/teste-pesquisa.js +63 -0
- package/dist/esm/{index-72d4e2e0.js → index-427447f8.js} +439 -8
- package/dist/esm/loader.js +2 -2
- package/dist/esm/sankhyablocks.js +2 -2
- package/dist/esm/snk-application.entry.js +228 -58
- package/dist/esm/snk-pesquisa.entry.js +15 -0
- package/dist/esm/teste-pesquisa.entry.js +33 -0
- package/dist/sankhyablocks/p-106c4d7b.entry.js +63 -0
- package/dist/sankhyablocks/p-91ca1a98.entry.js +1 -0
- package/dist/sankhyablocks/p-e6ba985e.entry.js +1 -0
- package/dist/sankhyablocks/p-ee5a384b.js +2 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-application/snk-application.d.ts +8 -0
- package/dist/types/components/snk-pesquisa/snk-pesquisa.d.ts +7 -0
- package/dist/types/components/teste-pesquisa/teste-pesquisa.d.ts +6 -0
- package/dist/types/components.d.ts +34 -0
- package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +3 -0
- package/dist/types/lib/http/data-fetcher/fetchers/dataunit-fetcher.d.ts +1 -1
- package/dist/types/lib/http/data-fetcher/fetchers/pesquisa-fetcher.d.ts +17 -0
- package/package.json +9 -5
- package/react/components.d.ts +2 -0
- package/react/components.js +2 -0
- package/react/components.js.map +1 -1
- package/dist/sankhyablocks/p-5d8ddbda.entry.js +0 -57
- package/dist/sankhyablocks/p-a33afc3b.js +0 -2
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
5
|
+
const index = require('./index-8272993f.js');
|
|
6
6
|
const core = require('@sankhyalabs/core');
|
|
7
7
|
const utils = require('@sankhyalabs/ezui/dist/collection/utils');
|
|
8
|
+
const UnitMetadata = require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
|
|
8
9
|
|
|
9
10
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
10
11
|
|
|
@@ -6433,6 +6434,30 @@ Object.defineProperty(exports, "GraphQLWebSocketClient", { enumerable: true, get
|
|
|
6433
6434
|
//# sourceMappingURL=index.js.map
|
|
6434
6435
|
});
|
|
6435
6436
|
|
|
6437
|
+
class UrlUtils {
|
|
6438
|
+
static getQueryParams(queryString) {
|
|
6439
|
+
const params = new Map();
|
|
6440
|
+
const re = /[?&]?([^=]+)=([^&]*)/g;
|
|
6441
|
+
let tokens;
|
|
6442
|
+
//Necessário por causa da tela Histórico Padrão que possui resourceID com acento
|
|
6443
|
+
queryString = window.unescape(queryString);
|
|
6444
|
+
queryString = queryString.split("+").join(" ");
|
|
6445
|
+
while ((tokens = re.exec(queryString))) {
|
|
6446
|
+
params.set(window.decodeURIComponent(tokens[1]), tokens[2]);
|
|
6447
|
+
}
|
|
6448
|
+
//Inserimos a urlBase no params.
|
|
6449
|
+
params.set("urlBase", this.getUrlBase());
|
|
6450
|
+
if (window["moduleID"] && window["URIServiceBroker"]) {
|
|
6451
|
+
params.set("moduleID", window["moduleID"]);
|
|
6452
|
+
params.set("URIServiceBroker", window["URIServiceBroker"]);
|
|
6453
|
+
}
|
|
6454
|
+
return params;
|
|
6455
|
+
}
|
|
6456
|
+
static getUrlBase() {
|
|
6457
|
+
return `${location.protocol}"//"${location.hostname}${location.port ? ":" + location.port : ""}`;
|
|
6458
|
+
}
|
|
6459
|
+
}
|
|
6460
|
+
|
|
6436
6461
|
class HttpFetcher {
|
|
6437
6462
|
constructor() {
|
|
6438
6463
|
this.watingRequestsById = new Map();
|
|
@@ -6479,6 +6504,52 @@ class HttpFetcher {
|
|
|
6479
6504
|
return (_a = this.getWatingRequest(reqKey)) === null || _a === void 0 ? void 0 : _a.promise;
|
|
6480
6505
|
}
|
|
6481
6506
|
}
|
|
6507
|
+
resolveURL() {
|
|
6508
|
+
if (window['mock_url'])
|
|
6509
|
+
return window['mock_url'];
|
|
6510
|
+
return UrlUtils.getUrlBase();
|
|
6511
|
+
}
|
|
6512
|
+
getContext() {
|
|
6513
|
+
const urlParams = UrlUtils.getQueryParams(location.search);
|
|
6514
|
+
return {
|
|
6515
|
+
baseUrl: `${this.resolveURL()}/mge/service.sbr`,
|
|
6516
|
+
appName: "SankhyaBlocks",
|
|
6517
|
+
mgeSession: `${window['skw_session'] || urlParams.mgeSession}`,
|
|
6518
|
+
globalID: "85C0093DFA240EAB699B4E47A10215BD",
|
|
6519
|
+
resourceID: "br.com.sankhya.mov.bancaria"
|
|
6520
|
+
};
|
|
6521
|
+
}
|
|
6522
|
+
async callServiceBroker(serviceName, payload) {
|
|
6523
|
+
return new Promise((accept, reject) => {
|
|
6524
|
+
const ctx = this.getContext();
|
|
6525
|
+
const url = `${ctx.baseUrl}?serviceName=${serviceName}&counter=21&application=${ctx.appName}&outputType=json&preventTransform=false&mgeSession=${ctx.mgeSession}&resourceID=${ctx.resourceID}&globalID=${ctx.globalID}&allowConcurrentCalls=true`;
|
|
6526
|
+
document.cookie = `JSESSIONID=${ctx.mgeSession};`;
|
|
6527
|
+
const http = new XMLHttpRequest();
|
|
6528
|
+
http.open("POST", url, true);
|
|
6529
|
+
http.withCredentials = true;
|
|
6530
|
+
http.send(payload);
|
|
6531
|
+
http.onreadystatechange = function () {
|
|
6532
|
+
if (this.readyState == 4 && this.status == 200) {
|
|
6533
|
+
try {
|
|
6534
|
+
const jsonResp = JSON.parse(this.responseText);
|
|
6535
|
+
if (jsonResp.status == 1) {
|
|
6536
|
+
accept(jsonResp.responseBody);
|
|
6537
|
+
}
|
|
6538
|
+
else {
|
|
6539
|
+
reject(jsonResp);
|
|
6540
|
+
}
|
|
6541
|
+
}
|
|
6542
|
+
catch (e) {
|
|
6543
|
+
console.warn(`callServiceBroker error to parser response to JSON ${e}`);
|
|
6544
|
+
reject(this.responseText);
|
|
6545
|
+
}
|
|
6546
|
+
}
|
|
6547
|
+
else if (this.readyState == 4 && this.status != 200) {
|
|
6548
|
+
reject(this.responseText);
|
|
6549
|
+
}
|
|
6550
|
+
};
|
|
6551
|
+
});
|
|
6552
|
+
}
|
|
6482
6553
|
getReqKey(req) {
|
|
6483
6554
|
return window.btoa(this.hashCode(`${req.query}${JSON.stringify(req.values || "")}`)).replace(/=/g, "");
|
|
6484
6555
|
}
|
|
@@ -6604,6 +6675,7 @@ class DataUnitFetcher {
|
|
|
6604
6675
|
name
|
|
6605
6676
|
defaultValue
|
|
6606
6677
|
label
|
|
6678
|
+
visible
|
|
6607
6679
|
readOnly
|
|
6608
6680
|
required
|
|
6609
6681
|
dataType
|
|
@@ -6713,7 +6785,7 @@ class DataUnitFetcher {
|
|
|
6713
6785
|
const changes = duChanges.map((change) => {
|
|
6714
6786
|
const { dataUnit: changeDU, record, updatingFields, operation } = change;
|
|
6715
6787
|
const parsedUpdatingFields = Object.entries(updatingFields).map(([fieldName, value]) => {
|
|
6716
|
-
return { fieldName, value:
|
|
6788
|
+
return { fieldName, value: formatValueToServer(value) };
|
|
6717
6789
|
});
|
|
6718
6790
|
return { dataUnit: changeDU, updatingFields: parsedUpdatingFields, operation, recordId: record.__record__id__ };
|
|
6719
6791
|
});
|
|
@@ -6742,21 +6814,6 @@ class DataUnitFetcher {
|
|
|
6742
6814
|
});
|
|
6743
6815
|
});
|
|
6744
6816
|
}
|
|
6745
|
-
formatValueToServer(value) {
|
|
6746
|
-
if (value === undefined)
|
|
6747
|
-
return value;
|
|
6748
|
-
try {
|
|
6749
|
-
if (value instanceof Date) {
|
|
6750
|
-
return value.toString();
|
|
6751
|
-
}
|
|
6752
|
-
//Any others objects
|
|
6753
|
-
value = JSON.stringify(value);
|
|
6754
|
-
}
|
|
6755
|
-
catch (_a) {
|
|
6756
|
-
value = value.toString();
|
|
6757
|
-
}
|
|
6758
|
-
return value;
|
|
6759
|
-
}
|
|
6760
6817
|
removeRecords(dataUnit, recordIds) {
|
|
6761
6818
|
const changes = recordIds.map((recordId) => {
|
|
6762
6819
|
return { dataUnit: dataUnit.name, operation: core.ChangeOperation.DELETE, recordId };
|
|
@@ -6776,38 +6833,30 @@ class DataUnitFetcher {
|
|
|
6776
6833
|
});
|
|
6777
6834
|
}
|
|
6778
6835
|
}
|
|
6779
|
-
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
|
|
6783
|
-
|
|
6784
|
-
|
|
6785
|
-
//Necessário por causa da tela Histórico Padrão que possui resourceID com acento
|
|
6786
|
-
queryString = window.unescape(queryString);
|
|
6787
|
-
queryString = queryString.split("+").join(" ");
|
|
6788
|
-
while ((tokens = re.exec(queryString))) {
|
|
6789
|
-
params.set(window.decodeURIComponent(tokens[1]), tokens[2]);
|
|
6790
|
-
}
|
|
6791
|
-
//Inserimos a urlBase no params.
|
|
6792
|
-
params.set("urlBase", this.getUrlBase());
|
|
6793
|
-
if (window["moduleID"] && window["URIServiceBroker"]) {
|
|
6794
|
-
params.set("moduleID", window["moduleID"]);
|
|
6795
|
-
params.set("URIServiceBroker", window["URIServiceBroker"]);
|
|
6836
|
+
const formatValueToServer = (value) => {
|
|
6837
|
+
if (value === undefined)
|
|
6838
|
+
return value;
|
|
6839
|
+
try {
|
|
6840
|
+
if (value instanceof Date) {
|
|
6841
|
+
return value.toString();
|
|
6796
6842
|
}
|
|
6797
|
-
|
|
6843
|
+
//Any others objects
|
|
6844
|
+
value = JSON.stringify(value);
|
|
6798
6845
|
}
|
|
6799
|
-
|
|
6800
|
-
|
|
6846
|
+
catch (_a) {
|
|
6847
|
+
value = value.toString();
|
|
6801
6848
|
}
|
|
6802
|
-
|
|
6849
|
+
return value;
|
|
6850
|
+
};
|
|
6803
6851
|
|
|
6852
|
+
var _a;
|
|
6804
6853
|
class Workspace {
|
|
6805
6854
|
static openAppActivity(resourceId, pkObject) {
|
|
6806
6855
|
var _a;
|
|
6807
6856
|
(_a = window["workspace"]) === null || _a === void 0 ? void 0 : _a.openAppActivity(resourceId, pkObject);
|
|
6808
6857
|
}
|
|
6809
6858
|
}
|
|
6810
|
-
Workspace.resourceID = window["workspace"].resourceID;
|
|
6859
|
+
Workspace.resourceID = (_a = window["workspace"]) === null || _a === void 0 ? void 0 : _a.resourceID;
|
|
6811
6860
|
|
|
6812
6861
|
class ParametersFetcher {
|
|
6813
6862
|
constructor() {
|
|
@@ -6920,22 +6969,85 @@ class FormConfigFetcher extends ResourceFetcher {
|
|
|
6920
6969
|
}
|
|
6921
6970
|
}
|
|
6922
6971
|
|
|
6923
|
-
|
|
6924
|
-
|
|
6925
|
-
|
|
6926
|
-
|
|
6927
|
-
|
|
6928
|
-
|
|
6929
|
-
|
|
6930
|
-
|
|
6931
|
-
|
|
6932
|
-
|
|
6933
|
-
|
|
6934
|
-
|
|
6935
|
-
|
|
6936
|
-
|
|
6937
|
-
|
|
6938
|
-
|
|
6972
|
+
class PesquisaFetcher {
|
|
6973
|
+
constructor() {
|
|
6974
|
+
this.templateByQuery = new Map();
|
|
6975
|
+
this.buldTemplates();
|
|
6976
|
+
}
|
|
6977
|
+
buldTemplates() {
|
|
6978
|
+
this.templateByQuery.set("search", dist.gql `query($entityName: String! $argument: String $criteria: SearchCriteria) {
|
|
6979
|
+
$queryAlias$: search(entityName: $entityName argument: $argument criteria: $criteria){
|
|
6980
|
+
value
|
|
6981
|
+
label
|
|
6982
|
+
}
|
|
6983
|
+
}`);
|
|
6984
|
+
}
|
|
6985
|
+
loadSearchOptions(entityName, argument, criteria) {
|
|
6986
|
+
return new Promise((resolve, reject) => {
|
|
6987
|
+
HttpFetcher.get()
|
|
6988
|
+
.callGraphQL({
|
|
6989
|
+
values: { argument, entityName, criteria },
|
|
6990
|
+
query: this.templateByQuery.get("search"),
|
|
6991
|
+
})
|
|
6992
|
+
.then((result) => {
|
|
6993
|
+
resolve(result);
|
|
6994
|
+
})
|
|
6995
|
+
.catch((error) => {
|
|
6996
|
+
reject(error);
|
|
6997
|
+
});
|
|
6998
|
+
});
|
|
6999
|
+
}
|
|
7000
|
+
loadAdvancedSearch(entityName, argument, criteria) {
|
|
7001
|
+
const serviceName = "PesquisaSP.getSuggestion";
|
|
7002
|
+
const externalCriteria = {
|
|
7003
|
+
query: {
|
|
7004
|
+
$: criteria === null || criteria === void 0 ? void 0 : criteria.expression
|
|
7005
|
+
}
|
|
7006
|
+
};
|
|
7007
|
+
if ((criteria === null || criteria === void 0 ? void 0 : criteria.params.length) > 0) {
|
|
7008
|
+
externalCriteria.params = {
|
|
7009
|
+
param: criteria.params.map(p => { return { $: p.value, type: convertParamType(p.dataType) }; })
|
|
7010
|
+
};
|
|
7011
|
+
}
|
|
7012
|
+
const reqBody = {
|
|
7013
|
+
"serviceName": serviceName,
|
|
7014
|
+
"requestBody": {
|
|
7015
|
+
"criteria": {
|
|
7016
|
+
"entityName": entityName,
|
|
7017
|
+
"compacted": false,
|
|
7018
|
+
"ignoreEntityCriteria": false,
|
|
7019
|
+
"limit": "5",
|
|
7020
|
+
"query": { "$": argument },
|
|
7021
|
+
"orderByDesc": false,
|
|
7022
|
+
"options": { "showInactives": false },
|
|
7023
|
+
"externalCriteria": externalCriteria
|
|
7024
|
+
},
|
|
7025
|
+
"clientEventList": {
|
|
7026
|
+
"clientEvent": []
|
|
7027
|
+
}
|
|
7028
|
+
}
|
|
7029
|
+
};
|
|
7030
|
+
return new Promise((resolve, reject) => {
|
|
7031
|
+
HttpFetcher.get()
|
|
7032
|
+
.callServiceBroker("PesquisaSP.getSuggestion", JSON.stringify(reqBody))
|
|
7033
|
+
.then(result => resolve(result))
|
|
7034
|
+
.catch(error => reject(error));
|
|
7035
|
+
});
|
|
7036
|
+
}
|
|
7037
|
+
}
|
|
7038
|
+
function convertParamType(dataType) {
|
|
7039
|
+
//Alerta: Cuidado pra não contaminar o DataType com a implementação
|
|
7040
|
+
//atual da pesquisa... em geral, somente inteiros,
|
|
7041
|
+
//data (com ou sem hora) e string são realmente relevantes
|
|
7042
|
+
switch (dataType) {
|
|
7043
|
+
case core.DataType.NUMBER:
|
|
7044
|
+
return "I";
|
|
7045
|
+
case core.DataType.DATE:
|
|
7046
|
+
return "D";
|
|
7047
|
+
default:
|
|
7048
|
+
return "S";
|
|
7049
|
+
}
|
|
7050
|
+
}
|
|
6939
7051
|
|
|
6940
7052
|
const snkApplicationCss = ".sc-snk-application-h{display:flex;flex-direction:column;height:100%}";
|
|
6941
7053
|
|
|
@@ -6975,6 +7087,16 @@ const SnkApplication = class {
|
|
|
6975
7087
|
async getDateParam(name) {
|
|
6976
7088
|
return this.parameters.asDate(name, this.resourceID);
|
|
6977
7089
|
}
|
|
7090
|
+
async showPopUp(content) {
|
|
7091
|
+
this._popUp.appendChild(content);
|
|
7092
|
+
this._popUp["opened"] = true;
|
|
7093
|
+
}
|
|
7094
|
+
async closePopUp() {
|
|
7095
|
+
Array.from(this._popUp.children).forEach(c => {
|
|
7096
|
+
this._popUp.removeChild(c);
|
|
7097
|
+
});
|
|
7098
|
+
this._popUp["opened"] = false;
|
|
7099
|
+
}
|
|
6978
7100
|
async temOpcional(opcional) {
|
|
6979
7101
|
const opts = opcional.split(",");
|
|
6980
7102
|
return new Promise((resolve, reject) => {
|
|
@@ -7047,8 +7169,56 @@ const SnkApplication = class {
|
|
|
7047
7169
|
}
|
|
7048
7170
|
return this._formConfigFetcher;
|
|
7049
7171
|
}
|
|
7172
|
+
get pesquisaFetcher() {
|
|
7173
|
+
if (!this._pesquisaFetcher) {
|
|
7174
|
+
this._pesquisaFetcher = new PesquisaFetcher();
|
|
7175
|
+
}
|
|
7176
|
+
return this._pesquisaFetcher;
|
|
7177
|
+
}
|
|
7178
|
+
executeSearch(searchArgument, fieldName, dataUnit) {
|
|
7179
|
+
const descriptor = dataUnit.getField(fieldName);
|
|
7180
|
+
if (!descriptor) ;
|
|
7181
|
+
else {
|
|
7182
|
+
const { mode, argument } = searchArgument;
|
|
7183
|
+
const { ENTITYNAME } = descriptor.properties;
|
|
7184
|
+
const dependencies = descriptor.dependencies;
|
|
7185
|
+
let criteria;
|
|
7186
|
+
dependencies === null || dependencies === void 0 ? void 0 : dependencies.forEach(dependency => {
|
|
7187
|
+
var _a;
|
|
7188
|
+
if (dependency.type === UnitMetadata.DependencyType.SEARCHING) {
|
|
7189
|
+
if (((_a = dependency.masterFields) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
7190
|
+
criteria = {
|
|
7191
|
+
expression: dependency.expression,
|
|
7192
|
+
params: dependency.masterFields.map(fieldName => {
|
|
7193
|
+
const masterDescriptor = dataUnit.getField(fieldName);
|
|
7194
|
+
const dataType = (masterDescriptor === null || masterDescriptor === void 0 ? void 0 : masterDescriptor.dataType) || core.DataType.TEXT;
|
|
7195
|
+
return { name: fieldName, value: dataUnit.getFieldValue(fieldName), dataType };
|
|
7196
|
+
})
|
|
7197
|
+
};
|
|
7198
|
+
}
|
|
7199
|
+
}
|
|
7200
|
+
});
|
|
7201
|
+
if (mode === "ADVANCED") {
|
|
7202
|
+
return new Promise(accept => {
|
|
7203
|
+
const pesquisaContent = document.createElement("snk-pesquisa");
|
|
7204
|
+
pesquisaContent.argument = argument;
|
|
7205
|
+
pesquisaContent.searchLoader = (text) => this.pesquisaFetcher.loadAdvancedSearch(ENTITYNAME, text, criteria);
|
|
7206
|
+
pesquisaContent.onSelectItem = (option) => {
|
|
7207
|
+
accept(option);
|
|
7208
|
+
this.closePopUp();
|
|
7209
|
+
};
|
|
7210
|
+
this.showPopUp(pesquisaContent);
|
|
7211
|
+
});
|
|
7212
|
+
}
|
|
7213
|
+
else {
|
|
7214
|
+
return this.pesquisaFetcher.loadSearchOptions(ENTITYNAME, argument, criteria);
|
|
7215
|
+
}
|
|
7216
|
+
}
|
|
7217
|
+
}
|
|
7050
7218
|
componentWillLoad() {
|
|
7051
|
-
core.ApplicationContext.setContextValue("__EZUI__SEARCH__OPTION__LOADER__",
|
|
7219
|
+
core.ApplicationContext.setContextValue("__EZUI__SEARCH__OPTION__LOADER__", (searchArgument, fieldName, dataUnit) => {
|
|
7220
|
+
return this.executeSearch(searchArgument, fieldName, dataUnit);
|
|
7221
|
+
});
|
|
7052
7222
|
}
|
|
7053
7223
|
componentDidLoad() {
|
|
7054
7224
|
this.applicationLoading.emit(true);
|
|
@@ -7057,7 +7227,7 @@ const SnkApplication = class {
|
|
|
7057
7227
|
});
|
|
7058
7228
|
}
|
|
7059
7229
|
render() {
|
|
7060
|
-
return (index.h("div", null));
|
|
7230
|
+
return (index.h("div", null, index.h("ez-popup", { opened: false, ref: (ref) => this._popUp = ref, onEzClosePopup: () => this.closePopUp() })));
|
|
7061
7231
|
}
|
|
7062
7232
|
};
|
|
7063
7233
|
SnkApplication.style = snkApplicationCss;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-8272993f.js');
|
|
6
|
+
|
|
7
|
+
const snkPesquisaCss = ":host{display:block}";
|
|
8
|
+
|
|
9
|
+
const SnkPesquisa = class {
|
|
10
|
+
constructor(hostRef) {
|
|
11
|
+
index.registerInstance(this, hostRef);
|
|
12
|
+
}
|
|
13
|
+
render() {
|
|
14
|
+
return (index.h(index.Host, null, index.h("ez-text-input", { ref: ref => this._textInput = ref, value: this.argument }), index.h("button", { onClick: () => this.searchLoader(this._textInput["value"]) }, "pesquisar"), index.h("button", { onClick: () => this.onSelectItem({ value: "10", label: "Zé das couves" }) }, "selecionar")));
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
SnkPesquisa.style = snkPesquisaCss;
|
|
18
|
+
|
|
19
|
+
exports.snk_pesquisa = SnkPesquisa;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-8272993f.js');
|
|
6
|
+
const core = require('@sankhyalabs/core');
|
|
7
|
+
|
|
8
|
+
const testePesquisaCss = ":host{display:block}";
|
|
9
|
+
|
|
10
|
+
const TestePesquisa = class {
|
|
11
|
+
constructor(hostRef) {
|
|
12
|
+
index.registerInstance(this, hostRef);
|
|
13
|
+
}
|
|
14
|
+
componentWillLoad() {
|
|
15
|
+
this.dataUnit = new core.DataUnit("testes_com_formulario");
|
|
16
|
+
this.dataUnit.metadata = {
|
|
17
|
+
name: "dd://br.com.sankhya.fin.cad.movimentacaoFinanceira/Financeiro",
|
|
18
|
+
label: "Parceiro",
|
|
19
|
+
fields: [
|
|
20
|
+
{
|
|
21
|
+
name: "CODPARC",
|
|
22
|
+
label: "Parceiro",
|
|
23
|
+
dataType: core.DataType.NUMBER,
|
|
24
|
+
userInterface: core.UserInterface.SEARCH,
|
|
25
|
+
required: true,
|
|
26
|
+
properties: { ENTITYNAME: "Parceiro" }
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
render() {
|
|
32
|
+
return (index.h("snk-application", null, index.h("ez-form", { dataUnit: this.dataUnit })));
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
TestePesquisa.style = testePesquisaCss;
|
|
36
|
+
|
|
37
|
+
exports.teste_pesquisa = TestePesquisa;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"entries": [
|
|
3
|
-
"./components/snk-application/snk-application.js"
|
|
3
|
+
"./components/snk-application/snk-application.js",
|
|
4
|
+
"./components/snk-pesquisa/snk-pesquisa.js",
|
|
5
|
+
"./components/teste-pesquisa/teste-pesquisa.js"
|
|
4
6
|
],
|
|
5
7
|
"compiler": {
|
|
6
8
|
"name": "@stencil/core",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Component, h, Method, Event } from "@stencil/core";
|
|
2
|
+
import { DataType } from "@sankhyalabs/core";
|
|
2
3
|
import DataUnitFetcher from "../../lib/http/data-fetcher/fetchers/dataunit-fetcher";
|
|
3
4
|
import UrlUtils from "../../lib/utils/urlutils";
|
|
4
5
|
import Workspace from "../../lib/workspace/workspace";
|
|
@@ -6,7 +7,8 @@ import ParametersFetcher from "../../lib/http/data-fetcher/fetchers/parameters-f
|
|
|
6
7
|
import { ApplicationUtils } from "@sankhyalabs/ezui/dist/collection/utils";
|
|
7
8
|
import { FormConfigFetcher } from "../../lib/http/data-fetcher/fetchers/form-config-fetcher";
|
|
8
9
|
import { ApplicationContext } from "@sankhyalabs/core";
|
|
9
|
-
import {
|
|
10
|
+
import { PesquisaFetcher } from "../../lib/http/data-fetcher/fetchers/pesquisa-fetcher";
|
|
11
|
+
import { DependencyType } from "@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";
|
|
10
12
|
export class SnkApplication {
|
|
11
13
|
get parameters() {
|
|
12
14
|
if (!this._parameters) {
|
|
@@ -38,6 +40,16 @@ export class SnkApplication {
|
|
|
38
40
|
async getDateParam(name) {
|
|
39
41
|
return this.parameters.asDate(name, this.resourceID);
|
|
40
42
|
}
|
|
43
|
+
async showPopUp(content) {
|
|
44
|
+
this._popUp.appendChild(content);
|
|
45
|
+
this._popUp["opened"] = true;
|
|
46
|
+
}
|
|
47
|
+
async closePopUp() {
|
|
48
|
+
Array.from(this._popUp.children).forEach(c => {
|
|
49
|
+
this._popUp.removeChild(c);
|
|
50
|
+
});
|
|
51
|
+
this._popUp["opened"] = false;
|
|
52
|
+
}
|
|
41
53
|
async temOpcional(opcional) {
|
|
42
54
|
const opts = opcional.split(",");
|
|
43
55
|
return new Promise((resolve, reject) => {
|
|
@@ -110,8 +122,58 @@ export class SnkApplication {
|
|
|
110
122
|
}
|
|
111
123
|
return this._formConfigFetcher;
|
|
112
124
|
}
|
|
125
|
+
get pesquisaFetcher() {
|
|
126
|
+
if (!this._pesquisaFetcher) {
|
|
127
|
+
this._pesquisaFetcher = new PesquisaFetcher();
|
|
128
|
+
}
|
|
129
|
+
return this._pesquisaFetcher;
|
|
130
|
+
}
|
|
131
|
+
executeSearch(searchArgument, fieldName, dataUnit) {
|
|
132
|
+
const descriptor = dataUnit.getField(fieldName);
|
|
133
|
+
if (!descriptor) {
|
|
134
|
+
//TODO: Implementar mensagem de erro
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
const { mode, argument } = searchArgument;
|
|
138
|
+
const { ENTITYNAME } = descriptor.properties;
|
|
139
|
+
const dependencies = descriptor.dependencies;
|
|
140
|
+
let criteria;
|
|
141
|
+
dependencies === null || dependencies === void 0 ? void 0 : dependencies.forEach(dependency => {
|
|
142
|
+
var _a;
|
|
143
|
+
if (dependency.type === DependencyType.SEARCHING) {
|
|
144
|
+
if (((_a = dependency.masterFields) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
145
|
+
criteria = {
|
|
146
|
+
expression: dependency.expression,
|
|
147
|
+
params: dependency.masterFields.map(fieldName => {
|
|
148
|
+
const masterDescriptor = dataUnit.getField(fieldName);
|
|
149
|
+
const dataType = (masterDescriptor === null || masterDescriptor === void 0 ? void 0 : masterDescriptor.dataType) || DataType.TEXT;
|
|
150
|
+
return { name: fieldName, value: dataUnit.getFieldValue(fieldName), dataType };
|
|
151
|
+
})
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
if (mode === "ADVANCED") {
|
|
157
|
+
return new Promise(accept => {
|
|
158
|
+
const pesquisaContent = document.createElement("snk-pesquisa");
|
|
159
|
+
pesquisaContent.argument = argument;
|
|
160
|
+
pesquisaContent.searchLoader = (text) => this.pesquisaFetcher.loadAdvancedSearch(ENTITYNAME, text, criteria);
|
|
161
|
+
pesquisaContent.onSelectItem = (option) => {
|
|
162
|
+
accept(option);
|
|
163
|
+
this.closePopUp();
|
|
164
|
+
};
|
|
165
|
+
this.showPopUp(pesquisaContent);
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
return this.pesquisaFetcher.loadSearchOptions(ENTITYNAME, argument, criteria);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
113
173
|
componentWillLoad() {
|
|
114
|
-
ApplicationContext.setContextValue("__EZUI__SEARCH__OPTION__LOADER__",
|
|
174
|
+
ApplicationContext.setContextValue("__EZUI__SEARCH__OPTION__LOADER__", (searchArgument, fieldName, dataUnit) => {
|
|
175
|
+
return this.executeSearch(searchArgument, fieldName, dataUnit);
|
|
176
|
+
});
|
|
115
177
|
}
|
|
116
178
|
componentDidLoad() {
|
|
117
179
|
this.applicationLoading.emit(true);
|
|
@@ -120,7 +182,8 @@ export class SnkApplication {
|
|
|
120
182
|
});
|
|
121
183
|
}
|
|
122
184
|
render() {
|
|
123
|
-
return (h("div", null
|
|
185
|
+
return (h("div", null,
|
|
186
|
+
h("ez-popup", { opened: false, ref: (ref) => this._popUp = ref, onEzClosePopup: () => this.closePopUp() })));
|
|
124
187
|
}
|
|
125
188
|
static get is() { return "snk-application"; }
|
|
126
189
|
static get encapsulation() { return "scoped"; }
|
|
@@ -260,6 +323,44 @@ export class SnkApplication {
|
|
|
260
323
|
"tags": []
|
|
261
324
|
}
|
|
262
325
|
},
|
|
326
|
+
"showPopUp": {
|
|
327
|
+
"complexType": {
|
|
328
|
+
"signature": "(content: HTMLElement) => Promise<void>",
|
|
329
|
+
"parameters": [{
|
|
330
|
+
"tags": [],
|
|
331
|
+
"text": ""
|
|
332
|
+
}],
|
|
333
|
+
"references": {
|
|
334
|
+
"Promise": {
|
|
335
|
+
"location": "global"
|
|
336
|
+
},
|
|
337
|
+
"HTMLElement": {
|
|
338
|
+
"location": "global"
|
|
339
|
+
}
|
|
340
|
+
},
|
|
341
|
+
"return": "Promise<void>"
|
|
342
|
+
},
|
|
343
|
+
"docs": {
|
|
344
|
+
"text": "",
|
|
345
|
+
"tags": []
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
"closePopUp": {
|
|
349
|
+
"complexType": {
|
|
350
|
+
"signature": "() => Promise<void>",
|
|
351
|
+
"parameters": [],
|
|
352
|
+
"references": {
|
|
353
|
+
"Promise": {
|
|
354
|
+
"location": "global"
|
|
355
|
+
}
|
|
356
|
+
},
|
|
357
|
+
"return": "Promise<void>"
|
|
358
|
+
},
|
|
359
|
+
"docs": {
|
|
360
|
+
"text": "",
|
|
361
|
+
"tags": []
|
|
362
|
+
}
|
|
363
|
+
},
|
|
263
364
|
"temOpcional": {
|
|
264
365
|
"complexType": {
|
|
265
366
|
"signature": "(opcional: string) => Promise<boolean>",
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Component, Host, h, Prop } from '@stencil/core';
|
|
2
|
+
export class SnkPesquisa {
|
|
3
|
+
render() {
|
|
4
|
+
return (h(Host, null,
|
|
5
|
+
h("ez-text-input", { ref: ref => this._textInput = ref, value: this.argument }),
|
|
6
|
+
h("button", { onClick: () => this.searchLoader(this._textInput["value"]) }, "pesquisar"),
|
|
7
|
+
h("button", { onClick: () => this.onSelectItem({ value: "10", label: "Zé das couves" }) }, "selecionar")));
|
|
8
|
+
}
|
|
9
|
+
static get is() { return "snk-pesquisa"; }
|
|
10
|
+
static get encapsulation() { return "shadow"; }
|
|
11
|
+
static get originalStyleUrls() { return {
|
|
12
|
+
"$": ["snk-pesquisa.css"]
|
|
13
|
+
}; }
|
|
14
|
+
static get styleUrls() { return {
|
|
15
|
+
"$": ["snk-pesquisa.css"]
|
|
16
|
+
}; }
|
|
17
|
+
static get properties() { return {
|
|
18
|
+
"searchLoader": {
|
|
19
|
+
"type": "unknown",
|
|
20
|
+
"mutable": false,
|
|
21
|
+
"complexType": {
|
|
22
|
+
"original": "Function",
|
|
23
|
+
"resolved": "Function",
|
|
24
|
+
"references": {
|
|
25
|
+
"Function": {
|
|
26
|
+
"location": "global"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"required": false,
|
|
31
|
+
"optional": false,
|
|
32
|
+
"docs": {
|
|
33
|
+
"tags": [],
|
|
34
|
+
"text": ""
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"onSelectItem": {
|
|
38
|
+
"type": "unknown",
|
|
39
|
+
"mutable": false,
|
|
40
|
+
"complexType": {
|
|
41
|
+
"original": "Function",
|
|
42
|
+
"resolved": "Function",
|
|
43
|
+
"references": {
|
|
44
|
+
"Function": {
|
|
45
|
+
"location": "global"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"required": false,
|
|
50
|
+
"optional": false,
|
|
51
|
+
"docs": {
|
|
52
|
+
"tags": [],
|
|
53
|
+
"text": ""
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"argument": {
|
|
57
|
+
"type": "string",
|
|
58
|
+
"mutable": true,
|
|
59
|
+
"complexType": {
|
|
60
|
+
"original": "string",
|
|
61
|
+
"resolved": "string",
|
|
62
|
+
"references": {}
|
|
63
|
+
},
|
|
64
|
+
"required": false,
|
|
65
|
+
"optional": false,
|
|
66
|
+
"docs": {
|
|
67
|
+
"tags": [],
|
|
68
|
+
"text": ""
|
|
69
|
+
},
|
|
70
|
+
"attribute": "argument",
|
|
71
|
+
"reflect": false
|
|
72
|
+
}
|
|
73
|
+
}; }
|
|
74
|
+
}
|