@sankhyalabs/sankhyablocks 8.16.0-dev.44 → 8.16.0-dev.46

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 (62) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  3. package/dist/cjs/snk-actions-button_4.cjs.entry.js +25 -22
  4. package/dist/cjs/snk-application.cjs.entry.js +10 -0
  5. package/dist/cjs/snk-crud.cjs.entry.js +8 -2
  6. package/dist/cjs/snk-data-exporter.cjs.entry.js +1 -1
  7. package/dist/cjs/{snk-data-unit-3d4d0e2a.js → snk-data-unit-3d9b6ed4.js} +25 -13
  8. package/dist/cjs/snk-data-unit.cjs.entry.js +1 -1
  9. package/dist/cjs/snk-grid.cjs.entry.js +10 -2
  10. package/dist/cjs/snk-simple-crud.cjs.entry.js +7 -4
  11. package/dist/cjs/snk-taskbar.cjs.entry.js +37 -35
  12. package/dist/collection/components/snk-actions-button/interfaces/index.js +1 -0
  13. package/dist/collection/components/snk-actions-button/snk-actions-button.js +27 -26
  14. package/dist/collection/components/snk-application/snk-application.js +41 -1
  15. package/dist/collection/components/snk-crud/snk-crud.js +26 -2
  16. package/dist/collection/components/snk-data-unit/snk-data-unit.js +25 -13
  17. package/dist/collection/components/snk-grid/snk-grid.js +28 -2
  18. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +25 -4
  19. package/dist/collection/components/snk-taskbar/snk-taskbar.js +38 -36
  20. package/dist/components/snk-actions-button2.js +27 -26
  21. package/dist/components/snk-application2.js +12 -1
  22. package/dist/components/snk-crud.js +9 -2
  23. package/dist/components/snk-data-unit2.js +25 -13
  24. package/dist/components/snk-grid2.js +11 -2
  25. package/dist/components/snk-simple-crud2.js +8 -4
  26. package/dist/components/snk-taskbar2.js +38 -36
  27. package/dist/esm/loader.js +1 -1
  28. package/dist/esm/sankhyablocks.js +1 -1
  29. package/dist/esm/snk-actions-button_4.entry.js +26 -23
  30. package/dist/esm/snk-application.entry.js +11 -1
  31. package/dist/esm/snk-crud.entry.js +8 -2
  32. package/dist/esm/snk-data-exporter.entry.js +1 -1
  33. package/dist/esm/{snk-data-unit-618e0b80.js → snk-data-unit-9fa7d2b9.js} +25 -13
  34. package/dist/esm/snk-data-unit.entry.js +1 -1
  35. package/dist/esm/snk-grid.entry.js +10 -2
  36. package/dist/esm/snk-simple-crud.entry.js +7 -4
  37. package/dist/esm/snk-taskbar.entry.js +38 -36
  38. package/dist/sankhyablocks/{p-c1adf0dd.entry.js → p-0d2a2e9e.entry.js} +1 -1
  39. package/dist/sankhyablocks/p-200a5481.entry.js +11 -0
  40. package/dist/sankhyablocks/p-342eeb3b.js +1 -0
  41. package/dist/sankhyablocks/p-4e1f992e.entry.js +1 -0
  42. package/dist/sankhyablocks/p-520c7c38.entry.js +1 -0
  43. package/dist/sankhyablocks/{p-9c3138f5.entry.js → p-7075b789.entry.js} +1 -1
  44. package/dist/sankhyablocks/p-83e71703.entry.js +1 -0
  45. package/dist/sankhyablocks/p-a3fadd0b.entry.js +1 -0
  46. package/dist/sankhyablocks/p-af7f7b3e.entry.js +1 -0
  47. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  48. package/dist/types/components/snk-actions-button/interfaces/index.d.ts +3 -0
  49. package/dist/types/components/snk-actions-button/snk-actions-button.d.ts +3 -2
  50. package/dist/types/components/snk-application/snk-application.d.ts +6 -1
  51. package/dist/types/components/snk-crud/snk-crud.d.ts +4 -0
  52. package/dist/types/components/snk-grid/snk-grid.d.ts +4 -0
  53. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +2 -0
  54. package/dist/types/components.d.ts +22 -0
  55. package/package.json +1 -1
  56. package/dist/sankhyablocks/p-0e250436.entry.js +0 -1
  57. package/dist/sankhyablocks/p-1dbd5c18.entry.js +0 -1
  58. package/dist/sankhyablocks/p-2aae03a1.entry.js +0 -1
  59. package/dist/sankhyablocks/p-563b7c28.entry.js +0 -1
  60. package/dist/sankhyablocks/p-a75e9dcc.js +0 -1
  61. package/dist/sankhyablocks/p-da87e42c.entry.js +0 -11
  62. package/dist/sankhyablocks/p-f0aaad2b.entry.js +0 -1
@@ -121,6 +121,7 @@ const SnkSimpleCrud = class {
121
121
  this.mode = constants.SIMPLE_CRUD_MODE.SERVER;
122
122
  this.gridConfig = undefined;
123
123
  this.formConfig = undefined;
124
+ this.enableLockManger = false;
124
125
  this._formFields = [];
125
126
  this._fieldsProps = new Map();
126
127
  this._enableContinuousInsert = true;
@@ -805,16 +806,18 @@ const SnkSimpleCrud = class {
805
806
  return;
806
807
  this.goToView(constants.VIEW_MODE.FORM);
807
808
  }
809
+ renderTaskbarContent() {
810
+ var _a;
811
+ return (index$1.h("snk-taskbar", { class: this._currentViewMode === constants.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: index.PresentationMode.SECONDARY }, index$1.h("slot", { name: "TASKBAR_CUSTOM_ELEMENTS" })));
812
+ }
808
813
  /* istanbul ignore next */
809
814
  render() {
810
- var _a;
811
815
  if (this.dataUnit == undefined) {
812
816
  return;
813
817
  }
814
- const taskbarContent = (index$1.h("snk-taskbar", { class: this._currentViewMode === constants.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: index.PresentationMode.SECONDARY }, index$1.h("slot", { name: "TASKBAR_CUSTOM_ELEMENTS" })));
815
- return (index$1.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 === constants.VIEW_MODE.GRID && !this.enableGridInsert, onMessagesBuilderUpdated: evt => this.messagesBuilder = evt.detail, onDataUnitFieldsHidded: this.updateFormConfig.bind(this), domainMessagesBuilder: this.domainMessagesBuilder }, index$1.h("header", null, index$1.h("slot", { name: "snkSimpleCrudHeader" })), index$1.h("section", { class: "ez-box ez-box--shadow simple-crud__container-section" }, this._currentViewMode === constants.VIEW_MODE.FORM && taskbarContent, index$1.h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, index$1.h("stack-item", null, index$1.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(constants.VIEW_MODE.FORM), onConfigChange: evt => this.gridConfigChangeHandler(evt), columnfilterDataSource: this.dataUnit.name && this.dataUnit.name.includes(dataunitFetcher.InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME)
818
+ return (index$1.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 === constants.VIEW_MODE.GRID, onMessagesBuilderUpdated: evt => this.messagesBuilder = evt.detail, onDataUnitFieldsHidded: this.updateFormConfig.bind(this), domainMessagesBuilder: this.domainMessagesBuilder }, index$1.h("header", null, index$1.h("slot", { name: "snkSimpleCrudHeader" })), index$1.h("section", { class: "ez-box ez-box--shadow simple-crud__container-section" }, index$1.h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, index$1.h("stack-item", null, index$1.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(constants.VIEW_MODE.FORM), onConfigChange: evt => this.gridConfigChangeHandler(evt), columnfilterDataSource: this.dataUnit.name && this.dataUnit.name.includes(dataunitFetcher.InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME)
816
819
  ? undefined
817
- : this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab, autoFocus: this.autoFocus, enableGridInsert: this.enableGridInsert, enableContinuousInsert: this._enableContinuousInsert }, this._currentViewMode === constants.VIEW_MODE.GRID && taskbarContent, index$1.h("div", { slot: "footer" }, index$1.h("slot", { name: "snkSimpleCrudFooter" })))), index$1.h("stack-item", null, index$1.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() && index$1.h("snk-form-config", { messagesBuilder: this.messagesBuilder, dataUnit: this.dataUnit, configManager: this._formConfigManager, onConfigClose: () => this.closeFormConfig() })), this.messagesBuilder && index$1.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 })), index$1.h("div", { id: `${this._customContainerId}` }, index$1.h("slot", { name: "SnkConfigContainerSlot" }))), index$1.h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._showPopUpGridConfig, onEzCloseModal: () => this.closeGridConfig() }, index$1.h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this.gridConfig, "data-element-id": this._element.getAttribute(core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this.resolveResourceID() }))));
820
+ : this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab, autoFocus: this.autoFocus, enableGridInsert: this.enableGridInsert, enableContinuousInsert: this._enableContinuousInsert, enableLockManger: this.enableLockManger }, this.renderTaskbarContent(), index$1.h("div", { slot: "footer" }, index$1.h("slot", { name: "snkSimpleCrudFooter" })))), index$1.h("stack-item", null, this.renderTaskbarContent(), index$1.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() && index$1.h("snk-form-config", { messagesBuilder: this.messagesBuilder, dataUnit: this.dataUnit, configManager: this._formConfigManager, onConfigClose: () => this.closeFormConfig() })), this.messagesBuilder && index$1.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 })), index$1.h("div", { id: `${this._customContainerId}` }, index$1.h("slot", { name: "SnkConfigContainerSlot" }))), index$1.h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._showPopUpGridConfig, onEzCloseModal: () => this.closeGridConfig() }, index$1.h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this.gridConfig, "data-element-id": this._element.getAttribute(core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this.resolveResourceID() }))));
818
821
  }
819
822
  get _element() { return index$1.getElement(this); }
820
823
  static get watchers() { return {
@@ -160,42 +160,44 @@ const SnkTaskbar = class {
160
160
  return key ? (_a = this.messagesBuilder) === null || _a === void 0 ? void 0 : _a.getMessage(key, {}) : "";
161
161
  }
162
162
  elementClick(elem) {
163
- if (this.dataUnit) {
164
- switch (elem) {
165
- case taskbarElements.TaskbarElement.PREVIOUS:
166
- this.dataUnit.previousRecord();
167
- break;
168
- case taskbarElements.TaskbarElement.NEXT:
169
- this.dataUnit.nextRecord();
170
- break;
171
- case taskbarElements.TaskbarElement.REFRESH:
172
- this.dataUnit.loadData();
173
- break;
174
- case taskbarElements.TaskbarElement.CLONE:
175
- this.dataUnit.copySelected();
176
- break;
177
- case taskbarElements.TaskbarElement.REMOVE:
178
- this.dataUnit.removeSelectedRecords();
179
- break;
180
- case taskbarElements.TaskbarElement.INSERT:
181
- this.dataUnit.addRecord();
182
- break;
183
- case taskbarElements.TaskbarElement.CANCEL:
184
- this.dataUnit.cancelEdition();
185
- break;
186
- case taskbarElements.TaskbarElement.SAVE:
187
- if (!this._isWaitingForSave) {
188
- this._isWaitingForSave = true;
189
- this.dataUnit.saveData()
190
- .finally(() => {
191
- this._isWaitingForSave = false;
192
- });
193
- }
194
- break;
163
+ core.LockManager.whenResolve(this._element, core.LockManagerOperation.TASKBAR_CLICK).then(() => {
164
+ if (this.dataUnit) {
165
+ switch (elem) {
166
+ case taskbarElements.TaskbarElement.PREVIOUS:
167
+ this.dataUnit.previousRecord();
168
+ break;
169
+ case taskbarElements.TaskbarElement.NEXT:
170
+ this.dataUnit.nextRecord();
171
+ break;
172
+ case taskbarElements.TaskbarElement.REFRESH:
173
+ this.dataUnit.loadData();
174
+ break;
175
+ case taskbarElements.TaskbarElement.CLONE:
176
+ this.dataUnit.copySelected();
177
+ break;
178
+ case taskbarElements.TaskbarElement.REMOVE:
179
+ this.dataUnit.removeSelectedRecords();
180
+ break;
181
+ case taskbarElements.TaskbarElement.INSERT:
182
+ this.dataUnit.addRecord();
183
+ break;
184
+ case taskbarElements.TaskbarElement.CANCEL:
185
+ this.dataUnit.cancelEdition();
186
+ break;
187
+ case taskbarElements.TaskbarElement.SAVE:
188
+ if (!this._isWaitingForSave) {
189
+ this._isWaitingForSave = true;
190
+ this.dataUnit.saveData()
191
+ .finally(() => {
192
+ this._isWaitingForSave = false;
193
+ });
194
+ }
195
+ break;
196
+ }
195
197
  }
196
- }
197
- if (this.isEnabled(elem))
198
- this.actionClick.emit(elem);
198
+ if (this.isEnabled(elem))
199
+ this.actionClick.emit(elem);
200
+ });
199
201
  }
200
202
  isEnabled(elem) {
201
203
  if (!this.isAllowed(elem)) {
@@ -1,5 +1,5 @@
1
1
  import { h, Host } from '@stencil/core';
2
- import { ApplicationContext, ArrayUtils, ElementIDUtils } from '@sankhyalabs/core';
2
+ import { ApplicationContext, ArrayUtils, ElementIDUtils, ServiceUtils, StorageType } from '@sankhyalabs/core';
3
3
  import { DataFetcher } from '../../lib/http/data-fetcher/DataFetcher';
4
4
  import ExecutorFactory from './actions/factory/executor.factory';
5
5
  import Actions from './actions';
@@ -8,6 +8,7 @@ import ResourceIDUtils from '../../lib/resourceid/ResourceIDUtils';
8
8
  export class SnkActionsButton {
9
9
  constructor() {
10
10
  this.CLIENT_EVENT_CONFIRM_NAME = "br.com.sankhya.actionbutton.clientconfirm";
11
+ this._actions = [];
11
12
  this.handleClick = (evt) => {
12
13
  const selectedAction = this._actions.find((action) => action.actionID == evt.detail.id);
13
14
  const executor = new ExecutorFactory(selectedAction.type).executor;
@@ -17,27 +18,22 @@ export class SnkActionsButton {
17
18
  };
18
19
  this._items = [];
19
20
  this._showDropdown = false;
20
- this._actions = [];
21
- this._isOrderActions = false;
22
21
  }
23
22
  async getActions() {
24
- let param = {
25
- param: {
26
- entityName: this._entityName,
27
- resourceID: this._resourceID
28
- }
29
- };
30
- return DataFetcher.get().callServiceBroker('ActionButtonsSP.getActions', param).then((result) => {
23
+ const actions = await ServiceUtils.useCacheWithService(`SnkActionsButton_${this._entityName}-${this._resourceID}`, async () => {
31
24
  var _a;
32
- if (!((_a = result.actions) === null || _a === void 0 ? void 0 : _a.action))
33
- return;
34
- if (this._isOrderActions) {
35
- this._actions = ArrayUtils.sortAlphabetically(result.actions.action, 'description');
36
- }
37
- else {
38
- this._actions = result.actions.action;
39
- }
40
- });
25
+ const param = {
26
+ param: {
27
+ entityName: this._entityName,
28
+ resourceID: this._resourceID,
29
+ },
30
+ };
31
+ const result = await DataFetcher.get().callServiceBroker('ActionButtonsSP.getActions', param);
32
+ return ((_a = result.actions) === null || _a === void 0 ? void 0 : _a.action) || [];
33
+ }, StorageType.IN_MEMORY_CACHE);
34
+ this._actions = SnkActionsButton.parameters.isOrderActions
35
+ ? ArrayUtils.sortAlphabetically(actions, 'description')
36
+ : actions;
41
37
  }
42
38
  controlDropdown() {
43
39
  this._showDropdown = !this._showDropdown;
@@ -70,7 +66,7 @@ export class SnkActionsButton {
70
66
  }
71
67
  async componentWillLoad() {
72
68
  this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
73
- this._isOrderActions = await this._application.getBooleanParam('global.ordenar.acoes.personalizadas');
69
+ await this.loadParameters();
74
70
  const snkDataUnit = this._element.parentElement;
75
71
  this._dataUnit = snkDataUnit === null || snkDataUnit === void 0 ? void 0 : snkDataUnit.dataUnit;
76
72
  this._resourceID = snkDataUnit === null || snkDataUnit === void 0 ? void 0 : snkDataUnit.resourceID;
@@ -79,9 +75,8 @@ export class SnkActionsButton {
79
75
  this._resourceID = await ResourceIDUtils.getResourceID();
80
76
  }
81
77
  this.setEvents();
82
- this.getActions().then(() => {
83
- this.loadItems();
84
- });
78
+ await this.getActions();
79
+ this.loadItems();
85
80
  }
86
81
  async componentDidLoad() {
87
82
  if (!this._element)
@@ -108,6 +103,11 @@ export class SnkActionsButton {
108
103
  [ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: ElementIDUtils.getInternalIDInfo(sufix)
109
104
  };
110
105
  }
106
+ async loadParameters() {
107
+ if (SnkActionsButton.parameters.isOrderActions != null)
108
+ return;
109
+ SnkActionsButton.parameters.isOrderActions = await this._application.getBooleanParam('global.ordenar.acoes.personalizadas');
110
+ }
111
111
  render() {
112
112
  return (h(Host, null, (this._actions && this._actions.length > 0) &&
113
113
  (h("div", { class: `ez-padding-left--medium snk-actions-button
@@ -134,10 +134,11 @@ export class SnkActionsButton {
134
134
  static get states() {
135
135
  return {
136
136
  "_items": {},
137
- "_showDropdown": {},
138
- "_actions": {},
139
- "_isOrderActions": {}
137
+ "_showDropdown": {}
140
138
  };
141
139
  }
142
140
  static get elementRef() { return "_element"; }
143
141
  }
142
+ SnkActionsButton.parameters = {
143
+ isOrderActions: null
144
+ };
@@ -16,6 +16,7 @@ import UrlUtils from "../../lib/utils/urlutils";
16
16
  import Workspace from "../../lib/workspace/workspace";
17
17
  import { SnkErrorHandler } from "./errorhandler/snk-error-handler";
18
18
  import RequestListenerFactory from "./request-listener/RequestListenerFactory";
19
+ import PreloadManager from "../../lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager";
19
20
  /**
20
21
  * É possível customizar as mensagens dos blocos de construção através de um pequeno modulo na estrutura da aplicação:
21
22
  * - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
@@ -517,6 +518,16 @@ export class SnkApplication {
517
518
  async isLoadedByPk() {
518
519
  return Promise.resolve(this._isLoadedByPk);
519
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
+ }
520
531
  async getAuthList(auth) {
521
532
  return await (new MGEAuthorization()).parseFromJSON(auth);
522
533
  }
@@ -1097,7 +1108,7 @@ export class SnkApplication {
1097
1108
  "mutable": false,
1098
1109
  "complexType": {
1099
1110
  "original": "LoadByPkHandler",
1100
- "resolved": "(objPK: { pk: Record<string, any>; }, redirectFrom?: string) => void",
1111
+ "resolved": "(objPK: { pk: any; }, redirectFrom?: string) => void",
1101
1112
  "references": {
1102
1113
  "LoadByPkHandler": {
1103
1114
  "location": "global"
@@ -2201,6 +2212,35 @@ export class SnkApplication {
2201
2212
  }]
2202
2213
  }
2203
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
+ },
2204
2244
  "executeSearch": {
2205
2245
  "complexType": {
2206
2246
  "signature": "(searchArgument: ISearchArgument, fieldName: string, dataUnit: DataUnit) => Promise<Array<IOption> | IOption>",
@@ -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,
@@ -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);
@@ -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
  }
@@ -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;
@@ -725,16 +726,18 @@ export class SnkSimpleCrud {
725
726
  return;
726
727
  this.goToView(VIEW_MODE.FORM);
727
728
  }
729
+ renderTaskbarContent() {
730
+ var _a;
731
+ 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
+ }
728
733
  /* istanbul ignore next */
729
734
  render() {
730
- var _a;
731
735
  if (this.dataUnit == undefined) {
732
736
  return;
733
737
  }
734
- const taskbarContent = (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" })));
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" }, this._currentViewMode === VIEW_MODE.FORM && taskbarContent, 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)
738
+ 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
739
  ? undefined
737
- : this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab, autoFocus: this.autoFocus, enableGridInsert: this.enableGridInsert, enableContinuousInsert: this._enableContinuousInsert }, this._currentViewMode === VIEW_MODE.GRID && taskbarContent, h("div", { slot: "footer" }, h("slot", { name: "snkSimpleCrudFooter" })))), h("stack-item", null, 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() }))));
740
+ : 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
741
  }
739
742
  static get is() { return "snk-simple-crud"; }
740
743
  static get encapsulation() { return "scoped"; }
@@ -870,6 +873,24 @@ export class SnkSimpleCrud {
870
873
  "text": ""
871
874
  }
872
875
  },
876
+ "enableLockManger": {
877
+ "type": "boolean",
878
+ "mutable": false,
879
+ "complexType": {
880
+ "original": "boolean",
881
+ "resolved": "boolean",
882
+ "references": {}
883
+ },
884
+ "required": false,
885
+ "optional": true,
886
+ "docs": {
887
+ "tags": [],
888
+ "text": ""
889
+ },
890
+ "attribute": "enable-lock-manger",
891
+ "reflect": false,
892
+ "defaultValue": "false"
893
+ },
873
894
  "multipleSelection": {
874
895
  "type": "boolean",
875
896
  "mutable": false,