@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.
@@ -1,5 +1,5 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
- import { DataUnit, ChangeOperation, DateUtils, StringUtils, DataType, ApplicationContext } from '@sankhyalabs/core';
2
+ import { DataUnit, StringUtils, ChangeOperation, DateUtils, DataType, ApplicationContext } from '@sankhyalabs/core';
3
3
  import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
4
4
  import { DependencyType } from '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
5
5
  import { d as defineCustomElement$1 } from './snk-pesquisa2.js';
@@ -6451,24 +6451,26 @@ class UrlUtils {
6451
6451
  return params;
6452
6452
  }
6453
6453
  static getUrlBase() {
6454
+ if (window['mock_url'])
6455
+ return window['mock_url'];
6454
6456
  return `${location.protocol}"//"${location.hostname}${location.port ? ":" + location.port : ""}`;
6455
6457
  }
6456
6458
  }
6457
6459
 
6458
- class HttpFetcher {
6460
+ class DataFetcher {
6459
6461
  constructor() {
6460
6462
  this.watingRequestsById = new Map();
6461
6463
  }
6462
6464
  static get() {
6463
- if (!HttpFetcher.instance) {
6464
- HttpFetcher.instance = new HttpFetcher();
6465
+ if (!DataFetcher.instance) {
6466
+ DataFetcher.instance = new DataFetcher();
6465
6467
  const application = document.querySelector(this.appTagName);
6466
6468
  if (application === null) {
6467
- HttpFetcher.instance.resume();
6469
+ DataFetcher.instance.resume();
6468
6470
  }
6469
6471
  else {
6470
- application.addEventListener('applicationLoading', () => HttpFetcher.instance.pause());
6471
- application.addEventListener('applicationLoaded', () => HttpFetcher.instance.resume());
6472
+ application.addEventListener('applicationLoading', () => DataFetcher.instance.pause());
6473
+ application.addEventListener('applicationLoaded', () => DataFetcher.instance.resume());
6472
6474
  }
6473
6475
  }
6474
6476
  return this.instance;
@@ -6502,8 +6504,6 @@ class HttpFetcher {
6502
6504
  }
6503
6505
  }
6504
6506
  resolveURL() {
6505
- if (window['mock_url'])
6506
- return window['mock_url'];
6507
6507
  return UrlUtils.getUrlBase();
6508
6508
  }
6509
6509
  getContext() {
@@ -6595,7 +6595,7 @@ class HttpFetcher {
6595
6595
  let dataResponse = [];
6596
6596
  let errorsResponse = [];
6597
6597
  try {
6598
- res = await dist.batchRequests('http://localhost:8082/', request);
6598
+ res = await dist.batchRequests(this.resolveURL(), request);
6599
6599
  res.forEach((resItem) => {
6600
6600
  dataResponse.push(resItem.data);
6601
6601
  });
@@ -6633,7 +6633,7 @@ class HttpFetcher {
6633
6633
  }
6634
6634
  ;
6635
6635
  }
6636
- HttpFetcher.appTagName = "snk-application";
6636
+ DataFetcher.appTagName = "snk-application";
6637
6637
  class WaitingRequest {
6638
6638
  constructor(req) {
6639
6639
  this._resolve = () => { };
@@ -6689,10 +6689,10 @@ class DataUnitFetcher {
6689
6689
  }
6690
6690
  }
6691
6691
  }`);
6692
- this.templateByQuery.set("fetchData", dist.gql `query($dataunit: String! $first: Int $offset:Int $filter: [Filter!] $sort: [Sort!]) {
6692
+ this.templateByQuery.set("fetchData", dist.gql `query($dataunit: String! $limit: Int $offset:Int $filter: [Filter!] $sort: [Sort!]) {
6693
6693
  $queryAlias$: fetchDataUnit(name: $dataunit){
6694
- data(first: $first offset: $offset filters: $filter sort: $sort){
6695
- first
6694
+ data(limit: $limit offset: $offset filters: $filter sort: $sort){
6695
+ limit
6696
6696
  offset
6697
6697
  total
6698
6698
  hasMore
@@ -6720,14 +6720,14 @@ class DataUnitFetcher {
6720
6720
  getDataUnit(entityName, resourceID) {
6721
6721
  const dataUnit = new DataUnit(`dd://${entityName}/${resourceID}`);
6722
6722
  dataUnit.metadataLoader = (dataUnit) => this.loadMetadata(dataUnit);
6723
- dataUnit.dataLoader = (dataUnit, sort, filters) => this.loadData(dataUnit, sort, filters);
6723
+ dataUnit.dataLoader = (dataUnit, page, sort, filters) => this.loadData(dataUnit, page, sort, filters);
6724
6724
  dataUnit.saveLoader = (dataUnit, changes) => this.saveData(dataUnit, changes);
6725
6725
  dataUnit.removeLoader = (dataUnit, recordIds) => this.removeRecords(dataUnit, recordIds);
6726
6726
  return dataUnit;
6727
6727
  }
6728
6728
  loadMetadata(dataUnit) {
6729
6729
  return new Promise((resolve, reject) => {
6730
- HttpFetcher.get()
6730
+ DataFetcher.get()
6731
6731
  .callGraphQL({
6732
6732
  values: { name: dataUnit.name },
6733
6733
  query: this.templateByQuery.get("fetchDataUnit"),
@@ -6754,24 +6754,36 @@ class DataUnitFetcher {
6754
6754
  });
6755
6755
  });
6756
6756
  }
6757
- loadData(dataUnit, sort, filters) {
6757
+ loadData(dataUnit, page, sort, filters) {
6758
6758
  return new Promise((resolve, reject) => {
6759
- HttpFetcher.get()
6759
+ const variables = { dataunit: dataUnit.name, sort, filters };
6760
+ if (page) {
6761
+ variables.limit = page.limit;
6762
+ variables.offset = page.offset;
6763
+ }
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
+ }];
6770
+ }
6771
+ DataFetcher.get()
6760
6772
  .callGraphQL({
6761
- values: { dataunit: dataUnit.name, sort, filters },
6773
+ values: variables,
6762
6774
  query: this.templateByQuery.get("fetchData"),
6763
6775
  })
6764
6776
  .then((resp) => {
6765
- const result = resp.data;
6766
- const dataUnitRecords = [];
6767
- result.records.forEach((responseRecord) => {
6777
+ const pageResult = resp.data;
6778
+ const records = [];
6779
+ pageResult.records.forEach((responseRecord) => {
6768
6780
  const duRecord = { __record__id__: responseRecord.id };
6769
6781
  responseRecord.fields.forEach(({ name, value }) => {
6770
6782
  duRecord[name] = dataUnit.valueFromString(name, value);
6771
6783
  });
6772
- dataUnitRecords.push(duRecord);
6784
+ records.push(duRecord);
6773
6785
  });
6774
- resolve(dataUnitRecords);
6786
+ resolve(Object.assign(Object.assign({}, pageResult), { records }));
6775
6787
  })
6776
6788
  .catch((error) => {
6777
6789
  reject(error);
@@ -6794,7 +6806,7 @@ class DataUnitFetcher {
6794
6806
  return reqChange;
6795
6807
  });
6796
6808
  return new Promise((resolve, reject) => {
6797
- HttpFetcher.get()
6809
+ DataFetcher.get()
6798
6810
  .callGraphQL({
6799
6811
  values: { changes: changes },
6800
6812
  query: this.templateByQuery.get("saveData"),
@@ -6823,7 +6835,7 @@ class DataUnitFetcher {
6823
6835
  return { dataUnit: dataUnit.name, operation: ChangeOperation.DELETE, recordId };
6824
6836
  });
6825
6837
  return new Promise((resolve, reject) => {
6826
- HttpFetcher.get()
6838
+ DataFetcher.get()
6827
6839
  .callGraphQL({
6828
6840
  values: { changes: changes },
6829
6841
  query: this.templateByQuery.get("saveData"),
@@ -6877,7 +6889,7 @@ class ParametersFetcher {
6877
6889
  }
6878
6890
  async getParam(name, resourceID) {
6879
6891
  const completPath = `param://${resourceID}?params=${window.btoa(name)}`;
6880
- return HttpFetcher.get().callGraphQL({
6892
+ return DataFetcher.get().callGraphQL({
6881
6893
  values: { name: completPath },
6882
6894
  query: this.templateByQuery.get("fetchParam"),
6883
6895
  });
@@ -6933,7 +6945,7 @@ class ResourceFetcher {
6933
6945
  }
6934
6946
  loadResource(name) {
6935
6947
  return new Promise((resolve, reject) => {
6936
- HttpFetcher.get()
6948
+ DataFetcher.get()
6937
6949
  .callGraphQL({
6938
6950
  values: { name },
6939
6951
  query: this.templateByQuery.get("fetchResource"),
@@ -6988,7 +7000,7 @@ class PesquisaFetcher {
6988
7000
  }
6989
7001
  loadSearchOptions(entityName, argument, criteria) {
6990
7002
  return new Promise((resolve, reject) => {
6991
- HttpFetcher.get()
7003
+ DataFetcher.get()
6992
7004
  .callGraphQL({
6993
7005
  values: { argument, entityName, criteria },
6994
7006
  query: this.templateByQuery.get("search"),
@@ -7032,7 +7044,7 @@ class PesquisaFetcher {
7032
7044
  }
7033
7045
  };
7034
7046
  return new Promise((resolve, reject) => {
7035
- HttpFetcher.get()
7047
+ DataFetcher.get()
7036
7048
  .callServiceBroker("PesquisaSP.getSuggestion", JSON.stringify(reqBody))
7037
7049
  .then(result => resolve(result))
7038
7050
  .catch(error => reject(error));
@@ -7141,16 +7153,16 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7141
7153
  async getResourceID() {
7142
7154
  return Promise.resolve(this.resourceID);
7143
7155
  }
7144
- async alert(title, message, icon) {
7145
- return ApplicationUtils.alert(title, message, icon);
7156
+ async alert(title, message, icon, options) {
7157
+ return ApplicationUtils.alert(title, message, icon, options);
7146
7158
  }
7147
- async error(title, message, icon) {
7148
- return ApplicationUtils.error(title, message, icon);
7159
+ async error(title, message, icon, options) {
7160
+ return ApplicationUtils.error(title, message, icon, options);
7149
7161
  }
7150
- async confirm(title, message, icon, critical) {
7151
- return ApplicationUtils.confirm(title, message, icon, critical);
7162
+ async confirm(title, message, icon, critical, options) {
7163
+ return ApplicationUtils.confirm(title, message, icon, critical, options);
7152
7164
  }
7153
- async info(message, options = undefined) {
7165
+ async info(message, options) {
7154
7166
  return ApplicationUtils.info(message, options);
7155
7167
  }
7156
7168
  async loadFormConfig(name) {
@@ -7221,6 +7233,7 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
7221
7233
  }
7222
7234
  }
7223
7235
  componentWillLoad() {
7236
+ ApplicationContext.setContextValue("__EZUI__UPLOAD__ADD__URL__", `${UrlUtils.getUrlBase()}/mge/ez.uploading`);
7224
7237
  ApplicationContext.setContextValue("__EZUI__SEARCH__OPTION__LOADER__", (searchArgument, fieldName, dataUnit) => {
7225
7238
  return this.executeSearch(searchArgument, fieldName, dataUnit);
7226
7239
  });
@@ -1,5 +1,5 @@
1
1
  import { r as registerInstance, c as createEvent, h } from './index-427447f8.js';
2
- import { DataUnit, ChangeOperation, DateUtils, StringUtils, DataType, ApplicationContext } from '@sankhyalabs/core';
2
+ import { DataUnit, StringUtils, ChangeOperation, DateUtils, DataType, ApplicationContext } from '@sankhyalabs/core';
3
3
  import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
4
4
  import { DependencyType } from '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
5
5
 
@@ -6450,24 +6450,26 @@ class UrlUtils {
6450
6450
  return params;
6451
6451
  }
6452
6452
  static getUrlBase() {
6453
+ if (window['mock_url'])
6454
+ return window['mock_url'];
6453
6455
  return `${location.protocol}"//"${location.hostname}${location.port ? ":" + location.port : ""}`;
6454
6456
  }
6455
6457
  }
6456
6458
 
6457
- class HttpFetcher {
6459
+ class DataFetcher {
6458
6460
  constructor() {
6459
6461
  this.watingRequestsById = new Map();
6460
6462
  }
6461
6463
  static get() {
6462
- if (!HttpFetcher.instance) {
6463
- HttpFetcher.instance = new HttpFetcher();
6464
+ if (!DataFetcher.instance) {
6465
+ DataFetcher.instance = new DataFetcher();
6464
6466
  const application = document.querySelector(this.appTagName);
6465
6467
  if (application === null) {
6466
- HttpFetcher.instance.resume();
6468
+ DataFetcher.instance.resume();
6467
6469
  }
6468
6470
  else {
6469
- application.addEventListener('applicationLoading', () => HttpFetcher.instance.pause());
6470
- application.addEventListener('applicationLoaded', () => HttpFetcher.instance.resume());
6471
+ application.addEventListener('applicationLoading', () => DataFetcher.instance.pause());
6472
+ application.addEventListener('applicationLoaded', () => DataFetcher.instance.resume());
6471
6473
  }
6472
6474
  }
6473
6475
  return this.instance;
@@ -6501,8 +6503,6 @@ class HttpFetcher {
6501
6503
  }
6502
6504
  }
6503
6505
  resolveURL() {
6504
- if (window['mock_url'])
6505
- return window['mock_url'];
6506
6506
  return UrlUtils.getUrlBase();
6507
6507
  }
6508
6508
  getContext() {
@@ -6594,7 +6594,7 @@ class HttpFetcher {
6594
6594
  let dataResponse = [];
6595
6595
  let errorsResponse = [];
6596
6596
  try {
6597
- res = await dist.batchRequests('http://localhost:8082/', request);
6597
+ res = await dist.batchRequests(this.resolveURL(), request);
6598
6598
  res.forEach((resItem) => {
6599
6599
  dataResponse.push(resItem.data);
6600
6600
  });
@@ -6632,7 +6632,7 @@ class HttpFetcher {
6632
6632
  }
6633
6633
  ;
6634
6634
  }
6635
- HttpFetcher.appTagName = "snk-application";
6635
+ DataFetcher.appTagName = "snk-application";
6636
6636
  class WaitingRequest {
6637
6637
  constructor(req) {
6638
6638
  this._resolve = () => { };
@@ -6688,10 +6688,10 @@ class DataUnitFetcher {
6688
6688
  }
6689
6689
  }
6690
6690
  }`);
6691
- this.templateByQuery.set("fetchData", dist.gql `query($dataunit: String! $first: Int $offset:Int $filter: [Filter!] $sort: [Sort!]) {
6691
+ this.templateByQuery.set("fetchData", dist.gql `query($dataunit: String! $limit: Int $offset:Int $filter: [Filter!] $sort: [Sort!]) {
6692
6692
  $queryAlias$: fetchDataUnit(name: $dataunit){
6693
- data(first: $first offset: $offset filters: $filter sort: $sort){
6694
- first
6693
+ data(limit: $limit offset: $offset filters: $filter sort: $sort){
6694
+ limit
6695
6695
  offset
6696
6696
  total
6697
6697
  hasMore
@@ -6719,14 +6719,14 @@ class DataUnitFetcher {
6719
6719
  getDataUnit(entityName, resourceID) {
6720
6720
  const dataUnit = new DataUnit(`dd://${entityName}/${resourceID}`);
6721
6721
  dataUnit.metadataLoader = (dataUnit) => this.loadMetadata(dataUnit);
6722
- dataUnit.dataLoader = (dataUnit, sort, filters) => this.loadData(dataUnit, sort, filters);
6722
+ dataUnit.dataLoader = (dataUnit, page, sort, filters) => this.loadData(dataUnit, page, sort, filters);
6723
6723
  dataUnit.saveLoader = (dataUnit, changes) => this.saveData(dataUnit, changes);
6724
6724
  dataUnit.removeLoader = (dataUnit, recordIds) => this.removeRecords(dataUnit, recordIds);
6725
6725
  return dataUnit;
6726
6726
  }
6727
6727
  loadMetadata(dataUnit) {
6728
6728
  return new Promise((resolve, reject) => {
6729
- HttpFetcher.get()
6729
+ DataFetcher.get()
6730
6730
  .callGraphQL({
6731
6731
  values: { name: dataUnit.name },
6732
6732
  query: this.templateByQuery.get("fetchDataUnit"),
@@ -6753,24 +6753,36 @@ class DataUnitFetcher {
6753
6753
  });
6754
6754
  });
6755
6755
  }
6756
- loadData(dataUnit, sort, filters) {
6756
+ loadData(dataUnit, page, sort, filters) {
6757
6757
  return new Promise((resolve, reject) => {
6758
- HttpFetcher.get()
6758
+ const variables = { dataunit: dataUnit.name, sort, filters };
6759
+ if (page) {
6760
+ variables.limit = page.limit;
6761
+ variables.offset = page.offset;
6762
+ }
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
+ }];
6769
+ }
6770
+ DataFetcher.get()
6759
6771
  .callGraphQL({
6760
- values: { dataunit: dataUnit.name, sort, filters },
6772
+ values: variables,
6761
6773
  query: this.templateByQuery.get("fetchData"),
6762
6774
  })
6763
6775
  .then((resp) => {
6764
- const result = resp.data;
6765
- const dataUnitRecords = [];
6766
- result.records.forEach((responseRecord) => {
6776
+ const pageResult = resp.data;
6777
+ const records = [];
6778
+ pageResult.records.forEach((responseRecord) => {
6767
6779
  const duRecord = { __record__id__: responseRecord.id };
6768
6780
  responseRecord.fields.forEach(({ name, value }) => {
6769
6781
  duRecord[name] = dataUnit.valueFromString(name, value);
6770
6782
  });
6771
- dataUnitRecords.push(duRecord);
6783
+ records.push(duRecord);
6772
6784
  });
6773
- resolve(dataUnitRecords);
6785
+ resolve(Object.assign(Object.assign({}, pageResult), { records }));
6774
6786
  })
6775
6787
  .catch((error) => {
6776
6788
  reject(error);
@@ -6793,7 +6805,7 @@ class DataUnitFetcher {
6793
6805
  return reqChange;
6794
6806
  });
6795
6807
  return new Promise((resolve, reject) => {
6796
- HttpFetcher.get()
6808
+ DataFetcher.get()
6797
6809
  .callGraphQL({
6798
6810
  values: { changes: changes },
6799
6811
  query: this.templateByQuery.get("saveData"),
@@ -6822,7 +6834,7 @@ class DataUnitFetcher {
6822
6834
  return { dataUnit: dataUnit.name, operation: ChangeOperation.DELETE, recordId };
6823
6835
  });
6824
6836
  return new Promise((resolve, reject) => {
6825
- HttpFetcher.get()
6837
+ DataFetcher.get()
6826
6838
  .callGraphQL({
6827
6839
  values: { changes: changes },
6828
6840
  query: this.templateByQuery.get("saveData"),
@@ -6876,7 +6888,7 @@ class ParametersFetcher {
6876
6888
  }
6877
6889
  async getParam(name, resourceID) {
6878
6890
  const completPath = `param://${resourceID}?params=${window.btoa(name)}`;
6879
- return HttpFetcher.get().callGraphQL({
6891
+ return DataFetcher.get().callGraphQL({
6880
6892
  values: { name: completPath },
6881
6893
  query: this.templateByQuery.get("fetchParam"),
6882
6894
  });
@@ -6932,7 +6944,7 @@ class ResourceFetcher {
6932
6944
  }
6933
6945
  loadResource(name) {
6934
6946
  return new Promise((resolve, reject) => {
6935
- HttpFetcher.get()
6947
+ DataFetcher.get()
6936
6948
  .callGraphQL({
6937
6949
  values: { name },
6938
6950
  query: this.templateByQuery.get("fetchResource"),
@@ -6987,7 +6999,7 @@ class PesquisaFetcher {
6987
6999
  }
6988
7000
  loadSearchOptions(entityName, argument, criteria) {
6989
7001
  return new Promise((resolve, reject) => {
6990
- HttpFetcher.get()
7002
+ DataFetcher.get()
6991
7003
  .callGraphQL({
6992
7004
  values: { argument, entityName, criteria },
6993
7005
  query: this.templateByQuery.get("search"),
@@ -7031,7 +7043,7 @@ class PesquisaFetcher {
7031
7043
  }
7032
7044
  };
7033
7045
  return new Promise((resolve, reject) => {
7034
- HttpFetcher.get()
7046
+ DataFetcher.get()
7035
7047
  .callServiceBroker("PesquisaSP.getSuggestion", JSON.stringify(reqBody))
7036
7048
  .then(result => resolve(result))
7037
7049
  .catch(error => reject(error));
@@ -7139,16 +7151,16 @@ const SnkApplication = class {
7139
7151
  async getResourceID() {
7140
7152
  return Promise.resolve(this.resourceID);
7141
7153
  }
7142
- async alert(title, message, icon) {
7143
- return ApplicationUtils.alert(title, message, icon);
7154
+ async alert(title, message, icon, options) {
7155
+ return ApplicationUtils.alert(title, message, icon, options);
7144
7156
  }
7145
- async error(title, message, icon) {
7146
- return ApplicationUtils.error(title, message, icon);
7157
+ async error(title, message, icon, options) {
7158
+ return ApplicationUtils.error(title, message, icon, options);
7147
7159
  }
7148
- async confirm(title, message, icon, critical) {
7149
- return ApplicationUtils.confirm(title, message, icon, critical);
7160
+ async confirm(title, message, icon, critical, options) {
7161
+ return ApplicationUtils.confirm(title, message, icon, critical, options);
7150
7162
  }
7151
- async info(message, options = undefined) {
7163
+ async info(message, options) {
7152
7164
  return ApplicationUtils.info(message, options);
7153
7165
  }
7154
7166
  async loadFormConfig(name) {
@@ -7219,6 +7231,7 @@ const SnkApplication = class {
7219
7231
  }
7220
7232
  }
7221
7233
  componentWillLoad() {
7234
+ ApplicationContext.setContextValue("__EZUI__UPLOAD__ADD__URL__", `${UrlUtils.getUrlBase()}/mge/ez.uploading`);
7222
7235
  ApplicationContext.setContextValue("__EZUI__SEARCH__OPTION__LOADER__", (searchArgument, fieldName, dataUnit) => {
7223
7236
  return this.executeSearch(searchArgument, fieldName, dataUnit);
7224
7237
  });