@sankhyalabs/sankhyablocks 0.0.0-bugfix-dev-KB-68300.0 → 0.0.0-bugfix-dev-KB-68936.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 (85) hide show
  1. package/dist/cjs/{IExporterProvider-597949f9.js → IExporterProvider-d2a04ee7.js} +2 -2
  2. package/dist/cjs/{SnkMessageBuilder-722b104e.js → SnkMessageBuilder-28ceaaed.js} +5 -1
  3. package/dist/cjs/{dataunit-fetcher-688d3f05.js → dataunit-fetcher-75f89355.js} +9 -2
  4. package/dist/cjs/{field-search-f56aa7d6.js → field-search-68e34bf4.js} +5 -1
  5. package/dist/cjs/loader.cjs.js +1 -1
  6. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  7. package/dist/cjs/snk-actions-button_4.cjs.entry.js +1 -1
  8. package/dist/cjs/snk-application.cjs.entry.js +2 -2
  9. package/dist/cjs/snk-attach.cjs.entry.js +1 -1
  10. package/dist/cjs/snk-crud.cjs.entry.js +5 -2
  11. package/dist/cjs/snk-data-exporter.cjs.entry.js +3 -3
  12. package/dist/cjs/{snk-data-unit-eb7e29ca.js → snk-data-unit-bf418767.js} +6 -7
  13. package/dist/cjs/snk-data-unit.cjs.entry.js +3 -3
  14. package/dist/cjs/snk-detail-view.cjs.entry.js +4 -4
  15. package/dist/cjs/snk-grid.cjs.entry.js +32 -7
  16. package/dist/cjs/{snk-guides-viewer-bdc41281.js → snk-guides-viewer-14c27834.js} +8 -4
  17. package/dist/cjs/snk-guides-viewer.cjs.entry.js +3 -3
  18. package/dist/cjs/snk-simple-crud.cjs.entry.js +24 -6
  19. package/dist/collection/components/snk-crud/snk-crud.js +22 -1
  20. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +24 -2
  21. package/dist/collection/components/snk-data-unit/snk-data-unit.js +4 -5
  22. package/dist/collection/components/snk-grid/snk-grid.js +57 -5
  23. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +41 -6
  24. package/dist/collection/components/snk-taskbar/processor/taskbar-processor.js +5 -1
  25. package/dist/collection/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.js +1 -1
  26. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js +9 -2
  27. package/dist/collection/lib/message/resources/snk-grid.msg.js +5 -1
  28. package/dist/components/IExporterProvider.js +6 -2
  29. package/dist/components/SnkMessageBuilder.js +5 -1
  30. package/dist/components/dataunit-fetcher.js +9 -2
  31. package/dist/components/snk-crud.js +5 -1
  32. package/dist/components/snk-data-unit2.js +4 -5
  33. package/dist/components/snk-detail-view2.js +7 -2
  34. package/dist/components/snk-grid2.js +32 -6
  35. package/dist/components/snk-simple-crud2.js +22 -3
  36. package/dist/esm/{IExporterProvider-63a188b6.js → IExporterProvider-b2e244b3.js} +2 -2
  37. package/dist/esm/{SnkMessageBuilder-89925609.js → SnkMessageBuilder-0485b99a.js} +5 -1
  38. package/dist/esm/{dataunit-fetcher-264191b2.js → dataunit-fetcher-6463ac8d.js} +9 -2
  39. package/dist/esm/{field-search-efbe307f.js → field-search-f8b1d91e.js} +5 -1
  40. package/dist/esm/loader.js +1 -1
  41. package/dist/esm/sankhyablocks.js +1 -1
  42. package/dist/esm/snk-actions-button_4.entry.js +1 -1
  43. package/dist/esm/snk-application.entry.js +2 -2
  44. package/dist/esm/snk-attach.entry.js +1 -1
  45. package/dist/esm/snk-crud.entry.js +5 -2
  46. package/dist/esm/snk-data-exporter.entry.js +3 -3
  47. package/dist/esm/{snk-data-unit-2e5021e9.js → snk-data-unit-20860cfc.js} +6 -7
  48. package/dist/esm/snk-data-unit.entry.js +3 -3
  49. package/dist/esm/snk-detail-view.entry.js +4 -4
  50. package/dist/esm/snk-grid.entry.js +32 -7
  51. package/dist/esm/{snk-guides-viewer-dda0fede.js → snk-guides-viewer-b82ec79a.js} +8 -4
  52. package/dist/esm/snk-guides-viewer.entry.js +3 -3
  53. package/dist/esm/snk-simple-crud.entry.js +24 -6
  54. package/dist/sankhyablocks/{p-3a212712.js → p-0e85d9ba.js} +1 -1
  55. package/dist/sankhyablocks/p-14c2056a.js +1 -0
  56. package/dist/sankhyablocks/p-23736d75.js +1 -0
  57. package/dist/sankhyablocks/{p-7505da04.entry.js → p-249adf8b.entry.js} +1 -1
  58. package/dist/sankhyablocks/{p-8fb7d19d.entry.js → p-2f978e29.entry.js} +1 -1
  59. package/dist/sankhyablocks/{p-c1d57831.entry.js → p-4111c6ce.entry.js} +1 -1
  60. package/dist/sankhyablocks/p-4238fcd4.entry.js +1 -0
  61. package/dist/sankhyablocks/p-6614c578.js +1 -0
  62. package/dist/sankhyablocks/p-6fede3d4.entry.js +1 -0
  63. package/dist/sankhyablocks/p-701442ef.entry.js +1 -0
  64. package/dist/sankhyablocks/{p-045eae4d.entry.js → p-74fafa0d.entry.js} +2 -2
  65. package/dist/sankhyablocks/p-950037cb.js +1 -0
  66. package/dist/sankhyablocks/{p-70791b3c.entry.js → p-95e44a9c.entry.js} +1 -1
  67. package/dist/sankhyablocks/{p-fe79f83a.js → p-b4d016a3.js} +1 -1
  68. package/dist/sankhyablocks/{p-4e5e1313.entry.js → p-d0bec13f.entry.js} +1 -1
  69. package/dist/sankhyablocks/{p-75e674ed.entry.js → p-ebc4011a.entry.js} +1 -1
  70. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  71. package/dist/types/components/snk-crud/snk-crud.d.ts +4 -0
  72. package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +5 -0
  73. package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +1 -1
  74. package/dist/types/components/snk-grid/snk-grid.d.ts +9 -0
  75. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +7 -0
  76. package/dist/types/components/snk-taskbar/processor/taskbar-processor.d.ts +1 -0
  77. package/dist/types/components.d.ts +32 -0
  78. package/package.json +1 -1
  79. package/dist/sankhyablocks/p-4f3717df.entry.js +0 -1
  80. package/dist/sankhyablocks/p-61bf5b79.js +0 -1
  81. package/dist/sankhyablocks/p-75f83d1d.entry.js +0 -1
  82. package/dist/sankhyablocks/p-7a337364.js +0 -1
  83. package/dist/sankhyablocks/p-7a85fd49.entry.js +0 -1
  84. package/dist/sankhyablocks/p-c2495304.js +0 -1
  85. package/dist/sankhyablocks/p-fa4d8cb4.js +0 -1
@@ -1,5 +1,5 @@
1
1
  import { ApplicationContext, DataType, ElementIDUtils, FloatingManager, JSUtils, ObjectUtils, StringUtils, UserInterface, } from '@sankhyalabs/core';
2
- import { CSSVarsUtils } from "@sankhyalabs/ezui/dist/collection/utils";
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';
5
5
  import { TaskbarElement } from '../snk-taskbar/elements/taskbar-elements';
@@ -13,7 +13,7 @@ import { SnkFormConfigManager } from '../snk-form-config/SnkFormConfigManager';
13
13
  import { REGULAR_DEFAULT_BTNS, REGULAR_SELECTED_BTNS } from './regular-buttons';
14
14
  import RmPrecisionCustomValueFormatter from '../../lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter';
15
15
  import ClientSideExporterProvider from '../snk-data-exporter/providers/ClientSideExporterProvider';
16
- import store from "../../lib/store";
16
+ import store from '../../lib/store';
17
17
  export class SnkSimpleCrud {
18
18
  constructor() {
19
19
  this._multiSelectionListDataSource = new SnkMultiSelectionListDataSource();
@@ -26,7 +26,7 @@ export class SnkSimpleCrud {
26
26
  "snkSimpleCrudTaskbar.grid_regular": this.getButtons(false, [TaskbarElement.DATA_EXPORTER, TaskbarElement.FORM_MODE]),
27
27
  "snkSimpleCrudTaskbar.form_selected": this.getButtons(true, [TaskbarElement.GRID_MODE]),
28
28
  "snkSimpleCrudTaskbar.grid_selected": this.getButtons(true, [TaskbarElement.DATA_EXPORTER, TaskbarElement.FORM_MODE]),
29
- "snkSimpleCrudTaskbar.finish_edition": ["CANCEL", "SAVE"]
29
+ "snkSimpleCrudTaskbar.finish_edition": this.getFinishEditionButtonsCallback.bind(this)
30
30
  });
31
31
  this._showPopUpGridConfig = false;
32
32
  this._showFormConfig = false;
@@ -46,6 +46,7 @@ export class SnkSimpleCrud {
46
46
  this.useCancelConfirm = true;
47
47
  this.pageSize = 150;
48
48
  this.resourceID = undefined;
49
+ this.enableGridInsert = false;
49
50
  this.taskbarManager = undefined;
50
51
  this.messagesBuilder = undefined;
51
52
  this.useEnterLikeTab = false;
@@ -114,6 +115,13 @@ export class SnkSimpleCrud {
114
115
  newCustomFieldProps.set(fieldName, Object.assign(Object.assign({}, currentProps), { [propName]: value }));
115
116
  this._fieldsProps = newCustomFieldProps;
116
117
  }
118
+ getFinishEditionButtonsCallback() {
119
+ const btns = ["CANCEL", "SAVE"];
120
+ if (this.enableGridInsert && this._currentViewMode !== VIEW_MODE.ATTACHMENT) {
121
+ btns.push(this._currentViewMode === VIEW_MODE.GRID ? TaskbarElement.FORM_MODE : TaskbarElement.GRID_MODE);
122
+ }
123
+ return btns;
124
+ }
117
125
  getButtons(selected, extraButtons) {
118
126
  return this.addConfigButton(this.resolveInMemoryBtns(selected ? REGULAR_SELECTED_BTNS : REGULAR_DEFAULT_BTNS)
119
127
  .concat(extraButtons));
@@ -196,7 +204,6 @@ export class SnkSimpleCrud {
196
204
  await this.setFieldProp(field, 'precision', rmPrecision);
197
205
  await this.setFieldProp(field, 'prettyPrecision', rmPrecision);
198
206
  }
199
- ;
200
207
  this._rmPrecisionCustomValueFormatter.setDataState(this.dataState);
201
208
  }
202
209
  async handleUpdateGridLegacyConfig(newValue, oldValue) {
@@ -553,6 +560,9 @@ export class SnkSimpleCrud {
553
560
  const options = filteredFields.map(field => ({ value: field.name, label: field.label }));
554
561
  return Promise.resolve(options);
555
562
  }
563
+ isGridInsertActive() {
564
+ return this.enableGridInsert && this.dataUnit.hasNewRecord();
565
+ }
556
566
  getActionsList() {
557
567
  var _a, _b;
558
568
  const hardList = [{
@@ -564,6 +574,8 @@ export class SnkSimpleCrud {
564
574
  ? this.getColumnSearch(actionButton, item)
565
575
  : this.getFieldSearch(actionButton, item)
566
576
  }];
577
+ if (this.isGridInsertActive())
578
+ return hardList;
567
579
  if (this.taskbarManager != undefined && this.taskbarManager.getMoreOptions != undefined) {
568
580
  const taskbarID = this.getTopTaskBarId();
569
581
  return hardList.concat(this.taskbarManager.getMoreOptions(taskbarID, this.configName, this.dataState, this.actionsList));
@@ -687,15 +699,20 @@ export class SnkSimpleCrud {
687
699
  }
688
700
  this._formConfigManager.setConfig(this.formConfig);
689
701
  }
702
+ handleDataUnitOnInsertionMode() {
703
+ if (this.enableGridInsert)
704
+ return;
705
+ this.goToView(VIEW_MODE.FORM);
706
+ }
690
707
  /* istanbul ignore next */
691
708
  render() {
692
709
  var _a;
693
710
  if (this.dataUnit == undefined) {
694
711
  return;
695
712
  }
696
- 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.goToView(VIEW_MODE.FORM), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail), ignoreSaveMessage: this._currentViewMode === VIEW_MODE.GRID, onMessagesBuilderUpdated: evt => this.messagesBuilder = evt.detail, onDataUnitFieldsHidded: this.updateFormConfig.bind(this) }, h("header", null, h("slot", { name: "snkSimpleCrudHeader" })), h("section", { class: "ez-box ez-box--shadow simple-crud__container-section" }, h("snk-taskbar", { class: "ez-box ez-box--shadow ez-padding--medium", 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" })), 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)
713
+ 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) }, h("header", null, h("slot", { name: "snkSimpleCrudHeader" })), h("section", { class: "ez-box ez-box--shadow simple-crud__container-section" }, h("snk-taskbar", { class: "ez-box ez-box--shadow ez-padding--medium", 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" })), 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)
697
714
  ? undefined
698
- : this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab, autoFocus: this.autoFocus }, 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() }))));
715
+ : this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab, autoFocus: this.autoFocus, enableGridInsert: this.enableGridInsert }, 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() }))));
699
716
  }
700
717
  static get is() { return "snk-simple-crud"; }
701
718
  static get encapsulation() { return "scoped"; }
@@ -901,6 +918,24 @@ export class SnkSimpleCrud {
901
918
  "attribute": "resource-i-d",
902
919
  "reflect": false
903
920
  },
921
+ "enableGridInsert": {
922
+ "type": "boolean",
923
+ "mutable": false,
924
+ "complexType": {
925
+ "original": "boolean",
926
+ "resolved": "boolean",
927
+ "references": {}
928
+ },
929
+ "required": false,
930
+ "optional": true,
931
+ "docs": {
932
+ "tags": [],
933
+ "text": "Ativa inser\u00E7\u00E3o de registros no modo grade."
934
+ },
935
+ "attribute": "enable-grid-insert",
936
+ "reflect": false,
937
+ "defaultValue": "false"
938
+ },
904
939
  "taskbarManager": {
905
940
  "type": "unknown",
906
941
  "mutable": false,
@@ -29,12 +29,16 @@ export default class TaskbarProcessor {
29
29
  });
30
30
  }
31
31
  getButtonsArray(taskbarId, taskbarManager, dataState) {
32
- const defaults = this._defaultButtons[taskbarId];
32
+ const defaults = this.getButtonsFromKey(taskbarId);
33
33
  if (taskbarManager) {
34
34
  return taskbarManager.getButtons(taskbarId, dataState, [...defaults]);
35
35
  }
36
36
  return defaults;
37
37
  }
38
+ getButtonsFromKey(taskbarId) {
39
+ const btnsValue = this._defaultButtons[taskbarId];
40
+ return typeof btnsValue === 'function' ? btnsValue() : btnsValue;
41
+ }
38
42
  isEnabled(taskbarId, taskbarManager, buttonName, dataState, disabled) {
39
43
  const originalValue = disabled.includes(buttonName) ? false : true;
40
44
  if (taskbarManager && taskbarManager.isEnabled) {
@@ -8,7 +8,7 @@ export default class RmPrecisionCustomValueFormatter {
8
8
  this.refreshSelectedRows();
9
9
  }
10
10
  setDataState(dataState) {
11
- if (ObjectUtils.objectToString(dataState) === ObjectUtils.objectToString(this._dataState)) {
11
+ if (this._dataState && ObjectUtils.equals(dataState === null || dataState === void 0 ? void 0 : dataState.metadataByRow, this._dataState.metadataByRow)) {
12
12
  return;
13
13
  }
14
14
  this._dataState = dataState;
@@ -44,12 +44,19 @@ export class DatasetStrategy {
44
44
  const records = this.processRecords(dataUnit, fields, responseRecords);
45
45
  const loadingInProgress = pagerId != undefined;
46
46
  const count = loadingInfo.count + records.length;
47
+ const isInsertingNewRecord = dataUnit.hasNewRecord();
47
48
  const needReload = !loadingInProgress && localSorting.length > 0;
49
+ /**
50
+ * Caso precise recarregar dados, porém está no meio de uma inserção, os dados não devem recarregados instantaneamente,
51
+ * Mas sim, sinalizar que o dataUnit está aguardando para der recarregado.
52
+ */
53
+ if (needReload && isInsertingNewRecord) {
54
+ dataUnit.setWaitingToReload(true);
55
+ }
48
56
  return Promise.resolve({
49
57
  records,
50
58
  loadingInfo: Object.assign(Object.assign({}, loadingInfo), { pagerId,
51
- loadingInProgress, total: loadingInProgress ? undefined : count, count,
52
- needReload })
59
+ loadingInProgress, total: loadingInProgress ? undefined : count, count, needReload: needReload && !isInsertingNewRecord })
53
60
  });
54
61
  }
55
62
  catch (error) {
@@ -1,5 +1,9 @@
1
1
  export const snkGridMessages = {
2
- findColumn: "Busca de colunas"
2
+ findColumn: "Busca de colunas",
3
+ cancelConfirmation: {
4
+ title: "Aviso",
5
+ message: "As alterações realizadas serão descartadas<br/><br/><b>Você realmente gostaria de cancelar?</b>",
6
+ }
3
7
  };
4
8
  export const snkGridConfigMessages = {
5
9
  gridConfiguration: "Configuração da Grade",
@@ -124,12 +124,16 @@ class TaskbarProcessor {
124
124
  });
125
125
  }
126
126
  getButtonsArray(taskbarId, taskbarManager, dataState) {
127
- const defaults = this._defaultButtons[taskbarId];
127
+ const defaults = this.getButtonsFromKey(taskbarId);
128
128
  if (taskbarManager) {
129
129
  return taskbarManager.getButtons(taskbarId, dataState, [...defaults]);
130
130
  }
131
131
  return defaults;
132
132
  }
133
+ getButtonsFromKey(taskbarId) {
134
+ const btnsValue = this._defaultButtons[taskbarId];
135
+ return typeof btnsValue === 'function' ? btnsValue() : btnsValue;
136
+ }
133
137
  isEnabled(taskbarId, taskbarManager, buttonName, dataState, disabled) {
134
138
  const originalValue = disabled.includes(buttonName) ? false : true;
135
139
  if (taskbarManager && taskbarManager.isEnabled) {
@@ -217,7 +221,7 @@ class RmPrecisionCustomValueFormatter {
217
221
  this.refreshSelectedRows();
218
222
  }
219
223
  setDataState(dataState) {
220
- if (ObjectUtils.objectToString(dataState) === ObjectUtils.objectToString(this._dataState)) {
224
+ if (this._dataState && ObjectUtils.equals(dataState === null || dataState === void 0 ? void 0 : dataState.metadataByRow, this._dataState.metadataByRow)) {
221
225
  return;
222
226
  }
223
227
  this._dataState = dataState;
@@ -245,7 +245,11 @@ const snkConfiguratorMessages = {
245
245
  };
246
246
 
247
247
  const snkGridMessages = {
248
- findColumn: "Busca de colunas"
248
+ findColumn: "Busca de colunas",
249
+ cancelConfirmation: {
250
+ title: "Aviso",
251
+ message: "As alterações realizadas serão descartadas<br/><br/><b>Você realmente gostaria de cancelar?</b>",
252
+ }
249
253
  };
250
254
  const snkGridConfigMessages = {
251
255
  gridConfiguration: "Configuração da Grade",
@@ -424,12 +424,19 @@ class DatasetStrategy {
424
424
  const records = this.processRecords(dataUnit, fields, responseRecords);
425
425
  const loadingInProgress = pagerId != undefined;
426
426
  const count = loadingInfo.count + records.length;
427
+ const isInsertingNewRecord = dataUnit.hasNewRecord();
427
428
  const needReload = !loadingInProgress && localSorting.length > 0;
429
+ /**
430
+ * Caso precise recarregar dados, porém está no meio de uma inserção, os dados não devem recarregados instantaneamente,
431
+ * Mas sim, sinalizar que o dataUnit está aguardando para der recarregado.
432
+ */
433
+ if (needReload && isInsertingNewRecord) {
434
+ dataUnit.setWaitingToReload(true);
435
+ }
428
436
  return Promise.resolve({
429
437
  records,
430
438
  loadingInfo: Object.assign(Object.assign({}, loadingInfo), { pagerId,
431
- loadingInProgress, total: loadingInProgress ? undefined : count, count,
432
- needReload })
439
+ loadingInProgress, total: loadingInProgress ? undefined : count, count, needReload: needReload && !isInsertingNewRecord })
433
440
  });
434
441
  }
435
442
  catch (error) {
@@ -79,6 +79,7 @@ const SnkCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
79
79
  this.disablePersonalizedFilter = undefined;
80
80
  this.autoLoad = undefined;
81
81
  this.autoFocus = true;
82
+ this.enableGridInsert = false;
82
83
  this.customContainerId = `SNK-CRUD-CUSTOM-CONTAINER-${StringUtils.generateUUID()}`;
83
84
  }
84
85
  /**
@@ -202,6 +203,8 @@ const SnkCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
202
203
  ElementIDUtils.addIDInfo(this._element, null, dataInfo);
203
204
  }
204
205
  insertionModeHandler() {
206
+ if (this.enableGridInsert)
207
+ return;
205
208
  this.gridToForm();
206
209
  }
207
210
  cancelHandler() {
@@ -415,7 +418,7 @@ const SnkCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
415
418
  return;
416
419
  }
417
420
  this._snkDataUnit.ignoreSaveMessage = this._currentViewMode === VIEW_MODE.GRID;
418
- 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 }, 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 }, 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" }))));
421
+ 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 }, 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" }))));
419
422
  }
420
423
  get _element() { return this; }
421
424
  static get watchers() { return {
@@ -441,6 +444,7 @@ const SnkCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
441
444
  "disablePersonalizedFilter": [4, "disable-personalized-filter"],
442
445
  "autoLoad": [4, "auto-load"],
443
446
  "autoFocus": [4, "auto-focus"],
447
+ "enableGridInsert": [4, "enable-grid-insert"],
444
448
  "_dataUnit": [32],
445
449
  "_dataState": [32],
446
450
  "attachmentRegisterKey": [32],
@@ -109,7 +109,7 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
109
109
  this._application.updateDataunitCache(oldValue, this.dataUnitName, this.dataUnit);
110
110
  }
111
111
  else {
112
- this.loadDataUnit(true);
112
+ this.loadDataUnit();
113
113
  }
114
114
  }
115
115
  }
@@ -117,7 +117,7 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
117
117
  if (oldValue != newValue) {
118
118
  this.dataUnit = undefined;
119
119
  this.entityName = newValue;
120
- this.loadDataUnit(true);
120
+ this.loadDataUnit();
121
121
  }
122
122
  }
123
123
  observeDataState(newValue, oldValue) {
@@ -578,7 +578,7 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
578
578
  return await this._application.getDataUnit(this.entityName, cacheName, null, this.configName, this.resourceID);
579
579
  }
580
580
  }
581
- async loadDataUnit(forceMetadataLoad = false) {
581
+ async loadDataUnit() {
582
582
  var _a;
583
583
  if (this.dataUnit == null && this._application && this.entityName) {
584
584
  this.dataUnit = await this.getDataUnitParentOrChild();
@@ -588,8 +588,7 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
588
588
  this.dataUnit.unsubscribe(this._dataUnitObserver);
589
589
  this.dataUnit.addInterceptor(this);
590
590
  this.dataUnit.subscribe(this._dataUnitObserver);
591
- if (forceMetadataLoad || !this.dataUnit.metadata)
592
- await this.dataUnit.loadMetadata();
591
+ await this.dataUnit.loadMetadata();
593
592
  if ((_a = this.dataUnit.records) === null || _a === void 0 ? void 0 : _a.length) {
594
593
  this.getMetadataByRow(this.dataUnit);
595
594
  }
@@ -70,6 +70,7 @@ const SnkGuidesViewer = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
70
70
  this.resourceID = undefined;
71
71
  this.detailTaskbarCustomContainerId = undefined;
72
72
  this.formLegacyConfigName = undefined;
73
+ this.enableGridInsert = false;
73
74
  this._hasToCreateFieldSearch = true;
74
75
  this._breadcrumbItems = [];
75
76
  this._guides = undefined;
@@ -138,7 +139,7 @@ const SnkGuidesViewer = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
138
139
  this._container.focus();
139
140
  }
140
141
  exitViewer() {
141
- if (this.dataUnit.isDirty()) {
142
+ if (!this.enableGridInsert && this.dataUnit.isDirty()) {
142
143
  this.dataUnit.cancelEdition({ after: () => this.exit.emit() });
143
144
  }
144
145
  else {
@@ -247,10 +248,13 @@ const SnkGuidesViewer = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
247
248
  const invisibleButtons = this.getInvisibleButtons();
248
249
  this._taskbarProcessor = new TaskbarProcessor({
249
250
  "snkGuideViewer.regular": btnsRegularMode,
250
- "snkGuideViewer.finish_edition": ["CANCEL", "SAVE"],
251
+ "snkGuideViewer.finish_edition": ["CANCEL", "SAVE", this.handleAddGridMode()],
251
252
  });
252
253
  this._taskbarProcessor.process(taskbarId, this.taskbarManager, this.dataState, disabledButtons, invisibleButtons);
253
254
  }
255
+ handleAddGridMode() {
256
+ return this.enableGridInsert ? TaskbarElement.GRID_MODE : "";
257
+ }
254
258
  getInvisibleButtons() {
255
259
  const invisibleButtons = [];
256
260
  if (this.dataState && this.dataState.selectionInfo.mode === SelectionMode.ALL_RECORDS)
@@ -558,6 +562,7 @@ const SnkGuidesViewer = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
558
562
  "resourceID": [1, "resource-i-d"],
559
563
  "detailTaskbarCustomContainerId": [1, "detail-taskbar-custom-container-id"],
560
564
  "formLegacyConfigName": [1, "form-legacy-config-name"],
565
+ "enableGridInsert": [4, "enable-grid-insert"],
561
566
  "_hasToCreateFieldSearch": [32],
562
567
  "_breadcrumbItems": [32],
563
568
  "_guides": [32],
@@ -1,6 +1,6 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h, Fragment } from '@stencil/core/internal/client';
2
2
  import { Action, ElementIDUtils, ApplicationContext, StringUtils } from '@sankhyalabs/core';
3
- import { d as defineCustomElement$2, T as TaskbarElement } from './snk-taskbar2.js';
3
+ import { T as TaskbarElement, d as defineCustomElement$2 } from './snk-taskbar2.js';
4
4
  import { C as ConfigStorage } from './ConfigStorage.js';
5
5
  import { P as PresentationMode } from './ISave.js';
6
6
  import { C as CommonsExporter, T as TaskbarProcessor, S as SnkMultiSelectionListDataSource, o as openFieldSearch, a as CrudUtils, R as RmPrecisionCustomValueFormatter, b as buildFieldSearch } from './IExporterProvider.js';
@@ -100,7 +100,7 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
100
100
  "snkGridTopTaskbar.regular": ["FORM_MODE", "CONFIGURATOR", "INSERT"],
101
101
  "snkGridTopTaskbar.regular.secondary": ["FORM_MODE", "CONFIGURATOR", "INSERT"],
102
102
  "snkGridTopTaskbar.regular.singleTaskbar": [],
103
- "snkGridTopTaskbar.finish_edition": ["CANCEL", "SAVE"],
103
+ "snkGridTopTaskbar.finish_edition": ["CANCEL", "SAVE", this.handleAddFormMode()],
104
104
  "snkGridTopTaskbar.finish_edition.secondary": [],
105
105
  "snkGridTopTaskbar.finish_edition.singleTaskbar": [],
106
106
  });
@@ -113,7 +113,7 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
113
113
  "snkGridHeaderTaskbar.singleTaskbar.selected": ["UPDATE", "CLONE", "REMOVE", "MORE_OPTIONS", "DIVIDER", "ATTACH", "FORM_MODE", "CONFIGURATOR", "REFRESH", "DATA_EXPORTER", "ACTIONS_BUTTON"],
114
114
  "snkGridHeaderTaskbar.singleTaskbar.detail.unselected": ["INSERT", "FORM_MODE", "CONFIGURATOR", "REFRESH", "MORE_OPTIONS"],
115
115
  "snkGridHeaderTaskbar.singleTaskbar.detail.selected": ["UPDATE", "ATTACH", "CLONE", "REMOVE", "MORE_OPTIONS", "DIVIDER", "FORM_MODE", "CONFIGURATOR", "REFRESH"],
116
- "snkGridHeaderTaskbar.singleTaskbar.finish_edition": ["CANCEL", "SAVE"]
116
+ "snkGridHeaderTaskbar.singleTaskbar.finish_edition": ["CANCEL", "SAVE", this.handleAddFormMode()]
117
117
  });
118
118
  this.dataUnitInterceptor = {
119
119
  interceptAction: async (action) => {
@@ -151,6 +151,7 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
151
151
  this.filterBarLegacyConfigName = undefined;
152
152
  this.autoLoad = undefined;
153
153
  this.autoFocus = true;
154
+ this.enableGridInsert = false;
154
155
  }
155
156
  /**
156
157
  * Exibe a janela de configurações da grade.
@@ -237,6 +238,16 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
237
238
  async setFocus() {
238
239
  this._grid.setFocus();
239
240
  }
241
+ async handleClick(event) {
242
+ if (this.hasToBlockEvent(event)) {
243
+ event.preventDefault();
244
+ event.stopPropagation();
245
+ await this._dataUnit.cancelEdition();
246
+ }
247
+ }
248
+ hasToBlockEvent(event) {
249
+ return this._snkFilterBar.contains(event.target) && this.enableGridInsert && this._dataUnit.hasNewRecord();
250
+ }
240
251
  async handleGridLegacyConfigName(newLegacyConfig, oldLegacyConfig) {
241
252
  if (!newLegacyConfig) {
242
253
  return;
@@ -247,6 +258,9 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
247
258
  this.addGridLegacyConfigName();
248
259
  this.loadConfig();
249
260
  }
261
+ handleAddFormMode() {
262
+ return this.enableGridInsert ? TaskbarElement.FORM_MODE : "";
263
+ }
250
264
  openGridConfig() {
251
265
  this._grid.getColumnsState()
252
266
  .then((gridColumns) => {
@@ -376,8 +390,9 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
376
390
  this.loadConfig();
377
391
  }
378
392
  componentDidRender() {
393
+ var _a, _b;
379
394
  this._rmPrecisionCustomValueFormatter.setGrid(this._grid);
380
- this.loadGridCustomFormatters(this._dataUnit.metadata.fields);
395
+ this.loadGridCustomFormatters((_b = (_a = this._dataUnit) === null || _a === void 0 ? void 0 : _a.metadata) === null || _b === void 0 ? void 0 : _b.fields);
381
396
  this.setCustomRenders();
382
397
  this.setCustomEditors();
383
398
  }
@@ -475,6 +490,8 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
475
490
  eagerInitialize: true,
476
491
  itemBuilder: (actionButton, item) => this.getColumnSearch(actionButton, item)
477
492
  }];
493
+ if (this.isGridInsertActive())
494
+ return hardList;
478
495
  if (this.taskbarManager != undefined && this.taskbarManager.getMoreOptions != undefined) {
479
496
  const taskbarID = this.getTopTaskBarId();
480
497
  return hardList.concat(this.taskbarManager.getMoreOptions(taskbarID, this.configName, this._dataState, this.actionsList));
@@ -492,12 +509,20 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
492
509
  }
493
510
  this._showSnkFilterBar = true;
494
511
  }
512
+ getGridHeaderButtons() {
513
+ if (this.isGridInsertActive())
514
+ return TaskbarElement.MORE_OPTIONS;
515
+ return this._headerTaskbarProcessor.buttons;
516
+ }
517
+ isGridInsertActive() {
518
+ return this.enableGridInsert && this._dataUnit.hasNewRecord();
519
+ }
495
520
  render() {
496
521
  if (!this._dataUnit) {
497
522
  return undefined;
498
523
  }
499
524
  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--medium" }, this._showSnkFilterBar &&
500
- 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 }, h("snk-taskbar", { id: 'teste', dataUnit: this._dataUnit, configName: this.configName, messagesBuilder: this.messagesBuilder, "data-element-id": "grid_left", buttons: this._headerTaskbarProcessor.buttons, 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 }))));
525
+ 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 }, 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 }))));
501
526
  }
502
527
  get _element() { return this; }
503
528
  static get watchers() { return {
@@ -528,6 +553,7 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
528
553
  "filterBarLegacyConfigName": [1, "filter-bar-legacy-config-name"],
529
554
  "autoLoad": [4, "auto-load"],
530
555
  "autoFocus": [4, "auto-focus"],
556
+ "enableGridInsert": [4, "enable-grid-insert"],
531
557
  "_dataUnit": [32],
532
558
  "_dataState": [32],
533
559
  "_gridConfig": [32],
@@ -544,7 +570,7 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
544
570
  "addCustomValueFormatter": [64],
545
571
  "removeCustomValueFormatter": [64],
546
572
  "setFocus": [64]
547
- }]);
573
+ }, [[2, "click", "handleClick"]]]);
548
574
  function defineCustomElement() {
549
575
  if (typeof customElements === "undefined") {
550
576
  return;
@@ -108,7 +108,7 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
108
108
  "snkSimpleCrudTaskbar.grid_regular": this.getButtons(false, [TaskbarElement.DATA_EXPORTER, TaskbarElement.FORM_MODE]),
109
109
  "snkSimpleCrudTaskbar.form_selected": this.getButtons(true, [TaskbarElement.GRID_MODE]),
110
110
  "snkSimpleCrudTaskbar.grid_selected": this.getButtons(true, [TaskbarElement.DATA_EXPORTER, TaskbarElement.FORM_MODE]),
111
- "snkSimpleCrudTaskbar.finish_edition": ["CANCEL", "SAVE"]
111
+ "snkSimpleCrudTaskbar.finish_edition": this.getFinishEditionButtonsCallback.bind(this)
112
112
  });
113
113
  this._showPopUpGridConfig = false;
114
114
  this._showFormConfig = false;
@@ -128,6 +128,7 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
128
128
  this.useCancelConfirm = true;
129
129
  this.pageSize = 150;
130
130
  this.resourceID = undefined;
131
+ this.enableGridInsert = false;
131
132
  this.taskbarManager = undefined;
132
133
  this.messagesBuilder = undefined;
133
134
  this.useEnterLikeTab = false;
@@ -196,6 +197,13 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
196
197
  newCustomFieldProps.set(fieldName, Object.assign(Object.assign({}, currentProps), { [propName]: value }));
197
198
  this._fieldsProps = newCustomFieldProps;
198
199
  }
200
+ getFinishEditionButtonsCallback() {
201
+ const btns = ["CANCEL", "SAVE"];
202
+ if (this.enableGridInsert && this._currentViewMode !== VIEW_MODE.ATTACHMENT) {
203
+ btns.push(this._currentViewMode === VIEW_MODE.GRID ? TaskbarElement.FORM_MODE : TaskbarElement.GRID_MODE);
204
+ }
205
+ return btns;
206
+ }
199
207
  getButtons(selected, extraButtons) {
200
208
  return this.addConfigButton(this.resolveInMemoryBtns(selected ? REGULAR_SELECTED_BTNS : REGULAR_DEFAULT_BTNS)
201
209
  .concat(extraButtons));
@@ -634,6 +642,9 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
634
642
  const options = filteredFields.map(field => ({ value: field.name, label: field.label }));
635
643
  return Promise.resolve(options);
636
644
  }
645
+ isGridInsertActive() {
646
+ return this.enableGridInsert && this.dataUnit.hasNewRecord();
647
+ }
637
648
  getActionsList() {
638
649
  var _a, _b;
639
650
  const hardList = [{
@@ -645,6 +656,8 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
645
656
  ? this.getColumnSearch(actionButton, item)
646
657
  : this.getFieldSearch(actionButton, item)
647
658
  }];
659
+ if (this.isGridInsertActive())
660
+ return hardList;
648
661
  if (this.taskbarManager != undefined && this.taskbarManager.getMoreOptions != undefined) {
649
662
  const taskbarID = this.getTopTaskBarId();
650
663
  return hardList.concat(this.taskbarManager.getMoreOptions(taskbarID, this.configName, this.dataState, this.actionsList));
@@ -768,15 +781,20 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
768
781
  }
769
782
  this._formConfigManager.setConfig(this.formConfig);
770
783
  }
784
+ handleDataUnitOnInsertionMode() {
785
+ if (this.enableGridInsert)
786
+ return;
787
+ this.goToView(VIEW_MODE.FORM);
788
+ }
771
789
  /* istanbul ignore next */
772
790
  render() {
773
791
  var _a;
774
792
  if (this.dataUnit == undefined) {
775
793
  return;
776
794
  }
777
- 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.goToView(VIEW_MODE.FORM), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail), ignoreSaveMessage: this._currentViewMode === VIEW_MODE.GRID, onMessagesBuilderUpdated: evt => this.messagesBuilder = evt.detail, onDataUnitFieldsHidded: this.updateFormConfig.bind(this) }, h("header", null, h("slot", { name: "snkSimpleCrudHeader" })), h("section", { class: "ez-box ez-box--shadow simple-crud__container-section" }, h("snk-taskbar", { class: "ez-box ez-box--shadow ez-padding--medium", 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" })), 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)
795
+ 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) }, h("header", null, h("slot", { name: "snkSimpleCrudHeader" })), h("section", { class: "ez-box ez-box--shadow simple-crud__container-section" }, h("snk-taskbar", { class: "ez-box ez-box--shadow ez-padding--medium", 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" })), 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)
778
796
  ? undefined
779
- : this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab, autoFocus: this.autoFocus }, 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() }))));
797
+ : this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab, autoFocus: this.autoFocus, enableGridInsert: this.enableGridInsert }, 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() }))));
780
798
  }
781
799
  get _element() { return this; }
782
800
  static get watchers() { return {
@@ -799,6 +817,7 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
799
817
  "useCancelConfirm": [4, "use-cancel-confirm"],
800
818
  "pageSize": [2, "page-size"],
801
819
  "resourceID": [1, "resource-i-d"],
820
+ "enableGridInsert": [4, "enable-grid-insert"],
802
821
  "taskbarManager": [16],
803
822
  "messagesBuilder": [1040],
804
823
  "useEnterLikeTab": [4, "use-enter-like-tab"],
@@ -5,7 +5,7 @@ import './index-3aa4977a.js';
5
5
  import './ISave-d8c8bc59.js';
6
6
  import '@sankhyalabs/ezui/dist/collection/utils/constants';
7
7
  import { UserInterface as UserInterface$1 } from '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
8
- import { P as PreloadManager } from './dataunit-fetcher-264191b2.js';
8
+ import { P as PreloadManager } from './dataunit-fetcher-6463ac8d.js';
9
9
  import './filter-item-type.enum-d45e026f.js';
10
10
  import './form-config-fetcher-30fb808f.js';
11
11
  import InMemoryFilterColumnDataSource from '@sankhyalabs/ezui/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource';
@@ -140,7 +140,7 @@ class RmPrecisionCustomValueFormatter {
140
140
  this.refreshSelectedRows();
141
141
  }
142
142
  setDataState(dataState) {
143
- if (ObjectUtils.objectToString(dataState) === ObjectUtils.objectToString(this._dataState)) {
143
+ if (this._dataState && ObjectUtils.equals(dataState === null || dataState === void 0 ? void 0 : dataState.metadataByRow, this._dataState.metadataByRow)) {
144
144
  return;
145
145
  }
146
146
  this._dataState = dataState;