@sankhyalabs/sankhyablocks 1.3.4 → 1.3.7
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/snk-application.cjs.entry.js +49 -36
- package/dist/collection/components/snk-application/snk-application.js +37 -11
- package/dist/collection/lib/http/data-fetcher/DataFetcher.js +8 -10
- package/dist/collection/lib/http/data-fetcher/fetchers/application-config-fetcher.js +2 -2
- package/dist/collection/lib/http/data-fetcher/fetchers/dataunit-fetcher.js +29 -17
- package/dist/collection/lib/http/data-fetcher/fetchers/parameters-fecher.js +2 -2
- package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +3 -3
- package/dist/collection/lib/http/data-fetcher/fetchers/resource-fetcher.js +2 -2
- package/dist/collection/lib/utils/urlutils.js +2 -0
- package/dist/components/snk-application2.js +50 -37
- package/dist/esm/snk-application.entry.js +50 -37
- package/dist/sankhyablocks/{p-62f86dd6.entry.js → p-9c2b5779.entry.js} +8 -8
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-application/snk-application.d.ts +5 -4
- package/dist/types/components.d.ts +5 -4
- package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +2 -2
- package/package.json +1 -1
|
@@ -6454,24 +6454,26 @@ class UrlUtils {
|
|
|
6454
6454
|
return params;
|
|
6455
6455
|
}
|
|
6456
6456
|
static getUrlBase() {
|
|
6457
|
+
if (window['mock_url'])
|
|
6458
|
+
return window['mock_url'];
|
|
6457
6459
|
return `${location.protocol}"//"${location.hostname}${location.port ? ":" + location.port : ""}`;
|
|
6458
6460
|
}
|
|
6459
6461
|
}
|
|
6460
6462
|
|
|
6461
|
-
class
|
|
6463
|
+
class DataFetcher {
|
|
6462
6464
|
constructor() {
|
|
6463
6465
|
this.watingRequestsById = new Map();
|
|
6464
6466
|
}
|
|
6465
6467
|
static get() {
|
|
6466
|
-
if (!
|
|
6467
|
-
|
|
6468
|
+
if (!DataFetcher.instance) {
|
|
6469
|
+
DataFetcher.instance = new DataFetcher();
|
|
6468
6470
|
const application = document.querySelector(this.appTagName);
|
|
6469
6471
|
if (application === null) {
|
|
6470
|
-
|
|
6472
|
+
DataFetcher.instance.resume();
|
|
6471
6473
|
}
|
|
6472
6474
|
else {
|
|
6473
|
-
application.addEventListener('applicationLoading', () =>
|
|
6474
|
-
application.addEventListener('applicationLoaded', () =>
|
|
6475
|
+
application.addEventListener('applicationLoading', () => DataFetcher.instance.pause());
|
|
6476
|
+
application.addEventListener('applicationLoaded', () => DataFetcher.instance.resume());
|
|
6475
6477
|
}
|
|
6476
6478
|
}
|
|
6477
6479
|
return this.instance;
|
|
@@ -6505,8 +6507,6 @@ class HttpFetcher {
|
|
|
6505
6507
|
}
|
|
6506
6508
|
}
|
|
6507
6509
|
resolveURL() {
|
|
6508
|
-
if (window['mock_url'])
|
|
6509
|
-
return window['mock_url'];
|
|
6510
6510
|
return UrlUtils.getUrlBase();
|
|
6511
6511
|
}
|
|
6512
6512
|
getContext() {
|
|
@@ -6598,7 +6598,7 @@ class HttpFetcher {
|
|
|
6598
6598
|
let dataResponse = [];
|
|
6599
6599
|
let errorsResponse = [];
|
|
6600
6600
|
try {
|
|
6601
|
-
res = await dist.batchRequests(
|
|
6601
|
+
res = await dist.batchRequests(this.resolveURL(), request);
|
|
6602
6602
|
res.forEach((resItem) => {
|
|
6603
6603
|
dataResponse.push(resItem.data);
|
|
6604
6604
|
});
|
|
@@ -6636,7 +6636,7 @@ class HttpFetcher {
|
|
|
6636
6636
|
}
|
|
6637
6637
|
;
|
|
6638
6638
|
}
|
|
6639
|
-
|
|
6639
|
+
DataFetcher.appTagName = "snk-application";
|
|
6640
6640
|
class WaitingRequest {
|
|
6641
6641
|
constructor(req) {
|
|
6642
6642
|
this._resolve = () => { };
|
|
@@ -6692,10 +6692,10 @@ class DataUnitFetcher {
|
|
|
6692
6692
|
}
|
|
6693
6693
|
}
|
|
6694
6694
|
}`);
|
|
6695
|
-
this.templateByQuery.set("fetchData", dist.gql `query($dataunit: String! $
|
|
6695
|
+
this.templateByQuery.set("fetchData", dist.gql `query($dataunit: String! $limit: Int $offset:Int $filter: [Filter!] $sort: [Sort!]) {
|
|
6696
6696
|
$queryAlias$: fetchDataUnit(name: $dataunit){
|
|
6697
|
-
data(
|
|
6698
|
-
|
|
6697
|
+
data(limit: $limit offset: $offset filters: $filter sort: $sort){
|
|
6698
|
+
limit
|
|
6699
6699
|
offset
|
|
6700
6700
|
total
|
|
6701
6701
|
hasMore
|
|
@@ -6723,14 +6723,14 @@ class DataUnitFetcher {
|
|
|
6723
6723
|
getDataUnit(entityName, resourceID) {
|
|
6724
6724
|
const dataUnit = new core.DataUnit(`dd://${entityName}/${resourceID}`);
|
|
6725
6725
|
dataUnit.metadataLoader = (dataUnit) => this.loadMetadata(dataUnit);
|
|
6726
|
-
dataUnit.dataLoader = (dataUnit, sort, filters) => this.loadData(dataUnit, sort, filters);
|
|
6726
|
+
dataUnit.dataLoader = (dataUnit, page, sort, filters) => this.loadData(dataUnit, page, sort, filters);
|
|
6727
6727
|
dataUnit.saveLoader = (dataUnit, changes) => this.saveData(dataUnit, changes);
|
|
6728
6728
|
dataUnit.removeLoader = (dataUnit, recordIds) => this.removeRecords(dataUnit, recordIds);
|
|
6729
6729
|
return dataUnit;
|
|
6730
6730
|
}
|
|
6731
6731
|
loadMetadata(dataUnit) {
|
|
6732
6732
|
return new Promise((resolve, reject) => {
|
|
6733
|
-
|
|
6733
|
+
DataFetcher.get()
|
|
6734
6734
|
.callGraphQL({
|
|
6735
6735
|
values: { name: dataUnit.name },
|
|
6736
6736
|
query: this.templateByQuery.get("fetchDataUnit"),
|
|
@@ -6757,24 +6757,36 @@ class DataUnitFetcher {
|
|
|
6757
6757
|
});
|
|
6758
6758
|
});
|
|
6759
6759
|
}
|
|
6760
|
-
loadData(dataUnit, sort, filters) {
|
|
6760
|
+
loadData(dataUnit, page, sort, filters) {
|
|
6761
6761
|
return new Promise((resolve, reject) => {
|
|
6762
|
-
|
|
6762
|
+
const variables = { dataunit: dataUnit.name, sort, filters };
|
|
6763
|
+
if (page) {
|
|
6764
|
+
variables.limit = page.limit;
|
|
6765
|
+
variables.offset = page.offset;
|
|
6766
|
+
}
|
|
6767
|
+
if (!core.StringUtils.isEmpty(page === null || page === void 0 ? void 0 : page.quickFilter)) {
|
|
6768
|
+
variables.filter = [{
|
|
6769
|
+
name: "__ALL_SEARCHABLE_FIELDS__",
|
|
6770
|
+
expression: "__ALL_SEARCHABLE_FIELDS__",
|
|
6771
|
+
params: [{ name: "term", value: page.quickFilter }]
|
|
6772
|
+
}];
|
|
6773
|
+
}
|
|
6774
|
+
DataFetcher.get()
|
|
6763
6775
|
.callGraphQL({
|
|
6764
|
-
values:
|
|
6776
|
+
values: variables,
|
|
6765
6777
|
query: this.templateByQuery.get("fetchData"),
|
|
6766
6778
|
})
|
|
6767
6779
|
.then((resp) => {
|
|
6768
|
-
const
|
|
6769
|
-
const
|
|
6770
|
-
|
|
6780
|
+
const pageResult = resp.data;
|
|
6781
|
+
const records = [];
|
|
6782
|
+
pageResult.records.forEach((responseRecord) => {
|
|
6771
6783
|
const duRecord = { __record__id__: responseRecord.id };
|
|
6772
6784
|
responseRecord.fields.forEach(({ name, value }) => {
|
|
6773
6785
|
duRecord[name] = dataUnit.valueFromString(name, value);
|
|
6774
6786
|
});
|
|
6775
|
-
|
|
6787
|
+
records.push(duRecord);
|
|
6776
6788
|
});
|
|
6777
|
-
resolve(
|
|
6789
|
+
resolve(Object.assign(Object.assign({}, pageResult), { records }));
|
|
6778
6790
|
})
|
|
6779
6791
|
.catch((error) => {
|
|
6780
6792
|
reject(error);
|
|
@@ -6797,7 +6809,7 @@ class DataUnitFetcher {
|
|
|
6797
6809
|
return reqChange;
|
|
6798
6810
|
});
|
|
6799
6811
|
return new Promise((resolve, reject) => {
|
|
6800
|
-
|
|
6812
|
+
DataFetcher.get()
|
|
6801
6813
|
.callGraphQL({
|
|
6802
6814
|
values: { changes: changes },
|
|
6803
6815
|
query: this.templateByQuery.get("saveData"),
|
|
@@ -6826,7 +6838,7 @@ class DataUnitFetcher {
|
|
|
6826
6838
|
return { dataUnit: dataUnit.name, operation: core.ChangeOperation.DELETE, recordId };
|
|
6827
6839
|
});
|
|
6828
6840
|
return new Promise((resolve, reject) => {
|
|
6829
|
-
|
|
6841
|
+
DataFetcher.get()
|
|
6830
6842
|
.callGraphQL({
|
|
6831
6843
|
values: { changes: changes },
|
|
6832
6844
|
query: this.templateByQuery.get("saveData"),
|
|
@@ -6880,7 +6892,7 @@ class ParametersFetcher {
|
|
|
6880
6892
|
}
|
|
6881
6893
|
async getParam(name, resourceID) {
|
|
6882
6894
|
const completPath = `param://${resourceID}?params=${window.btoa(name)}`;
|
|
6883
|
-
return
|
|
6895
|
+
return DataFetcher.get().callGraphQL({
|
|
6884
6896
|
values: { name: completPath },
|
|
6885
6897
|
query: this.templateByQuery.get("fetchParam"),
|
|
6886
6898
|
});
|
|
@@ -6936,7 +6948,7 @@ class ResourceFetcher {
|
|
|
6936
6948
|
}
|
|
6937
6949
|
loadResource(name) {
|
|
6938
6950
|
return new Promise((resolve, reject) => {
|
|
6939
|
-
|
|
6951
|
+
DataFetcher.get()
|
|
6940
6952
|
.callGraphQL({
|
|
6941
6953
|
values: { name },
|
|
6942
6954
|
query: this.templateByQuery.get("fetchResource"),
|
|
@@ -6991,7 +7003,7 @@ class PesquisaFetcher {
|
|
|
6991
7003
|
}
|
|
6992
7004
|
loadSearchOptions(entityName, argument, criteria) {
|
|
6993
7005
|
return new Promise((resolve, reject) => {
|
|
6994
|
-
|
|
7006
|
+
DataFetcher.get()
|
|
6995
7007
|
.callGraphQL({
|
|
6996
7008
|
values: { argument, entityName, criteria },
|
|
6997
7009
|
query: this.templateByQuery.get("search"),
|
|
@@ -7035,7 +7047,7 @@ class PesquisaFetcher {
|
|
|
7035
7047
|
}
|
|
7036
7048
|
};
|
|
7037
7049
|
return new Promise((resolve, reject) => {
|
|
7038
|
-
|
|
7050
|
+
DataFetcher.get()
|
|
7039
7051
|
.callServiceBroker("PesquisaSP.getSuggestion", JSON.stringify(reqBody))
|
|
7040
7052
|
.then(result => resolve(result))
|
|
7041
7053
|
.catch(error => reject(error));
|
|
@@ -7143,16 +7155,16 @@ const SnkApplication = class {
|
|
|
7143
7155
|
async getResourceID() {
|
|
7144
7156
|
return Promise.resolve(this.resourceID);
|
|
7145
7157
|
}
|
|
7146
|
-
async alert(title, message, icon) {
|
|
7147
|
-
return utils.ApplicationUtils.alert(title, message, icon);
|
|
7158
|
+
async alert(title, message, icon, options) {
|
|
7159
|
+
return utils.ApplicationUtils.alert(title, message, icon, options);
|
|
7148
7160
|
}
|
|
7149
|
-
async error(title, message, icon) {
|
|
7150
|
-
return utils.ApplicationUtils.error(title, message, icon);
|
|
7161
|
+
async error(title, message, icon, options) {
|
|
7162
|
+
return utils.ApplicationUtils.error(title, message, icon, options);
|
|
7151
7163
|
}
|
|
7152
|
-
async confirm(title, message, icon, critical) {
|
|
7153
|
-
return utils.ApplicationUtils.confirm(title, message, icon, critical);
|
|
7164
|
+
async confirm(title, message, icon, critical, options) {
|
|
7165
|
+
return utils.ApplicationUtils.confirm(title, message, icon, critical, options);
|
|
7154
7166
|
}
|
|
7155
|
-
async info(message, options
|
|
7167
|
+
async info(message, options) {
|
|
7156
7168
|
return utils.ApplicationUtils.info(message, options);
|
|
7157
7169
|
}
|
|
7158
7170
|
async loadFormConfig(name) {
|
|
@@ -7223,6 +7235,7 @@ const SnkApplication = class {
|
|
|
7223
7235
|
}
|
|
7224
7236
|
}
|
|
7225
7237
|
componentWillLoad() {
|
|
7238
|
+
core.ApplicationContext.setContextValue("__EZUI__UPLOAD__ADD__URL__", `${UrlUtils.getUrlBase()}/mge/ez.uploading`);
|
|
7226
7239
|
core.ApplicationContext.setContextValue("__EZUI__SEARCH__OPTION__LOADER__", (searchArgument, fieldName, dataUnit) => {
|
|
7227
7240
|
return this.executeSearch(searchArgument, fieldName, dataUnit);
|
|
7228
7241
|
});
|
|
@@ -89,16 +89,16 @@ export class SnkApplication {
|
|
|
89
89
|
async getResourceID() {
|
|
90
90
|
return Promise.resolve(this.resourceID);
|
|
91
91
|
}
|
|
92
|
-
async alert(title, message, icon) {
|
|
93
|
-
return ApplicationUtils.alert(title, message, icon);
|
|
92
|
+
async alert(title, message, icon, options) {
|
|
93
|
+
return ApplicationUtils.alert(title, message, icon, options);
|
|
94
94
|
}
|
|
95
|
-
async error(title, message, icon) {
|
|
96
|
-
return ApplicationUtils.error(title, message, icon);
|
|
95
|
+
async error(title, message, icon, options) {
|
|
96
|
+
return ApplicationUtils.error(title, message, icon, options);
|
|
97
97
|
}
|
|
98
|
-
async confirm(title, message, icon, critical) {
|
|
99
|
-
return ApplicationUtils.confirm(title, message, icon, critical);
|
|
98
|
+
async confirm(title, message, icon, critical, options) {
|
|
99
|
+
return ApplicationUtils.confirm(title, message, icon, critical, options);
|
|
100
100
|
}
|
|
101
|
-
async info(message, options
|
|
101
|
+
async info(message, options) {
|
|
102
102
|
return ApplicationUtils.info(message, options);
|
|
103
103
|
}
|
|
104
104
|
async loadFormConfig(name) {
|
|
@@ -171,6 +171,7 @@ export class SnkApplication {
|
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
componentWillLoad() {
|
|
174
|
+
ApplicationContext.setContextValue("__EZUI__UPLOAD__ADD__URL__", `${UrlUtils.getUrlBase()}/mge/ez.uploading`);
|
|
174
175
|
ApplicationContext.setContextValue("__EZUI__SEARCH__OPTION__LOADER__", (searchArgument, fieldName, dataUnit) => {
|
|
175
176
|
return this.executeSearch(searchArgument, fieldName, dataUnit);
|
|
176
177
|
});
|
|
@@ -465,7 +466,7 @@ export class SnkApplication {
|
|
|
465
466
|
},
|
|
466
467
|
"alert": {
|
|
467
468
|
"complexType": {
|
|
468
|
-
"signature": "(title: string, message: string, icon?: string) => Promise<boolean>",
|
|
469
|
+
"signature": "(title: string, message: string, icon?: string, options?: MessageOptions) => Promise<boolean>",
|
|
469
470
|
"parameters": [{
|
|
470
471
|
"tags": [],
|
|
471
472
|
"text": ""
|
|
@@ -475,10 +476,17 @@ export class SnkApplication {
|
|
|
475
476
|
}, {
|
|
476
477
|
"tags": [],
|
|
477
478
|
"text": ""
|
|
479
|
+
}, {
|
|
480
|
+
"tags": [],
|
|
481
|
+
"text": ""
|
|
478
482
|
}],
|
|
479
483
|
"references": {
|
|
480
484
|
"Promise": {
|
|
481
485
|
"location": "global"
|
|
486
|
+
},
|
|
487
|
+
"MessageOptions": {
|
|
488
|
+
"location": "import",
|
|
489
|
+
"path": "@sankhyalabs/ezui/dist/collection/utils"
|
|
482
490
|
}
|
|
483
491
|
},
|
|
484
492
|
"return": "Promise<boolean>"
|
|
@@ -490,7 +498,7 @@ export class SnkApplication {
|
|
|
490
498
|
},
|
|
491
499
|
"error": {
|
|
492
500
|
"complexType": {
|
|
493
|
-
"signature": "(title: string, message: string, icon?: string) => Promise<boolean>",
|
|
501
|
+
"signature": "(title: string, message: string, icon?: string, options?: MessageOptions) => Promise<boolean>",
|
|
494
502
|
"parameters": [{
|
|
495
503
|
"tags": [],
|
|
496
504
|
"text": ""
|
|
@@ -500,10 +508,17 @@ export class SnkApplication {
|
|
|
500
508
|
}, {
|
|
501
509
|
"tags": [],
|
|
502
510
|
"text": ""
|
|
511
|
+
}, {
|
|
512
|
+
"tags": [],
|
|
513
|
+
"text": ""
|
|
503
514
|
}],
|
|
504
515
|
"references": {
|
|
505
516
|
"Promise": {
|
|
506
517
|
"location": "global"
|
|
518
|
+
},
|
|
519
|
+
"MessageOptions": {
|
|
520
|
+
"location": "import",
|
|
521
|
+
"path": "@sankhyalabs/ezui/dist/collection/utils"
|
|
507
522
|
}
|
|
508
523
|
},
|
|
509
524
|
"return": "Promise<boolean>"
|
|
@@ -515,7 +530,7 @@ export class SnkApplication {
|
|
|
515
530
|
},
|
|
516
531
|
"confirm": {
|
|
517
532
|
"complexType": {
|
|
518
|
-
"signature": "(title: string, message: string, icon?: string, critical?: boolean) => Promise<boolean>",
|
|
533
|
+
"signature": "(title: string, message: string, icon?: string, critical?: boolean, options?: MessageOptions) => Promise<boolean>",
|
|
519
534
|
"parameters": [{
|
|
520
535
|
"tags": [],
|
|
521
536
|
"text": ""
|
|
@@ -528,10 +543,17 @@ export class SnkApplication {
|
|
|
528
543
|
}, {
|
|
529
544
|
"tags": [],
|
|
530
545
|
"text": ""
|
|
546
|
+
}, {
|
|
547
|
+
"tags": [],
|
|
548
|
+
"text": ""
|
|
531
549
|
}],
|
|
532
550
|
"references": {
|
|
533
551
|
"Promise": {
|
|
534
552
|
"location": "global"
|
|
553
|
+
},
|
|
554
|
+
"MessageOptions": {
|
|
555
|
+
"location": "import",
|
|
556
|
+
"path": "@sankhyalabs/ezui/dist/collection/utils"
|
|
535
557
|
}
|
|
536
558
|
},
|
|
537
559
|
"return": "Promise<boolean>"
|
|
@@ -543,7 +565,7 @@ export class SnkApplication {
|
|
|
543
565
|
},
|
|
544
566
|
"info": {
|
|
545
567
|
"complexType": {
|
|
546
|
-
"signature": "(message: string, options?:
|
|
568
|
+
"signature": "(message: string, options?: MessageOptions) => Promise<void>",
|
|
547
569
|
"parameters": [{
|
|
548
570
|
"tags": [],
|
|
549
571
|
"text": ""
|
|
@@ -554,6 +576,10 @@ export class SnkApplication {
|
|
|
554
576
|
"references": {
|
|
555
577
|
"Promise": {
|
|
556
578
|
"location": "global"
|
|
579
|
+
},
|
|
580
|
+
"MessageOptions": {
|
|
581
|
+
"location": "import",
|
|
582
|
+
"path": "@sankhyalabs/ezui/dist/collection/utils"
|
|
557
583
|
}
|
|
558
584
|
},
|
|
559
585
|
"return": "Promise<void>"
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { batchRequests } from 'graphql-request';
|
|
2
2
|
import UrlUtils from "../../../lib/utils/urlutils";
|
|
3
|
-
export class
|
|
3
|
+
export class DataFetcher {
|
|
4
4
|
constructor() {
|
|
5
5
|
this.watingRequestsById = new Map();
|
|
6
6
|
}
|
|
7
7
|
static get() {
|
|
8
|
-
if (!
|
|
9
|
-
|
|
8
|
+
if (!DataFetcher.instance) {
|
|
9
|
+
DataFetcher.instance = new DataFetcher();
|
|
10
10
|
const application = document.querySelector(this.appTagName);
|
|
11
11
|
if (application === null) {
|
|
12
|
-
|
|
12
|
+
DataFetcher.instance.resume();
|
|
13
13
|
}
|
|
14
14
|
else {
|
|
15
|
-
application.addEventListener('applicationLoading', () =>
|
|
16
|
-
application.addEventListener('applicationLoaded', () =>
|
|
15
|
+
application.addEventListener('applicationLoading', () => DataFetcher.instance.pause());
|
|
16
|
+
application.addEventListener('applicationLoaded', () => DataFetcher.instance.resume());
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
return this.instance;
|
|
@@ -47,8 +47,6 @@ export class HttpFetcher {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
resolveURL() {
|
|
50
|
-
if (window['mock_url'])
|
|
51
|
-
return window['mock_url'];
|
|
52
50
|
return UrlUtils.getUrlBase();
|
|
53
51
|
}
|
|
54
52
|
getContext() {
|
|
@@ -140,7 +138,7 @@ export class HttpFetcher {
|
|
|
140
138
|
let dataResponse = [];
|
|
141
139
|
let errorsResponse = [];
|
|
142
140
|
try {
|
|
143
|
-
res = await batchRequests(
|
|
141
|
+
res = await batchRequests(this.resolveURL(), request);
|
|
144
142
|
res.forEach((resItem) => {
|
|
145
143
|
dataResponse.push(resItem.data);
|
|
146
144
|
});
|
|
@@ -178,7 +176,7 @@ export class HttpFetcher {
|
|
|
178
176
|
}
|
|
179
177
|
;
|
|
180
178
|
}
|
|
181
|
-
|
|
179
|
+
DataFetcher.appTagName = "snk-application";
|
|
182
180
|
class WaitingRequest {
|
|
183
181
|
constructor(req) {
|
|
184
182
|
this._resolve = () => { };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { gql } from "graphql-request";
|
|
2
|
-
import {
|
|
2
|
+
import { DataFetcher } from "../DataFetcher";
|
|
3
3
|
export default class ApplicationConfigFetcher {
|
|
4
4
|
constructor() {
|
|
5
5
|
this.templateByQuery = new Map();
|
|
@@ -15,7 +15,7 @@ export default class ApplicationConfigFetcher {
|
|
|
15
15
|
}
|
|
16
16
|
getResource(name, resourceID) {
|
|
17
17
|
const completPath = `cfg://app/${resourceID}/${name}`;
|
|
18
|
-
return
|
|
18
|
+
return DataFetcher.get().callGraphQL({
|
|
19
19
|
values: { name: completPath },
|
|
20
20
|
query: this.templateByQuery.get("getResource"),
|
|
21
21
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DataUnit, ChangeOperation, } from "@sankhyalabs/core";
|
|
2
|
-
import {
|
|
1
|
+
import { DataUnit, ChangeOperation, StringUtils, } from "@sankhyalabs/core";
|
|
2
|
+
import { DataFetcher } from "../DataFetcher";
|
|
3
3
|
import { gql } from "graphql-request";
|
|
4
4
|
export default class DataUnitFetcher {
|
|
5
5
|
constructor() {
|
|
@@ -31,10 +31,10 @@ export default class DataUnitFetcher {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
}`);
|
|
34
|
-
this.templateByQuery.set("fetchData", gql `query($dataunit: String! $
|
|
34
|
+
this.templateByQuery.set("fetchData", gql `query($dataunit: String! $limit: Int $offset:Int $filter: [Filter!] $sort: [Sort!]) {
|
|
35
35
|
$queryAlias$: fetchDataUnit(name: $dataunit){
|
|
36
|
-
data(
|
|
37
|
-
|
|
36
|
+
data(limit: $limit offset: $offset filters: $filter sort: $sort){
|
|
37
|
+
limit
|
|
38
38
|
offset
|
|
39
39
|
total
|
|
40
40
|
hasMore
|
|
@@ -62,14 +62,14 @@ export default class DataUnitFetcher {
|
|
|
62
62
|
getDataUnit(entityName, resourceID) {
|
|
63
63
|
const dataUnit = new DataUnit(`dd://${entityName}/${resourceID}`);
|
|
64
64
|
dataUnit.metadataLoader = (dataUnit) => this.loadMetadata(dataUnit);
|
|
65
|
-
dataUnit.dataLoader = (dataUnit, sort, filters) => this.loadData(dataUnit, sort, filters);
|
|
65
|
+
dataUnit.dataLoader = (dataUnit, page, sort, filters) => this.loadData(dataUnit, page, sort, filters);
|
|
66
66
|
dataUnit.saveLoader = (dataUnit, changes) => this.saveData(dataUnit, changes);
|
|
67
67
|
dataUnit.removeLoader = (dataUnit, recordIds) => this.removeRecords(dataUnit, recordIds);
|
|
68
68
|
return dataUnit;
|
|
69
69
|
}
|
|
70
70
|
loadMetadata(dataUnit) {
|
|
71
71
|
return new Promise((resolve, reject) => {
|
|
72
|
-
|
|
72
|
+
DataFetcher.get()
|
|
73
73
|
.callGraphQL({
|
|
74
74
|
values: { name: dataUnit.name },
|
|
75
75
|
query: this.templateByQuery.get("fetchDataUnit"),
|
|
@@ -96,24 +96,36 @@ export default class DataUnitFetcher {
|
|
|
96
96
|
});
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
|
-
loadData(dataUnit, sort, filters) {
|
|
99
|
+
loadData(dataUnit, page, sort, filters) {
|
|
100
100
|
return new Promise((resolve, reject) => {
|
|
101
|
-
|
|
101
|
+
const variables = { dataunit: dataUnit.name, sort, filters };
|
|
102
|
+
if (page) {
|
|
103
|
+
variables.limit = page.limit;
|
|
104
|
+
variables.offset = page.offset;
|
|
105
|
+
}
|
|
106
|
+
if (!StringUtils.isEmpty(page === null || page === void 0 ? void 0 : page.quickFilter)) {
|
|
107
|
+
variables.filter = [{
|
|
108
|
+
name: "__ALL_SEARCHABLE_FIELDS__",
|
|
109
|
+
expression: "__ALL_SEARCHABLE_FIELDS__",
|
|
110
|
+
params: [{ name: "term", value: page.quickFilter }]
|
|
111
|
+
}];
|
|
112
|
+
}
|
|
113
|
+
DataFetcher.get()
|
|
102
114
|
.callGraphQL({
|
|
103
|
-
values:
|
|
115
|
+
values: variables,
|
|
104
116
|
query: this.templateByQuery.get("fetchData"),
|
|
105
117
|
})
|
|
106
118
|
.then((resp) => {
|
|
107
|
-
const
|
|
108
|
-
const
|
|
109
|
-
|
|
119
|
+
const pageResult = resp.data;
|
|
120
|
+
const records = [];
|
|
121
|
+
pageResult.records.forEach((responseRecord) => {
|
|
110
122
|
const duRecord = { __record__id__: responseRecord.id };
|
|
111
123
|
responseRecord.fields.forEach(({ name, value }) => {
|
|
112
124
|
duRecord[name] = dataUnit.valueFromString(name, value);
|
|
113
125
|
});
|
|
114
|
-
|
|
126
|
+
records.push(duRecord);
|
|
115
127
|
});
|
|
116
|
-
resolve(
|
|
128
|
+
resolve(Object.assign(Object.assign({}, pageResult), { records }));
|
|
117
129
|
})
|
|
118
130
|
.catch((error) => {
|
|
119
131
|
reject(error);
|
|
@@ -136,7 +148,7 @@ export default class DataUnitFetcher {
|
|
|
136
148
|
return reqChange;
|
|
137
149
|
});
|
|
138
150
|
return new Promise((resolve, reject) => {
|
|
139
|
-
|
|
151
|
+
DataFetcher.get()
|
|
140
152
|
.callGraphQL({
|
|
141
153
|
values: { changes: changes },
|
|
142
154
|
query: this.templateByQuery.get("saveData"),
|
|
@@ -165,7 +177,7 @@ export default class DataUnitFetcher {
|
|
|
165
177
|
return { dataUnit: dataUnit.name, operation: ChangeOperation.DELETE, recordId };
|
|
166
178
|
});
|
|
167
179
|
return new Promise((resolve, reject) => {
|
|
168
|
-
|
|
180
|
+
DataFetcher.get()
|
|
169
181
|
.callGraphQL({
|
|
170
182
|
values: { changes: changes },
|
|
171
183
|
query: this.templateByQuery.get("saveData"),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { gql } from "graphql-request";
|
|
2
2
|
import { DateUtils, StringUtils } from "@sankhyalabs/core";
|
|
3
|
-
import {
|
|
3
|
+
import { DataFetcher } from "../DataFetcher";
|
|
4
4
|
export default class ParametersFetcher {
|
|
5
5
|
constructor() {
|
|
6
6
|
this.templateByQuery = new Map();
|
|
@@ -16,7 +16,7 @@ export default class ParametersFetcher {
|
|
|
16
16
|
}
|
|
17
17
|
async getParam(name, resourceID) {
|
|
18
18
|
const completPath = `param://${resourceID}?params=${window.btoa(name)}`;
|
|
19
|
-
return
|
|
19
|
+
return DataFetcher.get().callGraphQL({
|
|
20
20
|
values: { name: completPath },
|
|
21
21
|
query: this.templateByQuery.get("fetchParam"),
|
|
22
22
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DataType } from "@sankhyalabs/core";
|
|
2
2
|
import { gql } from "graphql-request";
|
|
3
|
-
import {
|
|
3
|
+
import { DataFetcher } from "../DataFetcher";
|
|
4
4
|
export class PesquisaFetcher {
|
|
5
5
|
constructor() {
|
|
6
6
|
this.templateByQuery = new Map();
|
|
@@ -16,7 +16,7 @@ export class PesquisaFetcher {
|
|
|
16
16
|
}
|
|
17
17
|
loadSearchOptions(entityName, argument, criteria) {
|
|
18
18
|
return new Promise((resolve, reject) => {
|
|
19
|
-
|
|
19
|
+
DataFetcher.get()
|
|
20
20
|
.callGraphQL({
|
|
21
21
|
values: { argument, entityName, criteria },
|
|
22
22
|
query: this.templateByQuery.get("search"),
|
|
@@ -60,7 +60,7 @@ export class PesquisaFetcher {
|
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
62
|
return new Promise((resolve, reject) => {
|
|
63
|
-
|
|
63
|
+
DataFetcher.get()
|
|
64
64
|
.callServiceBroker("PesquisaSP.getSuggestion", JSON.stringify(reqBody))
|
|
65
65
|
.then(result => resolve(result))
|
|
66
66
|
.catch(error => reject(error));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { gql } from "graphql-request";
|
|
2
|
-
import {
|
|
2
|
+
import { DataFetcher } from "../DataFetcher";
|
|
3
3
|
export class ResourceFetcher {
|
|
4
4
|
constructor() {
|
|
5
5
|
this.templateByQuery = new Map();
|
|
@@ -14,7 +14,7 @@ export class ResourceFetcher {
|
|
|
14
14
|
}
|
|
15
15
|
loadResource(name) {
|
|
16
16
|
return new Promise((resolve, reject) => {
|
|
17
|
-
|
|
17
|
+
DataFetcher.get()
|
|
18
18
|
.callGraphQL({
|
|
19
19
|
values: { name },
|
|
20
20
|
query: this.templateByQuery.get("fetchResource"),
|