@sankhyalabs/sankhyablocks 8.16.0-dev.21 → 8.16.0-dev.23

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 (101) hide show
  1. package/dist/cjs/{IExporterProvider-9ac15aaf.js → ContinuousInsertUtils-e8d801ee.js} +35 -2
  2. package/dist/cjs/{RecordIDUtils-3735135c.js → GetSelectedRecordsIDsInfo-bd50caf1.js} +10 -10
  3. package/dist/cjs/{SnkMessageBuilder-cceebbae.js → SnkMessageBuilder-bae64d0d.js} +5 -1
  4. package/dist/cjs/{dataunit-fetcher-4b12f70c.js → dataunit-fetcher-c1119754.js} +9 -2
  5. package/dist/cjs/{field-search-f56aa7d6.js → field-search-68e34bf4.js} +5 -1
  6. package/dist/cjs/loader.cjs.js +1 -1
  7. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  8. package/dist/cjs/snk-actions-button_4.cjs.entry.js +13 -10
  9. package/dist/cjs/snk-application.cjs.entry.js +2 -2
  10. package/dist/cjs/snk-attach.cjs.entry.js +1 -1
  11. package/dist/cjs/snk-crud.cjs.entry.js +5 -2
  12. package/dist/cjs/snk-data-exporter.cjs.entry.js +4 -4
  13. package/dist/cjs/{snk-data-unit-c095fb1a.js → snk-data-unit-3f5acfd1.js} +4 -4
  14. package/dist/cjs/snk-data-unit.cjs.entry.js +4 -4
  15. package/dist/cjs/snk-detail-view.cjs.entry.js +4 -4
  16. package/dist/cjs/snk-grid.cjs.entry.js +54 -14
  17. package/dist/cjs/{snk-guides-viewer-866447ab.js → snk-guides-viewer-c29b6316.js} +8 -4
  18. package/dist/cjs/snk-guides-viewer.cjs.entry.js +3 -3
  19. package/dist/cjs/snk-simple-crud.cjs.entry.js +45 -13
  20. package/dist/collection/components/snk-actions-button/actions/index.js +12 -9
  21. package/dist/collection/components/snk-crud/snk-crud.js +22 -1
  22. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +24 -2
  23. package/dist/collection/components/snk-data-exporter/providers/ClientSideExporterProvider.js +1 -1
  24. package/dist/collection/components/snk-data-exporter/providers/ServerSideExporterProvider.js +1 -1
  25. package/dist/collection/components/snk-data-unit/snk-data-unit.js +2 -2
  26. package/dist/collection/components/snk-grid/snk-grid.js +66 -6
  27. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +59 -8
  28. package/dist/collection/components/snk-taskbar/processor/taskbar-processor.js +5 -1
  29. package/dist/collection/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.js +1 -1
  30. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js +9 -2
  31. package/dist/collection/lib/message/resources/snk-grid.msg.js +5 -1
  32. package/dist/collection/lib/utils/ContinuousInsertUtils.js +31 -0
  33. package/dist/collection/{components/snk-data-exporter/utils/RecordIDUtils.js → lib/utils/GetSelectedRecordsIDsInfo.js} +9 -9
  34. package/dist/components/{IExporterProvider.js → ContinuousInsertUtils.js} +39 -4
  35. package/dist/{esm/RecordIDUtils-87d02110.js → components/GetSelectedRecordsIDsInfo.js} +10 -10
  36. package/dist/components/SnkMessageBuilder.js +5 -1
  37. package/dist/components/dataunit-fetcher.js +9 -2
  38. package/dist/components/snk-actions-button2.js +12 -9
  39. package/dist/components/snk-crud.js +5 -1
  40. package/dist/components/snk-data-unit2.js +4 -41
  41. package/dist/components/snk-detail-view2.js +8 -3
  42. package/dist/components/snk-grid2.js +50 -8
  43. package/dist/components/snk-simple-crud2.js +42 -7
  44. package/dist/esm/{IExporterProvider-09df2e3e.js → ContinuousInsertUtils-042cdd90.js} +36 -4
  45. package/dist/esm/GetSelectedRecordsIDsInfo-9fa41508.js +41 -0
  46. package/dist/esm/{SnkMessageBuilder-ae87b754.js → SnkMessageBuilder-6fff4a4c.js} +5 -1
  47. package/dist/esm/{dataunit-fetcher-3aac1a53.js → dataunit-fetcher-f80e80a6.js} +9 -2
  48. package/dist/esm/{field-search-efbe307f.js → field-search-f8b1d91e.js} +5 -1
  49. package/dist/esm/loader.js +1 -1
  50. package/dist/esm/sankhyablocks.js +1 -1
  51. package/dist/esm/snk-actions-button_4.entry.js +13 -10
  52. package/dist/esm/snk-application.entry.js +2 -2
  53. package/dist/esm/snk-attach.entry.js +1 -1
  54. package/dist/esm/snk-crud.entry.js +5 -2
  55. package/dist/esm/snk-data-exporter.entry.js +4 -4
  56. package/dist/esm/{snk-data-unit-75fc8910.js → snk-data-unit-cc1d8b4e.js} +4 -4
  57. package/dist/esm/snk-data-unit.entry.js +4 -4
  58. package/dist/esm/snk-detail-view.entry.js +4 -4
  59. package/dist/esm/snk-grid.entry.js +49 -9
  60. package/dist/esm/{snk-guides-viewer-cb8a0b48.js → snk-guides-viewer-292473eb.js} +8 -4
  61. package/dist/esm/snk-guides-viewer.entry.js +3 -3
  62. package/dist/esm/snk-simple-crud.entry.js +41 -9
  63. package/dist/sankhyablocks/p-031721d6.js +1 -0
  64. package/dist/sankhyablocks/{p-640140b3.entry.js → p-05af89d0.entry.js} +1 -1
  65. package/dist/sankhyablocks/p-12e2c750.js +1 -0
  66. package/dist/sankhyablocks/p-17425c72.js +1 -0
  67. package/dist/sankhyablocks/{p-f8698ad3.js → p-219452ed.js} +1 -1
  68. package/dist/sankhyablocks/p-23736d75.js +1 -0
  69. package/dist/sankhyablocks/p-39edee2a.js +1 -0
  70. package/dist/sankhyablocks/{p-16969508.entry.js → p-4fbd8c74.entry.js} +1 -1
  71. package/dist/sankhyablocks/p-656fbc8b.entry.js +1 -0
  72. package/dist/sankhyablocks/p-6bd7e6e4.entry.js +1 -0
  73. package/dist/sankhyablocks/{p-41556e8a.entry.js → p-6e89e14b.entry.js} +1 -1
  74. package/dist/sankhyablocks/{p-bc4b94d2.entry.js → p-7a9df88b.entry.js} +1 -1
  75. package/dist/sankhyablocks/p-7dd49d15.js +1 -0
  76. package/dist/sankhyablocks/{p-3757394b.entry.js → p-9fd54396.entry.js} +1 -1
  77. package/dist/sankhyablocks/p-b364a0b7.entry.js +1 -0
  78. package/dist/sankhyablocks/{p-e2a1273a.entry.js → p-d7837f33.entry.js} +1 -1
  79. package/dist/sankhyablocks/p-f5f5c94a.entry.js +1 -0
  80. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  81. package/dist/types/components/snk-actions-button/actions/index.d.ts +1 -0
  82. package/dist/types/components/snk-crud/snk-crud.d.ts +4 -0
  83. package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +5 -0
  84. package/dist/types/components/snk-grid/snk-grid.d.ts +12 -0
  85. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +10 -0
  86. package/dist/types/components/snk-taskbar/processor/taskbar-processor.d.ts +1 -0
  87. package/dist/types/components.d.ts +32 -0
  88. package/dist/types/lib/utils/ContinuousInsertUtils.d.ts +10 -0
  89. package/dist/types/lib/utils/GetSelectedRecordsIDsInfo.d.ts +3 -0
  90. package/package.json +1 -1
  91. package/dist/sankhyablocks/p-17aba142.entry.js +0 -1
  92. package/dist/sankhyablocks/p-1ab19772.js +0 -1
  93. package/dist/sankhyablocks/p-1f47a0b2.entry.js +0 -1
  94. package/dist/sankhyablocks/p-7c4aabe2.js +0 -1
  95. package/dist/sankhyablocks/p-9863d682.js +0 -1
  96. package/dist/sankhyablocks/p-a31e761f.js +0 -1
  97. package/dist/sankhyablocks/p-c2495304.js +0 -1
  98. package/dist/sankhyablocks/p-d137ae48.entry.js +0 -1
  99. package/dist/sankhyablocks/p-df8f4c4f.js +0 -1
  100. package/dist/sankhyablocks/p-fb0313db.entry.js +0 -1
  101. package/dist/types/components/snk-data-exporter/utils/RecordIDUtils.d.ts +0 -3
@@ -27,6 +27,7 @@ export class SnkGuidesViewer {
27
27
  this.resourceID = undefined;
28
28
  this.detailTaskbarCustomContainerId = undefined;
29
29
  this.formLegacyConfigName = undefined;
30
+ this.enableGridInsert = false;
30
31
  this.getCustomTitle = undefined;
31
32
  this._hasToCreateFieldSearch = true;
32
33
  this._breadcrumbItems = [];
@@ -96,7 +97,7 @@ export class SnkGuidesViewer {
96
97
  this._container.focus();
97
98
  }
98
99
  exitViewer() {
99
- if (this.dataUnit.isDirty()) {
100
+ if (!this.enableGridInsert && this.dataUnit.isDirty()) {
100
101
  this.dataUnit.cancelEdition({ after: () => this.exit.emit() });
101
102
  }
102
103
  else {
@@ -205,10 +206,13 @@ export class SnkGuidesViewer {
205
206
  const invisibleButtons = this.getInvisibleButtons();
206
207
  this._taskbarProcessor = new TaskbarProcessor({
207
208
  "snkGuideViewer.regular": btnsRegularMode,
208
- "snkGuideViewer.finish_edition": ["CANCEL", "SAVE"],
209
+ "snkGuideViewer.finish_edition": ["CANCEL", "SAVE", this.handleAddGridMode()],
209
210
  });
210
211
  this._taskbarProcessor.process(taskbarId, this.taskbarManager, this.dataState, disabledButtons, invisibleButtons);
211
212
  }
213
+ handleAddGridMode() {
214
+ return this.enableGridInsert ? TaskbarElement.GRID_MODE : "";
215
+ }
212
216
  getInvisibleButtons() {
213
217
  const invisibleButtons = [];
214
218
  if (this.dataState && this.dataState.selectionInfo.mode === SelectionMode.ALL_RECORDS)
@@ -803,6 +807,24 @@ export class SnkGuidesViewer {
803
807
  "attribute": "form-legacy-config-name",
804
808
  "reflect": false
805
809
  },
810
+ "enableGridInsert": {
811
+ "type": "boolean",
812
+ "mutable": false,
813
+ "complexType": {
814
+ "original": "boolean",
815
+ "resolved": "boolean",
816
+ "references": {}
817
+ },
818
+ "required": false,
819
+ "optional": true,
820
+ "docs": {
821
+ "tags": [],
822
+ "text": "Ativa inser\u00E7\u00E3o de registros no modo grade."
823
+ },
824
+ "attribute": "enable-grid-insert",
825
+ "reflect": false,
826
+ "defaultValue": "false"
827
+ },
806
828
  "getCustomTitle": {
807
829
  "type": "unknown",
808
830
  "mutable": false,
@@ -1,6 +1,6 @@
1
1
  import { CommonsExporter } from "../interfaces/IExporterProvider";
2
2
  import { UserInterface } from "@sankhyalabs/core";
3
- import { getSelectedIDs } from "../utils/RecordIDUtils";
3
+ import { getSelectedRecordsIDsInfo as getSelectedIDs } from '../../../lib/utils/GetSelectedRecordsIDsInfo';
4
4
  import { DataExporterOption } from "../../../lib/@types";
5
5
  export default class ClientSideExporterProvider extends CommonsExporter {
6
6
  getSelectedNumber() {
@@ -1,5 +1,5 @@
1
1
  import { CommonsExporter } from "../interfaces/IExporterProvider";
2
- import { getSelectedIDs } from "../utils/RecordIDUtils";
2
+ import { getSelectedRecordsIDsInfo as getSelectedIDs } from '../../../lib/utils/GetSelectedRecordsIDsInfo';
3
3
  export default class ServerSideExporterProvider extends CommonsExporter {
4
4
  getFilters() {
5
5
  var _a;
@@ -4,8 +4,8 @@ import { ApplicationUtils, DialogType } from '@sankhyalabs/ezui/dist/collection/
4
4
  import { OperationMap, SnkMessageBuilder } from '../../lib/message/SnkMessageBuilder';
5
5
  import { DatasetStrategy } from '../../lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy';
6
6
  import { getRecordValue } from '../../lib/dataUnit/ValueFormatter';
7
- import { getSelectedIDs } from '../snk-data-exporter/utils/RecordIDUtils';
8
7
  import { convertType } from '@sankhyalabs/core/dist/dataunit/metadata/DataType';
8
+ import { getSelectedRecordsIDsInfo } from '../../lib/utils/GetSelectedRecordsIDsInfo';
9
9
  export class SnkDataUnit {
10
10
  constructor() {
11
11
  this._onDataUnitResolve = [];
@@ -110,7 +110,7 @@ export class SnkDataUnit {
110
110
  * @returns Retorna a lista de IDs dos registros selecionados.
111
111
  */
112
112
  async getSelectedRecordsIDsInfo() {
113
- return Promise.resolve(getSelectedIDs(this.dataUnit));
113
+ return getSelectedRecordsIDsInfo(this.dataUnit);
114
114
  }
115
115
  /**
116
116
  * Retorna os campos que possuem a propriedade "rmp" (Row Metadata Provider).
@@ -1,4 +1,4 @@
1
- import { h, Fragment } from '@stencil/core';
1
+ import { h, Fragment, } from '@stencil/core';
2
2
  import { Action as DUAction, ApplicationContext, ElementIDUtils, StringUtils } from '@sankhyalabs/core';
3
3
  import { TaskbarElement } from '../snk-taskbar/elements/taskbar-elements';
4
4
  import { ConfigStorage } from '../../lib/configs/ConfigStorage';
@@ -11,6 +11,7 @@ import { buildFieldSearch, openFieldSearch } from '../snk-taskbar/subcomponents/
11
11
  import { CrudUtils } from '../../lib';
12
12
  import RmPrecisionCustomValueFormatter from '../../lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter';
13
13
  import ServerSideExporterProvider from '../snk-data-exporter/providers/ServerSideExporterProvider';
14
+ import { ContinuousInsertUtils } from '../../lib/utils/ContinuousInsertUtils';
14
15
  export class SnkGrid {
15
16
  constructor() {
16
17
  this._customEditors = new Map();
@@ -19,7 +20,7 @@ export class SnkGrid {
19
20
  "snkGridTopTaskbar.regular": ["FORM_MODE", "CONFIGURATOR", "INSERT"],
20
21
  "snkGridTopTaskbar.regular.secondary": ["FORM_MODE", "CONFIGURATOR", "INSERT"],
21
22
  "snkGridTopTaskbar.regular.singleTaskbar": [],
22
- "snkGridTopTaskbar.finish_edition": ["CANCEL", "SAVE"],
23
+ "snkGridTopTaskbar.finish_edition": ["CANCEL", "SAVE", this.handleAddFormMode()],
23
24
  "snkGridTopTaskbar.finish_edition.secondary": [],
24
25
  "snkGridTopTaskbar.finish_edition.singleTaskbar": [],
25
26
  });
@@ -32,7 +33,7 @@ export class SnkGrid {
32
33
  "snkGridHeaderTaskbar.singleTaskbar.selected": ["UPDATE", "CLONE", "REMOVE", "MORE_OPTIONS", "DIVIDER", "ATTACH", "FORM_MODE", "CONFIGURATOR", "REFRESH", "DATA_EXPORTER", "ACTIONS_BUTTON"],
33
34
  "snkGridHeaderTaskbar.singleTaskbar.detail.unselected": ["INSERT", "FORM_MODE", "CONFIGURATOR", "REFRESH", "MORE_OPTIONS"],
34
35
  "snkGridHeaderTaskbar.singleTaskbar.detail.selected": ["UPDATE", "ATTACH", "CLONE", "REMOVE", "MORE_OPTIONS", "DIVIDER", "FORM_MODE", "CONFIGURATOR", "REFRESH"],
35
- "snkGridHeaderTaskbar.singleTaskbar.finish_edition": ["CANCEL", "SAVE"]
36
+ "snkGridHeaderTaskbar.singleTaskbar.finish_edition": ["CANCEL", "SAVE", this.handleAddFormMode()]
36
37
  });
37
38
  this.dataUnitInterceptor = {
38
39
  interceptAction: async (action) => {
@@ -47,6 +48,7 @@ export class SnkGrid {
47
48
  this._gridConfig = undefined;
48
49
  this._popUpGridConfig = false;
49
50
  this._showSnkFilterBar = true;
51
+ this._enableContinuousInsert = false;
50
52
  this.columnFilterDataSource = new SnkMultiSelectionListDataSource();
51
53
  this.configName = undefined;
52
54
  this.filterBarTitle = undefined;
@@ -70,6 +72,7 @@ export class SnkGrid {
70
72
  this.filterBarLegacyConfigName = undefined;
71
73
  this.autoLoad = undefined;
72
74
  this.autoFocus = true;
75
+ this.enableGridInsert = false;
73
76
  }
74
77
  /**
75
78
  * Exibe a janela de configurações da grade.
@@ -156,6 +159,16 @@ export class SnkGrid {
156
159
  async setFocus() {
157
160
  this._grid.setFocus();
158
161
  }
162
+ async handleClick(event) {
163
+ if (this.hasToBlockEvent(event)) {
164
+ event.preventDefault();
165
+ event.stopPropagation();
166
+ await this._dataUnit.cancelEdition();
167
+ }
168
+ }
169
+ hasToBlockEvent(event) {
170
+ return this._snkFilterBar.contains(event.target) && this.enableGridInsert && this._dataUnit.hasNewRecord();
171
+ }
159
172
  async handleGridLegacyConfigName(newLegacyConfig, oldLegacyConfig) {
160
173
  if (!newLegacyConfig) {
161
174
  return;
@@ -166,6 +179,9 @@ export class SnkGrid {
166
179
  this.addGridLegacyConfigName();
167
180
  this.loadConfig();
168
181
  }
182
+ handleAddFormMode() {
183
+ return this.enableGridInsert ? TaskbarElement.FORM_MODE : "";
184
+ }
169
185
  openGridConfig() {
170
186
  this._grid.getColumnsState()
171
187
  .then((gridColumns) => {
@@ -290,13 +306,21 @@ export class SnkGrid {
290
306
  }
291
307
  parent = parent.parentElement;
292
308
  }
309
+ if (this._snkFilterBar) {
310
+ this._snkFilterBar.addEventListener('click', this.handleClick);
311
+ }
293
312
  this._rmPrecisionCustomValueFormatter = new RmPrecisionCustomValueFormatter();
294
313
  this.addGridLegacyConfigName();
295
314
  this.loadConfig();
315
+ this._continuousInsertUtils = new ContinuousInsertUtils(this._application, this.resourceID, this.configName);
316
+ if (this.enableGridInsert) {
317
+ this._continuousInsertUtils.getConfig().then(value => this._enableContinuousInsert = value);
318
+ }
296
319
  }
297
320
  componentDidRender() {
321
+ var _a, _b;
298
322
  this._rmPrecisionCustomValueFormatter.setGrid(this._grid);
299
- this.loadGridCustomFormatters(this._dataUnit.metadata.fields);
323
+ this.loadGridCustomFormatters((_b = (_a = this._dataUnit) === null || _a === void 0 ? void 0 : _a.metadata) === null || _b === void 0 ? void 0 : _b.fields);
300
324
  this.setCustomRenders();
301
325
  this.setCustomEditors();
302
326
  }
@@ -394,12 +418,21 @@ export class SnkGrid {
394
418
  eagerInitialize: true,
395
419
  itemBuilder: (actionButton, item) => this.getColumnSearch(actionButton, item)
396
420
  }];
421
+ if (this.enableGridInsert) {
422
+ hardList.push(this._continuousInsertUtils.actionContinuousInsert(this._enableContinuousInsert, this.handleEnableContinuousInsert));
423
+ }
424
+ if (this.isGridInsertActive())
425
+ return hardList;
397
426
  if (this.taskbarManager != undefined && this.taskbarManager.getMoreOptions != undefined) {
398
427
  const taskbarID = this.getTopTaskBarId();
399
428
  return hardList.concat(this.taskbarManager.getMoreOptions(taskbarID, this.configName, this._dataState, this.actionsList));
400
429
  }
401
430
  return hardList.concat(this.actionsList);
402
431
  }
432
+ handleEnableContinuousInsert() {
433
+ this._enableContinuousInsert = !this._enableContinuousInsert;
434
+ this._continuousInsertUtils.handleSaveConfig(this._enableContinuousInsert);
435
+ }
403
436
  handleFilterConfigUpdated(filterConfig) {
404
437
  if (!filterConfig.length) {
405
438
  this._showSnkFilterBar = false;
@@ -411,12 +444,20 @@ export class SnkGrid {
411
444
  }
412
445
  this._showSnkFilterBar = true;
413
446
  }
447
+ getGridHeaderButtons() {
448
+ if (this.isGridInsertActive())
449
+ return TaskbarElement.MORE_OPTIONS;
450
+ return this._headerTaskbarProcessor.buttons;
451
+ }
452
+ isGridInsertActive() {
453
+ return this.enableGridInsert && this._dataUnit.hasNewRecord();
454
+ }
414
455
  render() {
415
456
  if (!this._dataUnit) {
416
457
  return undefined;
417
458
  }
418
459
  return (h("div", { class: "snk-grid__container ez-flex ez-flex--column ez-flex-item--auto" }, h("div", { class: "snk-grid__header ez-margin-bottom--medium" }, this._showSnkFilterBar &&
419
- 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 }))));
460
+ 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 }))));
420
461
  }
421
462
  static get is() { return "snk-grid"; }
422
463
  static get encapsulation() { return "scoped"; }
@@ -862,6 +903,24 @@ export class SnkGrid {
862
903
  "attribute": "auto-focus",
863
904
  "reflect": false,
864
905
  "defaultValue": "true"
906
+ },
907
+ "enableGridInsert": {
908
+ "type": "boolean",
909
+ "mutable": false,
910
+ "complexType": {
911
+ "original": "boolean",
912
+ "resolved": "boolean",
913
+ "references": {}
914
+ },
915
+ "required": false,
916
+ "optional": true,
917
+ "docs": {
918
+ "tags": [],
919
+ "text": "Ativa inser\u00E7\u00E3o de registros no modo grade."
920
+ },
921
+ "attribute": "enable-grid-insert",
922
+ "reflect": false,
923
+ "defaultValue": "false"
865
924
  }
866
925
  };
867
926
  }
@@ -871,7 +930,8 @@ export class SnkGrid {
871
930
  "_dataState": {},
872
931
  "_gridConfig": {},
873
932
  "_popUpGridConfig": {},
874
- "_showSnkFilterBar": {}
933
+ "_showSnkFilterBar": {},
934
+ "_enableContinuousInsert": {}
875
935
  };
876
936
  }
877
937
  static get events() {
@@ -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,8 @@ 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
+ import { ContinuousInsertUtils } from '../../lib/utils/ContinuousInsertUtils';
17
18
  export class SnkSimpleCrud {
18
19
  constructor() {
19
20
  this._multiSelectionListDataSource = new SnkMultiSelectionListDataSource();
@@ -26,7 +27,7 @@ export class SnkSimpleCrud {
26
27
  "snkSimpleCrudTaskbar.grid_regular": this.getButtons(false, [TaskbarElement.DATA_EXPORTER, TaskbarElement.FORM_MODE]),
27
28
  "snkSimpleCrudTaskbar.form_selected": this.getButtons(true, [TaskbarElement.GRID_MODE]),
28
29
  "snkSimpleCrudTaskbar.grid_selected": this.getButtons(true, [TaskbarElement.DATA_EXPORTER, TaskbarElement.FORM_MODE]),
29
- "snkSimpleCrudTaskbar.finish_edition": ["CANCEL", "SAVE"]
30
+ "snkSimpleCrudTaskbar.finish_edition": this.getFinishEditionButtonsCallback.bind(this)
30
31
  });
31
32
  this._showPopUpGridConfig = false;
32
33
  this._showFormConfig = false;
@@ -42,10 +43,12 @@ export class SnkSimpleCrud {
42
43
  this.formConfig = undefined;
43
44
  this._formFields = [];
44
45
  this._fieldsProps = new Map();
46
+ this._enableContinuousInsert = true;
45
47
  this.multipleSelection = undefined;
46
48
  this.useCancelConfirm = true;
47
49
  this.pageSize = 150;
48
50
  this.resourceID = undefined;
51
+ this.enableGridInsert = false;
49
52
  this.taskbarManager = undefined;
50
53
  this.messagesBuilder = undefined;
51
54
  this.useEnterLikeTab = false;
@@ -115,6 +118,13 @@ export class SnkSimpleCrud {
115
118
  newCustomFieldProps.set(fieldName, Object.assign(Object.assign({}, currentProps), { [propName]: value }));
116
119
  this._fieldsProps = newCustomFieldProps;
117
120
  }
121
+ getFinishEditionButtonsCallback() {
122
+ const btns = ["CANCEL", "SAVE"];
123
+ if (this.enableGridInsert && this._currentViewMode !== VIEW_MODE.ATTACHMENT) {
124
+ btns.push(this._currentViewMode === VIEW_MODE.GRID ? TaskbarElement.FORM_MODE : TaskbarElement.GRID_MODE);
125
+ }
126
+ return btns;
127
+ }
118
128
  getButtons(selected, extraButtons) {
119
129
  return this.addConfigButton(this.resolveInMemoryBtns(selected ? REGULAR_SELECTED_BTNS : REGULAR_DEFAULT_BTNS)
120
130
  .concat(extraButtons));
@@ -197,7 +207,6 @@ export class SnkSimpleCrud {
197
207
  await this.setFieldProp(field, 'precision', rmPrecision);
198
208
  await this.setFieldProp(field, 'prettyPrecision', rmPrecision);
199
209
  }
200
- ;
201
210
  this._rmPrecisionCustomValueFormatter.setDataState(this.dataState);
202
211
  }
203
212
  async handleUpdateGridLegacyConfig(newValue, oldValue) {
@@ -320,6 +329,10 @@ export class SnkSimpleCrud {
320
329
  this.onModeChange();
321
330
  this.configDatasource();
322
331
  this._rmPrecisionCustomValueFormatter = new RmPrecisionCustomValueFormatter();
332
+ this._continuousInsertUtils = new ContinuousInsertUtils(this.application, this.resolveResourceID(), this.configName);
333
+ if (this.enableGridInsert) {
334
+ this._continuousInsertUtils.getConfig().then(value => this._enableContinuousInsert = value);
335
+ }
323
336
  }
324
337
  componentDidLoad() {
325
338
  CSSVarsUtils.applyVarsGrid(this._element, this._grid);
@@ -554,6 +567,9 @@ export class SnkSimpleCrud {
554
567
  const options = filteredFields.map(field => ({ value: field.name, label: field.label }));
555
568
  return Promise.resolve(options);
556
569
  }
570
+ isGridInsertActive() {
571
+ return this.enableGridInsert && this.dataUnit.hasNewRecord();
572
+ }
557
573
  getActionsList() {
558
574
  var _a, _b;
559
575
  const hardList = [{
@@ -565,11 +581,22 @@ export class SnkSimpleCrud {
565
581
  ? this.getColumnSearch(actionButton, item)
566
582
  : this.getFieldSearch(actionButton, item)
567
583
  }];
584
+ if (this.enableGridInsert) {
585
+ hardList.push(this._continuousInsertUtils.actionContinuousInsert(this._enableContinuousInsert, this.handleEnableContinuousInsert));
586
+ }
587
+ if (this.isGridInsertActive())
588
+ return hardList;
568
589
  if (this.taskbarManager != undefined && this.taskbarManager.getMoreOptions != undefined) {
569
590
  const taskbarID = this.getTopTaskBarId();
570
591
  return hardList.concat(this.taskbarManager.getMoreOptions(taskbarID, this.configName, this.dataState, this.actionsList));
571
592
  }
572
- return hardList.concat(this.actionsList);
593
+ if (this.actionsList)
594
+ return hardList.concat(this.actionsList);
595
+ return hardList;
596
+ }
597
+ handleEnableContinuousInsert() {
598
+ this._enableContinuousInsert = !this._enableContinuousInsert;
599
+ this._continuousInsertUtils.handleSaveConfig(this._enableContinuousInsert);
573
600
  }
574
601
  getTopTaskBarId() {
575
602
  var _a;
@@ -688,6 +715,11 @@ export class SnkSimpleCrud {
688
715
  }
689
716
  this._formConfigManager.setConfig(this.formConfig);
690
717
  }
718
+ handleDataUnitOnInsertionMode() {
719
+ if (this.enableGridInsert)
720
+ return;
721
+ this.goToView(VIEW_MODE.FORM);
722
+ }
691
723
  /* istanbul ignore next */
692
724
  render() {
693
725
  var _a;
@@ -695,9 +727,9 @@ export class SnkSimpleCrud {
695
727
  return;
696
728
  }
697
729
  const taskbarContent = (h("snk-taskbar", { class: this._currentViewMode === VIEW_MODE.FORM && "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" })));
698
- 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), 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)
730
+ 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" }, 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)
699
731
  ? undefined
700
- : this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab, autoFocus: this.autoFocus }, 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() }))));
732
+ : 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() }))));
701
733
  }
702
734
  static get is() { return "snk-simple-crud"; }
703
735
  static get encapsulation() { return "scoped"; }
@@ -903,6 +935,24 @@ export class SnkSimpleCrud {
903
935
  "attribute": "resource-i-d",
904
936
  "reflect": false
905
937
  },
938
+ "enableGridInsert": {
939
+ "type": "boolean",
940
+ "mutable": false,
941
+ "complexType": {
942
+ "original": "boolean",
943
+ "resolved": "boolean",
944
+ "references": {}
945
+ },
946
+ "required": false,
947
+ "optional": true,
948
+ "docs": {
949
+ "tags": [],
950
+ "text": "Ativa inser\u00E7\u00E3o de registros no modo grade."
951
+ },
952
+ "attribute": "enable-grid-insert",
953
+ "reflect": false,
954
+ "defaultValue": "false"
955
+ },
906
956
  "taskbarManager": {
907
957
  "type": "unknown",
908
958
  "mutable": false,
@@ -1133,7 +1183,8 @@ export class SnkSimpleCrud {
1133
1183
  "_fieldToGetFocus": {},
1134
1184
  "_customContainerId": {},
1135
1185
  "_formFields": {},
1136
- "_fieldsProps": {}
1186
+ "_fieldsProps": {},
1187
+ "_enableContinuousInsert": {}
1137
1188
  };
1138
1189
  }
1139
1190
  static get events() {
@@ -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",
@@ -0,0 +1,31 @@
1
+ import { h } from '@stencil/core';
2
+ import { StringUtils } from '@sankhyalabs/core';
3
+ export class ContinuousInsertUtils {
4
+ constructor(snkApplication, resourceID, configName) {
5
+ this.snkApplication = snkApplication;
6
+ this.keyConfigEnableContinuousInsert = `${resourceID}enableContinuousInsert${configName ? configName : ''}`;
7
+ }
8
+ handleSaveConfig(enableContinuousInsert) {
9
+ return this.snkApplication.saveConfig(this.keyConfigEnableContinuousInsert, enableContinuousInsert);
10
+ }
11
+ getConfig() {
12
+ return this.snkApplication.getConfig(this.keyConfigEnableContinuousInsert).then(value => {
13
+ if (value) {
14
+ return value == "true" ? true : false;
15
+ }
16
+ return false;
17
+ }).catch(() => {
18
+ return false;
19
+ });
20
+ }
21
+ actionContinuousInsert(enableContinuousInsert, handleEnableContinuousInsert) {
22
+ return {
23
+ value: StringUtils.generateUUID(),
24
+ label: enableContinuousInsert ? 'Desativar inclusão contínua' : 'Ativar inclusão contínua',
25
+ enabled: true,
26
+ itemBuilder: () => {
27
+ return (h("div", { class: "ez-dropdown__item-wrapper", onClick: () => handleEnableContinuousInsert() }, h("span", { class: "ez-dropdown__item-label" }, enableContinuousInsert ? 'Desativar inclusão contínua' : 'Ativar inclusão contínua')));
28
+ },
29
+ };
30
+ }
31
+ }
@@ -1,29 +1,29 @@
1
1
  import { DataType, JSUtils } from "@sankhyalabs/core";
2
- export const getSelectedIDs = (dataUnit) => {
3
- const selectionInfo = dataUnit.getSelectionInfo();
2
+ export function getSelectedRecordsIDsInfo(dataUnit) {
3
+ const selectionInfo = dataUnit === null || dataUnit === void 0 ? void 0 : dataUnit.getSelectionInfo();
4
4
  if (selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.isAllRecords()) {
5
5
  return [];
6
6
  }
7
7
  const selectedRecordsIDsInfo = [];
8
- const selectedRecords = selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.recordIds;
8
+ const selectedRecords = selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.records;
9
9
  if ((selectedRecords === null || selectedRecords === void 0 ? void 0 : selectedRecords.length) > 0) {
10
- selectedRecords.forEach(recordId => {
11
- if (!dataUnit.isNewRecord(recordId)) {
10
+ selectedRecords.forEach(({ __record__id__ }) => {
11
+ if (!dataUnit.isNewRecord(__record__id__)) {
12
12
  /*
13
13
  Esse if foi necessário para tratar corretamente o ID
14
14
  do record quando está sendo utilizado no modo standAlone
15
15
  isso não faz a exportação da grid funcionar no modo standAlone
16
16
  mas deixa de causar erro nas oprações de CRUD.
17
17
  */
18
- if (!JSUtils.isBase64(recordId)) {
18
+ if (!JSUtils.isBase64(__record__id__)) {
19
19
  selectedRecordsIDsInfo.push({
20
20
  name: "__record__id__",
21
21
  type: DataType.TEXT,
22
- value: recordId
22
+ value: __record__id__
23
23
  });
24
24
  return;
25
25
  }
26
- const revertBase64ToObject = JSON.parse(window.atob(recordId));
26
+ const revertBase64ToObject = JSON.parse(window.atob(__record__id__));
27
27
  Object.entries(revertBase64ToObject).forEach(([name, value]) => {
28
28
  const metadataField = dataUnit === null || dataUnit === void 0 ? void 0 : dataUnit.getField(name);
29
29
  if (metadataField == undefined) {
@@ -35,4 +35,4 @@ export const getSelectedIDs = (dataUnit) => {
35
35
  });
36
36
  }
37
37
  return selectedRecordsIDsInfo;
38
- };
38
+ }