@sankhyalabs/sankhyablocks 1.3.6 → 1.3.9

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.
@@ -6754,19 +6754,22 @@ class DataUnitFetcher {
6754
6754
  });
6755
6755
  });
6756
6756
  }
6757
- loadData(dataUnit, page, sort, filters) {
6757
+ loadData(dataUnit, page, sort, filter) {
6758
6758
  return new Promise((resolve, reject) => {
6759
- const variables = { dataunit: dataUnit.name, sort, filters };
6759
+ const variables = { dataunit: dataUnit.name, sort, filter };
6760
6760
  if (page) {
6761
6761
  variables.limit = page.limit;
6762
6762
  variables.offset = page.offset;
6763
6763
  }
6764
6764
  if (!StringUtils.isEmpty(page === null || page === void 0 ? void 0 : page.quickFilter)) {
6765
- variables.filter = [{
6766
- name: "__ALL_SEARCHABLE_FIELDS__",
6767
- expression: "__ALL_SEARCHABLE_FIELDS__",
6768
- params: [{ name: "term", value: page.quickFilter }]
6769
- }];
6765
+ if (variables.filter === undefined) {
6766
+ variables.filter = [];
6767
+ }
6768
+ variables.filter.push({
6769
+ name: "__ALL_SEARCHABLE_FIELDS__",
6770
+ expression: "__ALL_SEARCHABLE_FIELDS__",
6771
+ params: [{ name: "term", value: page.quickFilter }]
6772
+ });
6770
6773
  }
6771
6774
  DataFetcher.get()
6772
6775
  .callGraphQL({
@@ -6856,6 +6859,9 @@ const formatValueToServer = (value) => {
6856
6859
  if (value instanceof Date) {
6857
6860
  return value.toString();
6858
6861
  }
6862
+ if (typeof value === "string") {
6863
+ return value;
6864
+ }
6859
6865
  //Any others objects
6860
6866
  value = JSON.stringify(value);
6861
6867
  }
@@ -6942,6 +6948,9 @@ class ResourceFetcher {
6942
6948
  resource
6943
6949
  }
6944
6950
  }`);
6951
+ this.templateByQuery.set("saveResource", dist.gql `mutation($resource: ResourceToSave!) {
6952
+ $queryAlias$: saveResource(resource: $resource)
6953
+ }`);
6945
6954
  }
6946
6955
  loadResource(name) {
6947
6956
  return new Promise((resolve, reject) => {
@@ -6958,6 +6967,26 @@ class ResourceFetcher {
6958
6967
  });
6959
6968
  });
6960
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
+ }
6961
6990
  }
6962
6991
 
6963
6992
  class FormConfigFetcher extends ResourceFetcher {
@@ -6985,6 +7014,35 @@ class FormConfigFetcher extends ResourceFetcher {
6985
7014
  }
6986
7015
  }
6987
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
+
6988
7046
  class PesquisaFetcher {
6989
7047
  constructor() {
6990
7048
  this.templateByQuery = new Map();
@@ -7137,6 +7195,41 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7137
7195
  });
7138
7196
  });
7139
7197
  }
7198
+ async getConfig(key) {
7199
+ let payload = {
7200
+ "serviceName": "SystemUtilsSP.getConf",
7201
+ "requestBody": {
7202
+ "config": {
7203
+ "chave": key,
7204
+ "tipo": "T"
7205
+ }
7206
+ }
7207
+ };
7208
+ return new Promise((resolve, reject) => {
7209
+ DataFetcher.get()
7210
+ .callServiceBroker("SystemUtilsSP.getConf", JSON.stringify(payload))
7211
+ .then(result => { var _a; return resolve((_a = result.config) === null || _a === void 0 ? void 0 : _a.data); })
7212
+ .catch(error => reject(error));
7213
+ });
7214
+ }
7215
+ async saveConfig(key, data) {
7216
+ let payload = {
7217
+ "serviceName": "SystemUtilsSP.saveConf",
7218
+ "requestBody": {
7219
+ "config": {
7220
+ "chave": key,
7221
+ "tipo": "T",
7222
+ data
7223
+ }
7224
+ }
7225
+ };
7226
+ return new Promise((resolve, reject) => {
7227
+ DataFetcher.get()
7228
+ .callServiceBroker("SystemUtilsSP.saveConf", JSON.stringify(payload))
7229
+ .then(result => resolve(result))
7230
+ .catch(error => reject(error));
7231
+ });
7232
+ }
7140
7233
  async getAttributeFromHTMLWrapper(attribName) {
7141
7234
  return Promise.resolve(window[attribName]);
7142
7235
  }
@@ -7153,21 +7246,27 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7153
7246
  async getResourceID() {
7154
7247
  return Promise.resolve(this.resourceID);
7155
7248
  }
7156
- async alert(title, message, icon) {
7157
- return ApplicationUtils.alert(title, message, icon);
7249
+ async alert(title, message, icon, options) {
7250
+ return ApplicationUtils.alert(title, message, icon, options);
7158
7251
  }
7159
- async error(title, message, icon) {
7160
- return ApplicationUtils.error(title, message, icon);
7252
+ async error(title, message, icon, options) {
7253
+ return ApplicationUtils.error(title, message, icon, options);
7161
7254
  }
7162
- async confirm(title, message, icon, critical) {
7163
- return ApplicationUtils.confirm(title, message, icon, critical);
7255
+ async confirm(title, message, icon, critical, options) {
7256
+ return ApplicationUtils.confirm(title, message, icon, critical, options);
7164
7257
  }
7165
- async info(message, options = undefined) {
7258
+ async info(message, options) {
7166
7259
  return ApplicationUtils.info(message, options);
7167
7260
  }
7168
7261
  async loadFormConfig(name) {
7169
7262
  return this.formConfigFetcher.loadFormConfig(name, this.resourceID);
7170
7263
  }
7264
+ async loadGridConfig() {
7265
+ return this.gridConfigFetcher.getConfig(this.resourceID);
7266
+ }
7267
+ async saveGridConfig(config) {
7268
+ return this.gridConfigFetcher.saveConfig(config, this.resourceID);
7269
+ }
7171
7270
  get urlParams() {
7172
7271
  if (!this._urlParams) {
7173
7272
  this._urlParams = UrlUtils.getQueryParams(location.search);
@@ -7186,6 +7285,12 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7186
7285
  }
7187
7286
  return this._formConfigFetcher;
7188
7287
  }
7288
+ get gridConfigFetcher() {
7289
+ if (!this._gridConfigFetcher) {
7290
+ this._gridConfigFetcher = new GridConfigFetcher();
7291
+ }
7292
+ return this._gridConfigFetcher;
7293
+ }
7189
7294
  get pesquisaFetcher() {
7190
7295
  if (!this._pesquisaFetcher) {
7191
7296
  this._pesquisaFetcher = new PesquisaFetcher();
@@ -7257,6 +7362,8 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7257
7362
  "showPopUp": [64],
7258
7363
  "closePopUp": [64],
7259
7364
  "temOpcional": [64],
7365
+ "getConfig": [64],
7366
+ "saveConfig": [64],
7260
7367
  "getAttributeFromHTMLWrapper": [64],
7261
7368
  "openApp": [64],
7262
7369
  "createDataunit": [64],
@@ -7265,7 +7372,9 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7265
7372
  "error": [64],
7266
7373
  "confirm": [64],
7267
7374
  "info": [64],
7268
- "loadFormConfig": [64]
7375
+ "loadFormConfig": [64],
7376
+ "loadGridConfig": [64],
7377
+ "saveGridConfig": [64]
7269
7378
  }]);
7270
7379
  function defineCustomElement() {
7271
7380
  if (typeof customElements === "undefined") {
@@ -10,7 +10,7 @@ const patchEsm = () => {
10
10
  const defineCustomElements = (win, options) => {
11
11
  if (typeof window === 'undefined') return Promise.resolve();
12
12
  return patchEsm().then(() => {
13
- return bootstrapLazy([["snk-pesquisa",[[1,"snk-pesquisa",{"searchLoader":[16],"onSelectItem":[16],"argument":[1025]}]]],["snk-application",[[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",[[1,"teste-pesquisa"]]]], options);
13
+ return bootstrapLazy([["snk-pesquisa",[[1,"snk-pesquisa",{"searchLoader":[16],"onSelectItem":[16],"argument":[1025]}]]],["snk-application",[[2,"snk-application",{"getStringParam":[64],"getIntParam":[64],"getFloatParam":[64],"getBooleanParam":[64],"getDateParam":[64],"showPopUp":[64],"closePopUp":[64],"temOpcional":[64],"getConfig":[64],"saveConfig":[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",[[1,"teste-pesquisa"]]]], options);
14
14
  });
15
15
  };
16
16
 
@@ -13,5 +13,5 @@ const patchBrowser = () => {
13
13
  };
14
14
 
15
15
  patchBrowser().then(options => {
16
- return bootstrapLazy([["snk-pesquisa",[[1,"snk-pesquisa",{"searchLoader":[16],"onSelectItem":[16],"argument":[1025]}]]],["snk-application",[[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",[[1,"teste-pesquisa"]]]], options);
16
+ return bootstrapLazy([["snk-pesquisa",[[1,"snk-pesquisa",{"searchLoader":[16],"onSelectItem":[16],"argument":[1025]}]]],["snk-application",[[2,"snk-application",{"getStringParam":[64],"getIntParam":[64],"getFloatParam":[64],"getBooleanParam":[64],"getDateParam":[64],"showPopUp":[64],"closePopUp":[64],"temOpcional":[64],"getConfig":[64],"saveConfig":[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",[[1,"teste-pesquisa"]]]], options);
17
17
  });
@@ -6753,19 +6753,22 @@ class DataUnitFetcher {
6753
6753
  });
6754
6754
  });
6755
6755
  }
6756
- loadData(dataUnit, page, sort, filters) {
6756
+ loadData(dataUnit, page, sort, filter) {
6757
6757
  return new Promise((resolve, reject) => {
6758
- const variables = { dataunit: dataUnit.name, sort, filters };
6758
+ const variables = { dataunit: dataUnit.name, sort, filter };
6759
6759
  if (page) {
6760
6760
  variables.limit = page.limit;
6761
6761
  variables.offset = page.offset;
6762
6762
  }
6763
6763
  if (!StringUtils.isEmpty(page === null || page === void 0 ? void 0 : page.quickFilter)) {
6764
- variables.filter = [{
6765
- name: "__ALL_SEARCHABLE_FIELDS__",
6766
- expression: "__ALL_SEARCHABLE_FIELDS__",
6767
- params: [{ name: "term", value: page.quickFilter }]
6768
- }];
6764
+ if (variables.filter === undefined) {
6765
+ variables.filter = [];
6766
+ }
6767
+ variables.filter.push({
6768
+ name: "__ALL_SEARCHABLE_FIELDS__",
6769
+ expression: "__ALL_SEARCHABLE_FIELDS__",
6770
+ params: [{ name: "term", value: page.quickFilter }]
6771
+ });
6769
6772
  }
6770
6773
  DataFetcher.get()
6771
6774
  .callGraphQL({
@@ -6855,6 +6858,9 @@ const formatValueToServer = (value) => {
6855
6858
  if (value instanceof Date) {
6856
6859
  return value.toString();
6857
6860
  }
6861
+ if (typeof value === "string") {
6862
+ return value;
6863
+ }
6858
6864
  //Any others objects
6859
6865
  value = JSON.stringify(value);
6860
6866
  }
@@ -6941,6 +6947,9 @@ class ResourceFetcher {
6941
6947
  resource
6942
6948
  }
6943
6949
  }`);
6950
+ this.templateByQuery.set("saveResource", dist.gql `mutation($resource: ResourceToSave!) {
6951
+ $queryAlias$: saveResource(resource: $resource)
6952
+ }`);
6944
6953
  }
6945
6954
  loadResource(name) {
6946
6955
  return new Promise((resolve, reject) => {
@@ -6957,6 +6966,26 @@ class ResourceFetcher {
6957
6966
  });
6958
6967
  });
6959
6968
  }
6969
+ saveResource(resource, name) {
6970
+ return new Promise((resolve, reject) => {
6971
+ DataFetcher.get()
6972
+ .callGraphQL({
6973
+ values: {
6974
+ resource: {
6975
+ name: name,
6976
+ resource: JSON.stringify(resource)
6977
+ }
6978
+ },
6979
+ query: this.templateByQuery.get("saveResource")
6980
+ })
6981
+ .then((resp) => {
6982
+ resolve(resp);
6983
+ })
6984
+ .catch((error) => {
6985
+ reject(error);
6986
+ });
6987
+ });
6988
+ }
6960
6989
  }
6961
6990
 
6962
6991
  class FormConfigFetcher extends ResourceFetcher {
@@ -6984,6 +7013,35 @@ class FormConfigFetcher extends ResourceFetcher {
6984
7013
  }
6985
7014
  }
6986
7015
 
7016
+ class GridConfigFetcher extends ResourceFetcher {
7017
+ getConfig(resourceID) {
7018
+ const completePath = `cfg://grid/GrdCfgHtml5:${resourceID}`;
7019
+ return new Promise((resolve, reject) => {
7020
+ this.loadResource(completePath)
7021
+ .then(loadedResource => {
7022
+ if (loadedResource) {
7023
+ let config = JSON.parse(loadedResource);
7024
+ resolve(config);
7025
+ }
7026
+ }).catch((error) => {
7027
+ reject(error);
7028
+ });
7029
+ });
7030
+ }
7031
+ saveConfig(config, resourceID) {
7032
+ const completePath = `cfg://grid/GrdCfgHtml5:${resourceID}`;
7033
+ return new Promise((resolve, reject) => {
7034
+ this.saveResource(config, completePath)
7035
+ .then((resp) => {
7036
+ resolve(resp);
7037
+ })
7038
+ .catch((error) => {
7039
+ reject(error);
7040
+ });
7041
+ });
7042
+ }
7043
+ }
7044
+
6987
7045
  class PesquisaFetcher {
6988
7046
  constructor() {
6989
7047
  this.templateByQuery = new Map();
@@ -7135,6 +7193,41 @@ const SnkApplication = class {
7135
7193
  });
7136
7194
  });
7137
7195
  }
7196
+ async getConfig(key) {
7197
+ let payload = {
7198
+ "serviceName": "SystemUtilsSP.getConf",
7199
+ "requestBody": {
7200
+ "config": {
7201
+ "chave": key,
7202
+ "tipo": "T"
7203
+ }
7204
+ }
7205
+ };
7206
+ return new Promise((resolve, reject) => {
7207
+ DataFetcher.get()
7208
+ .callServiceBroker("SystemUtilsSP.getConf", JSON.stringify(payload))
7209
+ .then(result => { var _a; return resolve((_a = result.config) === null || _a === void 0 ? void 0 : _a.data); })
7210
+ .catch(error => reject(error));
7211
+ });
7212
+ }
7213
+ async saveConfig(key, data) {
7214
+ let payload = {
7215
+ "serviceName": "SystemUtilsSP.saveConf",
7216
+ "requestBody": {
7217
+ "config": {
7218
+ "chave": key,
7219
+ "tipo": "T",
7220
+ data
7221
+ }
7222
+ }
7223
+ };
7224
+ return new Promise((resolve, reject) => {
7225
+ DataFetcher.get()
7226
+ .callServiceBroker("SystemUtilsSP.saveConf", JSON.stringify(payload))
7227
+ .then(result => resolve(result))
7228
+ .catch(error => reject(error));
7229
+ });
7230
+ }
7138
7231
  async getAttributeFromHTMLWrapper(attribName) {
7139
7232
  return Promise.resolve(window[attribName]);
7140
7233
  }
@@ -7151,21 +7244,27 @@ const SnkApplication = class {
7151
7244
  async getResourceID() {
7152
7245
  return Promise.resolve(this.resourceID);
7153
7246
  }
7154
- async alert(title, message, icon) {
7155
- return ApplicationUtils.alert(title, message, icon);
7247
+ async alert(title, message, icon, options) {
7248
+ return ApplicationUtils.alert(title, message, icon, options);
7156
7249
  }
7157
- async error(title, message, icon) {
7158
- return ApplicationUtils.error(title, message, icon);
7250
+ async error(title, message, icon, options) {
7251
+ return ApplicationUtils.error(title, message, icon, options);
7159
7252
  }
7160
- async confirm(title, message, icon, critical) {
7161
- return ApplicationUtils.confirm(title, message, icon, critical);
7253
+ async confirm(title, message, icon, critical, options) {
7254
+ return ApplicationUtils.confirm(title, message, icon, critical, options);
7162
7255
  }
7163
- async info(message, options = undefined) {
7256
+ async info(message, options) {
7164
7257
  return ApplicationUtils.info(message, options);
7165
7258
  }
7166
7259
  async loadFormConfig(name) {
7167
7260
  return this.formConfigFetcher.loadFormConfig(name, this.resourceID);
7168
7261
  }
7262
+ async loadGridConfig() {
7263
+ return this.gridConfigFetcher.getConfig(this.resourceID);
7264
+ }
7265
+ async saveGridConfig(config) {
7266
+ return this.gridConfigFetcher.saveConfig(config, this.resourceID);
7267
+ }
7169
7268
  get urlParams() {
7170
7269
  if (!this._urlParams) {
7171
7270
  this._urlParams = UrlUtils.getQueryParams(location.search);
@@ -7184,6 +7283,12 @@ const SnkApplication = class {
7184
7283
  }
7185
7284
  return this._formConfigFetcher;
7186
7285
  }
7286
+ get gridConfigFetcher() {
7287
+ if (!this._gridConfigFetcher) {
7288
+ this._gridConfigFetcher = new GridConfigFetcher();
7289
+ }
7290
+ return this._gridConfigFetcher;
7291
+ }
7187
7292
  get pesquisaFetcher() {
7188
7293
  if (!this._pesquisaFetcher) {
7189
7294
  this._pesquisaFetcher = new PesquisaFetcher();