@sankhyalabs/sankhyablocks 1.3.5 → 1.3.8

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.
Files changed (24) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  3. package/dist/cjs/snk-application.cjs.entry.js +93 -25
  4. package/dist/collection/components/snk-application/snk-application.js +93 -11
  5. package/dist/collection/lib/http/data-fetcher/DataFetcher.js +8 -10
  6. package/dist/collection/lib/http/data-fetcher/fetchers/application-config-fetcher.js +2 -2
  7. package/dist/collection/lib/http/data-fetcher/fetchers/dataunit-fetcher.js +8 -5
  8. package/dist/collection/lib/http/data-fetcher/fetchers/grid-config-fetcher.js +28 -1
  9. package/dist/collection/lib/http/data-fetcher/fetchers/parameters-fecher.js +2 -2
  10. package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +3 -3
  11. package/dist/collection/lib/http/data-fetcher/fetchers/resource-fetcher.js +25 -2
  12. package/dist/collection/lib/utils/urlutils.js +2 -0
  13. package/dist/components/snk-application2.js +96 -26
  14. package/dist/esm/loader.js +1 -1
  15. package/dist/esm/sankhyablocks.js +1 -1
  16. package/dist/esm/snk-application.entry.js +93 -25
  17. package/dist/sankhyablocks/{p-727ea2f4.entry.js → p-58b10602.entry.js} +9 -7
  18. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  19. package/dist/types/components/snk-application/snk-application.d.ts +11 -4
  20. package/dist/types/components.d.ts +8 -4
  21. package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +2 -2
  22. package/dist/types/lib/http/data-fetcher/fetchers/grid-config-fetcher.d.ts +5 -1
  23. package/dist/types/lib/http/data-fetcher/fetchers/resource-fetcher.d.ts +1 -0
  24. package/package.json +1 -1
@@ -14,7 +14,7 @@ const patchEsm = () => {
14
14
  const defineCustomElements = (win, options) => {
15
15
  if (typeof window === 'undefined') return Promise.resolve();
16
16
  return patchEsm().then(() => {
17
- return index.bootstrapLazy([["snk-pesquisa.cjs",[[1,"snk-pesquisa",{"searchLoader":[16],"onSelectItem":[16],"argument":[1025]}]]],["snk-application.cjs",[[2,"snk-application",{"getStringParam":[64],"getIntParam":[64],"getFloatParam":[64],"getBooleanParam":[64],"getDateParam":[64],"showPopUp":[64],"closePopUp":[64],"temOpcional":[64],"getAttributeFromHTMLWrapper":[64],"openApp":[64],"createDataunit":[64],"getResourceID":[64],"alert":[64],"error":[64],"confirm":[64],"info":[64],"loadFormConfig":[64]}]]],["teste-pesquisa.cjs",[[1,"teste-pesquisa"]]]], options);
17
+ return index.bootstrapLazy([["snk-pesquisa.cjs",[[1,"snk-pesquisa",{"searchLoader":[16],"onSelectItem":[16],"argument":[1025]}]]],["snk-application.cjs",[[2,"snk-application",{"getStringParam":[64],"getIntParam":[64],"getFloatParam":[64],"getBooleanParam":[64],"getDateParam":[64],"showPopUp":[64],"closePopUp":[64],"temOpcional":[64],"getAttributeFromHTMLWrapper":[64],"openApp":[64],"createDataunit":[64],"getResourceID":[64],"alert":[64],"error":[64],"confirm":[64],"info":[64],"loadFormConfig":[64],"loadGridConfig":[64],"saveGridConfig":[64]}]]],["teste-pesquisa.cjs",[[1,"teste-pesquisa"]]]], options);
18
18
  });
19
19
  };
20
20
 
@@ -15,5 +15,5 @@ const patchBrowser = () => {
15
15
  };
16
16
 
17
17
  patchBrowser().then(options => {
18
- return index.bootstrapLazy([["snk-pesquisa.cjs",[[1,"snk-pesquisa",{"searchLoader":[16],"onSelectItem":[16],"argument":[1025]}]]],["snk-application.cjs",[[2,"snk-application",{"getStringParam":[64],"getIntParam":[64],"getFloatParam":[64],"getBooleanParam":[64],"getDateParam":[64],"showPopUp":[64],"closePopUp":[64],"temOpcional":[64],"getAttributeFromHTMLWrapper":[64],"openApp":[64],"createDataunit":[64],"getResourceID":[64],"alert":[64],"error":[64],"confirm":[64],"info":[64],"loadFormConfig":[64]}]]],["teste-pesquisa.cjs",[[1,"teste-pesquisa"]]]], options);
18
+ return index.bootstrapLazy([["snk-pesquisa.cjs",[[1,"snk-pesquisa",{"searchLoader":[16],"onSelectItem":[16],"argument":[1025]}]]],["snk-application.cjs",[[2,"snk-application",{"getStringParam":[64],"getIntParam":[64],"getFloatParam":[64],"getBooleanParam":[64],"getDateParam":[64],"showPopUp":[64],"closePopUp":[64],"temOpcional":[64],"getAttributeFromHTMLWrapper":[64],"openApp":[64],"createDataunit":[64],"getResourceID":[64],"alert":[64],"error":[64],"confirm":[64],"info":[64],"loadFormConfig":[64],"loadGridConfig":[64],"saveGridConfig":[64]}]]],["teste-pesquisa.cjs",[[1,"teste-pesquisa"]]]], options);
19
19
  });
@@ -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 HttpFetcher {
6463
+ class DataFetcher {
6462
6464
  constructor() {
6463
6465
  this.watingRequestsById = new Map();
6464
6466
  }
6465
6467
  static get() {
6466
- if (!HttpFetcher.instance) {
6467
- HttpFetcher.instance = new HttpFetcher();
6468
+ if (!DataFetcher.instance) {
6469
+ DataFetcher.instance = new DataFetcher();
6468
6470
  const application = document.querySelector(this.appTagName);
6469
6471
  if (application === null) {
6470
- HttpFetcher.instance.resume();
6472
+ DataFetcher.instance.resume();
6471
6473
  }
6472
6474
  else {
6473
- application.addEventListener('applicationLoading', () => HttpFetcher.instance.pause());
6474
- application.addEventListener('applicationLoaded', () => HttpFetcher.instance.resume());
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('http://localhost:8082/', request);
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
- HttpFetcher.appTagName = "snk-application";
6639
+ DataFetcher.appTagName = "snk-application";
6640
6640
  class WaitingRequest {
6641
6641
  constructor(req) {
6642
6642
  this._resolve = () => { };
@@ -6730,7 +6730,7 @@ class DataUnitFetcher {
6730
6730
  }
6731
6731
  loadMetadata(dataUnit) {
6732
6732
  return new Promise((resolve, reject) => {
6733
- HttpFetcher.get()
6733
+ DataFetcher.get()
6734
6734
  .callGraphQL({
6735
6735
  values: { name: dataUnit.name },
6736
6736
  query: this.templateByQuery.get("fetchDataUnit"),
@@ -6771,7 +6771,7 @@ class DataUnitFetcher {
6771
6771
  params: [{ name: "term", value: page.quickFilter }]
6772
6772
  }];
6773
6773
  }
6774
- HttpFetcher.get()
6774
+ DataFetcher.get()
6775
6775
  .callGraphQL({
6776
6776
  values: variables,
6777
6777
  query: this.templateByQuery.get("fetchData"),
@@ -6809,7 +6809,7 @@ class DataUnitFetcher {
6809
6809
  return reqChange;
6810
6810
  });
6811
6811
  return new Promise((resolve, reject) => {
6812
- HttpFetcher.get()
6812
+ DataFetcher.get()
6813
6813
  .callGraphQL({
6814
6814
  values: { changes: changes },
6815
6815
  query: this.templateByQuery.get("saveData"),
@@ -6838,7 +6838,7 @@ class DataUnitFetcher {
6838
6838
  return { dataUnit: dataUnit.name, operation: core.ChangeOperation.DELETE, recordId };
6839
6839
  });
6840
6840
  return new Promise((resolve, reject) => {
6841
- HttpFetcher.get()
6841
+ DataFetcher.get()
6842
6842
  .callGraphQL({
6843
6843
  values: { changes: changes },
6844
6844
  query: this.templateByQuery.get("saveData"),
@@ -6859,6 +6859,9 @@ const formatValueToServer = (value) => {
6859
6859
  if (value instanceof Date) {
6860
6860
  return value.toString();
6861
6861
  }
6862
+ if (typeof value === "string") {
6863
+ return value;
6864
+ }
6862
6865
  //Any others objects
6863
6866
  value = JSON.stringify(value);
6864
6867
  }
@@ -6892,7 +6895,7 @@ class ParametersFetcher {
6892
6895
  }
6893
6896
  async getParam(name, resourceID) {
6894
6897
  const completPath = `param://${resourceID}?params=${window.btoa(name)}`;
6895
- return HttpFetcher.get().callGraphQL({
6898
+ return DataFetcher.get().callGraphQL({
6896
6899
  values: { name: completPath },
6897
6900
  query: this.templateByQuery.get("fetchParam"),
6898
6901
  });
@@ -6945,10 +6948,13 @@ class ResourceFetcher {
6945
6948
  resource
6946
6949
  }
6947
6950
  }`);
6951
+ this.templateByQuery.set("saveResource", dist.gql `mutation($resource: ResourceToSave!) {
6952
+ $queryAlias$: saveResource(resource: $resource)
6953
+ }`);
6948
6954
  }
6949
6955
  loadResource(name) {
6950
6956
  return new Promise((resolve, reject) => {
6951
- HttpFetcher.get()
6957
+ DataFetcher.get()
6952
6958
  .callGraphQL({
6953
6959
  values: { name },
6954
6960
  query: this.templateByQuery.get("fetchResource"),
@@ -6961,6 +6967,26 @@ class ResourceFetcher {
6961
6967
  });
6962
6968
  });
6963
6969
  }
6970
+ saveResource(resource, name) {
6971
+ return new Promise((resolve, reject) => {
6972
+ DataFetcher.get()
6973
+ .callGraphQL({
6974
+ values: {
6975
+ resource: {
6976
+ name: name,
6977
+ resource: JSON.stringify(resource)
6978
+ }
6979
+ },
6980
+ query: this.templateByQuery.get("saveResource")
6981
+ })
6982
+ .then((resp) => {
6983
+ resolve(resp);
6984
+ })
6985
+ .catch((error) => {
6986
+ reject(error);
6987
+ });
6988
+ });
6989
+ }
6964
6990
  }
6965
6991
 
6966
6992
  class FormConfigFetcher extends ResourceFetcher {
@@ -6988,6 +7014,35 @@ class FormConfigFetcher extends ResourceFetcher {
6988
7014
  }
6989
7015
  }
6990
7016
 
7017
+ class GridConfigFetcher extends ResourceFetcher {
7018
+ getConfig(resourceID) {
7019
+ const completePath = `cfg://grid/GrdCfgHtml5:${resourceID}`;
7020
+ return new Promise((resolve, reject) => {
7021
+ this.loadResource(completePath)
7022
+ .then(loadedResource => {
7023
+ if (loadedResource) {
7024
+ let config = JSON.parse(loadedResource);
7025
+ resolve(config);
7026
+ }
7027
+ }).catch((error) => {
7028
+ reject(error);
7029
+ });
7030
+ });
7031
+ }
7032
+ saveConfig(config, resourceID) {
7033
+ const completePath = `cfg://grid/GrdCfgHtml5:${resourceID}`;
7034
+ return new Promise((resolve, reject) => {
7035
+ this.saveResource(config, completePath)
7036
+ .then((resp) => {
7037
+ resolve(resp);
7038
+ })
7039
+ .catch((error) => {
7040
+ reject(error);
7041
+ });
7042
+ });
7043
+ }
7044
+ }
7045
+
6991
7046
  class PesquisaFetcher {
6992
7047
  constructor() {
6993
7048
  this.templateByQuery = new Map();
@@ -7003,7 +7058,7 @@ class PesquisaFetcher {
7003
7058
  }
7004
7059
  loadSearchOptions(entityName, argument, criteria) {
7005
7060
  return new Promise((resolve, reject) => {
7006
- HttpFetcher.get()
7061
+ DataFetcher.get()
7007
7062
  .callGraphQL({
7008
7063
  values: { argument, entityName, criteria },
7009
7064
  query: this.templateByQuery.get("search"),
@@ -7047,7 +7102,7 @@ class PesquisaFetcher {
7047
7102
  }
7048
7103
  };
7049
7104
  return new Promise((resolve, reject) => {
7050
- HttpFetcher.get()
7105
+ DataFetcher.get()
7051
7106
  .callServiceBroker("PesquisaSP.getSuggestion", JSON.stringify(reqBody))
7052
7107
  .then(result => resolve(result))
7053
7108
  .catch(error => reject(error));
@@ -7155,21 +7210,27 @@ const SnkApplication = class {
7155
7210
  async getResourceID() {
7156
7211
  return Promise.resolve(this.resourceID);
7157
7212
  }
7158
- async alert(title, message, icon) {
7159
- return utils.ApplicationUtils.alert(title, message, icon);
7213
+ async alert(title, message, icon, options) {
7214
+ return utils.ApplicationUtils.alert(title, message, icon, options);
7160
7215
  }
7161
- async error(title, message, icon) {
7162
- return utils.ApplicationUtils.error(title, message, icon);
7216
+ async error(title, message, icon, options) {
7217
+ return utils.ApplicationUtils.error(title, message, icon, options);
7163
7218
  }
7164
- async confirm(title, message, icon, critical) {
7165
- return utils.ApplicationUtils.confirm(title, message, icon, critical);
7219
+ async confirm(title, message, icon, critical, options) {
7220
+ return utils.ApplicationUtils.confirm(title, message, icon, critical, options);
7166
7221
  }
7167
- async info(message, options = undefined) {
7222
+ async info(message, options) {
7168
7223
  return utils.ApplicationUtils.info(message, options);
7169
7224
  }
7170
7225
  async loadFormConfig(name) {
7171
7226
  return this.formConfigFetcher.loadFormConfig(name, this.resourceID);
7172
7227
  }
7228
+ async loadGridConfig() {
7229
+ return this.gridConfigFetcher.getConfig(this.resourceID);
7230
+ }
7231
+ async saveGridConfig(config) {
7232
+ return this.gridConfigFetcher.saveConfig(config, this.resourceID);
7233
+ }
7173
7234
  get urlParams() {
7174
7235
  if (!this._urlParams) {
7175
7236
  this._urlParams = UrlUtils.getQueryParams(location.search);
@@ -7188,6 +7249,12 @@ const SnkApplication = class {
7188
7249
  }
7189
7250
  return this._formConfigFetcher;
7190
7251
  }
7252
+ get gridConfigFetcher() {
7253
+ if (!this._gridConfigFetcher) {
7254
+ this._gridConfigFetcher = new GridConfigFetcher();
7255
+ }
7256
+ return this._gridConfigFetcher;
7257
+ }
7191
7258
  get pesquisaFetcher() {
7192
7259
  if (!this._pesquisaFetcher) {
7193
7260
  this._pesquisaFetcher = new PesquisaFetcher();
@@ -7235,6 +7302,7 @@ const SnkApplication = class {
7235
7302
  }
7236
7303
  }
7237
7304
  componentWillLoad() {
7305
+ core.ApplicationContext.setContextValue("__EZUI__UPLOAD__ADD__URL__", `${UrlUtils.getUrlBase()}/mge/ez.uploading`);
7238
7306
  core.ApplicationContext.setContextValue("__EZUI__SEARCH__OPTION__LOADER__", (searchArgument, fieldName, dataUnit) => {
7239
7307
  return this.executeSearch(searchArgument, fieldName, dataUnit);
7240
7308
  });
@@ -7,6 +7,7 @@ import ParametersFetcher from "../../lib/http/data-fetcher/fetchers/parameters-f
7
7
  import { ApplicationUtils } from "@sankhyalabs/ezui/dist/collection/utils";
8
8
  import { FormConfigFetcher } from "../../lib/http/data-fetcher/fetchers/form-config-fetcher";
9
9
  import { ApplicationContext } from "@sankhyalabs/core";
10
+ import GridConfigFetcher from "../../lib/http/data-fetcher/fetchers/grid-config-fetcher";
10
11
  import { PesquisaFetcher } from "../../lib/http/data-fetcher/fetchers/pesquisa-fetcher";
11
12
  import { DependencyType } from "@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";
12
13
  export class SnkApplication {
@@ -89,21 +90,27 @@ export class SnkApplication {
89
90
  async getResourceID() {
90
91
  return Promise.resolve(this.resourceID);
91
92
  }
92
- async alert(title, message, icon) {
93
- return ApplicationUtils.alert(title, message, icon);
93
+ async alert(title, message, icon, options) {
94
+ return ApplicationUtils.alert(title, message, icon, options);
94
95
  }
95
- async error(title, message, icon) {
96
- return ApplicationUtils.error(title, message, icon);
96
+ async error(title, message, icon, options) {
97
+ return ApplicationUtils.error(title, message, icon, options);
97
98
  }
98
- async confirm(title, message, icon, critical) {
99
- return ApplicationUtils.confirm(title, message, icon, critical);
99
+ async confirm(title, message, icon, critical, options) {
100
+ return ApplicationUtils.confirm(title, message, icon, critical, options);
100
101
  }
101
- async info(message, options = undefined) {
102
+ async info(message, options) {
102
103
  return ApplicationUtils.info(message, options);
103
104
  }
104
105
  async loadFormConfig(name) {
105
106
  return this.formConfigFetcher.loadFormConfig(name, this.resourceID);
106
107
  }
108
+ async loadGridConfig() {
109
+ return this.gridConfigFetcher.getConfig(this.resourceID);
110
+ }
111
+ async saveGridConfig(config) {
112
+ return this.gridConfigFetcher.saveConfig(config, this.resourceID);
113
+ }
107
114
  get urlParams() {
108
115
  if (!this._urlParams) {
109
116
  this._urlParams = UrlUtils.getQueryParams(location.search);
@@ -122,6 +129,12 @@ export class SnkApplication {
122
129
  }
123
130
  return this._formConfigFetcher;
124
131
  }
132
+ get gridConfigFetcher() {
133
+ if (!this._gridConfigFetcher) {
134
+ this._gridConfigFetcher = new GridConfigFetcher();
135
+ }
136
+ return this._gridConfigFetcher;
137
+ }
125
138
  get pesquisaFetcher() {
126
139
  if (!this._pesquisaFetcher) {
127
140
  this._pesquisaFetcher = new PesquisaFetcher();
@@ -171,6 +184,7 @@ export class SnkApplication {
171
184
  }
172
185
  }
173
186
  componentWillLoad() {
187
+ ApplicationContext.setContextValue("__EZUI__UPLOAD__ADD__URL__", `${UrlUtils.getUrlBase()}/mge/ez.uploading`);
174
188
  ApplicationContext.setContextValue("__EZUI__SEARCH__OPTION__LOADER__", (searchArgument, fieldName, dataUnit) => {
175
189
  return this.executeSearch(searchArgument, fieldName, dataUnit);
176
190
  });
@@ -465,7 +479,7 @@ export class SnkApplication {
465
479
  },
466
480
  "alert": {
467
481
  "complexType": {
468
- "signature": "(title: string, message: string, icon?: string) => Promise<boolean>",
482
+ "signature": "(title: string, message: string, icon?: string, options?: MessageOptions) => Promise<boolean>",
469
483
  "parameters": [{
470
484
  "tags": [],
471
485
  "text": ""
@@ -475,10 +489,17 @@ export class SnkApplication {
475
489
  }, {
476
490
  "tags": [],
477
491
  "text": ""
492
+ }, {
493
+ "tags": [],
494
+ "text": ""
478
495
  }],
479
496
  "references": {
480
497
  "Promise": {
481
498
  "location": "global"
499
+ },
500
+ "MessageOptions": {
501
+ "location": "import",
502
+ "path": "@sankhyalabs/ezui/dist/collection/utils"
482
503
  }
483
504
  },
484
505
  "return": "Promise<boolean>"
@@ -490,7 +511,7 @@ export class SnkApplication {
490
511
  },
491
512
  "error": {
492
513
  "complexType": {
493
- "signature": "(title: string, message: string, icon?: string) => Promise<boolean>",
514
+ "signature": "(title: string, message: string, icon?: string, options?: MessageOptions) => Promise<boolean>",
494
515
  "parameters": [{
495
516
  "tags": [],
496
517
  "text": ""
@@ -500,10 +521,17 @@ export class SnkApplication {
500
521
  }, {
501
522
  "tags": [],
502
523
  "text": ""
524
+ }, {
525
+ "tags": [],
526
+ "text": ""
503
527
  }],
504
528
  "references": {
505
529
  "Promise": {
506
530
  "location": "global"
531
+ },
532
+ "MessageOptions": {
533
+ "location": "import",
534
+ "path": "@sankhyalabs/ezui/dist/collection/utils"
507
535
  }
508
536
  },
509
537
  "return": "Promise<boolean>"
@@ -515,7 +543,7 @@ export class SnkApplication {
515
543
  },
516
544
  "confirm": {
517
545
  "complexType": {
518
- "signature": "(title: string, message: string, icon?: string, critical?: boolean) => Promise<boolean>",
546
+ "signature": "(title: string, message: string, icon?: string, critical?: boolean, options?: MessageOptions) => Promise<boolean>",
519
547
  "parameters": [{
520
548
  "tags": [],
521
549
  "text": ""
@@ -528,10 +556,17 @@ export class SnkApplication {
528
556
  }, {
529
557
  "tags": [],
530
558
  "text": ""
559
+ }, {
560
+ "tags": [],
561
+ "text": ""
531
562
  }],
532
563
  "references": {
533
564
  "Promise": {
534
565
  "location": "global"
566
+ },
567
+ "MessageOptions": {
568
+ "location": "import",
569
+ "path": "@sankhyalabs/ezui/dist/collection/utils"
535
570
  }
536
571
  },
537
572
  "return": "Promise<boolean>"
@@ -543,7 +578,7 @@ export class SnkApplication {
543
578
  },
544
579
  "info": {
545
580
  "complexType": {
546
- "signature": "(message: string, options?: any) => Promise<void>",
581
+ "signature": "(message: string, options?: MessageOptions) => Promise<void>",
547
582
  "parameters": [{
548
583
  "tags": [],
549
584
  "text": ""
@@ -554,6 +589,10 @@ export class SnkApplication {
554
589
  "references": {
555
590
  "Promise": {
556
591
  "location": "global"
592
+ },
593
+ "MessageOptions": {
594
+ "location": "import",
595
+ "path": "@sankhyalabs/ezui/dist/collection/utils"
557
596
  }
558
597
  },
559
598
  "return": "Promise<void>"
@@ -588,6 +627,49 @@ export class SnkApplication {
588
627
  "text": "",
589
628
  "tags": []
590
629
  }
630
+ },
631
+ "loadGridConfig": {
632
+ "complexType": {
633
+ "signature": "() => Promise<EzGridConfig>",
634
+ "parameters": [],
635
+ "references": {
636
+ "Promise": {
637
+ "location": "global"
638
+ },
639
+ "EzGridConfig": {
640
+ "location": "import",
641
+ "path": "@sankhyalabs/ezui/dist/types/components/ez-grid/controller/EzGridController"
642
+ }
643
+ },
644
+ "return": "Promise<EzGridConfig>"
645
+ },
646
+ "docs": {
647
+ "text": "",
648
+ "tags": []
649
+ }
650
+ },
651
+ "saveGridConfig": {
652
+ "complexType": {
653
+ "signature": "(config: EzGridConfig) => Promise<boolean>",
654
+ "parameters": [{
655
+ "tags": [],
656
+ "text": ""
657
+ }],
658
+ "references": {
659
+ "Promise": {
660
+ "location": "global"
661
+ },
662
+ "EzGridConfig": {
663
+ "location": "import",
664
+ "path": "@sankhyalabs/ezui/dist/types/components/ez-grid/controller/EzGridController"
665
+ }
666
+ },
667
+ "return": "Promise<boolean>"
668
+ },
669
+ "docs": {
670
+ "text": "",
671
+ "tags": []
672
+ }
591
673
  }
592
674
  }; }
593
675
  }
@@ -1,19 +1,19 @@
1
1
  import { batchRequests } from 'graphql-request';
2
2
  import UrlUtils from "../../../lib/utils/urlutils";
3
- export class HttpFetcher {
3
+ export class DataFetcher {
4
4
  constructor() {
5
5
  this.watingRequestsById = new Map();
6
6
  }
7
7
  static get() {
8
- if (!HttpFetcher.instance) {
9
- HttpFetcher.instance = new HttpFetcher();
8
+ if (!DataFetcher.instance) {
9
+ DataFetcher.instance = new DataFetcher();
10
10
  const application = document.querySelector(this.appTagName);
11
11
  if (application === null) {
12
- HttpFetcher.instance.resume();
12
+ DataFetcher.instance.resume();
13
13
  }
14
14
  else {
15
- application.addEventListener('applicationLoading', () => HttpFetcher.instance.pause());
16
- application.addEventListener('applicationLoaded', () => HttpFetcher.instance.resume());
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('http://localhost:8082/', request);
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
- HttpFetcher.appTagName = "snk-application";
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 { HttpFetcher } from "../DataFetcher";
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 HttpFetcher.get().callGraphQL({
18
+ return DataFetcher.get().callGraphQL({
19
19
  values: { name: completPath },
20
20
  query: this.templateByQuery.get("getResource"),
21
21
  });
@@ -1,5 +1,5 @@
1
1
  import { DataUnit, ChangeOperation, StringUtils, } from "@sankhyalabs/core";
2
- import { HttpFetcher } from "../DataFetcher";
2
+ import { DataFetcher } from "../DataFetcher";
3
3
  import { gql } from "graphql-request";
4
4
  export default class DataUnitFetcher {
5
5
  constructor() {
@@ -69,7 +69,7 @@ export default class DataUnitFetcher {
69
69
  }
70
70
  loadMetadata(dataUnit) {
71
71
  return new Promise((resolve, reject) => {
72
- HttpFetcher.get()
72
+ DataFetcher.get()
73
73
  .callGraphQL({
74
74
  values: { name: dataUnit.name },
75
75
  query: this.templateByQuery.get("fetchDataUnit"),
@@ -110,7 +110,7 @@ export default class DataUnitFetcher {
110
110
  params: [{ name: "term", value: page.quickFilter }]
111
111
  }];
112
112
  }
113
- HttpFetcher.get()
113
+ DataFetcher.get()
114
114
  .callGraphQL({
115
115
  values: variables,
116
116
  query: this.templateByQuery.get("fetchData"),
@@ -148,7 +148,7 @@ export default class DataUnitFetcher {
148
148
  return reqChange;
149
149
  });
150
150
  return new Promise((resolve, reject) => {
151
- HttpFetcher.get()
151
+ DataFetcher.get()
152
152
  .callGraphQL({
153
153
  values: { changes: changes },
154
154
  query: this.templateByQuery.get("saveData"),
@@ -177,7 +177,7 @@ export default class DataUnitFetcher {
177
177
  return { dataUnit: dataUnit.name, operation: ChangeOperation.DELETE, recordId };
178
178
  });
179
179
  return new Promise((resolve, reject) => {
180
- HttpFetcher.get()
180
+ DataFetcher.get()
181
181
  .callGraphQL({
182
182
  values: { changes: changes },
183
183
  query: this.templateByQuery.get("saveData"),
@@ -198,6 +198,9 @@ export const formatValueToServer = (value) => {
198
198
  if (value instanceof Date) {
199
199
  return value.toString();
200
200
  }
201
+ if (typeof value === "string") {
202
+ return value;
203
+ }
201
204
  //Any others objects
202
205
  value = JSON.stringify(value);
203
206
  }
@@ -1,2 +1,29 @@
1
- export class GridConfigFetcher {
1
+ import { ResourceFetcher } from "./resource-fetcher";
2
+ export default class GridConfigFetcher extends ResourceFetcher {
3
+ getConfig(resourceID) {
4
+ const completePath = `cfg://grid/GrdCfgHtml5:${resourceID}`;
5
+ return new Promise((resolve, reject) => {
6
+ this.loadResource(completePath)
7
+ .then(loadedResource => {
8
+ if (loadedResource) {
9
+ let config = JSON.parse(loadedResource);
10
+ resolve(config);
11
+ }
12
+ }).catch((error) => {
13
+ reject(error);
14
+ });
15
+ });
16
+ }
17
+ saveConfig(config, resourceID) {
18
+ const completePath = `cfg://grid/GrdCfgHtml5:${resourceID}`;
19
+ return new Promise((resolve, reject) => {
20
+ this.saveResource(config, completePath)
21
+ .then((resp) => {
22
+ resolve(resp);
23
+ })
24
+ .catch((error) => {
25
+ reject(error);
26
+ });
27
+ });
28
+ }
2
29
  }
@@ -1,6 +1,6 @@
1
1
  import { gql } from "graphql-request";
2
2
  import { DateUtils, StringUtils } from "@sankhyalabs/core";
3
- import { HttpFetcher } from "../DataFetcher";
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 HttpFetcher.get().callGraphQL({
19
+ return DataFetcher.get().callGraphQL({
20
20
  values: { name: completPath },
21
21
  query: this.templateByQuery.get("fetchParam"),
22
22
  });