@sankhyalabs/sankhyablocks 8.16.0-dev.22 → 8.16.0-dev.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/dist/cjs/{IExporterProvider-9ac15aaf.js → ContinuousInsertUtils-b32220f0.js} +35 -2
  2. package/dist/cjs/{SnkMessageBuilder-cceebbae.js → SnkMessageBuilder-bae64d0d.js} +5 -1
  3. package/dist/cjs/{dataunit-fetcher-4b12f70c.js → dataunit-fetcher-f89461c1.js} +45 -17
  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 +2 -4
  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-2f2e6f8c.js → snk-data-unit-004f781a.js} +2 -2
  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 +52 -12
  16. package/dist/cjs/{snk-guides-viewer-866447ab.js → snk-guides-viewer-68777d37.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 +43 -11
  19. package/dist/collection/components/snk-attach/structure/fetcher/factory/attach-fetcher-data-unit.factory.js +2 -4
  20. package/dist/collection/components/snk-crud/snk-crud.js +22 -1
  21. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +24 -2
  22. package/dist/collection/components/snk-grid/snk-grid.js +66 -6
  23. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +59 -8
  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/dataUnit/InMemoryLoader.js +2 -4
  27. package/dist/collection/lib/dataUnit/dataUnitInMemoryUtils.js +34 -9
  28. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js +9 -2
  29. package/dist/collection/lib/message/resources/snk-grid.msg.js +5 -1
  30. package/dist/collection/lib/utils/ContinuousInsertUtils.js +31 -0
  31. package/dist/components/{IExporterProvider.js → ContinuousInsertUtils.js} +39 -4
  32. package/dist/components/SnkMessageBuilder.js +5 -1
  33. package/dist/components/dataunit-fetcher.js +45 -15
  34. package/dist/components/snk-attach2.js +2 -4
  35. package/dist/components/snk-crud.js +5 -1
  36. package/dist/components/snk-data-unit2.js +1 -1
  37. package/dist/components/snk-detail-view2.js +8 -3
  38. package/dist/components/snk-grid2.js +48 -6
  39. package/dist/components/snk-simple-crud2.js +39 -5
  40. package/dist/esm/{IExporterProvider-09df2e3e.js → ContinuousInsertUtils-aae77a37.js} +36 -4
  41. package/dist/esm/{SnkMessageBuilder-ae87b754.js → SnkMessageBuilder-6fff4a4c.js} +5 -1
  42. package/dist/esm/{dataunit-fetcher-3aac1a53.js → dataunit-fetcher-c24c76c6.js} +45 -15
  43. package/dist/esm/{field-search-efbe307f.js → field-search-f8b1d91e.js} +5 -1
  44. package/dist/esm/loader.js +1 -1
  45. package/dist/esm/sankhyablocks.js +1 -1
  46. package/dist/esm/snk-actions-button_4.entry.js +1 -1
  47. package/dist/esm/snk-application.entry.js +2 -2
  48. package/dist/esm/snk-attach.entry.js +2 -4
  49. package/dist/esm/snk-crud.entry.js +5 -2
  50. package/dist/esm/snk-data-exporter.entry.js +3 -3
  51. package/dist/esm/{snk-data-unit-acf3dd64.js → snk-data-unit-a90ce6f2.js} +2 -2
  52. package/dist/esm/snk-data-unit.entry.js +3 -3
  53. package/dist/esm/snk-detail-view.entry.js +4 -4
  54. package/dist/esm/snk-grid.entry.js +47 -7
  55. package/dist/esm/{snk-guides-viewer-cb8a0b48.js → snk-guides-viewer-b5dd30e6.js} +8 -4
  56. package/dist/esm/snk-guides-viewer.entry.js +3 -3
  57. package/dist/esm/snk-simple-crud.entry.js +39 -7
  58. package/dist/sankhyablocks/p-17425c72.js +1 -0
  59. package/dist/sankhyablocks/p-23736d75.js +1 -0
  60. package/dist/sankhyablocks/p-3e3cc017.js +1 -0
  61. package/dist/sankhyablocks/{p-8d7e2747.entry.js → p-43a73838.entry.js} +1 -1
  62. package/dist/sankhyablocks/p-47a038a3.js +1 -0
  63. package/dist/sankhyablocks/p-50779ad3.entry.js +1 -0
  64. package/dist/sankhyablocks/{p-16969508.entry.js → p-694e1c4a.entry.js} +1 -1
  65. package/dist/sankhyablocks/p-7ac7932c.js +60 -0
  66. package/dist/sankhyablocks/{p-bc4b94d2.entry.js → p-7eef0898.entry.js} +1 -1
  67. package/dist/sankhyablocks/{p-8862ba4a.entry.js → p-7f918d0b.entry.js} +1 -1
  68. package/dist/sankhyablocks/{p-ce6eed2c.js → p-9132a0a1.js} +1 -1
  69. package/dist/sankhyablocks/p-9bc1c239.entry.js +1 -0
  70. package/dist/sankhyablocks/{p-640140b3.entry.js → p-a42e7a1e.entry.js} +1 -1
  71. package/dist/sankhyablocks/p-b0ef9faa.entry.js +1 -0
  72. package/dist/sankhyablocks/p-e16e87fc.entry.js +1 -0
  73. package/dist/sankhyablocks/{p-3d542b58.entry.js → p-eb9f0407.entry.js} +1 -1
  74. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  75. package/dist/types/components/snk-crud/snk-crud.d.ts +4 -0
  76. package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +5 -0
  77. package/dist/types/components/snk-grid/snk-grid.d.ts +12 -0
  78. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +10 -0
  79. package/dist/types/components/snk-taskbar/processor/taskbar-processor.d.ts +1 -0
  80. package/dist/types/components.d.ts +32 -0
  81. package/dist/types/lib/dataUnit/dataUnitInMemoryUtils.d.ts +12 -2
  82. package/dist/types/lib/utils/ContinuousInsertUtils.d.ts +10 -0
  83. package/package.json +1 -1
  84. package/dist/sankhyablocks/p-0e9a872d.entry.js +0 -1
  85. package/dist/sankhyablocks/p-1ab19772.js +0 -1
  86. package/dist/sankhyablocks/p-1f47a0b2.entry.js +0 -1
  87. package/dist/sankhyablocks/p-3757394b.entry.js +0 -1
  88. package/dist/sankhyablocks/p-53c1d25d.entry.js +0 -1
  89. package/dist/sankhyablocks/p-7c4aabe2.js +0 -1
  90. package/dist/sankhyablocks/p-a31e761f.js +0 -1
  91. package/dist/sankhyablocks/p-c2495304.js +0 -1
  92. package/dist/sankhyablocks/p-f8698ad3.js +0 -60
@@ -235,6 +235,21 @@ function applyFilter(records, dataUnit, filters) {
235
235
  }
236
236
  return records.filter(filterFunction);
237
237
  }
238
+ function buildLoadDataResponse(recordsIn, dataUnit, request) {
239
+ let records = recordsIn ? [...recordsIn] : [];
240
+ records = applyFilter(records, dataUnit, request.filters);
241
+ records = applySorting(records, dataUnit, request.sort);
242
+ const { offset, limit } = request;
243
+ const paginationInfoBuilderParams = {
244
+ recordsLength: records.length,
245
+ offset,
246
+ recordsPerPage: limit,
247
+ };
248
+ return Promise.resolve({
249
+ records: getPagesByRecords(records, offset, limit),
250
+ paginationInfo: buildPaginationInfo(paginationInfoBuilderParams),
251
+ });
252
+ }
238
253
  function applySorting(records, dataUnit, sorting) {
239
254
  if (sorting == undefined || sorting.length == 0) {
240
255
  return records;
@@ -245,18 +260,28 @@ function applySorting(records, dataUnit, sorting) {
245
260
  }
246
261
  return records.sort(sortingFunction);
247
262
  }
248
- function buildPaginationInfo(records, offset = 0, limit = 0) {
249
- if (records === undefined) {
250
- return undefined;
263
+ function hasValidLimitAndOffset(offset, limit) {
264
+ return offset >= 0 && limit >= 0;
265
+ }
266
+ function getPagesByRecords(records, offset = 0, limit = 0) {
267
+ if (!records || !records.length || !hasValidLimitAndOffset(offset, limit))
268
+ return [];
269
+ if (limit === 0 && offset === 0)
270
+ return records;
271
+ return records.slice(offset, offset + limit);
272
+ }
273
+ function buildPaginationInfo({ recordsLength = 0, offset = 0, recordsPerPage = 0 }) {
274
+ if (!recordsLength) {
275
+ return { currentPage: 0, firstRecord: 0, lastRecord: 0, total: 0, hasMore: false };
251
276
  }
252
- const total = (records === null || records === void 0 ? void 0 : records.length) || 0;
253
- const lastRecord = Math.min(offset + limit, total);
277
+ const lastRecordIndex = offset + recordsPerPage;
278
+ const lastRecord = lastRecordIndex ? Math.min(lastRecordIndex, recordsLength) : recordsLength;
254
279
  return {
255
- currentPage: limit === 0 ? 0 : Math.ceil(offset / limit),
256
- firstRecord: offset,
280
+ currentPage: recordsPerPage === 0 ? 0 : Math.ceil(offset / recordsPerPage),
281
+ firstRecord: offset + 1,
257
282
  lastRecord: lastRecord,
258
- total: total,
259
- hasMore: !!(total - lastRecord),
283
+ total: recordsLength,
284
+ hasMore: lastRecord < recordsLength,
260
285
  };
261
286
  }
262
287
 
@@ -342,9 +367,7 @@ class InMemoryLoader {
342
367
  return StringUtils.generateUUID();
343
368
  }
344
369
  inMemoryLoader(dataUnit, request, recordsIn) {
345
- let records = applyFilter(recordsIn, dataUnit, request.filters);
346
- records = applySorting(records, dataUnit, request.sort);
347
- return Promise.resolve({ records, paginationInfo: buildPaginationInfo(records, request.offset, request.limit) });
370
+ return buildLoadDataResponse(recordsIn, dataUnit, request);
348
371
  }
349
372
  metadaLoader() {
350
373
  return Promise.resolve(this._metadata);
@@ -424,12 +447,19 @@ class DatasetStrategy {
424
447
  const records = this.processRecords(dataUnit, fields, responseRecords);
425
448
  const loadingInProgress = pagerId != undefined;
426
449
  const count = loadingInfo.count + records.length;
450
+ const isInsertingNewRecord = dataUnit.hasNewRecord();
427
451
  const needReload = !loadingInProgress && localSorting.length > 0;
452
+ /**
453
+ * Caso precise recarregar dados, porém está no meio de uma inserção, os dados não devem recarregados instantaneamente,
454
+ * Mas sim, sinalizar que o dataUnit está aguardando para der recarregado.
455
+ */
456
+ if (needReload && isInsertingNewRecord) {
457
+ dataUnit.setWaitingToReload(true);
458
+ }
428
459
  return Promise.resolve({
429
460
  records,
430
461
  loadingInfo: Object.assign(Object.assign({}, loadingInfo), { pagerId,
431
- loadingInProgress, total: loadingInProgress ? undefined : count, count,
432
- needReload })
462
+ loadingInProgress, total: loadingInProgress ? undefined : count, count, needReload: needReload && !isInsertingNewRecord })
433
463
  });
434
464
  }
435
465
  catch (error) {
@@ -1052,4 +1082,4 @@ class DataUnitFetcher {
1052
1082
  }
1053
1083
  }
1054
1084
 
1055
- export { DataUnitFetcher as D, InMemoryLoader as I, PreloadManager as P, applyFilter as a, applySorting as b, buildPaginationInfo as c, DatasetStrategy as d, getRecordValue as g };
1085
+ export { DataUnitFetcher as D, InMemoryLoader as I, PreloadManager as P, DatasetStrategy as a, buildLoadDataResponse as b, getRecordValue as g };
@@ -3,7 +3,7 @@ import { ApplicationContext, DataType, Action, UserInterface, StringUtils, DataU
3
3
  import { D as DataFetcher } from './DataFetcher.js';
4
4
  import './pesquisa-fetcher.js';
5
5
  import { S as SaveErrorsEnum } from './ISave.js';
6
- import { P as PreloadManager, a as applyFilter, b as applySorting, c as buildPaginationInfo, D as DataUnitFetcher, I as InMemoryLoader } from './dataunit-fetcher.js';
6
+ import { P as PreloadManager, b as buildLoadDataResponse, D as DataUnitFetcher, I as InMemoryLoader } from './dataunit-fetcher.js';
7
7
  import './filter-item-type.enum.js';
8
8
  import './form-config-fetcher.js';
9
9
  import { V as VIEW_MODE } from './constants.js';
@@ -466,9 +466,7 @@ class AttachFetcherDataUnitFactory {
466
466
  });
467
467
  this._records = records;
468
468
  }
469
- let records = applyFilter(this._records, dataUnit, request.filters);
470
- records = applySorting(records, dataUnit, request.sort);
471
- return Promise.resolve({ records, paginationInfo: buildPaginationInfo(records, request.offset, request.limit) });
469
+ return buildLoadDataResponse(this._records, dataUnit, request);
472
470
  }
473
471
  saveLoader(changes, fetcher) {
474
472
  return new Promise((resolve) => {
@@ -80,6 +80,7 @@ const SnkCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
80
80
  this.disablePersonalizedFilter = undefined;
81
81
  this.autoLoad = undefined;
82
82
  this.autoFocus = true;
83
+ this.enableGridInsert = false;
83
84
  this.domainMessagesBuilder = undefined;
84
85
  this.setCustomFormTitle = undefined;
85
86
  this.customContainerId = `SNK-CRUD-CUSTOM-CONTAINER-${StringUtils.generateUUID()}`;
@@ -206,6 +207,8 @@ const SnkCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
206
207
  ElementIDUtils.addIDInfo(this._element, null, dataInfo);
207
208
  }
208
209
  insertionModeHandler() {
210
+ if (this.enableGridInsert)
211
+ return;
209
212
  this.gridToForm();
210
213
  }
211
214
  cancelHandler() {
@@ -420,7 +423,7 @@ const SnkCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
420
423
  return;
421
424
  }
422
425
  this._snkDataUnit.ignoreSaveMessage = this._currentViewMode === VIEW_MODE.GRID;
423
- 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, getCustomTitle: this.setCustomFormTitle }, 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" }))));
426
+ return (h(Host, null, h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "crud" }, h("stack-item", null, h("snk-grid", { ref: (ref) => this._snkGrid = ref, filterBarTitle: this.filterBarTitle, "data-element-id": "crud_grid", configName: this.configName, onGridDoubleClick: () => this.gridToForm(true), taskbarManager: this.taskbarManager, onActionClick: evt => this.executeAction(evt.detail), messagesBuilder: this.messagesBuilder, actionsList: this.actionsList, statusResolver: this.statusResolver, multipleSelection: this.multipleSelection, presentationMode: this.presentationMode, recordsValidator: this.recordsValidator, selectionToastConfig: this.selectionToastConfig, useEnterLikeTab: this.useEnterLikeTab, canEdit: this._canEdit, resourceID: this._resourceID, disablePersonalizedFilter: this.disablePersonalizedFilter, gridLegacyConfigName: this.gridLegacyConfigName, filterBarLegacyConfigName: this.filterBarLegacyConfigName, autoLoad: this.autoLoad, autoFocus: this.autoFocus, enableGridInsert: this.enableGridInsert }, h("slot", { name: "GRID_TASKBAR_CUSTOM_ELEMENTS" }), h("slot", { name: "GRID_HEADER_CUSTOM_ELEMENTS" }), h("slot", { name: "SnkGridHeader" }), h("slot", { name: "SnkGridFooter" }), h("slot", { name: "SnkGridTaskBar" }))), h("stack-item", null, h("snk-guides-viewer", { ref: ref => this._guidesViewer = ref, entityPath: this._snkDataUnit.entityName, messagesBuilder: this.messagesBuilder, onExit: () => this.setViewMode(VIEW_MODE.GRID), dataState: this._dataState, dataUnit: this._dataUnit, actionsList: this.actionsList, taskbarManager: this.taskbarManager, configName: this.configName, onActionClick: evt => this.executeAction(evt.detail), presentationMode: this.presentationMode, "data-element-id": "crud_form", canEdit: this._canEdit, recordsValidator: this.recordsValidator, resourceID: this._resourceID, detailTaskbarCustomContainerId: this.customContainerId, formLegacyConfigName: this.formLegacyConfigName, enableGridInsert: this.enableGridInsert, getCustomTitle: this.setCustomFormTitle }, 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" }))));
424
427
  }
425
428
  get _element() { return this; }
426
429
  static get watchers() { return {
@@ -446,6 +449,7 @@ const SnkCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
446
449
  "disablePersonalizedFilter": [4, "disable-personalized-filter"],
447
450
  "autoLoad": [4, "auto-load"],
448
451
  "autoFocus": [4, "auto-focus"],
452
+ "enableGridInsert": [4, "enable-grid-insert"],
449
453
  "domainMessagesBuilder": [1, "domain-messages-builder"],
450
454
  "setCustomFormTitle": [16],
451
455
  "_dataUnit": [32],
@@ -2,7 +2,7 @@ import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/
2
2
  import { Action, ObjectUtils, DataUnitAction, StringUtils, ApplicationContext } from '@sankhyalabs/core';
3
3
  import { ApplicationUtils, DialogType } from '@sankhyalabs/ezui/dist/collection/utils';
4
4
  import { O as OperationMap, S as SnkMessageBuilder } from './SnkMessageBuilder.js';
5
- import { g as getRecordValue, d as DatasetStrategy } from './dataunit-fetcher.js';
5
+ import { g as getRecordValue, a as DatasetStrategy } from './dataunit-fetcher.js';
6
6
  import { convertType } from '@sankhyalabs/core/dist/dataunit/metadata/DataType';
7
7
  import { g as getSelectedRecordsIDsInfo } from './GetSelectedRecordsIDsInfo.js';
8
8
 
@@ -12,7 +12,7 @@ import './filter-item-type.enum.js';
12
12
  import './form-config-fetcher.js';
13
13
  import { T as TaskbarElement, d as defineCustomElement$3 } from './snk-taskbar2.js';
14
14
  import { V as VIEW_MODE } from './constants.js';
15
- import { o as openFieldSearch, T as TaskbarProcessor, b as buildFieldSearch } from './IExporterProvider.js';
15
+ import { o as openFieldSearch, T as TaskbarProcessor, b as buildFieldSearch } from './ContinuousInsertUtils.js';
16
16
  import { SelectionMode } from '@sankhyalabs/core/dist/dataunit/DataUnit';
17
17
  import { d as defineCustomElement$u } from './snk-actions-button2.js';
18
18
  import { d as defineCustomElement$t } from './snk-attach2.js';
@@ -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.getCustomTitle = undefined;
74
75
  this._hasToCreateFieldSearch = true;
75
76
  this._breadcrumbItems = [];
@@ -139,7 +140,7 @@ const SnkGuidesViewer = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
139
140
  this._container.focus();
140
141
  }
141
142
  exitViewer() {
142
- if (this.dataUnit.isDirty()) {
143
+ if (!this.enableGridInsert && this.dataUnit.isDirty()) {
143
144
  this.dataUnit.cancelEdition({ after: () => this.exit.emit() });
144
145
  }
145
146
  else {
@@ -248,10 +249,13 @@ const SnkGuidesViewer = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
248
249
  const invisibleButtons = this.getInvisibleButtons();
249
250
  this._taskbarProcessor = new TaskbarProcessor({
250
251
  "snkGuideViewer.regular": btnsRegularMode,
251
- "snkGuideViewer.finish_edition": ["CANCEL", "SAVE"],
252
+ "snkGuideViewer.finish_edition": ["CANCEL", "SAVE", this.handleAddGridMode()],
252
253
  });
253
254
  this._taskbarProcessor.process(taskbarId, this.taskbarManager, this.dataState, disabledButtons, invisibleButtons);
254
255
  }
256
+ handleAddGridMode() {
257
+ return this.enableGridInsert ? TaskbarElement.GRID_MODE : "";
258
+ }
255
259
  getInvisibleButtons() {
256
260
  const invisibleButtons = [];
257
261
  if (this.dataState && this.dataState.selectionInfo.mode === SelectionMode.ALL_RECORDS)
@@ -566,6 +570,7 @@ const SnkGuidesViewer = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
566
570
  "resourceID": [1, "resource-i-d"],
567
571
  "detailTaskbarCustomContainerId": [1, "detail-taskbar-custom-container-id"],
568
572
  "formLegacyConfigName": [1, "form-legacy-config-name"],
573
+ "enableGridInsert": [4, "enable-grid-insert"],
569
574
  "getCustomTitle": [16],
570
575
  "_hasToCreateFieldSearch": [32],
571
576
  "_breadcrumbItems": [32],
@@ -1,9 +1,9 @@
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
- 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';
6
+ import { C as CommonsExporter, T as TaskbarProcessor, S as SnkMultiSelectionListDataSource, o as openFieldSearch, a as CrudUtils, R as RmPrecisionCustomValueFormatter, c as ContinuousInsertUtils, b as buildFieldSearch } from './ContinuousInsertUtils.js';
7
7
  import { s as store } from './index2.js';
8
8
  import { SelectionMode } from '@sankhyalabs/core/dist/dataunit/DataUnit';
9
9
  import './DataFetcher.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) => {
@@ -128,6 +128,7 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
128
128
  this._gridConfig = undefined;
129
129
  this._popUpGridConfig = false;
130
130
  this._showSnkFilterBar = true;
131
+ this._enableContinuousInsert = false;
131
132
  this.columnFilterDataSource = new SnkMultiSelectionListDataSource();
132
133
  this.configName = undefined;
133
134
  this.filterBarTitle = undefined;
@@ -151,6 +152,7 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
151
152
  this.filterBarLegacyConfigName = undefined;
152
153
  this.autoLoad = undefined;
153
154
  this.autoFocus = true;
155
+ this.enableGridInsert = false;
154
156
  }
155
157
  /**
156
158
  * Exibe a janela de configurações da grade.
@@ -237,6 +239,16 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
237
239
  async setFocus() {
238
240
  this._grid.setFocus();
239
241
  }
242
+ async handleClick(event) {
243
+ if (this.hasToBlockEvent(event)) {
244
+ event.preventDefault();
245
+ event.stopPropagation();
246
+ await this._dataUnit.cancelEdition();
247
+ }
248
+ }
249
+ hasToBlockEvent(event) {
250
+ return this._snkFilterBar.contains(event.target) && this.enableGridInsert && this._dataUnit.hasNewRecord();
251
+ }
240
252
  async handleGridLegacyConfigName(newLegacyConfig, oldLegacyConfig) {
241
253
  if (!newLegacyConfig) {
242
254
  return;
@@ -247,6 +259,9 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
247
259
  this.addGridLegacyConfigName();
248
260
  this.loadConfig();
249
261
  }
262
+ handleAddFormMode() {
263
+ return this.enableGridInsert ? TaskbarElement.FORM_MODE : "";
264
+ }
250
265
  openGridConfig() {
251
266
  this._grid.getColumnsState()
252
267
  .then((gridColumns) => {
@@ -371,13 +386,21 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
371
386
  }
372
387
  parent = parent.parentElement;
373
388
  }
389
+ if (this._snkFilterBar) {
390
+ this._snkFilterBar.addEventListener('click', this.handleClick);
391
+ }
374
392
  this._rmPrecisionCustomValueFormatter = new RmPrecisionCustomValueFormatter();
375
393
  this.addGridLegacyConfigName();
376
394
  this.loadConfig();
395
+ this._continuousInsertUtils = new ContinuousInsertUtils(this._application, this.resourceID, this.configName);
396
+ if (this.enableGridInsert) {
397
+ this._continuousInsertUtils.getConfig().then(value => this._enableContinuousInsert = value);
398
+ }
377
399
  }
378
400
  componentDidRender() {
401
+ var _a, _b;
379
402
  this._rmPrecisionCustomValueFormatter.setGrid(this._grid);
380
- this.loadGridCustomFormatters(this._dataUnit.metadata.fields);
403
+ this.loadGridCustomFormatters((_b = (_a = this._dataUnit) === null || _a === void 0 ? void 0 : _a.metadata) === null || _b === void 0 ? void 0 : _b.fields);
381
404
  this.setCustomRenders();
382
405
  this.setCustomEditors();
383
406
  }
@@ -475,12 +498,21 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
475
498
  eagerInitialize: true,
476
499
  itemBuilder: (actionButton, item) => this.getColumnSearch(actionButton, item)
477
500
  }];
501
+ if (this.enableGridInsert) {
502
+ hardList.push(this._continuousInsertUtils.actionContinuousInsert(this._enableContinuousInsert, this.handleEnableContinuousInsert));
503
+ }
504
+ if (this.isGridInsertActive())
505
+ return hardList;
478
506
  if (this.taskbarManager != undefined && this.taskbarManager.getMoreOptions != undefined) {
479
507
  const taskbarID = this.getTopTaskBarId();
480
508
  return hardList.concat(this.taskbarManager.getMoreOptions(taskbarID, this.configName, this._dataState, this.actionsList));
481
509
  }
482
510
  return hardList.concat(this.actionsList);
483
511
  }
512
+ handleEnableContinuousInsert() {
513
+ this._enableContinuousInsert = !this._enableContinuousInsert;
514
+ this._continuousInsertUtils.handleSaveConfig(this._enableContinuousInsert);
515
+ }
484
516
  handleFilterConfigUpdated(filterConfig) {
485
517
  if (!filterConfig.length) {
486
518
  this._showSnkFilterBar = false;
@@ -492,12 +524,20 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
492
524
  }
493
525
  this._showSnkFilterBar = true;
494
526
  }
527
+ getGridHeaderButtons() {
528
+ if (this.isGridInsertActive())
529
+ return TaskbarElement.MORE_OPTIONS;
530
+ return this._headerTaskbarProcessor.buttons;
531
+ }
532
+ isGridInsertActive() {
533
+ return this.enableGridInsert && this._dataUnit.hasNewRecord();
534
+ }
495
535
  render() {
496
536
  if (!this._dataUnit) {
497
537
  return undefined;
498
538
  }
499
539
  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 &&
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 }))));
540
+ 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 }))));
501
541
  }
502
542
  get _element() { return this; }
503
543
  static get watchers() { return {
@@ -528,11 +568,13 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
528
568
  "filterBarLegacyConfigName": [1, "filter-bar-legacy-config-name"],
529
569
  "autoLoad": [4, "auto-load"],
530
570
  "autoFocus": [4, "auto-focus"],
571
+ "enableGridInsert": [4, "enable-grid-insert"],
531
572
  "_dataUnit": [32],
532
573
  "_dataState": [32],
533
574
  "_gridConfig": [32],
534
575
  "_popUpGridConfig": [32],
535
576
  "_showSnkFilterBar": [32],
577
+ "_enableContinuousInsert": [32],
536
578
  "showConfig": [64],
537
579
  "hideConfig": [64],
538
580
  "setConfig": [64],
@@ -5,7 +5,7 @@ import { V as VIEW_MODE, S as SIMPLE_CRUD_MODE } from './constants.js';
5
5
  import { T as TaskbarElement, d as defineCustomElement$2 } from './snk-taskbar2.js';
6
6
  import './DataFetcher.js';
7
7
  import './pesquisa-fetcher.js';
8
- import { C as CommonsExporter, S as SnkMultiSelectionListDataSource, T as TaskbarProcessor, R as RmPrecisionCustomValueFormatter, b as buildFieldSearch, o as openFieldSearch, a as CrudUtils } from './IExporterProvider.js';
8
+ import { C as CommonsExporter, S as SnkMultiSelectionListDataSource, T as TaskbarProcessor, R as RmPrecisionCustomValueFormatter, c as ContinuousInsertUtils, b as buildFieldSearch, o as openFieldSearch, a as CrudUtils } from './ContinuousInsertUtils.js';
9
9
  import { D as DataExporterOption, P as PresentationMode } from './ISave.js';
10
10
  import '@sankhyalabs/ezui/dist/collection/utils/constants';
11
11
  import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
@@ -109,7 +109,7 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
109
109
  "snkSimpleCrudTaskbar.grid_regular": this.getButtons(false, [TaskbarElement.DATA_EXPORTER, TaskbarElement.FORM_MODE]),
110
110
  "snkSimpleCrudTaskbar.form_selected": this.getButtons(true, [TaskbarElement.GRID_MODE]),
111
111
  "snkSimpleCrudTaskbar.grid_selected": this.getButtons(true, [TaskbarElement.DATA_EXPORTER, TaskbarElement.FORM_MODE]),
112
- "snkSimpleCrudTaskbar.finish_edition": ["CANCEL", "SAVE"]
112
+ "snkSimpleCrudTaskbar.finish_edition": this.getFinishEditionButtonsCallback.bind(this)
113
113
  });
114
114
  this._showPopUpGridConfig = false;
115
115
  this._showFormConfig = false;
@@ -125,10 +125,12 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
125
125
  this.formConfig = undefined;
126
126
  this._formFields = [];
127
127
  this._fieldsProps = new Map();
128
+ this._enableContinuousInsert = true;
128
129
  this.multipleSelection = undefined;
129
130
  this.useCancelConfirm = true;
130
131
  this.pageSize = 150;
131
132
  this.resourceID = undefined;
133
+ this.enableGridInsert = false;
132
134
  this.taskbarManager = undefined;
133
135
  this.messagesBuilder = undefined;
134
136
  this.useEnterLikeTab = false;
@@ -198,6 +200,13 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
198
200
  newCustomFieldProps.set(fieldName, Object.assign(Object.assign({}, currentProps), { [propName]: value }));
199
201
  this._fieldsProps = newCustomFieldProps;
200
202
  }
203
+ getFinishEditionButtonsCallback() {
204
+ const btns = ["CANCEL", "SAVE"];
205
+ if (this.enableGridInsert && this._currentViewMode !== VIEW_MODE.ATTACHMENT) {
206
+ btns.push(this._currentViewMode === VIEW_MODE.GRID ? TaskbarElement.FORM_MODE : TaskbarElement.GRID_MODE);
207
+ }
208
+ return btns;
209
+ }
201
210
  getButtons(selected, extraButtons) {
202
211
  return this.addConfigButton(this.resolveInMemoryBtns(selected ? REGULAR_SELECTED_BTNS : REGULAR_DEFAULT_BTNS)
203
212
  .concat(extraButtons));
@@ -402,6 +411,10 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
402
411
  this.onModeChange();
403
412
  this.configDatasource();
404
413
  this._rmPrecisionCustomValueFormatter = new RmPrecisionCustomValueFormatter();
414
+ this._continuousInsertUtils = new ContinuousInsertUtils(this.application, this.resolveResourceID(), this.configName);
415
+ if (this.enableGridInsert) {
416
+ this._continuousInsertUtils.getConfig().then(value => this._enableContinuousInsert = value);
417
+ }
405
418
  }
406
419
  componentDidLoad() {
407
420
  CSSVarsUtils.applyVarsGrid(this._element, this._grid);
@@ -636,6 +649,9 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
636
649
  const options = filteredFields.map(field => ({ value: field.name, label: field.label }));
637
650
  return Promise.resolve(options);
638
651
  }
652
+ isGridInsertActive() {
653
+ return this.enableGridInsert && this.dataUnit.hasNewRecord();
654
+ }
639
655
  getActionsList() {
640
656
  var _a, _b;
641
657
  const hardList = [{
@@ -647,11 +663,22 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
647
663
  ? this.getColumnSearch(actionButton, item)
648
664
  : this.getFieldSearch(actionButton, item)
649
665
  }];
666
+ if (this.enableGridInsert) {
667
+ hardList.push(this._continuousInsertUtils.actionContinuousInsert(this._enableContinuousInsert, this.handleEnableContinuousInsert));
668
+ }
669
+ if (this.isGridInsertActive())
670
+ return hardList;
650
671
  if (this.taskbarManager != undefined && this.taskbarManager.getMoreOptions != undefined) {
651
672
  const taskbarID = this.getTopTaskBarId();
652
673
  return hardList.concat(this.taskbarManager.getMoreOptions(taskbarID, this.configName, this.dataState, this.actionsList));
653
674
  }
654
- return hardList.concat(this.actionsList);
675
+ if (this.actionsList)
676
+ return hardList.concat(this.actionsList);
677
+ return hardList;
678
+ }
679
+ handleEnableContinuousInsert() {
680
+ this._enableContinuousInsert = !this._enableContinuousInsert;
681
+ this._continuousInsertUtils.handleSaveConfig(this._enableContinuousInsert);
655
682
  }
656
683
  getTopTaskBarId() {
657
684
  var _a;
@@ -770,6 +797,11 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
770
797
  }
771
798
  this._formConfigManager.setConfig(this.formConfig);
772
799
  }
800
+ handleDataUnitOnInsertionMode() {
801
+ if (this.enableGridInsert)
802
+ return;
803
+ this.goToView(VIEW_MODE.FORM);
804
+ }
773
805
  /* istanbul ignore next */
774
806
  render() {
775
807
  var _a;
@@ -777,9 +809,9 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
777
809
  return;
778
810
  }
779
811
  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" })));
780
- 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)
812
+ 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)
781
813
  ? undefined
782
- : 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() }))));
814
+ : 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() }))));
783
815
  }
784
816
  get _element() { return this; }
785
817
  static get watchers() { return {
@@ -802,6 +834,7 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
802
834
  "useCancelConfirm": [4, "use-cancel-confirm"],
803
835
  "pageSize": [2, "page-size"],
804
836
  "resourceID": [1, "resource-i-d"],
837
+ "enableGridInsert": [4, "enable-grid-insert"],
805
838
  "taskbarManager": [16],
806
839
  "messagesBuilder": [1040],
807
840
  "useEnterLikeTab": [4, "use-enter-like-tab"],
@@ -822,6 +855,7 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
822
855
  "_customContainerId": [32],
823
856
  "_formFields": [32],
824
857
  "_fieldsProps": [32],
858
+ "_enableContinuousInsert": [32],
825
859
  "addCustomEditor": [64],
826
860
  "addGridCustomRender": [64],
827
861
  "addCustomValueFormatter": [64],
@@ -1,14 +1,15 @@
1
1
  import { D as DataFetcher } from './DataFetcher-a9c598f2.js';
2
2
  import './pesquisa-fetcher-8edaa8cd.js';
3
- import { SortMode, ApplicationContext, UserInterface, DateUtils, ObjectUtils, NumberUtils, DataType } from '@sankhyalabs/core';
3
+ import { SortMode, ApplicationContext, UserInterface, DateUtils, ObjectUtils, NumberUtils, DataType, StringUtils } from '@sankhyalabs/core';
4
4
  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-3aac1a53.js';
8
+ import { P as PreloadManager } from './dataunit-fetcher-c24c76c6.js';
9
9
  import './filter-item-type.enum-d45e026f.js';
10
10
  import './form-config-fetcher-adbe5d34.js';
11
11
  import InMemoryFilterColumnDataSource from '@sankhyalabs/ezui/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource';
12
+ import { h } from './index-a7d3d3f1.js';
12
13
 
13
14
  class CrudUtils {
14
15
  static assertDefaultSorting(gridConfig, dataUnit) {
@@ -140,7 +141,7 @@ class RmPrecisionCustomValueFormatter {
140
141
  this.refreshSelectedRows();
141
142
  }
142
143
  setDataState(dataState) {
143
- if (ObjectUtils.objectToString(dataState) === ObjectUtils.objectToString(this._dataState)) {
144
+ if (this._dataState && ObjectUtils.equals(dataState === null || dataState === void 0 ? void 0 : dataState.metadataByRow, this._dataState.metadataByRow)) {
144
145
  return;
145
146
  }
146
147
  this._dataState = dataState;
@@ -218,4 +219,35 @@ class CommonsExporter {
218
219
  }
219
220
  }
220
221
 
221
- export { CommonsExporter as C, RmPrecisionCustomValueFormatter as R, SnkMultiSelectionListDataSource as S, CrudUtils as a };
222
+ class ContinuousInsertUtils {
223
+ constructor(snkApplication, resourceID, configName) {
224
+ this.snkApplication = snkApplication;
225
+ this.keyConfigEnableContinuousInsert = `${resourceID}enableContinuousInsert${configName ? configName : ''}`;
226
+ }
227
+ handleSaveConfig(enableContinuousInsert) {
228
+ return this.snkApplication.saveConfig(this.keyConfigEnableContinuousInsert, enableContinuousInsert);
229
+ }
230
+ getConfig() {
231
+ return this.snkApplication.getConfig(this.keyConfigEnableContinuousInsert).then(value => {
232
+ if (value) {
233
+ return value == "true" ? true : false;
234
+ }
235
+ return false;
236
+ }).catch(() => {
237
+ return false;
238
+ });
239
+ }
240
+ actionContinuousInsert(enableContinuousInsert, handleEnableContinuousInsert) {
241
+ return {
242
+ value: StringUtils.generateUUID(),
243
+ label: enableContinuousInsert ? 'Desativar inclusão contínua' : 'Ativar inclusão contínua',
244
+ enabled: true,
245
+ itemBuilder: () => {
246
+ return (h("div", { class: "ez-dropdown__item-wrapper", onClick: () => handleEnableContinuousInsert() },
247
+ h("span", { class: "ez-dropdown__item-label" }, enableContinuousInsert ? 'Desativar inclusão contínua' : 'Ativar inclusão contínua')));
248
+ },
249
+ };
250
+ }
251
+ }
252
+
253
+ export { CommonsExporter as C, RmPrecisionCustomValueFormatter as R, SnkMultiSelectionListDataSource as S, CrudUtils as a, ContinuousInsertUtils as b };
@@ -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",