@sankhyalabs/sankhyablocks 0.0.0-bugfix-dev-KB-81512.2 → 0.0.0-bugfix-dev-KB-82051.0

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 (92) hide show
  1. package/dist/cjs/{ContinuousInsertUtils-e9454466.js → ContinuousInsertUtils-0bb99a5a.js} +2 -2
  2. package/dist/cjs/{dataunit-fetcher-8ea97d88.js → dataunit-fetcher-c32fdff7.js} +171 -17
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/{pesquisa-fetcher-8a4857b5.js → pesquisa-fetcher-acbda8a1.js} +18 -10
  5. package/dist/cjs/pesquisa-grid_2.cjs.entry.js +34 -12
  6. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  7. package/dist/cjs/snk-actions-button_5.cjs.entry.js +2 -2
  8. package/dist/cjs/snk-application.cjs.entry.js +2 -2
  9. package/dist/cjs/snk-attach.cjs.entry.js +2 -2
  10. package/dist/cjs/snk-crud.cjs.entry.js +2 -2
  11. package/dist/cjs/snk-data-exporter.cjs.entry.js +3 -3
  12. package/dist/cjs/{snk-data-unit-72ef8777.js → snk-data-unit-2c7c1964.js} +1 -1
  13. package/dist/cjs/snk-data-unit.cjs.entry.js +2 -2
  14. package/dist/cjs/snk-detail-view.cjs.entry.js +3 -3
  15. package/dist/cjs/snk-grid.cjs.entry.js +3 -3
  16. package/dist/cjs/{snk-guides-viewer-0a547d11.js → snk-guides-viewer-3916dc33.js} +2 -2
  17. package/dist/cjs/snk-guides-viewer.cjs.entry.js +3 -3
  18. package/dist/cjs/snk-pesquisa.cjs.entry.js +22 -35
  19. package/dist/cjs/snk-simple-crud.cjs.entry.js +3 -3
  20. package/dist/cjs/snk-taskbar.cjs.entry.js +8 -2
  21. package/dist/collection/components/snk-pesquisa/pesquisa-grid/pesquisa-grid.css +0 -1
  22. package/dist/collection/components/snk-pesquisa/pesquisa-grid/pesquisa-grid.js +41 -5
  23. package/dist/collection/components/snk-pesquisa/pesquisa-tree/pesquisa-tree.css +4 -1
  24. package/dist/collection/components/snk-pesquisa/pesquisa-tree/pesquisa-tree.js +36 -7
  25. package/dist/collection/components/snk-pesquisa/pesquisaHelper.js +6 -4
  26. package/dist/collection/components/snk-pesquisa/snk-pesquisa.css +10 -0
  27. package/dist/collection/components/snk-pesquisa/snk-pesquisa.js +22 -34
  28. package/dist/collection/components/snk-taskbar/snk-taskbar.js +9 -3
  29. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.js +57 -12
  30. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/helpers/DataUnitDataLoaderHelper.js +108 -0
  31. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js +9 -8
  32. package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +12 -6
  33. package/dist/components/ISave.js +19 -11
  34. package/dist/components/dataunit-fetcher.js +171 -17
  35. package/dist/components/pesquisa-grid2.js +21 -6
  36. package/dist/components/pesquisa-tree2.js +15 -6
  37. package/dist/components/snk-pesquisa2.js +23 -35
  38. package/dist/components/snk-taskbar2.js +9 -3
  39. package/dist/esm/{ContinuousInsertUtils-c599f41b.js → ContinuousInsertUtils-5040a02b.js} +2 -2
  40. package/dist/esm/{dataunit-fetcher-8dd93d8b.js → dataunit-fetcher-26c2bed4.js} +171 -17
  41. package/dist/esm/loader.js +1 -1
  42. package/dist/esm/{pesquisa-fetcher-3b206fe3.js → pesquisa-fetcher-718cd6c6.js} +19 -11
  43. package/dist/esm/pesquisa-grid_2.entry.js +34 -12
  44. package/dist/esm/sankhyablocks.js +1 -1
  45. package/dist/esm/snk-actions-button_5.entry.js +2 -2
  46. package/dist/esm/snk-application.entry.js +2 -2
  47. package/dist/esm/snk-attach.entry.js +2 -2
  48. package/dist/esm/snk-crud.entry.js +2 -2
  49. package/dist/esm/snk-data-exporter.entry.js +3 -3
  50. package/dist/esm/{snk-data-unit-11a49fc3.js → snk-data-unit-a36df23f.js} +1 -1
  51. package/dist/esm/snk-data-unit.entry.js +2 -2
  52. package/dist/esm/snk-detail-view.entry.js +3 -3
  53. package/dist/esm/snk-grid.entry.js +3 -3
  54. package/dist/esm/{snk-guides-viewer-a87a4639.js → snk-guides-viewer-81c6be78.js} +2 -2
  55. package/dist/esm/snk-guides-viewer.entry.js +3 -3
  56. package/dist/esm/snk-pesquisa.entry.js +22 -35
  57. package/dist/esm/snk-simple-crud.entry.js +3 -3
  58. package/dist/esm/snk-taskbar.entry.js +9 -3
  59. package/dist/sankhyablocks/{p-5b5e877f.js → p-01da70b7.js} +1 -1
  60. package/dist/sankhyablocks/{p-cc8b7b73.entry.js → p-034d3518.entry.js} +1 -1
  61. package/dist/sankhyablocks/{p-1a91d1f3.entry.js → p-045398fb.entry.js} +1 -1
  62. package/dist/sankhyablocks/p-0904b8c6.entry.js +1 -0
  63. package/dist/sankhyablocks/{p-bd2e8377.entry.js → p-248d3ea0.entry.js} +1 -1
  64. package/dist/sankhyablocks/{p-619aeac8.entry.js → p-28ca3908.entry.js} +1 -1
  65. package/dist/sankhyablocks/p-342cdf88.entry.js +1 -0
  66. package/dist/sankhyablocks/p-3f9e54bf.js +6 -0
  67. package/dist/sankhyablocks/{p-4b85ab68.entry.js → p-6360b63b.entry.js} +1 -1
  68. package/dist/sankhyablocks/{p-60e4db34.js → p-70ae0779.js} +1 -1
  69. package/dist/sankhyablocks/p-78d49c74.js +60 -0
  70. package/dist/sankhyablocks/{p-c691d03b.entry.js → p-84e6f1e4.entry.js} +1 -1
  71. package/dist/sankhyablocks/{p-7b5f24ec.entry.js → p-9d42dacd.entry.js} +1 -1
  72. package/dist/sankhyablocks/{p-4d3e557b.js → p-b5dfc651.js} +1 -1
  73. package/dist/sankhyablocks/{p-b1e0fcdd.entry.js → p-c93a448a.entry.js} +1 -1
  74. package/dist/sankhyablocks/{p-f1120c28.entry.js → p-cc1c6732.entry.js} +1 -1
  75. package/dist/sankhyablocks/{p-07f40d74.entry.js → p-d7700845.entry.js} +2 -2
  76. package/dist/sankhyablocks/{p-ad5ae3ef.entry.js → p-f53baf42.entry.js} +1 -1
  77. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  78. package/dist/types/components/snk-pesquisa/pesquisa-grid/pesquisa-grid.d.ts +11 -5
  79. package/dist/types/components/snk-pesquisa/pesquisa-tree/pesquisa-tree.d.ts +8 -4
  80. package/dist/types/components/snk-pesquisa/pesquisaHelper.d.ts +6 -1
  81. package/dist/types/components/snk-pesquisa/snk-pesquisa.d.ts +5 -6
  82. package/dist/types/components.d.ts +18 -2
  83. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.d.ts +9 -1
  84. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/helpers/DataUnitDataLoaderHelper.d.ts +6 -0
  85. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/interfaces/ILoadingInfo.d.ts +4 -0
  86. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.d.ts +3 -3
  87. package/dist/types/lib/http/data-fetcher/fetchers/pesquisa-fetcher.d.ts +4 -2
  88. package/package.json +1 -1
  89. package/dist/sankhyablocks/p-500f7114.js +0 -6
  90. package/dist/sankhyablocks/p-ddefbbc7.js +0 -60
  91. package/dist/sankhyablocks/p-ef0e94b9.entry.js +0 -1
  92. package/dist/sankhyablocks/p-ef566451.entry.js +0 -1
@@ -5,12 +5,20 @@ export class PesquisaTree {
5
5
  this.treeLoader = undefined;
6
6
  this.argument = undefined;
7
7
  this.allowsNonAnalytic = false;
8
+ this.shouldLoadTree = false;
8
9
  this.items = [];
9
10
  }
10
11
  async applyFilter() {
11
12
  await this._tree.applyFilter(this.argument);
12
13
  }
14
+ async observeShouldLoadTree(newValue) {
15
+ if (!newValue || this.items.length > 0)
16
+ return;
17
+ await this.loadTree();
18
+ }
13
19
  async loadTree() {
20
+ if (!this.shouldLoadTree)
21
+ return;
14
22
  if (!this.treeLoader || typeof this.treeLoader !== 'function')
15
23
  return;
16
24
  const response = await this.treeLoader((this.argument || '').trim());
@@ -39,16 +47,13 @@ export class PesquisaTree {
39
47
  };
40
48
  this.pesquisaTreeSelectItem.emit(option);
41
49
  }
42
- async componentWillLoad() {
43
- await this.loadTree();
44
- }
45
- renderEmptyMessate() {
50
+ renderEmptyMessage() {
46
51
  return (h("div", { class: "ez-flex ez-flex--justify-center ez-flex--align-items-center ez-margin--large ez-text ez-text--xlarge ez-text--secondary" }, h("span", null, "Nenhum registro encontrado...")));
47
52
  }
48
53
  render() {
49
54
  var _a;
50
55
  return (h(Host, null, !((_a = this.items) === null || _a === void 0 ? void 0 : _a.length) ?
51
- this.renderEmptyMessate() :
56
+ this.renderEmptyMessage() :
52
57
  h(Fragment, null, h("div", { class: 'actions-container' }, h("ez-button", { size: 'small', mode: 'icon', class: 'ez-margin-right--small', iconName: 'show-list', title: "Expandir", onClick: () => this.handleExpandAll() }), h("ez-button", { size: 'small', mode: 'icon', iconName: 'hide-list', title: "Recolher", onClick: () => this.handleCloseAll() })), h("ez-tree", { ref: (element) => this._tree = element, onEzDbClickItem: ({ detail }) => this.handleDbClick(detail), items: this.items }))));
53
58
  }
54
59
  static get is() { return "pesquisa-tree"; }
@@ -80,7 +85,7 @@ export class PesquisaTree {
80
85
  },
81
86
  "ITreeItem": {
82
87
  "location": "import",
83
- "path": "@sankhyalabs/ezui/.diststorybook/types/components/ez-tree/interfaces/ITreeItem"
88
+ "path": "@sankhyalabs/ezui/src/components/ez-tree/interfaces/ITreeItem"
84
89
  }
85
90
  }
86
91
  },
@@ -125,6 +130,24 @@ export class PesquisaTree {
125
130
  "attribute": "allows-non-analytic",
126
131
  "reflect": false,
127
132
  "defaultValue": "false"
133
+ },
134
+ "shouldLoadTree": {
135
+ "type": "boolean",
136
+ "mutable": false,
137
+ "complexType": {
138
+ "original": "boolean",
139
+ "resolved": "boolean",
140
+ "references": {}
141
+ },
142
+ "required": false,
143
+ "optional": false,
144
+ "docs": {
145
+ "tags": [],
146
+ "text": "Informa se a \u00E1rvore hier\u00E1rquica deve ou n\u00E3o ser carregada."
147
+ },
148
+ "attribute": "should-load-tree",
149
+ "reflect": false,
150
+ "defaultValue": "false"
128
151
  }
129
152
  };
130
153
  }
@@ -150,7 +173,7 @@ export class PesquisaTree {
150
173
  "references": {
151
174
  "IOption": {
152
175
  "location": "import",
153
- "path": "@sankhyalabs/ezui/.diststorybook/types/components/ez-combo-box/ez-combo-box"
176
+ "path": "@sankhyalabs/ezui/src/components/ez-search/ez-search"
154
177
  }
155
178
  }
156
179
  }
@@ -176,4 +199,10 @@ export class PesquisaTree {
176
199
  }
177
200
  };
178
201
  }
202
+ static get watchers() {
203
+ return [{
204
+ "propName": "shouldLoadTree",
205
+ "methodName": "observeShouldLoadTree"
206
+ }];
207
+ }
179
208
  }
@@ -55,8 +55,6 @@ function buildUserInterface(field) {
55
55
  return UserInterface.DATETIME;
56
56
  if (field['type'] === 'T')
57
57
  return UserInterface.TIME;
58
- if (field['type'] === 'I')
59
- return UserInterface.INTEGERNUMBER;
60
58
  return undefined;
61
59
  }
62
60
  function buildDataType(rawType) {
@@ -68,8 +66,6 @@ function buildDataType(rawType) {
68
66
  return DataType.DATE;
69
67
  case 'B':
70
68
  return DataType.OBJECT;
71
- case 'I':
72
- return DataType.NUMBER;
73
69
  default:
74
70
  return DataType.TEXT;
75
71
  }
@@ -91,3 +87,9 @@ export function parseGridConfig(rawConfig) {
91
87
  return undefined;
92
88
  return { columns };
93
89
  }
90
+ export var PESQUISA_VIEW_MODE;
91
+ (function (PESQUISA_VIEW_MODE) {
92
+ PESQUISA_VIEW_MODE[PESQUISA_VIEW_MODE["GRID"] = 0] = "GRID";
93
+ PESQUISA_VIEW_MODE[PESQUISA_VIEW_MODE["CARDS"] = 1] = "CARDS";
94
+ PESQUISA_VIEW_MODE[PESQUISA_VIEW_MODE["TREE"] = 2] = "TREE";
95
+ })(PESQUISA_VIEW_MODE || (PESQUISA_VIEW_MODE = {}));
@@ -79,6 +79,7 @@
79
79
  /*public*/
80
80
  scrollbar-color: var(--snk-pesquisa__scrollbar--color-clicked) var(--snk-pesquisa__scrollbar--color-background);
81
81
  padding-right: var(--snk-pesquisa__content--padding-right);
82
+ height: 100vh;
82
83
  }
83
84
 
84
85
  .snk-pesquisa__content::-webkit-scrollbar {
@@ -125,6 +126,10 @@
125
126
  padding-top: var(--snk-pesquisa__records--padding-vertical);
126
127
  }
127
128
 
129
+ .snk-pesquisa__records-label.hidden{
130
+ display: none;
131
+ }
132
+
128
133
  .snk-pesquisa__records {
129
134
  color: var(--snk-pesquisa__records--color);
130
135
  }
@@ -166,3 +171,8 @@
166
171
  /*public*/
167
172
  color: var(--snk-pesquisa__btn-hover--color);
168
173
  }
174
+
175
+ .snk-pesquisa__cards-container{
176
+ height: 100%;
177
+ overflow-y: auto;
178
+ }
@@ -1,8 +1,7 @@
1
1
  import { ElementIDUtils, ObjectUtils, StringUtils } from '@sankhyalabs/core';
2
2
  import { h, Host } from '@stencil/core';
3
- import { buildGridMetadata } from './pesquisaHelper';
3
+ import { buildGridMetadata, PESQUISA_VIEW_MODE } from './pesquisaHelper';
4
4
  import { PesquisaFetcher } from '../../lib';
5
- import { EzScrollDirection } from '@sankhyalabs/ezui/dist/collection/components/ez-scroller/EzScrollDirection';
6
5
  export class SnkPesquisa {
7
6
  constructor() {
8
7
  this._mdByName = {};
@@ -19,6 +18,7 @@ export class SnkPesquisa {
19
18
  this._itemList = undefined;
20
19
  this._startLoading = false;
21
20
  this._presentationMode = "list";
21
+ this._currentView = undefined;
22
22
  this.searchLoader = undefined;
23
23
  this.treeLoader = undefined;
24
24
  this.selectItem = undefined;
@@ -321,25 +321,29 @@ export class SnkPesquisa {
321
321
  }
322
322
  async componentDidLoad() {
323
323
  ElementIDUtils.addIDInfo(this._element);
324
+ await this.chooseViewMode();
324
325
  }
325
- async onClickList() {
326
+ async handleChangeViewMode() {
326
327
  this._presentationMode = this._presentationMode === 'list' ? 'table' : 'list';
328
+ await this.chooseViewMode();
327
329
  await this.pesquisaFetcher.savePresentationConfig(this.entityName, this._presentationMode);
328
330
  }
329
- enableListButton() {
330
- var _a;
331
- return ((_a = this._itemList) === null || _a === void 0 ? void 0 : _a.length) > 0;
331
+ async chooseViewMode() {
332
+ var _a, _b;
333
+ if (this._presentationMode !== 'list') {
334
+ await ((_a = this._viewStack) === null || _a === void 0 ? void 0 : _a.show(PESQUISA_VIEW_MODE.GRID));
335
+ this._currentView = PESQUISA_VIEW_MODE.GRID;
336
+ return;
337
+ }
338
+ const view = this.isHierarchyEntity ? PESQUISA_VIEW_MODE.TREE : PESQUISA_VIEW_MODE.CARDS;
339
+ await ((_b = this._viewStack) === null || _b === void 0 ? void 0 : _b.show(view));
340
+ this._currentView = view;
332
341
  }
333
342
  //Os limites de exibição são diferentes para lista e grade
334
343
  hideLimitMessage() {
335
344
  if (!this._itemList)
336
345
  return true;
337
- if (this._presentationMode === "list") {
338
- if (this.isHierarchyEntity)
339
- return true;
340
- return this._itemList.length <= 100;
341
- }
342
- return this._itemList.length <= 150;
346
+ return this._itemList.length < 100;
343
347
  }
344
348
  hideRecordsMessage() {
345
349
  return (this._presentationMode === "list" && this.isHierarchyEntity);
@@ -362,30 +366,13 @@ export class SnkPesquisa {
362
366
  title: 'Modo lista',
363
367
  };
364
368
  }
365
- renderContent() {
366
- if (!this._itemList)
367
- return;
368
- if (this._presentationMode === 'list') {
369
- return this.isHierarchyEntity ? this.renderTree() : this.renderCards();
370
- }
371
- return this.renderPesquisaGrid();
372
- }
373
- renderTree() {
374
- return h("ez-scroller", { direction: EzScrollDirection.VERTICAL }, h("pesquisa-tree", { ref: (element) => this._pesquisaTree = element, argument: this.argument, treeLoader: this.treeLoader, allowsNonAnalytic: this.allowsNonAnalytic, onPesquisaTreeSelectItem: ({ detail }) => this.selectItem(detail) }));
375
- }
376
- renderCards() {
377
- return (h("ez-scroller", { direction: EzScrollDirection.VERTICAL }, h("div", { class: "snk-pesquisa__cards-container" }, this._itemList.map((item) => {
378
- return (h("ez-card-item", { onEzClick: (event) => this.createOption(event.detail), item: item }));
379
- }))));
380
- }
381
- renderPesquisaGrid() {
382
- return h("pesquisa-grid", { metadata: this._gridMetadata, dataSource: this._gridDataSource, pkField: this._pkField, descriptionField: this._descriptionField, entityName: this.entityName, onPesquisaGridSelectItem: ({ detail }) => this.selectItem(detail) });
383
- }
384
369
  render() {
385
- var _a;
370
+ var _a, _b;
386
371
  return (h(Host, null, h("div", { class: "snk-pesquisa" }, h("div", { class: "snk-pesquisa__input" }, h("ez-text-input", { label: "Buscar", class: "ez-margin-right--medium", canShowError: false, ref: (ref) => this._textInput = ref, onEzChange: (event) => this.onChangeValue(event), value: this.argument, "data-element-id": "searchInput" }, h("ez-icon", { slot: "leftIcon", iconName: "search" }), this.argument && ((_a = this._textInput) === null || _a === void 0 ? void 0 : _a.value)
387
372
  ? h("button", { slot: "rightIcon", class: "snk-pesquisa__btn", onClick: () => this.clearSearch() }, h("ez-icon", { iconName: "close" }))
388
- : undefined), h("ez-button", { class: "ez-button--primary", label: "Pesquisar", onClick: () => this.onClickSearch() }), h("ez-button", { class: "ez-margin-left--medium", mode: "icon", iconName: this.getButtonModeInfo().iconName, title: this.getButtonModeInfo().title, onClick: async () => await this.onClickList(), enabled: this.enableListButton() })), h("div", { class: "snk-pesquisa__records-label" }, h("label", { class: `snk-pesquisa__records ${this.hideRecordsMessage() ? "hidden" : ""}` }, this.getMessageView()), h("label", { class: `snk-pesquisa__records-limit ${this.hideLimitMessage() ? "hidden" : ""}` }, "Essa pesquisa foi limitada, existem mais resultados.")), h("div", { class: "snk-pesquisa__content" }, this.renderContent()))));
373
+ : undefined), h("ez-button", { class: "ez-button--primary", label: "Pesquisar", onClick: () => this.onClickSearch() }), h("ez-button", { class: "ez-margin-left--medium", mode: "icon", iconName: this.getButtonModeInfo().iconName, title: this.getButtonModeInfo().title, onClick: async () => await this.handleChangeViewMode() })), h("div", { class: `snk-pesquisa__records-label ${this._currentView === PESQUISA_VIEW_MODE.TREE ? 'hidden' : ''}` }, h("label", { class: `snk-pesquisa__records ${this.hideRecordsMessage() ? "hidden" : ""}` }, this.getMessageView()), h("label", { class: `snk-pesquisa__records-limit ${this.hideLimitMessage() ? "hidden" : ""}` }, "Essa pesquisa foi limitada, existem mais resultados.")), h("div", { class: "snk-pesquisa__content" }, h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, h("stack-item", null, h("pesquisa-grid", { metadata: this._gridMetadata, dataSource: this._gridDataSource, pkField: this._pkField, descriptionField: this._descriptionField, entityName: this.entityName, shouldLoadConfig: this._currentView === PESQUISA_VIEW_MODE.GRID, onPesquisaGridSelectItem: ({ detail }) => this.selectItem(detail) })), h("stack-item", null, h("div", { class: 'snk-pesquisa__cards-container' }, (_b = this._itemList) === null || _b === void 0 ? void 0 : _b.map((item) => {
374
+ return (h("ez-card-item", { onEzClick: (event) => this.createOption(event.detail), item: item }));
375
+ }))), h("stack-item", null, h("pesquisa-tree", { ref: (element) => this._pesquisaTree = element, argument: this.argument, treeLoader: this.treeLoader, allowsNonAnalytic: this.allowsNonAnalytic, shouldLoadTree: this._currentView === PESQUISA_VIEW_MODE.TREE, onPesquisaTreeSelectItem: ({ detail }) => this.selectItem(detail) })))))));
389
376
  }
390
377
  static get is() { return "snk-pesquisa"; }
391
378
  static get encapsulation() { return "scoped"; }
@@ -535,7 +522,8 @@ export class SnkPesquisa {
535
522
  return {
536
523
  "_itemList": {},
537
524
  "_startLoading": {},
538
- "_presentationMode": {}
525
+ "_presentationMode": {},
526
+ "_currentView": {}
539
527
  };
540
528
  }
541
529
  static get elementRef() { return "_element"; }
@@ -1,4 +1,4 @@
1
- import { ApplicationContext, ElementIDUtils, OverflowDirection, OverflowWatcher, StringUtils, OVERFLOWED_CLASS_NAME, LockManager, LockManagerOperation } from '@sankhyalabs/core';
1
+ import { ApplicationContext, ElementIDUtils, OverflowDirection, OverflowWatcher, StringUtils, OVERFLOWED_CLASS_NAME, LockManager, LockManagerOperation, SilentException } from '@sankhyalabs/core';
2
2
  import { h, Host } from '@stencil/core';
3
3
  import { AuthorizationConfig } from '../snk-configurator/AuthorizationConfig';
4
4
  import { AuthorizationElements, buildCustomButton, buildElem, TaskbarElement, VisibleWhenForbidden, } from './elements/taskbar-elements';
@@ -176,8 +176,14 @@ export class SnkTaskbar {
176
176
  case TaskbarElement.SAVE:
177
177
  if (!this._isWaitingForSave) {
178
178
  this._isWaitingForSave = true;
179
- this.dataUnit.saveData()
180
- .finally(() => {
179
+ this.dataUnit.saveData().catch((err) => {
180
+ if (err instanceof SilentException) {
181
+ return;
182
+ }
183
+ else {
184
+ throw err;
185
+ }
186
+ }).finally(() => {
181
187
  this._isWaitingForSave = false;
182
188
  });
183
189
  }
@@ -1,6 +1,8 @@
1
1
  import PreloadManager from "./cache/PreloadManager";
2
2
  import { DatasetStrategy } from "./loadstrategy/DatasetStrategy";
3
+ import { CancelPaginationResponse, showAskCancelPaginationPopup } from './helpers/DataUnitDataLoaderHelper';
3
4
  export default class DataUnitDataLoader {
5
+ constructor() { }
4
6
  static async debounce(dataUnit, callBack) {
5
7
  const duName = dataUnit.name;
6
8
  if (DataUnitDataLoader._debouncingTimeouts[duName]) {
@@ -46,25 +48,67 @@ export default class DataUnitDataLoader {
46
48
  }
47
49
  static async callLoader(dataUnit, request, requestLoadingInfo, dataLoader) {
48
50
  if (dataLoader == undefined) {
49
- //dataLoader = new DataUnitStrategy();
50
51
  dataLoader = new DatasetStrategy();
51
52
  }
52
53
  const result = await dataLoader.load(dataUnit, request, requestLoadingInfo);
53
- const { records, loadingInfo: responseLoadingInfo } = result;
54
- if (DataUnitDataLoader.isOldRequest(dataUnit, responseLoadingInfo)) {
54
+ const responseLoadingInfo = result.loadingInfo;
55
+ if (DataUnitDataLoader.isOldRequest(dataUnit, responseLoadingInfo))
55
56
  return Promise.resolve(undefined);
57
+ this.handleCache(dataLoader, responseLoadingInfo, dataUnit, result.records);
58
+ if (dataUnit.cancelPagination)
59
+ return this.handlePaginationCanceled(dataUnit, result);
60
+ //Não existem mais páginas a serem carregadas
61
+ if (this.canFinishPagination(dataUnit, responseLoadingInfo))
62
+ return Promise.resolve(result);
63
+ const newRequest = Object.assign(Object.assign({}, request), { offset: responseLoadingInfo.count });
64
+ let newLoadingInfo = this.buildNewLoadingInfo(responseLoadingInfo);
65
+ if (this.canProceedPagination(responseLoadingInfo))
66
+ return this.recallLoader(dataUnit, newRequest, newLoadingInfo, dataLoader, result);
67
+ const confirm = await showAskCancelPaginationPopup();
68
+ if (confirm === CancelPaginationResponse.CANCEL)
69
+ return this.handlePaginationCanceled(dataUnit, result);
70
+ if (confirm === CancelPaginationResponse.LOAD_ALL) {
71
+ newLoadingInfo = Object.assign(Object.assign({}, newLoadingInfo), { loadAllRecords: true });
56
72
  }
73
+ newLoadingInfo = Object.assign(Object.assign({}, newLoadingInfo), { lastRowLimitAsked: newLoadingInfo.count });
74
+ return this.recallLoader(dataUnit, newRequest, newLoadingInfo, dataLoader, result);
75
+ }
76
+ static buildNewLoadingInfo(responseLoadingInfo) {
77
+ let newLoadingInfo = Object.assign(Object.assign({}, responseLoadingInfo), { pageNumber: (responseLoadingInfo.pageNumber || 0) + 1, quiet: true });
78
+ return newLoadingInfo;
79
+ }
80
+ static handleCache(dataLoader, responseLoadingInfo, dataUnit, records) {
57
81
  const recreateCache = !dataLoader.canSlice() || responseLoadingInfo.count === 0;
58
82
  PreloadManager.cacheRecords(dataUnit, records, recreateCache, responseLoadingInfo.loadingInProgress);
59
- if (PreloadManager.isCacheEnabled(dataUnit) && responseLoadingInfo.loadingInProgress) {
60
- const newRequest = Object.assign(Object.assign({}, request), { offset: responseLoadingInfo.count });
61
- const newLoadingInfo = Object.assign(Object.assign({}, responseLoadingInfo), { pageNumber: (responseLoadingInfo.pageNumber || 0) + 1, quiet: true });
62
- this.callLoader(dataUnit, newRequest, newLoadingInfo, dataLoader)
63
- .then(result => DataUnitDataLoader.afterLoadingPage(dataUnit, result.loadingInfo))
64
- .catch(reason => console.error(reason));
65
- }
83
+ }
84
+ static recallLoader(dataUnit, newRequest, newLoadingInfo, dataLoader, result) {
85
+ this.callLoader(dataUnit, newRequest, newLoadingInfo, dataLoader)
86
+ .then(result => DataUnitDataLoader.afterLoadingPage(dataUnit, result.loadingInfo))
87
+ .catch(reason => console.error(reason));
66
88
  return Promise.resolve(result);
67
89
  }
90
+ static canFinishPagination(dataUnit, responseLoadingInfo) {
91
+ return !PreloadManager.isCacheEnabled(dataUnit) || !responseLoadingInfo.loadingInProgress;
92
+ }
93
+ static canProceedPagination(info) {
94
+ const { count, askRowsLimit, loadAllRecords, lastRowLimitAsked } = info;
95
+ if (loadAllRecords)
96
+ return true;
97
+ if (!count || !askRowsLimit)
98
+ return true;
99
+ const askRowLimitNumber = Number(askRowsLimit);
100
+ if (count < askRowLimitNumber)
101
+ return true;
102
+ const nextLimitToAsk = askRowLimitNumber + (lastRowLimitAsked ? lastRowLimitAsked : 0);
103
+ return count < nextLimitToAsk;
104
+ }
105
+ static handlePaginationCanceled(dataUnit, result) {
106
+ dataUnit.cancelPagination = false;
107
+ let loadingInfo = result.loadingInfo;
108
+ loadingInfo = Object.assign(Object.assign({}, loadingInfo), { total: loadingInfo.count, loadingInProgress: false, pagerId: undefined, needReload: loadingInfo.hasLocalSorting });
109
+ const loadDataResult = { records: result.records, loadingInfo };
110
+ return Promise.resolve(loadDataResult);
111
+ }
68
112
  static afterLoadingPage(dataUnit, loadingInfo) {
69
113
  PreloadManager.setLoadingStatus(dataUnit, loadingInfo.loadingInProgress);
70
114
  const dataUnitPagination = dataUnit.getPaginationInfo();
@@ -104,7 +148,7 @@ export default class DataUnitDataLoader {
104
148
  // controle de paginação voltar pra primeira página.
105
149
  offset = 0;
106
150
  }
107
- const { total, count, loadingInProgress } = loadingInfo;
151
+ const { total, count, loadingInProgress, askRowsLimit } = loadingInfo;
108
152
  const firstRecord = (count === 0 || pageSize === 0) ? 0 : offset + 1;
109
153
  const lastRecord = offset + Math.min(pageSize, limit);
110
154
  return {
@@ -113,7 +157,8 @@ export default class DataUnitDataLoader {
113
157
  lastRecord,
114
158
  firstRecord,
115
159
  currentPage: offset / limit,
116
- hasMore: lastRecord < count || loadingInProgress
160
+ hasMore: lastRecord < count || loadingInProgress,
161
+ askRowsLimit
117
162
  };
118
163
  }
119
164
  }
@@ -0,0 +1,108 @@
1
+ export async function showAskCancelPaginationPopup() {
2
+ return new Promise((resolve) => {
3
+ const { checkboxContainer, checkbox } = buildCheckboxContainer();
4
+ const popup = builPopup(resolve, checkbox);
5
+ const contentContainer = buildContentContainer();
6
+ contentContainer.appendChild(buildMessage());
7
+ contentContainer.appendChild(checkboxContainer);
8
+ const actionsContainer = buildActionsContainer();
9
+ actionsContainer.appendChild(buildContinuePaginationBtn(popup, checkbox, resolve));
10
+ actionsContainer.appendChild(buildCancelPaginationBtn(popup, resolve));
11
+ contentContainer.appendChild(actionsContainer);
12
+ popup.appendChild(contentContainer);
13
+ document.body.appendChild(popup);
14
+ });
15
+ }
16
+ function buildCheckboxContainer() {
17
+ const checkboxContainer = document.createElement('div');
18
+ checkboxContainer.style.marginBottom = '14px';
19
+ checkboxContainer.style.display = 'flex';
20
+ checkboxContainer.style.alignItems = 'center';
21
+ const { checkbox, checkboxLabel } = buildCheckbox();
22
+ checkboxContainer.appendChild(checkbox);
23
+ checkboxContainer.appendChild(checkboxLabel);
24
+ return { checkboxContainer, checkbox };
25
+ }
26
+ function buildCheckbox() {
27
+ const checkbox = document.createElement('input');
28
+ checkbox.type = 'checkbox';
29
+ checkbox.id = 'loadAll';
30
+ const checkboxLabel = document.createElement('label');
31
+ checkboxLabel.htmlFor = 'loadAll';
32
+ checkboxLabel.textContent = 'Carregar tudo';
33
+ checkboxLabel.style.marginLeft = '5px';
34
+ return { checkbox, checkboxLabel };
35
+ }
36
+ function buildActionsContainer() {
37
+ const actionsContainer = document.createElement('div');
38
+ actionsContainer.style.display = 'flex';
39
+ actionsContainer.style.flexDirection = 'row';
40
+ actionsContainer.style.justifyContent = 'end';
41
+ actionsContainer.style.gap = '5px';
42
+ return actionsContainer;
43
+ }
44
+ function buildContentContainer() {
45
+ const contentContainer = document.createElement('div');
46
+ contentContainer.style.display = 'flex';
47
+ contentContainer.style.flexDirection = 'column';
48
+ contentContainer.style.fontFamily = 'var(--font-pattern, Roboto)';
49
+ contentContainer.style.fontSize = 'var(--text--medium)';
50
+ return contentContainer;
51
+ }
52
+ function buildMessage() {
53
+ const message = document.createElement('div');
54
+ const line1 = document.createElement('p');
55
+ const line2 = document.createElement('p');
56
+ const line3 = document.createElement('p');
57
+ line3.style.fontWeight = 'var(--text-weight--large, 600)';
58
+ line1.textContent = 'Uma quantidade de registros muito grande está sendo carregada.';
59
+ line2.textContent = 'Recomendamos que a paginação seja cancelada e que seja criado um filtro para os registros.';
60
+ line3.textContent = 'Deseja cancelar o carregamento?';
61
+ message.appendChild(line1);
62
+ message.appendChild(line2);
63
+ message.appendChild(line3);
64
+ return message;
65
+ }
66
+ function buildCancelPaginationBtn(popup, resolve) {
67
+ const cancelPaginationBtn = document.createElement('ez-button');
68
+ cancelPaginationBtn.label = 'Cancelar paginação';
69
+ cancelPaginationBtn.size = 'medium';
70
+ cancelPaginationBtn.classList.add('ez-button--primary');
71
+ cancelPaginationBtn.onclick = () => {
72
+ document.body.removeChild(popup);
73
+ resolve(CancelPaginationResponse.CANCEL);
74
+ };
75
+ return cancelPaginationBtn;
76
+ }
77
+ function buildContinuePaginationBtn(popup, checkBox, resolve) {
78
+ const continuePaginationBtn = document.createElement('ez-button');
79
+ continuePaginationBtn.label = 'Continuar';
80
+ continuePaginationBtn.size = 'medium';
81
+ continuePaginationBtn.onclick = () => {
82
+ document.body.removeChild(popup);
83
+ resolve(checkBox.checked ? CancelPaginationResponse.LOAD_ALL : CancelPaginationResponse.CONTINUE);
84
+ };
85
+ return continuePaginationBtn;
86
+ }
87
+ function builPopup(resolve, checkBox) {
88
+ const popup = document.createElement('ez-popup');
89
+ popup.opened = true;
90
+ popup.size = 'x-small';
91
+ popup.ezTitle = 'Aviso';
92
+ popup.heightMode = "auto";
93
+ popup.addEventListener('ezClosePopup', () => {
94
+ document.body.removeChild(popup);
95
+ resolve(checkBox.checked ? CancelPaginationResponse.LOAD_ALL : CancelPaginationResponse.CONTINUE);
96
+ }, { once: true });
97
+ popup.addEventListener('ezPopupAction', () => {
98
+ document.body.removeChild(popup);
99
+ resolve(CancelPaginationResponse.CANCEL);
100
+ }, { once: true });
101
+ return popup;
102
+ }
103
+ export var CancelPaginationResponse;
104
+ (function (CancelPaginationResponse) {
105
+ CancelPaginationResponse["CANCEL"] = "CANCEL";
106
+ CancelPaginationResponse["CONTINUE"] = "CONTINUE";
107
+ CancelPaginationResponse["LOAD_ALL"] = "LOAD_ALL";
108
+ })(CancelPaginationResponse || (CancelPaginationResponse = {}));
@@ -1,7 +1,7 @@
1
1
  import { ApplicationContext, StringUtils, UserInterface, } from '@sankhyalabs/core';
2
- import { DataFetcher } from "../../../DataFetcher";
3
- import DataUnitFetcher from "../dataunit-fetcher";
4
- import InMemoryLoader from "../../../../../dataUnit/InMemoryLoader";
2
+ import { DataFetcher } from '../../../DataFetcher';
3
+ import DataUnitFetcher from '../dataunit-fetcher';
4
+ import InMemoryLoader from '../../../../../dataUnit/InMemoryLoader';
5
5
  import { getRecordValue } from '../../../../../dataUnit/ValueFormatter';
6
6
  export class DatasetStrategy {
7
7
  canSlice() {
@@ -40,12 +40,13 @@ export class DatasetStrategy {
40
40
  const serviceName = "DatasetSP.loadRecords";
41
41
  const requestBody = this.buildRequestBody(serviceName, fields, dataUnit, request, loadingInfo, serverSorting, serverSideFilters);
42
42
  const params = loadingInfo.quiet ? { urlParams: { quietMode: "true" } } : undefined;
43
- const { result: responseRecords, pagerID: pagerId } = await DataFetcher.get().callServiceBroker(serviceName, requestBody, params);
43
+ const { result: responseRecords, pagerID: pagerId, askRowsLimit } = await DataFetcher.get().callServiceBroker(serviceName, requestBody, params);
44
44
  const records = this.processRecords(dataUnit, fields, responseRecords);
45
45
  const loadingInProgress = pagerId != undefined;
46
46
  const count = loadingInfo.count + records.length;
47
47
  const isInsertingNewRecord = dataUnit.hasNewRecord();
48
- const needReload = !loadingInProgress && localSorting.length > 0;
48
+ const hasLocalSorting = localSorting.length > 0;
49
+ const needReload = !loadingInProgress && hasLocalSorting;
49
50
  /**
50
51
  * Caso precise recarregar dados, porém está no meio de uma inserção, os dados não devem recarregados instantaneamente,
51
52
  * Mas sim, sinalizar que o dataUnit está aguardando para der recarregado.
@@ -56,7 +57,8 @@ export class DatasetStrategy {
56
57
  return Promise.resolve({
57
58
  records,
58
59
  loadingInfo: Object.assign(Object.assign({}, loadingInfo), { pagerId,
59
- loadingInProgress, total: loadingInProgress ? undefined : count, count, needReload: needReload && !isInsertingNewRecord })
60
+ loadingInProgress, total: loadingInProgress ? undefined : count, count, needReload: needReload && !isInsertingNewRecord, askRowsLimit,
61
+ hasLocalSorting })
60
62
  });
61
63
  }
62
64
  catch (error) {
@@ -108,8 +110,7 @@ export class DatasetStrategy {
108
110
  },
109
111
  }
110
112
  };
111
- const parsedRequestBody = JSON.stringify(requestBody);
112
- return parsedRequestBody;
113
+ return JSON.stringify(requestBody);
113
114
  }
114
115
  getFieldsList(dataUnit) {
115
116
  let fields = ["__record__id__", "__record__label__"];
@@ -176,14 +176,13 @@ export class PesquisaFetcher {
176
176
  return parseLegacyTree(response);
177
177
  }
178
178
  buildLoadTreeRequestBody(entityName, argument, criteria, searchOptions) {
179
- var _a, _b, _c;
179
+ var _a, _b;
180
180
  const listenerResult = this.applySearchListener(SearchListenerType.beforeSearch, entityName, argument, criteria, searchOptions);
181
- console.log("criteria: ", criteria);
182
181
  const incomeSearchOptions = (_a = listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.searchOptions) !== null && _a !== void 0 ? _a : searchOptions;
183
182
  const rootEntity = incomeSearchOptions === null || incomeSearchOptions === void 0 ? void 0 : incomeSearchOptions.rootEntity;
184
183
  const codeFieldName = incomeSearchOptions === null || incomeSearchOptions === void 0 ? void 0 : incomeSearchOptions.codeFieldName;
185
184
  const expression = (_b = listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) === null || _b === void 0 ? void 0 : _b.expression;
186
- const params = (_c = listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) === null || _c === void 0 ? void 0 : _c.params;
185
+ const params = this.buildParams(listenerResult);
187
186
  const instancia = {
188
187
  'nome': entityName,
189
188
  'nomeInstanciaLocal': rootEntity,
@@ -201,6 +200,14 @@ export class PesquisaFetcher {
201
200
  'instancia': instancia,
202
201
  };
203
202
  }
203
+ buildParams(listenerResult) {
204
+ var _a, _b;
205
+ let params = (_b = (_a = listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) === null || _a === void 0 ? void 0 : _a.params) !== null && _b !== void 0 ? _b : [];
206
+ params = params.map(param => {
207
+ return Object.assign(Object.assign({}, param), { tipo: convertParamType(param.dataType), $: param.value });
208
+ });
209
+ return params;
210
+ }
204
211
  }
205
212
  function buildLoadGridConfigPayload(entityName) {
206
213
  return {
@@ -238,9 +245,8 @@ function buildSaveConfig(entityName, lastUsedMode) {
238
245
  };
239
246
  }
240
247
  function convertParamType(dataType) {
241
- //Alerta: Cuidado pra não contaminar o DataType com a implementação
242
- //atual da pesquisa... em geral, somente inteiros,
243
- //data (com ou sem hora) e string são realmente relevantes
248
+ // Alerta: Cuidado para não contaminar o DataType com a implementação atual da pesquisa!
249
+ // Em geral, somente inteiros, data (com ou sem hora) e string são realmente relevantes.
244
250
  switch (dataType) {
245
251
  case DataType.NUMBER:
246
252
  return "I";
@@ -57,8 +57,6 @@ function buildUserInterface(field) {
57
57
  return UserInterface.DATETIME;
58
58
  if (field['type'] === 'T')
59
59
  return UserInterface.TIME;
60
- if (field['type'] === 'I')
61
- return UserInterface.INTEGERNUMBER;
62
60
  return undefined;
63
61
  }
64
62
  function buildDataType(rawType) {
@@ -70,8 +68,6 @@ function buildDataType(rawType) {
70
68
  return DataType.DATE;
71
69
  case 'B':
72
70
  return DataType.OBJECT;
73
- case 'I':
74
- return DataType.NUMBER;
75
71
  default:
76
72
  return DataType.TEXT;
77
73
  }
@@ -93,6 +89,12 @@ function parseGridConfig(rawConfig) {
93
89
  return undefined;
94
90
  return { columns };
95
91
  }
92
+ var PESQUISA_VIEW_MODE;
93
+ (function (PESQUISA_VIEW_MODE) {
94
+ PESQUISA_VIEW_MODE[PESQUISA_VIEW_MODE["GRID"] = 0] = "GRID";
95
+ PESQUISA_VIEW_MODE[PESQUISA_VIEW_MODE["CARDS"] = 1] = "CARDS";
96
+ PESQUISA_VIEW_MODE[PESQUISA_VIEW_MODE["TREE"] = 2] = "TREE";
97
+ })(PESQUISA_VIEW_MODE || (PESQUISA_VIEW_MODE = {}));
96
98
 
97
99
  class PesquisaFetcher {
98
100
  constructor() {
@@ -268,14 +270,13 @@ class PesquisaFetcher {
268
270
  return parseLegacyTree(response);
269
271
  }
270
272
  buildLoadTreeRequestBody(entityName, argument, criteria, searchOptions) {
271
- var _a, _b, _c;
273
+ var _a, _b;
272
274
  const listenerResult = this.applySearchListener(SearchListenerType.beforeSearch, entityName, argument, criteria, searchOptions);
273
- console.log("criteria: ", criteria);
274
275
  const incomeSearchOptions = (_a = listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.searchOptions) !== null && _a !== void 0 ? _a : searchOptions;
275
276
  const rootEntity = incomeSearchOptions === null || incomeSearchOptions === void 0 ? void 0 : incomeSearchOptions.rootEntity;
276
277
  const codeFieldName = incomeSearchOptions === null || incomeSearchOptions === void 0 ? void 0 : incomeSearchOptions.codeFieldName;
277
278
  const expression = (_b = listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) === null || _b === void 0 ? void 0 : _b.expression;
278
- const params = (_c = listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) === null || _c === void 0 ? void 0 : _c.params;
279
+ const params = this.buildParams(listenerResult);
279
280
  const instancia = {
280
281
  'nome': entityName,
281
282
  'nomeInstanciaLocal': rootEntity,
@@ -293,6 +294,14 @@ class PesquisaFetcher {
293
294
  'instancia': instancia,
294
295
  };
295
296
  }
297
+ buildParams(listenerResult) {
298
+ var _a, _b;
299
+ let params = (_b = (_a = listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) === null || _a === void 0 ? void 0 : _a.params) !== null && _b !== void 0 ? _b : [];
300
+ params = params.map(param => {
301
+ return Object.assign(Object.assign({}, param), { tipo: convertParamType(param.dataType), $: param.value });
302
+ });
303
+ return params;
304
+ }
296
305
  }
297
306
  function buildLoadGridConfigPayload(entityName) {
298
307
  return {
@@ -330,9 +339,8 @@ function buildSaveConfig(entityName, lastUsedMode) {
330
339
  };
331
340
  }
332
341
  function convertParamType(dataType) {
333
- //Alerta: Cuidado pra não contaminar o DataType com a implementação
334
- //atual da pesquisa... em geral, somente inteiros,
335
- //data (com ou sem hora) e string são realmente relevantes
342
+ // Alerta: Cuidado para não contaminar o DataType com a implementação atual da pesquisa!
343
+ // Em geral, somente inteiros, data (com ou sem hora) e string são realmente relevantes.
336
344
  switch (dataType) {
337
345
  case DataType.NUMBER:
338
346
  return "I";
@@ -393,4 +401,4 @@ var SaveErrorsEnum;
393
401
  SaveErrorsEnum["DESCRIPTION_CANNOT_BE_CHANGED"] = "DESCRIPTION_CANNOT_BE_CHANGED";
394
402
  })(SaveErrorsEnum || (SaveErrorsEnum = {}));
395
403
 
396
- export { DataExporterOption as D, PresentationMode as P, SaveErrorsEnum as S, PesquisaFetcher as a, DataExporterType as b, DataExporterFormat as c, buildGridMetadata as d };
404
+ export { DataExporterOption as D, PresentationMode as P, SaveErrorsEnum as S, PesquisaFetcher as a, DataExporterType as b, DataExporterFormat as c, buildGridMetadata as d, PESQUISA_VIEW_MODE as e };