@sankhyalabs/sankhyablocks 0.0.0-bugfix-dev-KB-74224.1 → 0.0.0-bugfix-dev-KB-75070.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 (157) hide show
  1. package/dist/cjs/{ConfigStorage-ecc0ed20.js → ConfigStorage-f079f5fd.js} +2 -2
  2. package/dist/cjs/{ContinuousInsertUtils-29b65619.js → ContinuousInsertUtils-64e47516.js} +29 -20
  3. package/dist/cjs/{DataFetcher-cadeef8e.js → DataFetcher-e059eb72.js} +7 -5
  4. package/dist/cjs/{SnkFormConfigManager-f1c92f79.js → SnkFormConfigManager-63369164.js} +2 -2
  5. package/dist/cjs/{auth-fetcher-d68841bc.js → auth-fetcher-4f853233.js} +1 -1
  6. package/dist/cjs/{dataunit-fetcher-f89461c1.js → dataunit-fetcher-228016f4.js} +3 -3
  7. package/dist/cjs/{form-config-fetcher-ed497282.js → form-config-fetcher-39397ac5.js} +1 -1
  8. package/dist/cjs/index-f9e81701.js +8 -28
  9. package/dist/cjs/loader.cjs.js +1 -1
  10. package/dist/cjs/{pesquisa-fetcher-ca89181c.js → pesquisa-fetcher-a9bfeb22.js} +7 -2
  11. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  12. package/dist/cjs/snk-actions-button_4.cjs.entry.js +5 -5
  13. package/dist/cjs/snk-application.cjs.entry.js +111 -59
  14. package/dist/cjs/snk-attach.cjs.entry.js +5 -5
  15. package/dist/cjs/{snk-form-config.cjs.entry.js → snk-config-options_3.cjs.entry.js} +365 -3
  16. package/dist/cjs/snk-crud.cjs.entry.js +13 -7
  17. package/dist/cjs/snk-data-exporter.cjs.entry.js +5 -5
  18. package/dist/cjs/{snk-data-unit-668dc5e8.js → snk-data-unit-3d9b6ed4.js} +26 -14
  19. package/dist/cjs/snk-data-unit.cjs.entry.js +3 -3
  20. package/dist/cjs/snk-detail-view.cjs.entry.js +7 -7
  21. package/dist/cjs/{snk-filter-bar.cjs.entry.js → snk-filter-bar_4.cjs.entry.js} +691 -3
  22. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +3 -3
  23. package/dist/cjs/snk-grid.cjs.entry.js +16 -8
  24. package/dist/cjs/{snk-guides-viewer-4236cb9d.js → snk-guides-viewer-eee43c8b.js} +8 -5
  25. package/dist/cjs/snk-guides-viewer.cjs.entry.js +7 -7
  26. package/dist/cjs/snk-personalized-filter.cjs.entry.js +3 -3
  27. package/dist/cjs/snk-simple-crud.cjs.entry.js +45 -10
  28. package/dist/cjs/snk-taskbar.cjs.entry.js +37 -35
  29. package/dist/collection/collection-manifest.json +11 -31
  30. package/dist/collection/components/snk-application/request-listener/DebouncedRequestListener.js +28 -0
  31. package/dist/collection/components/snk-application/request-listener/RequestListenerFactory.js +16 -0
  32. package/dist/collection/components/snk-application/request-listener/RequestListenerLoadingBar.js +52 -0
  33. package/dist/collection/components/snk-application/snk-application.js +44 -54
  34. package/dist/collection/components/snk-crud/snk-crud.js +26 -2
  35. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +3 -0
  36. package/dist/collection/components/snk-data-unit/snk-data-unit.js +25 -13
  37. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +18 -0
  38. package/dist/collection/components/snk-grid/snk-grid.js +28 -2
  39. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +57 -4
  40. package/dist/collection/components/snk-taskbar/snk-taskbar.js +38 -36
  41. package/dist/collection/lib/http/data-fetcher/DataFetcher.js +8 -6
  42. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.js +2 -2
  43. package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +6 -1
  44. package/dist/collection/lib/utils/CrudUtils.js +25 -16
  45. package/dist/collection/sw.js +46 -0
  46. package/dist/components/ContinuousInsertUtils.js +25 -16
  47. package/dist/components/DataFetcher.js +7 -5
  48. package/dist/components/dataunit-fetcher.js +2 -2
  49. package/dist/components/pesquisa-fetcher.js +6 -1
  50. package/dist/components/snk-application2.js +107 -54
  51. package/dist/components/snk-crud.js +9 -2
  52. package/dist/components/snk-data-unit2.js +25 -13
  53. package/dist/components/snk-detail-view2.js +3 -0
  54. package/dist/components/snk-filter-bar2.js +4 -0
  55. package/dist/components/snk-grid2.js +11 -2
  56. package/dist/components/snk-simple-crud2.js +40 -4
  57. package/dist/components/snk-taskbar2.js +38 -36
  58. package/dist/esm/{ConfigStorage-7b36d041.js → ConfigStorage-6514d66e.js} +2 -2
  59. package/dist/esm/{ContinuousInsertUtils-30caa626.js → ContinuousInsertUtils-b62906f9.js} +29 -20
  60. package/dist/esm/{DataFetcher-a9c598f2.js → DataFetcher-5034df59.js} +7 -5
  61. package/dist/esm/{SnkFormConfigManager-139f09fa.js → SnkFormConfigManager-b409c745.js} +3 -3
  62. package/dist/esm/{auth-fetcher-749d880f.js → auth-fetcher-ca5d3a49.js} +1 -1
  63. package/dist/esm/{constants-8457af36.js → constants-7302ee87.js} +1 -1
  64. package/dist/esm/{dataunit-fetcher-c24c76c6.js → dataunit-fetcher-56cb648b.js} +3 -3
  65. package/dist/esm/{form-config-fetcher-adbe5d34.js → form-config-fetcher-a7d3e277.js} +1 -1
  66. package/dist/esm/index-a7d3d3f1.js +8 -28
  67. package/dist/esm/loader.js +1 -1
  68. package/dist/esm/{pesquisa-fetcher-8edaa8cd.js → pesquisa-fetcher-6bc2e41a.js} +7 -2
  69. package/dist/esm/sankhyablocks.js +1 -1
  70. package/dist/esm/snk-actions-button_4.entry.js +6 -6
  71. package/dist/esm/snk-application.entry.js +111 -59
  72. package/dist/esm/snk-attach.entry.js +6 -6
  73. package/dist/esm/{snk-form-config.entry.js → snk-config-options_3.entry.js} +366 -6
  74. package/dist/esm/snk-configurator.entry.js +1 -1
  75. package/dist/esm/snk-crud.entry.js +14 -8
  76. package/dist/esm/snk-data-exporter.entry.js +6 -6
  77. package/dist/esm/{snk-data-unit-0fdfb6c2.js → snk-data-unit-9fa7d2b9.js} +26 -14
  78. package/dist/esm/snk-data-unit.entry.js +3 -3
  79. package/dist/esm/snk-detail-view.entry.js +8 -8
  80. package/dist/esm/snk-field-config.entry.js +1 -1
  81. package/dist/esm/{snk-filter-bar.entry.js → snk-filter-bar_4.entry.js} +690 -5
  82. package/dist/esm/snk-filter-modal-item.entry.js +3 -3
  83. package/dist/esm/snk-grid.entry.js +16 -8
  84. package/dist/esm/{snk-guides-viewer-8934c537.js → snk-guides-viewer-e8ca764a.js} +9 -6
  85. package/dist/esm/snk-guides-viewer.entry.js +8 -8
  86. package/dist/esm/snk-personalized-filter.entry.js +3 -3
  87. package/dist/esm/snk-simple-crud.entry.js +47 -12
  88. package/dist/esm/snk-tab-config.entry.js +1 -1
  89. package/dist/esm/snk-taskbar.entry.js +38 -36
  90. package/dist/sankhyablocks/{p-f3434fc4.js → p-00278e07.js} +1 -1
  91. package/dist/sankhyablocks/{p-b9c67e45.entry.js → p-0d2a2e9e.entry.js} +1 -1
  92. package/dist/sankhyablocks/{p-afbb070d.js → p-0e206e62.js} +1 -1
  93. package/dist/sankhyablocks/{p-06421fdb.js → p-126c58ea.js} +1 -1
  94. package/dist/sankhyablocks/p-200a5481.entry.js +11 -0
  95. package/dist/sankhyablocks/{p-8eb67fa4.entry.js → p-2d3f9482.entry.js} +1 -1
  96. package/dist/sankhyablocks/p-30ebcbe0.entry.js +1 -0
  97. package/dist/sankhyablocks/{p-1bf06cd3.js → p-341465ce.js} +2 -2
  98. package/dist/sankhyablocks/p-342eeb3b.js +1 -0
  99. package/dist/sankhyablocks/{p-7663f597.entry.js → p-41793e17.entry.js} +1 -1
  100. package/dist/sankhyablocks/p-42130213.entry.js +1 -0
  101. package/dist/sankhyablocks/{p-be5d8fcb.entry.js → p-43353d86.entry.js} +1 -1
  102. package/dist/sankhyablocks/{p-7ac7932c.js → p-47d24ac8.js} +2 -2
  103. package/dist/sankhyablocks/p-520c7c38.entry.js +1 -0
  104. package/dist/sankhyablocks/{p-430e4d3c.entry.js → p-7075b789.entry.js} +1 -1
  105. package/dist/sankhyablocks/p-83e71703.entry.js +1 -0
  106. package/dist/sankhyablocks/{p-95df461f.entry.js → p-8b4fc28f.entry.js} +1 -1
  107. package/dist/sankhyablocks/{p-b0ef4383.js → p-95ce311a.js} +1 -1
  108. package/dist/sankhyablocks/{p-4d9549cf.js → p-9ffd9fc7.js} +1 -1
  109. package/dist/sankhyablocks/{p-dcead955.entry.js → p-a2c790ac.entry.js} +1 -1
  110. package/dist/sankhyablocks/p-a3fadd0b.entry.js +1 -0
  111. package/dist/sankhyablocks/{p-212213d9.entry.js → p-aa003d4e.entry.js} +1 -1
  112. package/dist/sankhyablocks/p-aaf94476.js +1 -0
  113. package/dist/sankhyablocks/p-ac26df7a.entry.js +1 -0
  114. package/dist/sankhyablocks/{p-fd8e631c.entry.js → p-af7f7b3e.entry.js} +1 -1
  115. package/dist/sankhyablocks/p-c51ad0e7.entry.js +1 -0
  116. package/dist/sankhyablocks/{p-16869f77.js → p-e3a285a2.js} +1 -1
  117. package/dist/sankhyablocks/p-e4391e16.js +1 -0
  118. package/dist/sankhyablocks/{p-fb34e0cf.entry.js → p-fca0e5cc.entry.js} +1 -1
  119. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  120. package/dist/types/components/snk-application/request-listener/DebouncedRequestListener.d.ts +11 -0
  121. package/dist/types/components/snk-application/request-listener/RequestListenerFactory.d.ts +12 -0
  122. package/dist/types/components/snk-application/request-listener/RequestListenerLoadingBar.d.ts +13 -0
  123. package/dist/types/components/snk-application/snk-application.d.ts +9 -13
  124. package/dist/types/components/snk-crud/snk-crud.d.ts +4 -0
  125. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +4 -0
  126. package/dist/types/components/snk-grid/snk-grid.d.ts +4 -0
  127. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +2 -0
  128. package/dist/types/components.d.ts +30 -0
  129. package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +1 -0
  130. package/dist/types/lib/utils/CrudUtils.d.ts +1 -0
  131. package/package.json +3 -2
  132. package/dist/cjs/snk-config-options.cjs.entry.js +0 -239
  133. package/dist/cjs/snk-filter-item.cjs.entry.js +0 -312
  134. package/dist/cjs/snk-filter-list.cjs.entry.js +0 -152
  135. package/dist/cjs/snk-filter-modal.cjs.entry.js +0 -249
  136. package/dist/cjs/snk-form.cjs.entry.js +0 -144
  137. package/dist/esm/snk-config-options.entry.js +0 -235
  138. package/dist/esm/snk-filter-item.entry.js +0 -308
  139. package/dist/esm/snk-filter-list.entry.js +0 -148
  140. package/dist/esm/snk-filter-modal.entry.js +0 -245
  141. package/dist/esm/snk-form.entry.js +0 -140
  142. package/dist/sankhyablocks/p-01086ff7.entry.js +0 -1
  143. package/dist/sankhyablocks/p-2923c1b5.js +0 -1
  144. package/dist/sankhyablocks/p-2aae03a1.entry.js +0 -1
  145. package/dist/sankhyablocks/p-3b60db06.entry.js +0 -1
  146. package/dist/sankhyablocks/p-5dd8cf4f.js +0 -1
  147. package/dist/sankhyablocks/p-60b29483.entry.js +0 -1
  148. package/dist/sankhyablocks/p-70a4af56.entry.js +0 -1
  149. package/dist/sankhyablocks/p-92eadb1c.entry.js +0 -1
  150. package/dist/sankhyablocks/p-a42e7a1e.entry.js +0 -11
  151. package/dist/sankhyablocks/p-a724e798.entry.js +0 -1
  152. package/dist/sankhyablocks/p-a75d242d.entry.js +0 -1
  153. package/dist/sankhyablocks/p-b9679243.entry.js +0 -1
  154. package/dist/sankhyablocks/p-ca5ec380.js +0 -1
  155. package/dist/sankhyablocks/p-d3f53df2.entry.js +0 -1
  156. package/dist/sankhyablocks/p-e8763234.entry.js +0 -1
  157. package/dist/sankhyablocks/p-feba9d4b.entry.js +0 -1
@@ -15,6 +15,8 @@ import { SnkMessageBuilder } from "../../lib/message/SnkMessageBuilder";
15
15
  import UrlUtils from "../../lib/utils/urlutils";
16
16
  import Workspace from "../../lib/workspace/workspace";
17
17
  import { SnkErrorHandler } from "./errorhandler/snk-error-handler";
18
+ import RequestListenerFactory from "./request-listener/RequestListenerFactory";
19
+ import PreloadManager from "../../lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager";
18
20
  /**
19
21
  * É possível customizar as mensagens dos blocos de construção através de um pequeno modulo na estrutura da aplicação:
20
22
  * - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
@@ -28,7 +30,7 @@ export class SnkApplication {
28
30
  this._waitingAppReady = new Array();
29
31
  this._duCache = new Map();
30
32
  this._duPromises = new Map();
31
- this._requestListener = new RequestListenerLoadingBar();
33
+ this._requestListener = RequestListenerFactory.create({ strategy: 'request_time' });
32
34
  this._pendingActions = new Map;
33
35
  this._loadPkParameter = null;
34
36
  this._isLoadedByPk = false;
@@ -516,6 +518,16 @@ export class SnkApplication {
516
518
  async isLoadedByPk() {
517
519
  return Promise.resolve(this._isLoadedByPk);
518
520
  }
521
+ /**
522
+ * Remove registro do cache do PreLoader do dataunit.
523
+ * Deve ser usado quando existe um dataunit usando loader do application, mas o removeLoader está sendo sobrescrito.
524
+ */
525
+ async preloadMangerRemoveRecord(dataUnit, recordsIDs) {
526
+ const records = recordsIDs.map(id => {
527
+ return { "__record__id__": id };
528
+ });
529
+ PreloadManager.removeRecords(dataUnit, records);
530
+ }
519
531
  async getAuthList(auth) {
520
532
  return await (new MGEAuthorization()).parseFromJSON(auth);
521
533
  }
@@ -1004,7 +1016,7 @@ export class SnkApplication {
1004
1016
  .unbind("F1");
1005
1017
  }
1006
1018
  render() {
1007
- return (h("div", null, h("ez-loading-bar", { ref: (ref) => this._requestListener.loadingBar = ref }), h("ez-popup", { opened: false, ref: (ref) => this._popUp = ref, onEzClosePopup: () => this.closePopUp() }), h("ez-modal", { opened: false, ref: (ref) => this._rightModal = ref, "modal-size": "small", closeOutsideClick: true, closeEsc: true })));
1019
+ return (h("div", null, h("ez-loading-bar", { ref: (ref) => this._requestListener.ezLoadingBar = ref }), h("ez-popup", { opened: false, ref: (ref) => this._popUp = ref, onEzClosePopup: () => this.closePopUp() }), h("ez-modal", { opened: false, ref: (ref) => this._rightModal = ref, "modal-size": "small", closeOutsideClick: true, closeEsc: true })));
1008
1020
  }
1009
1021
  static get is() { return "snk-application"; }
1010
1022
  static get encapsulation() { return "scoped"; }
@@ -1096,7 +1108,7 @@ export class SnkApplication {
1096
1108
  "mutable": false,
1097
1109
  "complexType": {
1098
1110
  "original": "LoadByPkHandler",
1099
- "resolved": "(objPK: { pk: Record<string, any>; }, redirectFrom?: string) => void",
1111
+ "resolved": "(objPK: { pk: any; }, redirectFrom?: string) => void",
1100
1112
  "references": {
1101
1113
  "LoadByPkHandler": {
1102
1114
  "location": "global"
@@ -2200,6 +2212,35 @@ export class SnkApplication {
2200
2212
  }]
2201
2213
  }
2202
2214
  },
2215
+ "preloadMangerRemoveRecord": {
2216
+ "complexType": {
2217
+ "signature": "(dataUnit: DataUnit, recordsIDs: Array<string>) => Promise<void>",
2218
+ "parameters": [{
2219
+ "tags": [],
2220
+ "text": ""
2221
+ }, {
2222
+ "tags": [],
2223
+ "text": ""
2224
+ }],
2225
+ "references": {
2226
+ "Promise": {
2227
+ "location": "global"
2228
+ },
2229
+ "DataUnit": {
2230
+ "location": "import",
2231
+ "path": "@sankhyalabs/core"
2232
+ },
2233
+ "Array": {
2234
+ "location": "global"
2235
+ }
2236
+ },
2237
+ "return": "Promise<void>"
2238
+ },
2239
+ "docs": {
2240
+ "text": "Remove registro do cache do PreLoader do dataunit.\nDeve ser usado quando existe um dataunit usando loader do application, mas o removeLoader est\u00E1 sendo sobrescrito.",
2241
+ "tags": []
2242
+ }
2243
+ },
2203
2244
  "executeSearch": {
2204
2245
  "complexType": {
2205
2246
  "signature": "(searchArgument: ISearchArgument, fieldName: string, dataUnit: DataUnit) => Promise<Array<IOption> | IOption>",
@@ -2513,57 +2554,6 @@ export class SnkApplication {
2513
2554
  }];
2514
2555
  }
2515
2556
  }
2516
- class RequestListenerLoadingBar {
2517
- constructor() {
2518
- this._debounceTime = 1000;
2519
- this._ignoredNameTypes = ["totals"];
2520
- this._countRequest = 0;
2521
- }
2522
- onRequestStart(param) {
2523
- if (this.isIgnoreLoadingOnRequest(param)) {
2524
- return;
2525
- }
2526
- this._countRequest++;
2527
- this.loadingBar.show();
2528
- if (this._timerLoading) {
2529
- clearTimeout(this._timerLoading);
2530
- }
2531
- }
2532
- ;
2533
- onRequestEnd(param) {
2534
- if (this.isIgnoreLoadingOnRequest(param)) {
2535
- return;
2536
- }
2537
- this._countRequest--;
2538
- this._timerLoading = setTimeout(() => {
2539
- if (this._countRequest <= 0) {
2540
- this.loadingBar.hide();
2541
- }
2542
- }, this._debounceTime);
2543
- }
2544
- ;
2545
- isIgnoreLoadingOnRequest(param) {
2546
- if (param == undefined) {
2547
- return false;
2548
- }
2549
- if (param.url.includes("quietMode=true")) {
2550
- return true;
2551
- }
2552
- if (param.requestBody == undefined) {
2553
- return false;
2554
- }
2555
- if (param.requestBody.length == 1) {
2556
- const { name } = param.requestBody[0].variables;
2557
- if (name) {
2558
- const nameParts = name.split(":");
2559
- const nameType = nameParts[0];
2560
- return this._ignoredNameTypes.indexOf(nameType) >= 0;
2561
- }
2562
- }
2563
- return false;
2564
- }
2565
- ;
2566
- }
2567
2557
  class PendingPromise {
2568
2558
  constructor(resolve, reject) {
2569
2559
  this.resolve = resolve;
@@ -42,6 +42,7 @@ export class SnkCrud {
42
42
  this.enableGridInsert = false;
43
43
  this.domainMessagesBuilder = undefined;
44
44
  this.ignoreReadOnlyFormFields = undefined;
45
+ this.enableLockManger = false;
45
46
  this.setCustomFormTitle = undefined;
46
47
  this.customContainerId = `SNK-CRUD-CUSTOM-CONTAINER-${StringUtils.generateUUID()}`;
47
48
  }
@@ -283,11 +284,16 @@ export class SnkCrud {
283
284
  if (!isDocumentBody)
284
285
  element.focus();
285
286
  }
287
+ async function handleAddRecord() {
288
+ if (!dataUnit.hasNewRecord()) {
289
+ dataUnit.addRecord();
290
+ }
291
+ }
286
292
  keyboardManager
287
293
  .bind("F6", this.toggleView.bind(this), { description: "Alterna entre modo formulário e grade.", element: this._element })
288
294
  .bind("F7", saveDataUnitHandlingFocus.bind(this), { description: "Salva os dados.", element: this._element })
289
295
  .bind("ctrl + \\", saveDataUnitHandlingFocus.bind(this), { description: "Salva os dados.", element: this._element })
290
- .bind("F8", dataUnit.addRecord.bind(dataUnit), { description: "Adiciona um novo registro.", element: this._element })
296
+ .bind("F8", handleAddRecord.bind(this), { description: "Adiciona um novo registro.", element: this._element })
291
297
  .bind("F9", dataUnit.removeSelectedRecords.bind(dataUnit), { description: "Remove o registro selecionado.", element: this._element })
292
298
  .bind("ctrl + F9", dataUnit.removeSelectedRecords.bind(dataUnit), { description: "Remove o registro selecionado.", element: this._element })
293
299
  .bind("ctrl + .", () => {
@@ -384,7 +390,7 @@ export class SnkCrud {
384
390
  return;
385
391
  }
386
392
  this._snkDataUnit.ignoreSaveMessage = (this._currentViewMode === VIEW_MODE.GRID && !this.enableGridInsert);
387
- return (h(Host, null, h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "crud" }, h("stack-item", null, h("snk-grid", { ref: (ref) => this._snkGrid = ref, filterBarTitle: this.filterBarTitle, "data-element-id": "crud_grid", configName: this.configName, onGridDoubleClick: () => this.gridToForm(true), taskbarManager: this.taskbarManager, onActionClick: evt => this.executeAction(evt.detail), messagesBuilder: this.messagesBuilder, actionsList: this.actionsList, statusResolver: this.statusResolver, multipleSelection: this.multipleSelection, presentationMode: this.presentationMode, recordsValidator: this.recordsValidator, selectionToastConfig: this.selectionToastConfig, useEnterLikeTab: this.useEnterLikeTab, canEdit: this._canEdit, resourceID: this._resourceID, disablePersonalizedFilter: this.disablePersonalizedFilter, gridLegacyConfigName: this.gridLegacyConfigName, filterBarLegacyConfigName: this.filterBarLegacyConfigName, autoLoad: this.autoLoad, autoFocus: this.autoFocus, enableGridInsert: this.enableGridInsert }, h("slot", { name: "GRID_TASKBAR_CUSTOM_ELEMENTS" }), h("slot", { name: "GRID_HEADER_CUSTOM_ELEMENTS" }), h("slot", { name: "SnkGridHeader" }), h("slot", { name: "SnkGridFooter" }), h("slot", { name: "SnkGridTaskBar" }))), h("stack-item", null, h("snk-guides-viewer", { ref: ref => this._guidesViewer = ref, entityPath: this._snkDataUnit.entityName, messagesBuilder: this.messagesBuilder, onExit: () => this.setViewMode(VIEW_MODE.GRID), dataState: this._dataState, dataUnit: this._dataUnit, actionsList: this.actionsList, taskbarManager: this.taskbarManager, configName: this.configName, onActionClick: evt => this.executeAction(evt.detail), presentationMode: this.presentationMode, "data-element-id": "crud_form", canEdit: this._canEdit, recordsValidator: this.recordsValidator, resourceID: this._resourceID, detailTaskbarCustomContainerId: this.customContainerId, formLegacyConfigName: this.formLegacyConfigName, enableGridInsert: this.enableGridInsert, getCustomTitle: this.setCustomFormTitle, ignoreReadOnlyFormFields: this.ignoreReadOnlyFormFields }, h("slot", { name: "GUIDES_VIEWER_TASKBAR_CUSTOM_ELEMENTS" }), h("slot", { name: "SnkFormTaskBar" }))), h("stack-item", null, h("snk-attach", { registerKey: this.attachmentRegisterKey, messagesBuilder: this.messagesBuilder, entityName: this._snkDataUnit.entityName, onBack: this.backView.bind(this) })), h("snk-configurator", { ref: (ref) => this._snkConfigurator = ref, viewMode: this._currentViewMode, messagesBuilder: this.messagesBuilder, onConfigSelected: (evt) => this.setViewMode(evt.detail), onOpenConfig: (evt) => this.openConfig(evt.detail), showActionButtons: this.showActionButtons, onSave: evt => this.handleConfiguratorEvent(evt, 'SAVE'), onCancel: evt => this.handleConfiguratorEvent(evt, 'CANCEL'), resourceID: this._resourceID, customContainerId: this.customContainerId })), h("div", { id: `${this.customContainerId}` }, h("slot", { name: "SnkConfigContainerSlot" }), h("slot", { name: "DETAIL_GRID_HEADER_CUSTOM_ELEMENTS" }), h("slot", { name: "DETAIL_GRID_TASKBAR_CUSTOM_ELEMENTS" }), h("slot", { name: "DETAIL_TASKBAR_CUSTOM_ELEMENTS" }))));
393
+ return (h(Host, null, h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "crud" }, h("stack-item", null, h("snk-grid", { ref: (ref) => this._snkGrid = ref, filterBarTitle: this.filterBarTitle, "data-element-id": "crud_grid", configName: this.configName, onGridDoubleClick: () => this.gridToForm(true), taskbarManager: this.taskbarManager, onActionClick: evt => this.executeAction(evt.detail), messagesBuilder: this.messagesBuilder, actionsList: this.actionsList, statusResolver: this.statusResolver, multipleSelection: this.multipleSelection, presentationMode: this.presentationMode, recordsValidator: this.recordsValidator, selectionToastConfig: this.selectionToastConfig, useEnterLikeTab: this.useEnterLikeTab, canEdit: this._canEdit, resourceID: this._resourceID, disablePersonalizedFilter: this.disablePersonalizedFilter, gridLegacyConfigName: this.gridLegacyConfigName, filterBarLegacyConfigName: this.filterBarLegacyConfigName, autoLoad: this.autoLoad, autoFocus: this.autoFocus, enableGridInsert: this.enableGridInsert, enableLockManger: this.enableLockManger }, h("slot", { name: "GRID_TASKBAR_CUSTOM_ELEMENTS" }), h("slot", { name: "GRID_HEADER_CUSTOM_ELEMENTS" }), h("slot", { name: "SnkGridHeader" }), h("slot", { name: "SnkGridFooter" }), h("slot", { name: "SnkGridTaskBar" }))), h("stack-item", null, h("snk-guides-viewer", { ref: ref => this._guidesViewer = ref, entityPath: this._snkDataUnit.entityName, messagesBuilder: this.messagesBuilder, onExit: () => this.setViewMode(VIEW_MODE.GRID), dataState: this._dataState, dataUnit: this._dataUnit, actionsList: this.actionsList, taskbarManager: this.taskbarManager, configName: this.configName, onActionClick: evt => this.executeAction(evt.detail), presentationMode: this.presentationMode, "data-element-id": "crud_form", canEdit: this._canEdit, recordsValidator: this.recordsValidator, resourceID: this._resourceID, detailTaskbarCustomContainerId: this.customContainerId, formLegacyConfigName: this.formLegacyConfigName, enableGridInsert: this.enableGridInsert, getCustomTitle: this.setCustomFormTitle, ignoreReadOnlyFormFields: this.ignoreReadOnlyFormFields }, h("slot", { name: "GUIDES_VIEWER_TASKBAR_CUSTOM_ELEMENTS" }), h("slot", { name: "SnkFormTaskBar" }))), h("stack-item", null, h("snk-attach", { registerKey: this.attachmentRegisterKey, messagesBuilder: this.messagesBuilder, entityName: this._snkDataUnit.entityName, onBack: this.backView.bind(this) })), h("snk-configurator", { ref: (ref) => this._snkConfigurator = ref, viewMode: this._currentViewMode, messagesBuilder: this.messagesBuilder, onConfigSelected: (evt) => this.setViewMode(evt.detail), onOpenConfig: (evt) => this.openConfig(evt.detail), showActionButtons: this.showActionButtons, onSave: evt => this.handleConfiguratorEvent(evt, 'SAVE'), onCancel: evt => this.handleConfiguratorEvent(evt, 'CANCEL'), resourceID: this._resourceID, customContainerId: this.customContainerId })), h("div", { id: `${this.customContainerId}` }, h("slot", { name: "SnkConfigContainerSlot" }), h("slot", { name: "DETAIL_GRID_HEADER_CUSTOM_ELEMENTS" }), h("slot", { name: "DETAIL_GRID_TASKBAR_CUSTOM_ELEMENTS" }), h("slot", { name: "DETAIL_TASKBAR_CUSTOM_ELEMENTS" }))));
388
394
  }
389
395
  static get is() { return "snk-crud"; }
390
396
  static get encapsulation() { return "scoped"; }
@@ -793,6 +799,24 @@ export class SnkCrud {
793
799
  "attribute": "ignore-read-only-form-fields",
794
800
  "reflect": false
795
801
  },
802
+ "enableLockManger": {
803
+ "type": "boolean",
804
+ "mutable": false,
805
+ "complexType": {
806
+ "original": "boolean",
807
+ "resolved": "boolean",
808
+ "references": {}
809
+ },
810
+ "required": false,
811
+ "optional": true,
812
+ "docs": {
813
+ "tags": [],
814
+ "text": "Ativa o gerenciamento de locks na grade."
815
+ },
816
+ "attribute": "enable-lock-manger",
817
+ "reflect": false,
818
+ "defaultValue": "false"
819
+ },
796
820
  "setCustomFormTitle": {
797
821
  "type": "unknown",
798
822
  "mutable": false,
@@ -439,6 +439,9 @@ export class SnkGuidesViewer {
439
439
  await this.addErrorBadgeToGuide(guideName);
440
440
  await this.openGuideNavigator(guideName);
441
441
  }
442
+ if (action.type === DUAction.METADATA_LOADED) {
443
+ this.loadGuides(false);
444
+ }
442
445
  }
443
446
  async addErrorBadgeToGuide(guideName) {
444
447
  var _a;
@@ -16,7 +16,7 @@ export class SnkDataUnit {
16
16
  this._rowMetadataCache = new Map();
17
17
  this.REGEX_DATAUNIT_NAME = /dd:\/\/(.+?)\//;
18
18
  this._dataUnitObserver = async (action) => {
19
- const duState = this.buildDataState(action.type);
19
+ const duState = await this.buildDataState(action.type);
20
20
  this.dataState = duState;
21
21
  this.messagesBuilder.currentOperation = this.getMessageOperation();
22
22
  switch (action.type) {
@@ -130,14 +130,22 @@ export class SnkDataUnit {
130
130
  async getRowMetadata(record) {
131
131
  return this.doGetRowMetadata(record);
132
132
  }
133
- doGetRowMetadata(record) {
133
+ async doGetRowMetadata(record) {
134
134
  const selectedRecord = this.dataUnit.getSelectedRecord();
135
135
  if (!record && !selectedRecord) {
136
136
  return;
137
137
  }
138
138
  const currentRecord = record || selectedRecord;
139
139
  const recordId = typeof currentRecord === 'string' ? currentRecord : currentRecord.__record__id__;
140
- const rowMetadata = this._metadataByRow.get(recordId);
140
+ let rowMetadata = this._metadataByRow.get(recordId);
141
+ /*
142
+ Nao fazemos cache de metadataByRow pra registros novos, pois a chave do mesmo
143
+ muda ao ser salvo, por isso essa tratativa é necessária para que o dataState fique com metadados
144
+ corretos nao confiando apenas no _metadataByRow
145
+ */
146
+ if (this.dataUnit.isNewRecord(recordId) && !rowMetadata) {
147
+ rowMetadata = await this.handleLoadRowMetadata(selectedRecord);
148
+ }
141
149
  if (!rowMetadata) {
142
150
  return;
143
151
  }
@@ -331,7 +339,7 @@ export class SnkDataUnit {
331
339
  case Action.RECORDS_COPIED:
332
340
  return this.interceptRecordsCopied(action);
333
341
  case Action.DATA_CHANGED:
334
- await this.handleLoadRowMetadata(action);
342
+ await this.handleLoadRowMetadata(action.payload);
335
343
  return await this.interceptDataChange(action);
336
344
  case Action.CHANGING_DATA:
337
345
  return await this.interceptDataChange(action);
@@ -351,8 +359,9 @@ export class SnkDataUnit {
351
359
  return action;
352
360
  }
353
361
  }
354
- async handleLoadRowMetadata(action) {
355
- const record = action.type === Action.DATA_CHANGED ? action.payload : action.payload.changes[0].record;
362
+ async handleLoadRowMetadata(record) {
363
+ if (!record)
364
+ return;
356
365
  const keysPayload = Object.keys(record);
357
366
  const rmpField = keysPayload.find((field) => this._fieldsWithRmp.includes(field));
358
367
  if (rmpField) {
@@ -431,7 +440,7 @@ export class SnkDataUnit {
431
440
  isAllowed(flag) {
432
441
  return this._permissions ? this._permissions.isSup || this._permissions[flag] : false;
433
442
  }
434
- buildDataState(actionType) {
443
+ async buildDataState(actionType) {
435
444
  var _a;
436
445
  const selectionInfo = this.dataUnit.getSelectionInfo();
437
446
  const isStartingInsertionMode = (this.dataUnit.hasDirtyRecords() || this.dataUnit.hasWaitingChanges()) && (selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.isEmpty());
@@ -439,7 +448,7 @@ export class SnkDataUnit {
439
448
  let rowMetadata = (_a = this.dataState) === null || _a === void 0 ? void 0 : _a.rowMetadata;
440
449
  const allowedOverwrite = [Action.SELECTION_CHANGED, Action.EDITION_CANCELED, Action.NEXT_SELECTED, Action.PREVIOUS_SELECTED];
441
450
  if (selectedRecord && (!rowMetadata || allowedOverwrite.includes(actionType))) {
442
- rowMetadata = this.doGetRowMetadata(selectedRecord);
451
+ rowMetadata = await this.doGetRowMetadata(selectedRecord);
443
452
  }
444
453
  else if (rowMetadata) {
445
454
  rowMetadata.getProp = this.buildGetPropRowMetadata(rowMetadata);
@@ -461,17 +470,20 @@ export class SnkDataUnit {
461
470
  });
462
471
  }
463
472
  async handleDataSaved(action) {
464
- const newRowMetadata = await this.handleLoadRowMetadata(action);
473
+ var _a, _b, _c;
474
+ const newRowMetadata = await this.handleLoadRowMetadata((_c = (_b = (_a = action === null || action === void 0 ? void 0 : action.payload) === null || _a === void 0 ? void 0 : _a.changes) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.record);
465
475
  if (newRowMetadata) {
466
476
  newRowMetadata.getProp = this.buildGetPropRowMetadata(newRowMetadata);
467
477
  }
468
478
  const recordId = action.payload.records[0].__record__id__;
469
479
  this._metadataByRow.set(recordId, newRowMetadata);
470
- this.dataState = this.buildDataState();
471
- if (this.ignoreSaveMessage) {
480
+ this.dataState = await this.buildDataState();
481
+ let saveOperation = action.payload.changes[0]._operation.toLowerCase();
482
+ if (saveOperation == 'copy')
483
+ saveOperation = OperationMap.CLONE;
484
+ if (this.ignoreSaveMessage && ![OperationMap.CLONE, OperationMap.INSERT].includes(saveOperation)) {
472
485
  return;
473
486
  }
474
- const saveOperation = action.payload.changes[0]._operation.toLowerCase();
475
487
  const msg = this.getMessage("snkDataUnit.saveInfo", action.payload.records[0], saveOperation);
476
488
  if (msg != undefined) {
477
489
  this.showSuccessMessage(msg);
@@ -564,7 +576,7 @@ export class SnkDataUnit {
564
576
  const { records } = this.getMetadataByRow(this.dataUnit);
565
577
  this.dataUnit.records = records;
566
578
  }
567
- this.dataState = this.buildDataState();
579
+ this.dataState = await this.buildDataState();
568
580
  let resolver;
569
581
  while (resolver = this._onDataUnitResolve.pop()) {
570
582
  resolver(this.dataUnit);
@@ -38,6 +38,7 @@ export class SnkFilterBar {
38
38
  this.disablePersonalizedFilter = undefined;
39
39
  this.filterBarLegacyConfigName = undefined;
40
40
  this.autoLoad = undefined;
41
+ this.afterFilterModalApply = undefined;
41
42
  this.allowDefault = undefined;
42
43
  this.scrollerLocked = false;
43
44
  this.showPersonalizedFilter = false;
@@ -392,7 +393,9 @@ export class SnkFilterBar {
392
393
  */
393
394
  async showFilterModal() {
394
395
  const callbackOnApplyFilter = (filters) => {
396
+ var _a;
395
397
  this.filterConfig = filters.map(this.normalizeItem).sort((a, b) => this._filtersComparator(a, b));
398
+ (_a = this.afterFilterModalApply) === null || _a === void 0 ? void 0 : _a.call(this);
396
399
  };
397
400
  let filtersConfigCopy = ObjectUtils.copy(this.filterConfig);
398
401
  filtersConfigCopy = filtersConfigCopy.sort((itemA, itemB) => {
@@ -689,6 +692,21 @@ export class SnkFilterBar {
689
692
  },
690
693
  "attribute": "auto-load",
691
694
  "reflect": false
695
+ },
696
+ "afterFilterModalApply": {
697
+ "type": "unknown",
698
+ "mutable": false,
699
+ "complexType": {
700
+ "original": "() => void",
701
+ "resolved": "() => void",
702
+ "references": {}
703
+ },
704
+ "required": false,
705
+ "optional": true,
706
+ "docs": {
707
+ "tags": [],
708
+ "text": "Fun\u00E7\u00E3o chamada depois de aplicar os filtros."
709
+ }
692
710
  }
693
711
  };
694
712
  }
@@ -73,6 +73,7 @@ export class SnkGrid {
73
73
  this.autoLoad = undefined;
74
74
  this.autoFocus = true;
75
75
  this.enableGridInsert = false;
76
+ this.enableLockManger = false;
76
77
  }
77
78
  /**
78
79
  * Exibe a janela de configurações da grade.
@@ -160,10 +161,17 @@ export class SnkGrid {
160
161
  this._grid.setFocus();
161
162
  }
162
163
  async handleClick(event) {
164
+ var _a;
163
165
  if (this.hasToBlockEvent(event)) {
164
166
  event.preventDefault();
165
167
  event.stopPropagation();
166
- await this._dataUnit.cancelEdition();
168
+ if (!await this._dataUnit.cancelEdition())
169
+ return;
170
+ const newEvent = new event.constructor(event.type, event);
171
+ (_a = event.target) === null || _a === void 0 ? void 0 : _a.dispatchEvent(newEvent);
172
+ }
173
+ if (this._grid && !this._grid.contains(event.target)) {
174
+ this._grid.stopEdit();
167
175
  }
168
176
  }
169
177
  hasToBlockEvent(event) {
@@ -454,7 +462,7 @@ export class SnkGrid {
454
462
  return undefined;
455
463
  }
456
464
  return (h("div", { class: "snk-grid__container ez-flex ez-flex--column ez-flex-item--auto ez-padding--large" }, h("div", { class: "snk-grid__header ez-margin-bottom--extra-small" }, this._showSnkFilterBar &&
457
- h(Fragment, null, h("snk-filter-bar", { ref: (ref) => this._snkFilterBar = ref, title: this.filterBarTitle, dataUnit: this._dataUnit, "data-element-id": "gridFilter", class: "snk-grid__filter-bar ez-align--top", configName: this.configName, messagesBuilder: this.messagesBuilder, resourceID: this.resourceID, onConfigUpdated: evt => this.handleFilterConfigUpdated(evt.detail), disablePersonalizedFilter: this.disablePersonalizedFilter, filterBarLegacyConfigName: this.filterBarLegacyConfigName, autoLoad: this.autoLoad }), h("hr", { class: "ez-divider-vertical ez-divider--dark ez-margin-left--medium snk-grid__header-divider" })), h("snk-taskbar", { class: "ez-padding-left--medium", "data-element-id": "grid_top", key: "topTaskbar", configName: this.configName, dataUnit: this._dataUnit, messagesBuilder: this.messagesBuilder, buttons: this._topTaskbarProcessor.buttons, disabledButtons: this._topTaskbarProcessor.disabledButtons, customButtons: this._topTaskbarProcessor.customButtons, primaryButton: this.getPrimaryButton(), resourceID: this.resourceID, customContainerId: this.taskbarCustomContainerId, customSlotId: this.topTaskbarCustomSlotId, overflowStrategy: 'none' }, h("slot", { name: this.topTaskbarCustomSlotId }))), h("ez-grid", { ref: ref => this._grid = ref, class: (this.presentationMode === PresentationMode.SECONDARY ? "snk-grid-container__without-shadow " : "") + "snk-grid__table", "data-element-id": "embedded", dataUnit: this._dataUnit, key: "grid-" + this._snkDataUnit.entityName, config: this._gridConfig, onConfigChange: (evt) => { this.gridConfigChangeHandler(evt); }, onEzDoubleClick: (evt) => this.gridDoubleClick.emit(evt.detail), statusResolver: this.statusResolver, multipleSelection: this.multipleSelection, columnfilterDataSource: this.columnFilterDataSource, selectionToastConfig: this.selectionToastConfig, useEnterLikeTab: this.useEnterLikeTab, recordsValidator: this.recordsValidator, canEdit: this.canEdit, autoFocus: this.autoFocus, enableGridInsert: this.enableGridInsert, enableContinuousInsert: this._enableContinuousInsert }, h("snk-taskbar", { id: 'teste', dataUnit: this._dataUnit, configName: this.configName, messagesBuilder: this.messagesBuilder, "data-element-id": "grid_left", buttons: this.getGridHeaderButtons(), presentationMode: this.presentationMode, disabledButtons: this._headerTaskbarProcessor.disabledButtons, customButtons: this._headerTaskbarProcessor.customButtons, slot: "leftButtons", actionsList: this.getActionsList(), primaryButton: this.getPrimaryButton(), resourceID: this.resourceID, customContainerId: this.taskbarCustomContainerId, customSlotId: this.gridHeaderCustomSlotId }, h("slot", { name: this.gridHeaderCustomSlotId }))), h("div", { class: "ez-col ez-col--sd-12" }, h("slot", { name: "SnkGridFooter" })), h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._popUpGridConfig, onEzCloseModal: () => this.closeGridConfig() }, h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this._gridConfig, "data-element-id": this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this.resourceID }))));
465
+ h(Fragment, null, h("snk-filter-bar", { ref: (ref) => this._snkFilterBar = ref, title: this.filterBarTitle, dataUnit: this._dataUnit, "data-element-id": "gridFilter", class: "snk-grid__filter-bar ez-align--top", configName: this.configName, messagesBuilder: this.messagesBuilder, resourceID: this.resourceID, onConfigUpdated: evt => this.handleFilterConfigUpdated(evt.detail), disablePersonalizedFilter: this.disablePersonalizedFilter, filterBarLegacyConfigName: this.filterBarLegacyConfigName, autoLoad: this.autoLoad }), h("hr", { class: "ez-divider-vertical ez-divider--dark ez-margin-left--medium snk-grid__header-divider" })), h("snk-taskbar", { class: "ez-padding-left--medium", "data-element-id": "grid_top", key: "topTaskbar", configName: this.configName, dataUnit: this._dataUnit, messagesBuilder: this.messagesBuilder, buttons: this._topTaskbarProcessor.buttons, disabledButtons: this._topTaskbarProcessor.disabledButtons, customButtons: this._topTaskbarProcessor.customButtons, primaryButton: this.getPrimaryButton(), resourceID: this.resourceID, customContainerId: this.taskbarCustomContainerId, customSlotId: this.topTaskbarCustomSlotId, overflowStrategy: 'none' }, h("slot", { name: this.topTaskbarCustomSlotId }))), h("ez-grid", { ref: ref => this._grid = ref, class: (this.presentationMode === PresentationMode.SECONDARY ? "snk-grid-container__without-shadow " : "") + "snk-grid__table", "data-element-id": "embedded", dataUnit: this._dataUnit, key: "grid-" + this._snkDataUnit.entityName, config: this._gridConfig, onConfigChange: (evt) => { this.gridConfigChangeHandler(evt); }, onEzDoubleClick: (evt) => this.gridDoubleClick.emit(evt.detail), statusResolver: this.statusResolver, multipleSelection: this.multipleSelection, columnfilterDataSource: this.columnFilterDataSource, selectionToastConfig: this.selectionToastConfig, useEnterLikeTab: this.useEnterLikeTab, recordsValidator: this.recordsValidator, canEdit: this.canEdit, autoFocus: this.autoFocus, enableGridInsert: this.enableGridInsert, enableContinuousInsert: this._enableContinuousInsert, enableLockManger: this.enableLockManger }, h("snk-taskbar", { id: 'teste', dataUnit: this._dataUnit, configName: this.configName, messagesBuilder: this.messagesBuilder, "data-element-id": "grid_left", buttons: this.getGridHeaderButtons(), presentationMode: this.presentationMode, disabledButtons: this._headerTaskbarProcessor.disabledButtons, customButtons: this._headerTaskbarProcessor.customButtons, slot: "leftButtons", actionsList: this.getActionsList(), primaryButton: this.getPrimaryButton(), resourceID: this.resourceID, customContainerId: this.taskbarCustomContainerId, customSlotId: this.gridHeaderCustomSlotId }, h("slot", { name: this.gridHeaderCustomSlotId }))), h("div", { class: "ez-col ez-col--sd-12" }, h("slot", { name: "SnkGridFooter" })), h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._popUpGridConfig, onEzCloseModal: () => this.closeGridConfig() }, h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this._gridConfig, "data-element-id": this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this.resourceID }))));
458
466
  }
459
467
  static get is() { return "snk-grid"; }
460
468
  static get encapsulation() { return "scoped"; }
@@ -918,6 +926,24 @@ export class SnkGrid {
918
926
  "attribute": "enable-grid-insert",
919
927
  "reflect": false,
920
928
  "defaultValue": "false"
929
+ },
930
+ "enableLockManger": {
931
+ "type": "boolean",
932
+ "mutable": false,
933
+ "complexType": {
934
+ "original": "boolean",
935
+ "resolved": "boolean",
936
+ "references": {}
937
+ },
938
+ "required": false,
939
+ "optional": true,
940
+ "docs": {
941
+ "tags": [],
942
+ "text": "Ativa o gerenciamento de locks na grade."
943
+ },
944
+ "attribute": "enable-lock-manger",
945
+ "reflect": false,
946
+ "defaultValue": "false"
921
947
  }
922
948
  };
923
949
  }
@@ -1,4 +1,4 @@
1
- import { ApplicationContext, DataType, ElementIDUtils, FloatingManager, JSUtils, ObjectUtils, StringUtils, UserInterface, } from '@sankhyalabs/core';
1
+ import { ApplicationContext, DataType, ElementIDUtils, FloatingManager, JSUtils, KeyboardManager, ObjectUtils, StringUtils, UserInterface, } from '@sankhyalabs/core';
2
2
  import { CSSVarsUtils } from '@sankhyalabs/ezui/dist/collection/utils';
3
3
  import { h } from '@stencil/core';
4
4
  import { SIMPLE_CRUD_MODE, VIEW_MODE } from '../../lib/utils/constants';
@@ -41,6 +41,7 @@ export class SnkSimpleCrud {
41
41
  this.mode = SIMPLE_CRUD_MODE.SERVER;
42
42
  this.gridConfig = undefined;
43
43
  this.formConfig = undefined;
44
+ this.enableLockManger = false;
44
45
  this._formFields = [];
45
46
  this._fieldsProps = new Map();
46
47
  this._enableContinuousInsert = true;
@@ -340,6 +341,7 @@ export class SnkSimpleCrud {
340
341
  }
341
342
  componentDidLoad() {
342
343
  CSSVarsUtils.applyVarsGrid(this._element, this._grid);
344
+ this.initKeyboardManager();
343
345
  }
344
346
  setCustomRenders() {
345
347
  if (!this._grid) {
@@ -644,9 +646,11 @@ export class SnkSimpleCrud {
644
646
  window.removeEventListener("keydown", this._keyDownHandler);
645
647
  }
646
648
  gridConfigChangeHandler(evt) {
649
+ evt.stopPropagation();
650
+ if (!this.configName)
651
+ return;
647
652
  const config = evt.detail;
648
653
  ConfigStorage.saveGridConfig(config, this.configName, this.resolveResourceID());
649
- evt.stopPropagation();
650
654
  }
651
655
  modalConfigChangeHandler(evt) {
652
656
  const config = evt.detail;
@@ -723,6 +727,37 @@ export class SnkSimpleCrud {
723
727
  return;
724
728
  this.goToView(VIEW_MODE.FORM);
725
729
  }
730
+ async initKeyboardManager() {
731
+ const keyboardManager = new KeyboardManager();
732
+ if (keyboardManager) {
733
+ const dataUnit = this.dataUnit || await this._snkDataUnit.getDataUnit();
734
+ async function saveDataUnitHandlingFocus() {
735
+ const element = document.activeElement;
736
+ const isDocumentBody = (element == document.body);
737
+ if (!isDocumentBody)
738
+ element.blur();
739
+ await dataUnit.saveData();
740
+ if (!isDocumentBody && element.setFocus != undefined) {
741
+ element.setFocus();
742
+ return;
743
+ }
744
+ if (!isDocumentBody)
745
+ element.focus();
746
+ }
747
+ keyboardManager
748
+ .bind("F7", saveDataUnitHandlingFocus.bind(this), { description: "Salva os dados.", element: this._element })
749
+ .bind("F8", dataUnit.addRecord.bind(dataUnit), { description: "Adiciona um novo registro.", element: this._element })
750
+ .bind("F9", dataUnit.removeSelectedRecords.bind(dataUnit), { description: "Remove o registro selecionado.", element: this._element })
751
+ .bind("Escape", () => {
752
+ if (dataUnit.isDirty()) {
753
+ dataUnit.cancelEdition();
754
+ }
755
+ }, {
756
+ debounceTime: 1000,
757
+ description: "Cancela uma ação.", element: this._element
758
+ });
759
+ }
760
+ }
726
761
  renderTaskbarContent() {
727
762
  var _a;
728
763
  return (h("snk-taskbar", { class: this._currentViewMode === VIEW_MODE.FORM && "ez-box ez-box--shadow ez-padding--small", dataUnit: this.dataUnit, primaryButton: ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? "SAVE" : "INSERT", "data-element-id": "grid_left", messagesBuilder: this.messagesBuilder, buttons: this._taskbarProcessor.buttons, actionsList: this.getActionsList(), disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, "data-exporter-store-key": this.getDataExporterStoreKey(), slot: "leftButtons", presentationMode: PresentationMode.SECONDARY }, h("slot", { name: "TASKBAR_CUSTOM_ELEMENTS" })));
@@ -732,9 +767,9 @@ export class SnkSimpleCrud {
732
767
  if (this.dataUnit == undefined) {
733
768
  return;
734
769
  }
735
- return (h("snk-data-unit", { ref: ref => this._snkDataUnit = ref, class: "simple-crud__container", dataUnit: this.dataUnit, useCancelConfirm: this.useCancelConfirm, onDataStateChange: evt => this.onDataStateChange(evt), onCancelEdition: this.handleCancelEdit.bind(this), pageSize: this.getPageSize(), onInsertionMode: this.handleDataUnitOnInsertionMode.bind(this), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail), ignoreSaveMessage: this._currentViewMode === VIEW_MODE.GRID && !this.enableGridInsert, onMessagesBuilderUpdated: evt => this.messagesBuilder = evt.detail, onDataUnitFieldsHidded: this.updateFormConfig.bind(this), domainMessagesBuilder: this.domainMessagesBuilder }, h("header", null, h("slot", { name: "snkSimpleCrudHeader" })), h("section", { class: "ez-box ez-box--shadow simple-crud__container-section" }, h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, h("stack-item", null, h("ez-grid", { class: "ez-margin-bottom--large", ref: ref => this._grid = ref, dataUnit: this.dataUnit, config: this.gridConfig, "no-header": true, multipleSelection: this.multipleSelection, onEzDoubleClick: () => this.goToView(VIEW_MODE.FORM), onConfigChange: evt => this.gridConfigChangeHandler(evt), columnfilterDataSource: this.dataUnit.name && this.dataUnit.name.includes(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME)
770
+ return (h("snk-data-unit", { ref: ref => this._snkDataUnit = ref, class: "simple-crud__container", dataUnit: this.dataUnit, useCancelConfirm: this.useCancelConfirm, onDataStateChange: evt => this.onDataStateChange(evt), onCancelEdition: this.handleCancelEdit.bind(this), pageSize: this.getPageSize(), onInsertionMode: this.handleDataUnitOnInsertionMode.bind(this), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail), ignoreSaveMessage: this._currentViewMode === VIEW_MODE.GRID, onMessagesBuilderUpdated: evt => this.messagesBuilder = evt.detail, onDataUnitFieldsHidded: this.updateFormConfig.bind(this), domainMessagesBuilder: this.domainMessagesBuilder }, h("header", null, h("slot", { name: "snkSimpleCrudHeader" })), h("section", { class: "ez-box ez-box--shadow simple-crud__container-section" }, h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, h("stack-item", null, h("ez-grid", { class: "ez-margin-bottom--large", ref: ref => this._grid = ref, dataUnit: this.dataUnit, config: this.gridConfig, "no-header": true, multipleSelection: this.multipleSelection, onEzDoubleClick: () => this.goToView(VIEW_MODE.FORM), onConfigChange: evt => this.gridConfigChangeHandler(evt), columnfilterDataSource: this.dataUnit.name && this.dataUnit.name.includes(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME)
736
771
  ? undefined
737
- : this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab, autoFocus: this.autoFocus, enableGridInsert: this.enableGridInsert, enableContinuousInsert: this._enableContinuousInsert }, this.renderTaskbarContent(), h("div", { slot: "footer" }, h("slot", { name: "snkSimpleCrudFooter" })))), h("stack-item", null, this.renderTaskbarContent(), h("ez-form", { ref: (ref) => this._form = ref, class: `ez-margin-top--large ${this.handleShowFormConfig() ? "simple-crud__form--hidden" : ""}`, dataUnit: this.dataUnit, config: this.getFormConfig(), fieldToFocus: this._fieldToGetFocus, onEzFormSetFields: (evt) => this.handleFormSetFields(evt.detail), onEzFormRequestClearFieldToFocus: this.clearFieldToFocusHandler.bind(this) }), this.handleShowFormConfig() && h("snk-form-config", { messagesBuilder: this.messagesBuilder, dataUnit: this.dataUnit, configManager: this._formConfigManager, onConfigClose: () => this.closeFormConfig() })), this.messagesBuilder && h("snk-configurator", { ref: (ref) => this._snkConfigurator = ref, viewMode: this._currentViewMode, messagesBuilder: this.messagesBuilder, onConfigSelected: (evt) => this.goToView(evt.detail), onOpenConfig: (evt) => this.openConfig(evt.detail), showActionButtons: this.showConfiguratorButtons, onSave: evt => this.handleConfiguratorEvent(evt, 'SAVE'), onCancel: evt => this.handleConfiguratorEvent(evt, 'CANCEL'), resourceID: this.resolveResourceID(), customContainerId: this._customContainerId })), h("div", { id: `${this._customContainerId}` }, h("slot", { name: "SnkConfigContainerSlot" }))), h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._showPopUpGridConfig, onEzCloseModal: () => this.closeGridConfig() }, h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this.gridConfig, "data-element-id": this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this.resolveResourceID() }))));
772
+ : this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab, autoFocus: this.autoFocus, enableGridInsert: this.enableGridInsert, enableContinuousInsert: this._enableContinuousInsert, enableLockManger: this.enableLockManger }, this.renderTaskbarContent(), h("div", { slot: "footer" }, h("slot", { name: "snkSimpleCrudFooter" })))), h("stack-item", null, this.renderTaskbarContent(), h("ez-form", { ref: (ref) => this._form = ref, class: `ez-margin-top--large ${this.handleShowFormConfig() ? "simple-crud__form--hidden" : ""}`, dataUnit: this.dataUnit, config: this.getFormConfig(), fieldToFocus: this._fieldToGetFocus, onEzFormSetFields: (evt) => this.handleFormSetFields(evt.detail), onEzFormRequestClearFieldToFocus: this.clearFieldToFocusHandler.bind(this) }), this.handleShowFormConfig() && h("snk-form-config", { messagesBuilder: this.messagesBuilder, dataUnit: this.dataUnit, configManager: this._formConfigManager, onConfigClose: () => this.closeFormConfig() })), this.messagesBuilder && h("snk-configurator", { ref: (ref) => this._snkConfigurator = ref, viewMode: this._currentViewMode, messagesBuilder: this.messagesBuilder, onConfigSelected: (evt) => this.goToView(evt.detail), onOpenConfig: (evt) => this.openConfig(evt.detail), showActionButtons: this.showConfiguratorButtons, onSave: evt => this.handleConfiguratorEvent(evt, 'SAVE'), onCancel: evt => this.handleConfiguratorEvent(evt, 'CANCEL'), resourceID: this.resolveResourceID(), customContainerId: this._customContainerId })), h("div", { id: `${this._customContainerId}` }, h("slot", { name: "SnkConfigContainerSlot" }))), h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._showPopUpGridConfig, onEzCloseModal: () => this.closeGridConfig() }, h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this.gridConfig, "data-element-id": this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this.resolveResourceID() }))));
738
773
  }
739
774
  static get is() { return "snk-simple-crud"; }
740
775
  static get encapsulation() { return "scoped"; }
@@ -870,6 +905,24 @@ export class SnkSimpleCrud {
870
905
  "text": ""
871
906
  }
872
907
  },
908
+ "enableLockManger": {
909
+ "type": "boolean",
910
+ "mutable": false,
911
+ "complexType": {
912
+ "original": "boolean",
913
+ "resolved": "boolean",
914
+ "references": {}
915
+ },
916
+ "required": false,
917
+ "optional": true,
918
+ "docs": {
919
+ "tags": [],
920
+ "text": ""
921
+ },
922
+ "attribute": "enable-lock-manger",
923
+ "reflect": false,
924
+ "defaultValue": "false"
925
+ },
873
926
  "multipleSelection": {
874
927
  "type": "boolean",
875
928
  "mutable": false,
@@ -1,4 +1,4 @@
1
- import { ApplicationContext, ElementIDUtils, OverflowDirection, OverflowWatcher, StringUtils, OVERFLOWED_CLASS_NAME } from '@sankhyalabs/core';
1
+ import { ApplicationContext, ElementIDUtils, OverflowDirection, OverflowWatcher, StringUtils, OVERFLOWED_CLASS_NAME, LockManager, LockManagerOperation } 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';
@@ -149,42 +149,44 @@ export class SnkTaskbar {
149
149
  return key ? (_a = this.messagesBuilder) === null || _a === void 0 ? void 0 : _a.getMessage(key, {}) : "";
150
150
  }
151
151
  elementClick(elem) {
152
- if (this.dataUnit) {
153
- switch (elem) {
154
- case TaskbarElement.PREVIOUS:
155
- this.dataUnit.previousRecord();
156
- break;
157
- case TaskbarElement.NEXT:
158
- this.dataUnit.nextRecord();
159
- break;
160
- case TaskbarElement.REFRESH:
161
- this.dataUnit.loadData();
162
- break;
163
- case TaskbarElement.CLONE:
164
- this.dataUnit.copySelected();
165
- break;
166
- case TaskbarElement.REMOVE:
167
- this.dataUnit.removeSelectedRecords();
168
- break;
169
- case TaskbarElement.INSERT:
170
- this.dataUnit.addRecord();
171
- break;
172
- case TaskbarElement.CANCEL:
173
- this.dataUnit.cancelEdition();
174
- break;
175
- case TaskbarElement.SAVE:
176
- if (!this._isWaitingForSave) {
177
- this._isWaitingForSave = true;
178
- this.dataUnit.saveData()
179
- .finally(() => {
180
- this._isWaitingForSave = false;
181
- });
182
- }
183
- break;
152
+ LockManager.whenResolve(this._element, LockManagerOperation.TASKBAR_CLICK).then(() => {
153
+ if (this.dataUnit) {
154
+ switch (elem) {
155
+ case TaskbarElement.PREVIOUS:
156
+ this.dataUnit.previousRecord();
157
+ break;
158
+ case TaskbarElement.NEXT:
159
+ this.dataUnit.nextRecord();
160
+ break;
161
+ case TaskbarElement.REFRESH:
162
+ this.dataUnit.loadData();
163
+ break;
164
+ case TaskbarElement.CLONE:
165
+ this.dataUnit.copySelected();
166
+ break;
167
+ case TaskbarElement.REMOVE:
168
+ this.dataUnit.removeSelectedRecords();
169
+ break;
170
+ case TaskbarElement.INSERT:
171
+ this.dataUnit.addRecord();
172
+ break;
173
+ case TaskbarElement.CANCEL:
174
+ this.dataUnit.cancelEdition();
175
+ break;
176
+ case TaskbarElement.SAVE:
177
+ if (!this._isWaitingForSave) {
178
+ this._isWaitingForSave = true;
179
+ this.dataUnit.saveData()
180
+ .finally(() => {
181
+ this._isWaitingForSave = false;
182
+ });
183
+ }
184
+ break;
185
+ }
184
186
  }
185
- }
186
- if (this.isEnabled(elem))
187
- this.actionClick.emit(elem);
187
+ if (this.isEnabled(elem))
188
+ this.actionClick.emit(elem);
189
+ });
188
190
  }
189
191
  isEnabled(elem) {
190
192
  if (!this.isAllowed(elem)) {