@sankhyalabs/sankhyablocks 0.0.0-bugfix-dev-KB-55889.0 → 0.0.0-bugfix-dev-KB-60622.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{IExporterProvider-9ac15aaf.js → ContinuousInsertUtils-b32220f0.js} +35 -2
- package/dist/cjs/{SnkMessageBuilder-cceebbae.js → SnkMessageBuilder-bae64d0d.js} +5 -1
- package/dist/cjs/{dataunit-fetcher-4b12f70c.js → dataunit-fetcher-f89461c1.js} +45 -17
- package/dist/cjs/{field-search-f56aa7d6.js → field-search-68e34bf4.js} +5 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-actions-button_4.cjs.entry.js +1 -1
- package/dist/cjs/snk-application.cjs.entry.js +2 -2
- package/dist/cjs/snk-attach.cjs.entry.js +2 -4
- package/dist/cjs/snk-crud.cjs.entry.js +5 -2
- package/dist/cjs/snk-data-exporter.cjs.entry.js +3 -3
- package/dist/cjs/{snk-data-unit-ed17da6b.js → snk-data-unit-004f781a.js} +10 -11
- package/dist/cjs/snk-data-unit.cjs.entry.js +3 -3
- package/dist/cjs/snk-detail-view.cjs.entry.js +4 -4
- package/dist/cjs/snk-grid.cjs.entry.js +52 -12
- package/dist/cjs/{snk-guides-viewer-866447ab.js → snk-guides-viewer-68777d37.js} +8 -4
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +3 -3
- package/dist/cjs/snk-simple-crud.cjs.entry.js +51 -15
- package/dist/collection/components/snk-attach/structure/fetcher/factory/attach-fetcher-data-unit.factory.js +2 -4
- package/dist/collection/components/snk-crud/snk-crud.js +22 -1
- package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +24 -2
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +8 -9
- package/dist/collection/components/snk-grid/snk-grid.js +66 -6
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +67 -12
- package/dist/collection/components/snk-taskbar/processor/taskbar-processor.js +5 -1
- package/dist/collection/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.js +1 -1
- package/dist/collection/lib/dataUnit/InMemoryLoader.js +2 -4
- package/dist/collection/lib/dataUnit/dataUnitInMemoryUtils.js +34 -9
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js +9 -2
- package/dist/collection/lib/message/resources/snk-grid.msg.js +5 -1
- package/dist/collection/lib/utils/ContinuousInsertUtils.js +31 -0
- package/dist/components/{IExporterProvider.js → ContinuousInsertUtils.js} +39 -4
- package/dist/components/SnkMessageBuilder.js +5 -1
- package/dist/components/dataunit-fetcher.js +45 -15
- package/dist/components/snk-attach2.js +2 -4
- package/dist/components/snk-crud.js +5 -1
- package/dist/components/snk-data-unit2.js +9 -10
- package/dist/components/snk-detail-view2.js +8 -3
- package/dist/components/snk-grid2.js +48 -6
- package/dist/components/snk-simple-crud2.js +47 -9
- package/dist/esm/{IExporterProvider-09df2e3e.js → ContinuousInsertUtils-aae77a37.js} +36 -4
- package/dist/esm/{SnkMessageBuilder-ae87b754.js → SnkMessageBuilder-6fff4a4c.js} +5 -1
- package/dist/esm/{dataunit-fetcher-3aac1a53.js → dataunit-fetcher-c24c76c6.js} +45 -15
- package/dist/esm/{field-search-efbe307f.js → field-search-f8b1d91e.js} +5 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-actions-button_4.entry.js +1 -1
- package/dist/esm/snk-application.entry.js +2 -2
- package/dist/esm/snk-attach.entry.js +2 -4
- package/dist/esm/snk-crud.entry.js +5 -2
- package/dist/esm/snk-data-exporter.entry.js +3 -3
- package/dist/esm/{snk-data-unit-6888df8f.js → snk-data-unit-a90ce6f2.js} +10 -11
- package/dist/esm/snk-data-unit.entry.js +3 -3
- package/dist/esm/snk-detail-view.entry.js +4 -4
- package/dist/esm/snk-grid.entry.js +47 -7
- package/dist/esm/{snk-guides-viewer-cb8a0b48.js → snk-guides-viewer-b5dd30e6.js} +8 -4
- package/dist/esm/snk-guides-viewer.entry.js +3 -3
- package/dist/esm/snk-simple-crud.entry.js +47 -11
- package/dist/sankhyablocks/p-17425c72.js +1 -0
- package/dist/sankhyablocks/p-23736d75.js +1 -0
- package/dist/sankhyablocks/p-3e3cc017.js +1 -0
- package/dist/sankhyablocks/{p-559bfb9b.entry.js → p-43a73838.entry.js} +1 -1
- package/dist/sankhyablocks/p-47a038a3.js +1 -0
- package/dist/sankhyablocks/p-50779ad3.entry.js +1 -0
- package/dist/sankhyablocks/{p-16969508.entry.js → p-694e1c4a.entry.js} +1 -1
- package/dist/sankhyablocks/p-7ac7932c.js +60 -0
- package/dist/sankhyablocks/{p-bc4b94d2.entry.js → p-7eef0898.entry.js} +1 -1
- package/dist/sankhyablocks/{p-439a50fb.entry.js → p-7f918d0b.entry.js} +1 -1
- package/dist/sankhyablocks/{p-9cbef862.js → p-9132a0a1.js} +1 -1
- package/dist/sankhyablocks/p-9bc1c239.entry.js +1 -0
- package/dist/sankhyablocks/{p-640140b3.entry.js → p-a42e7a1e.entry.js} +1 -1
- package/dist/sankhyablocks/p-b82a7720.entry.js +1 -0
- package/dist/sankhyablocks/p-e16e87fc.entry.js +1 -0
- package/dist/sankhyablocks/{p-3d542b58.entry.js → p-eb9f0407.entry.js} +1 -1
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-crud/snk-crud.d.ts +4 -0
- package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +5 -0
- package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +0 -1
- package/dist/types/components/snk-grid/snk-grid.d.ts +12 -0
- package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +10 -0
- package/dist/types/components/snk-taskbar/processor/taskbar-processor.d.ts +1 -0
- package/dist/types/components.d.ts +32 -0
- package/dist/types/lib/dataUnit/dataUnitInMemoryUtils.d.ts +12 -2
- package/dist/types/lib/utils/ContinuousInsertUtils.d.ts +10 -0
- package/package.json +1 -1
- package/dist/sankhyablocks/p-0e9a872d.entry.js +0 -1
- package/dist/sankhyablocks/p-1ab19772.js +0 -1
- package/dist/sankhyablocks/p-1f47a0b2.entry.js +0 -1
- package/dist/sankhyablocks/p-3757394b.entry.js +0 -1
- package/dist/sankhyablocks/p-53c1d25d.entry.js +0 -1
- package/dist/sankhyablocks/p-7c4aabe2.js +0 -1
- package/dist/sankhyablocks/p-a31e761f.js +0 -1
- package/dist/sankhyablocks/p-c2495304.js +0 -1
- package/dist/sankhyablocks/p-f8698ad3.js +0 -60
|
@@ -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",
|
|
@@ -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
|
|
249
|
-
|
|
250
|
-
|
|
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
|
|
253
|
-
const lastRecord = Math.min(
|
|
277
|
+
const lastRecordIndex = offset + recordsPerPage;
|
|
278
|
+
const lastRecord = lastRecordIndex ? Math.min(lastRecordIndex, recordsLength) : recordsLength;
|
|
254
279
|
return {
|
|
255
|
-
currentPage:
|
|
256
|
-
firstRecord: offset,
|
|
280
|
+
currentPage: recordsPerPage === 0 ? 0 : Math.ceil(offset / recordsPerPage),
|
|
281
|
+
firstRecord: offset + 1,
|
|
257
282
|
lastRecord: lastRecord,
|
|
258
|
-
total:
|
|
259
|
-
hasMore:
|
|
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
|
-
|
|
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,
|
|
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,
|
|
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
|
-
|
|
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,
|
|
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
|
|
|
@@ -485,7 +485,14 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
485
485
|
}
|
|
486
486
|
handleRecordsRemoved(action) {
|
|
487
487
|
var _a, _b;
|
|
488
|
-
|
|
488
|
+
const cachedRecords = action.payload.cachedRecords;
|
|
489
|
+
let removeFinishMsg;
|
|
490
|
+
if ((cachedRecords === null || cachedRecords === void 0 ? void 0 : cachedRecords.length) > 1) {
|
|
491
|
+
removeFinishMsg = this.getMessage("snkDataUnit.removeAllInfo", { size: cachedRecords.length });
|
|
492
|
+
}
|
|
493
|
+
else {
|
|
494
|
+
removeFinishMsg = this.getMessage("snkDataUnit.removeInfo", action.payload.cachedRecords[0]);
|
|
495
|
+
}
|
|
489
496
|
if (removeFinishMsg != undefined) {
|
|
490
497
|
this.showSuccessMessage(removeFinishMsg);
|
|
491
498
|
}
|
|
@@ -496,14 +503,6 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
496
503
|
this.dataUnit.gotoPage(page);
|
|
497
504
|
}
|
|
498
505
|
}
|
|
499
|
-
buildRemoveFinishMessage(action) {
|
|
500
|
-
const records = action.payload.records;
|
|
501
|
-
if (!records || !records.length)
|
|
502
|
-
return undefined;
|
|
503
|
-
if ((records === null || records === void 0 ? void 0 : records.length) > 1)
|
|
504
|
-
return this.getMessage('snkDataUnit.removeAllInfo', { size: records.length });
|
|
505
|
-
return this.getMessage('snkDataUnit.removeInfo', records);
|
|
506
|
-
}
|
|
507
506
|
/**
|
|
508
507
|
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
|
509
508
|
* através de um pequeno modulo na estrutura da aplicação:
|
|
@@ -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 './
|
|
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 {
|
|
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 './
|
|
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.
|
|
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 './
|
|
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';
|
|
@@ -105,11 +105,11 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
105
105
|
this._customEditors = new Map();
|
|
106
106
|
this._customRenders = new Map();
|
|
107
107
|
this._taskbarProcessor = new TaskbarProcessor({
|
|
108
|
-
"snkSimpleCrudTaskbar.form_regular": this.getButtons(false, [TaskbarElement.GRID_MODE]),
|
|
108
|
+
"snkSimpleCrudTaskbar.form_regular": this.getButtons(false, [TaskbarElement.GRID_MODE], true),
|
|
109
109
|
"snkSimpleCrudTaskbar.grid_regular": this.getButtons(false, [TaskbarElement.DATA_EXPORTER, TaskbarElement.FORM_MODE]),
|
|
110
|
-
"snkSimpleCrudTaskbar.form_selected": this.getButtons(true, [TaskbarElement.GRID_MODE]),
|
|
110
|
+
"snkSimpleCrudTaskbar.form_selected": this.getButtons(true, [TaskbarElement.GRID_MODE], true),
|
|
111
111
|
"snkSimpleCrudTaskbar.grid_selected": this.getButtons(true, [TaskbarElement.DATA_EXPORTER, TaskbarElement.FORM_MODE]),
|
|
112
|
-
"snkSimpleCrudTaskbar.finish_edition":
|
|
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,8 +200,19 @@ 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
|
}
|
|
201
|
-
|
|
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
|
+
}
|
|
210
|
+
getButtons(selected, extraButtons, removeRefresh) {
|
|
211
|
+
let btnList = selected ? REGULAR_SELECTED_BTNS : REGULAR_DEFAULT_BTNS;
|
|
212
|
+
if (removeRefresh) {
|
|
213
|
+
btnList = btnList.filter(item => item !== TaskbarElement.REFRESH);
|
|
214
|
+
}
|
|
215
|
+
return this.addConfigButton(this.resolveInMemoryBtns(btnList)
|
|
203
216
|
.concat(extraButtons));
|
|
204
217
|
}
|
|
205
218
|
addConfigButton(buttons) {
|
|
@@ -402,6 +415,10 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
402
415
|
this.onModeChange();
|
|
403
416
|
this.configDatasource();
|
|
404
417
|
this._rmPrecisionCustomValueFormatter = new RmPrecisionCustomValueFormatter();
|
|
418
|
+
this._continuousInsertUtils = new ContinuousInsertUtils(this.application, this.resolveResourceID(), this.configName);
|
|
419
|
+
if (this.enableGridInsert) {
|
|
420
|
+
this._continuousInsertUtils.getConfig().then(value => this._enableContinuousInsert = value);
|
|
421
|
+
}
|
|
405
422
|
}
|
|
406
423
|
componentDidLoad() {
|
|
407
424
|
CSSVarsUtils.applyVarsGrid(this._element, this._grid);
|
|
@@ -636,6 +653,9 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
636
653
|
const options = filteredFields.map(field => ({ value: field.name, label: field.label }));
|
|
637
654
|
return Promise.resolve(options);
|
|
638
655
|
}
|
|
656
|
+
isGridInsertActive() {
|
|
657
|
+
return this.enableGridInsert && this.dataUnit.hasNewRecord();
|
|
658
|
+
}
|
|
639
659
|
getActionsList() {
|
|
640
660
|
var _a, _b;
|
|
641
661
|
const hardList = [{
|
|
@@ -647,11 +667,22 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
647
667
|
? this.getColumnSearch(actionButton, item)
|
|
648
668
|
: this.getFieldSearch(actionButton, item)
|
|
649
669
|
}];
|
|
670
|
+
if (this.enableGridInsert) {
|
|
671
|
+
hardList.push(this._continuousInsertUtils.actionContinuousInsert(this._enableContinuousInsert, this.handleEnableContinuousInsert));
|
|
672
|
+
}
|
|
673
|
+
if (this.isGridInsertActive())
|
|
674
|
+
return hardList;
|
|
650
675
|
if (this.taskbarManager != undefined && this.taskbarManager.getMoreOptions != undefined) {
|
|
651
676
|
const taskbarID = this.getTopTaskBarId();
|
|
652
677
|
return hardList.concat(this.taskbarManager.getMoreOptions(taskbarID, this.configName, this.dataState, this.actionsList));
|
|
653
678
|
}
|
|
654
|
-
|
|
679
|
+
if (this.actionsList)
|
|
680
|
+
return hardList.concat(this.actionsList);
|
|
681
|
+
return hardList;
|
|
682
|
+
}
|
|
683
|
+
handleEnableContinuousInsert() {
|
|
684
|
+
this._enableContinuousInsert = !this._enableContinuousInsert;
|
|
685
|
+
this._continuousInsertUtils.handleSaveConfig(this._enableContinuousInsert);
|
|
655
686
|
}
|
|
656
687
|
getTopTaskBarId() {
|
|
657
688
|
var _a;
|
|
@@ -770,6 +801,11 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
770
801
|
}
|
|
771
802
|
this._formConfigManager.setConfig(this.formConfig);
|
|
772
803
|
}
|
|
804
|
+
handleDataUnitOnInsertionMode() {
|
|
805
|
+
if (this.enableGridInsert)
|
|
806
|
+
return;
|
|
807
|
+
this.goToView(VIEW_MODE.FORM);
|
|
808
|
+
}
|
|
773
809
|
/* istanbul ignore next */
|
|
774
810
|
render() {
|
|
775
811
|
var _a;
|
|
@@ -777,9 +813,9 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
777
813
|
return;
|
|
778
814
|
}
|
|
779
815
|
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:
|
|
816
|
+
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
817
|
? 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() }))));
|
|
818
|
+
: 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
819
|
}
|
|
784
820
|
get _element() { return this; }
|
|
785
821
|
static get watchers() { return {
|
|
@@ -802,6 +838,7 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
802
838
|
"useCancelConfirm": [4, "use-cancel-confirm"],
|
|
803
839
|
"pageSize": [2, "page-size"],
|
|
804
840
|
"resourceID": [1, "resource-i-d"],
|
|
841
|
+
"enableGridInsert": [4, "enable-grid-insert"],
|
|
805
842
|
"taskbarManager": [16],
|
|
806
843
|
"messagesBuilder": [1040],
|
|
807
844
|
"useEnterLikeTab": [4, "use-enter-like-tab"],
|
|
@@ -822,6 +859,7 @@ const SnkSimpleCrud = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
822
859
|
"_customContainerId": [32],
|
|
823
860
|
"_formFields": [32],
|
|
824
861
|
"_fieldsProps": [32],
|
|
862
|
+
"_enableContinuousInsert": [32],
|
|
825
863
|
"addCustomEditor": [64],
|
|
826
864
|
"addGridCustomRender": [64],
|
|
827
865
|
"addCustomValueFormatter": [64],
|