@sankhyalabs/sankhyablocks 8.14.9 → 8.14.11
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/{dataunit-fetcher-1b46e106.js → dataunit-fetcher-d839c5d7.js} +24 -4
- package/dist/cjs/snk-actions-button.cjs.entry.js +1 -1
- package/dist/cjs/snk-application.cjs.entry.js +1 -1
- package/dist/cjs/snk-attach.cjs.entry.js +1 -1
- package/dist/cjs/snk-crud.cjs.entry.js +2 -2
- package/dist/cjs/snk-detail-view.cjs.entry.js +2 -2
- package/dist/cjs/{snk-guides-viewer-894da8ad.js → snk-guides-viewer-88a7f880.js} +1 -1
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +2 -2
- package/dist/cjs/snk-simple-crud.cjs.entry.js +1 -1
- package/dist/collection/components/snk-crud/snk-crud.js +1 -1
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/dataunit-fetcher.js +14 -1
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js +10 -3
- package/dist/components/dataunit-fetcher.js +24 -4
- package/dist/components/snk-crud.js +1 -1
- package/dist/esm/{dataunit-fetcher-7a82866b.js → dataunit-fetcher-cf01a8f4.js} +24 -4
- package/dist/esm/snk-actions-button.entry.js +1 -1
- package/dist/esm/snk-application.entry.js +1 -1
- package/dist/esm/snk-attach.entry.js +1 -1
- package/dist/esm/snk-crud.entry.js +2 -2
- package/dist/esm/snk-detail-view.entry.js +2 -2
- package/dist/esm/{snk-guides-viewer-32122fb6.js → snk-guides-viewer-fde509bf.js} +1 -1
- package/dist/esm/snk-guides-viewer.entry.js +2 -2
- package/dist/esm/snk-simple-crud.entry.js +1 -1
- package/dist/sankhyablocks/{p-999d89cd.entry.js → p-08ced1fd.entry.js} +1 -1
- package/dist/sankhyablocks/p-3160fa64.js +60 -0
- package/dist/sankhyablocks/{p-2600b8c7.entry.js → p-34774923.entry.js} +1 -1
- package/dist/sankhyablocks/{p-8043fb84.entry.js → p-3ab540cc.entry.js} +2 -2
- package/dist/sankhyablocks/{p-1771bc15.entry.js → p-6ea96bb1.entry.js} +1 -1
- package/dist/sankhyablocks/{p-f3628f71.js → p-936addf1.js} +1 -1
- package/dist/sankhyablocks/{p-b6567ade.entry.js → p-c53926eb.entry.js} +1 -1
- package/dist/sankhyablocks/{p-c4349760.entry.js → p-cfbebb49.entry.js} +1 -1
- package/dist/sankhyablocks/{p-ad6d2805.entry.js → p-d2923a2a.entry.js} +1 -1
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/dataunit-fetcher.d.ts +1 -0
- package/package.json +1 -1
- package/dist/sankhyablocks/p-0648947b.js +0 -60
@@ -236,7 +236,7 @@ class DatasetStrategy {
|
|
236
236
|
tryJoinedFields: true,
|
237
237
|
parallelLoader: useParallelLoader,
|
238
238
|
crudListener: `br.com.sankhya.bff.${this.getModuleName()}.BFFDataUnitDatasetAdapter`,
|
239
|
-
txProperties: this.getTxProperties(
|
239
|
+
txProperties: this.getTxProperties(dataUnit, request, sorting),
|
240
240
|
useDefaultRowsLimit: false
|
241
241
|
}
|
242
242
|
};
|
@@ -247,10 +247,10 @@ class DatasetStrategy {
|
|
247
247
|
const moduleName = app.getModuleName();
|
248
248
|
return moduleName.replace("-bff", "");
|
249
249
|
}
|
250
|
-
getTxProperties(
|
250
|
+
getTxProperties(dataUnit, request, sorting) {
|
251
251
|
var _a, _b;
|
252
252
|
const txProperties = {
|
253
|
-
"__DATA_UNIT_ADAPTER__[dataUnitName]":
|
253
|
+
"__DATA_UNIT_ADAPTER__[dataUnitName]": dataUnit.name
|
254
254
|
};
|
255
255
|
const serverSideFilters = (_b = (_a = request.filters) === null || _a === void 0 ? void 0 : _a.filter(filter => !filter.name.startsWith("FILTRO_COLUNA_"))) !== null && _b !== void 0 ? _b : [];
|
256
256
|
if (serverSideFilters.length !== 0) {
|
@@ -262,6 +262,13 @@ class DatasetStrategy {
|
|
262
262
|
if (request.parentRecordId != undefined) {
|
263
263
|
txProperties["__DATA_UNIT_ADAPTER__[parentRecordId]"] = request.parentRecordId;
|
264
264
|
}
|
265
|
+
const loaderProps = dataUnit.getGlobalLoaderProps();
|
266
|
+
if (loaderProps == undefined || loaderProps.size === 0) {
|
267
|
+
return txProperties;
|
268
|
+
}
|
269
|
+
Array.from(loaderProps.entries()).forEach(([name, value]) => {
|
270
|
+
txProperties[name] = value;
|
271
|
+
});
|
265
272
|
return txProperties;
|
266
273
|
}
|
267
274
|
processRecords(dataUnit, fields, responseRecords) {
|
@@ -591,6 +598,19 @@ class DataUnitFetcher {
|
|
591
598
|
});
|
592
599
|
});
|
593
600
|
}
|
601
|
+
addTransientProperties(dataUnit, updatingFields) {
|
602
|
+
const loaderProps = dataUnit.getGlobalLoaderProps();
|
603
|
+
if (loaderProps == undefined || loaderProps.size === 0) {
|
604
|
+
return updatingFields;
|
605
|
+
}
|
606
|
+
if (updatingFields == undefined) {
|
607
|
+
updatingFields = {};
|
608
|
+
}
|
609
|
+
Array.from(loaderProps.entries()).forEach(([name, value]) => {
|
610
|
+
updatingFields[`transient.${name}`] = value;
|
611
|
+
});
|
612
|
+
return updatingFields;
|
613
|
+
}
|
594
614
|
saveData(dataUnit, duChanges) {
|
595
615
|
const updatedRecordsIds = [];
|
596
616
|
const addedRecordsIds = [];
|
@@ -599,7 +619,7 @@ class DataUnitFetcher {
|
|
599
619
|
const dataUnitInstance = core.DataUnitStorage.get(changeDU);
|
600
620
|
let parsedUpdatingFields;
|
601
621
|
if (updatingFields) {
|
602
|
-
parsedUpdatingFields = Object.entries(updatingFields).map(([fieldName, value]) => {
|
622
|
+
parsedUpdatingFields = Object.entries(this.addTransientProperties(dataUnit, updatingFields)).map(([fieldName, value]) => {
|
603
623
|
const descriptor = dataUnitInstance.getField(fieldName);
|
604
624
|
const dataType = descriptor ? descriptor.dataType : core.DataType.TEXT;
|
605
625
|
return { fieldName, dataType, value: dataUnitInstance.valueToString(fieldName, value) };
|
@@ -11,7 +11,7 @@ require('./index-0e663819.js');
|
|
11
11
|
require('./ISave-d68ce3cd.js');
|
12
12
|
require('@sankhyalabs/ezui/dist/collection/utils/constants');
|
13
13
|
require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
|
14
|
-
require('./dataunit-fetcher-
|
14
|
+
require('./dataunit-fetcher-d839c5d7.js');
|
15
15
|
require('./PreloadManager-84466da6.js');
|
16
16
|
require('./filter-item-type.enum-a7ffdaa6.js');
|
17
17
|
require('./form-config-fetcher-df043d3d.js');
|
@@ -8,7 +8,7 @@ const utils = require('@sankhyalabs/ezui/dist/collection/utils');
|
|
8
8
|
const ConfigStorage = require('./ConfigStorage-8009ecb2.js');
|
9
9
|
const DataFetcher = require('./DataFetcher-ba94ed5b.js');
|
10
10
|
const authFetcher = require('./auth-fetcher-c8467c07.js');
|
11
|
-
const dataunitFetcher = require('./dataunit-fetcher-
|
11
|
+
const dataunitFetcher = require('./dataunit-fetcher-d839c5d7.js');
|
12
12
|
const pesquisaFetcher = require('./pesquisa-fetcher-ef050a47.js');
|
13
13
|
const SnkMessageBuilder = require('./SnkMessageBuilder-7293d0ad.js');
|
14
14
|
require('./form-config-fetcher-df043d3d.js');
|
@@ -7,7 +7,7 @@ const core = require('@sankhyalabs/core');
|
|
7
7
|
const DataFetcher = require('./DataFetcher-ba94ed5b.js');
|
8
8
|
const ISave = require('./ISave-d68ce3cd.js');
|
9
9
|
const constants = require('./constants-35ddd366.js');
|
10
|
-
const dataunitFetcher = require('./dataunit-fetcher-
|
10
|
+
const dataunitFetcher = require('./dataunit-fetcher-d839c5d7.js');
|
11
11
|
const PreloadManager = require('./PreloadManager-84466da6.js');
|
12
12
|
const taskbarElements = require('./taskbar-elements-39949c7a.js');
|
13
13
|
require('./PrintUtils-bcaeb82f.js');
|
@@ -11,7 +11,7 @@ const index$1 = require('./index-0e663819.js');
|
|
11
11
|
require('./ISave-d68ce3cd.js');
|
12
12
|
require('@sankhyalabs/ezui/dist/collection/utils/constants');
|
13
13
|
require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
|
14
|
-
require('./dataunit-fetcher-
|
14
|
+
require('./dataunit-fetcher-d839c5d7.js');
|
15
15
|
require('./PreloadManager-84466da6.js');
|
16
16
|
require('./filter-item-type.enum-a7ffdaa6.js');
|
17
17
|
require('./form-config-fetcher-df043d3d.js');
|
@@ -298,7 +298,7 @@ const SnkCrud = class {
|
|
298
298
|
return;
|
299
299
|
}
|
300
300
|
this._snkDataUnit.ignoreSaveMessage = this._currentViewMode === constants.VIEW_MODE.GRID;
|
301
|
-
return (index.h(index.Host, null, index.h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "crud" }, index.h("stack-item", null, index.h("snk-grid", { ref: (ref) => this._snkGrid = ref, "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, selectionToastConfig: this.selectionToastConfig, useEnterLikeTab: this.useEnterLikeTab, canEdit: this._canEdit, resourceID: this._resourceID }, index.h("slot", { name: "GRID_TASKBAR_CUSTOM_ELEMENTS" }), index.h("slot", { name: "GRID_HEADER_CUSTOM_ELEMENTS" }), index.h("slot", { name: "SnkGridHeader" }), index.h("slot", { name: "SnkGridFooter" }), index.h("slot", { name: "SnkGridTaskBar" }))), index.h("stack-item", null, index.h("snk-guides-viewer", { ref: ref => this._guidesViewer = ref, entityPath: this._snkDataUnit.entityName, messagesBuilder: this.messagesBuilder, onExit: () => this.setViewMode(constants.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, resourceID: this._resourceID, detailTaskbarCustomContainerId: this.customContainerId }, index.h("slot", { name: "GUIDES_VIEWER_TASKBAR_CUSTOM_ELEMENTS" }), index.h("slot", { name: "SnkFormTaskBar" }))), index.h("stack-item", null, index.h("snk-attach", { registerKey: this.attachmentRegisterKey, messagesBuilder: this.messagesBuilder, entityName: this._snkDataUnit.entityName, onBack: this.backView.bind(this) })), index.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 })), index.h("div", { id: `${this.customContainerId}` }, index.h("slot", { name: "SnkConfigContainerSlot" }), index.h("slot", { name: "DETAIL_GRID_HEADER_CUSTOM_ELEMENTS" }), index.h("slot", { name: "DETAIL_GRID_TASKBAR_CUSTOM_ELEMENTS" }), index.h("slot", { name: "DETAIL_TASKBAR_CUSTOM_ELEMENTS" }))));
|
301
|
+
return (index.h(index.Host, null, index.h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "crud" }, index.h("stack-item", null, index.h("snk-grid", { ref: (ref) => this._snkGrid = ref, "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 }, index.h("slot", { name: "GRID_TASKBAR_CUSTOM_ELEMENTS" }), index.h("slot", { name: "GRID_HEADER_CUSTOM_ELEMENTS" }), index.h("slot", { name: "SnkGridHeader" }), index.h("slot", { name: "SnkGridFooter" }), index.h("slot", { name: "SnkGridTaskBar" }))), index.h("stack-item", null, index.h("snk-guides-viewer", { ref: ref => this._guidesViewer = ref, entityPath: this._snkDataUnit.entityName, messagesBuilder: this.messagesBuilder, onExit: () => this.setViewMode(constants.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 }, index.h("slot", { name: "GUIDES_VIEWER_TASKBAR_CUSTOM_ELEMENTS" }), index.h("slot", { name: "SnkFormTaskBar" }))), index.h("stack-item", null, index.h("snk-attach", { registerKey: this.attachmentRegisterKey, messagesBuilder: this.messagesBuilder, entityName: this._snkDataUnit.entityName, onBack: this.backView.bind(this) })), index.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 })), index.h("div", { id: `${this.customContainerId}` }, index.h("slot", { name: "SnkConfigContainerSlot" }), index.h("slot", { name: "DETAIL_GRID_HEADER_CUSTOM_ELEMENTS" }), index.h("slot", { name: "DETAIL_GRID_TASKBAR_CUSTOM_ELEMENTS" }), index.h("slot", { name: "DETAIL_TASKBAR_CUSTOM_ELEMENTS" }))));
|
302
302
|
}
|
303
303
|
get _element() { return index.getElement(this); }
|
304
304
|
static get watchers() { return {
|
@@ -12,13 +12,13 @@ const index$1 = require('./index-0e663819.js');
|
|
12
12
|
require('./ISave-d68ce3cd.js');
|
13
13
|
require('@sankhyalabs/ezui/dist/collection/utils/constants');
|
14
14
|
require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
|
15
|
-
require('./dataunit-fetcher-
|
15
|
+
require('./dataunit-fetcher-d839c5d7.js');
|
16
16
|
require('./PreloadManager-84466da6.js');
|
17
17
|
require('./filter-item-type.enum-a7ffdaa6.js');
|
18
18
|
require('./form-config-fetcher-df043d3d.js');
|
19
19
|
const taskbarElements = require('./taskbar-elements-39949c7a.js');
|
20
20
|
const constants = require('./constants-35ddd366.js');
|
21
|
-
const snkGuidesViewer = require('./snk-guides-viewer-
|
21
|
+
const snkGuidesViewer = require('./snk-guides-viewer-88a7f880.js');
|
22
22
|
const SnkMessageBuilder = require('./SnkMessageBuilder-7293d0ad.js');
|
23
23
|
require('./ConfigStorage-8009ecb2.js');
|
24
24
|
require('./PrintUtils-bcaeb82f.js');
|
@@ -13,7 +13,7 @@ const index$1 = require('./index-0e663819.js');
|
|
13
13
|
require('./ISave-d68ce3cd.js');
|
14
14
|
require('@sankhyalabs/ezui/dist/collection/utils/constants');
|
15
15
|
require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
|
16
|
-
require('./dataunit-fetcher-
|
16
|
+
require('./dataunit-fetcher-d839c5d7.js');
|
17
17
|
require('./PreloadManager-84466da6.js');
|
18
18
|
require('./filter-item-type.enum-a7ffdaa6.js');
|
19
19
|
require('./form-config-fetcher-df043d3d.js');
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
const snkGuidesViewer = require('./snk-guides-viewer-
|
5
|
+
const snkGuidesViewer = require('./snk-guides-viewer-88a7f880.js');
|
6
6
|
require('./index-f9e81701.js');
|
7
7
|
require('@sankhyalabs/core');
|
8
8
|
require('./SnkFormConfigManager-7d850fbc.js');
|
@@ -21,7 +21,7 @@ require('./constants-35ddd366.js');
|
|
21
21
|
require('./pesquisa-fetcher-ef050a47.js');
|
22
22
|
require('./ISave-d68ce3cd.js');
|
23
23
|
require('@sankhyalabs/ezui/dist/collection/utils/constants');
|
24
|
-
require('./dataunit-fetcher-
|
24
|
+
require('./dataunit-fetcher-d839c5d7.js');
|
25
25
|
require('./PreloadManager-84466da6.js');
|
26
26
|
require('@sankhyalabs/ezui/dist/collection/components/ez-grid/utils');
|
27
27
|
require('./ResourceIDUtils-5ff86aa7.js');
|
@@ -12,7 +12,7 @@ const index$1 = require('./index-0e663819.js');
|
|
12
12
|
require('./ISave-d68ce3cd.js');
|
13
13
|
require('@sankhyalabs/ezui/dist/collection/utils/constants');
|
14
14
|
require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
|
15
|
-
const dataunitFetcher = require('./dataunit-fetcher-
|
15
|
+
const dataunitFetcher = require('./dataunit-fetcher-d839c5d7.js');
|
16
16
|
require('./PreloadManager-84466da6.js');
|
17
17
|
require('./filter-item-type.enum-a7ffdaa6.js');
|
18
18
|
require('./form-config-fetcher-df043d3d.js');
|
@@ -278,7 +278,7 @@ export class SnkCrud {
|
|
278
278
|
return;
|
279
279
|
}
|
280
280
|
this._snkDataUnit.ignoreSaveMessage = this._currentViewMode === VIEW_MODE.GRID;
|
281
|
-
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, "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, selectionToastConfig: this.selectionToastConfig, useEnterLikeTab: this.useEnterLikeTab, canEdit: this._canEdit, resourceID: this._resourceID }, 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, resourceID: this._resourceID, detailTaskbarCustomContainerId: this.customContainerId }, 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" }))));
|
281
|
+
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, "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 }, 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 }, 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" }))));
|
282
282
|
}
|
283
283
|
static get is() { return "snk-crud"; }
|
284
284
|
static get encapsulation() { return "scoped"; }
|
@@ -171,6 +171,19 @@ export default class DataUnitFetcher {
|
|
171
171
|
});
|
172
172
|
});
|
173
173
|
}
|
174
|
+
addTransientProperties(dataUnit, updatingFields) {
|
175
|
+
const loaderProps = dataUnit.getGlobalLoaderProps();
|
176
|
+
if (loaderProps == undefined || loaderProps.size === 0) {
|
177
|
+
return updatingFields;
|
178
|
+
}
|
179
|
+
if (updatingFields == undefined) {
|
180
|
+
updatingFields = {};
|
181
|
+
}
|
182
|
+
Array.from(loaderProps.entries()).forEach(([name, value]) => {
|
183
|
+
updatingFields[`transient.${name}`] = value;
|
184
|
+
});
|
185
|
+
return updatingFields;
|
186
|
+
}
|
174
187
|
saveData(dataUnit, duChanges) {
|
175
188
|
const updatedRecordsIds = [];
|
176
189
|
const addedRecordsIds = [];
|
@@ -179,7 +192,7 @@ export default class DataUnitFetcher {
|
|
179
192
|
const dataUnitInstance = DataUnitStorage.get(changeDU);
|
180
193
|
let parsedUpdatingFields;
|
181
194
|
if (updatingFields) {
|
182
|
-
parsedUpdatingFields = Object.entries(updatingFields).map(([fieldName, value]) => {
|
195
|
+
parsedUpdatingFields = Object.entries(this.addTransientProperties(dataUnit, updatingFields)).map(([fieldName, value]) => {
|
183
196
|
const descriptor = dataUnitInstance.getField(fieldName);
|
184
197
|
const dataType = descriptor ? descriptor.dataType : DataType.TEXT;
|
185
198
|
return { fieldName, dataType, value: dataUnitInstance.valueToString(fieldName, value) };
|
package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js
CHANGED
@@ -87,7 +87,7 @@ export class DatasetStrategy {
|
|
87
87
|
tryJoinedFields: true,
|
88
88
|
parallelLoader: useParallelLoader,
|
89
89
|
crudListener: `br.com.sankhya.bff.${this.getModuleName()}.BFFDataUnitDatasetAdapter`,
|
90
|
-
txProperties: this.getTxProperties(
|
90
|
+
txProperties: this.getTxProperties(dataUnit, request, sorting),
|
91
91
|
useDefaultRowsLimit: false
|
92
92
|
}
|
93
93
|
};
|
@@ -98,10 +98,10 @@ export class DatasetStrategy {
|
|
98
98
|
const moduleName = app.getModuleName();
|
99
99
|
return moduleName.replace("-bff", "");
|
100
100
|
}
|
101
|
-
getTxProperties(
|
101
|
+
getTxProperties(dataUnit, request, sorting) {
|
102
102
|
var _a, _b;
|
103
103
|
const txProperties = {
|
104
|
-
"__DATA_UNIT_ADAPTER__[dataUnitName]":
|
104
|
+
"__DATA_UNIT_ADAPTER__[dataUnitName]": dataUnit.name
|
105
105
|
};
|
106
106
|
const serverSideFilters = (_b = (_a = request.filters) === null || _a === void 0 ? void 0 : _a.filter(filter => !filter.name.startsWith("FILTRO_COLUNA_"))) !== null && _b !== void 0 ? _b : [];
|
107
107
|
if (serverSideFilters.length !== 0) {
|
@@ -113,6 +113,13 @@ export class DatasetStrategy {
|
|
113
113
|
if (request.parentRecordId != undefined) {
|
114
114
|
txProperties["__DATA_UNIT_ADAPTER__[parentRecordId]"] = request.parentRecordId;
|
115
115
|
}
|
116
|
+
const loaderProps = dataUnit.getGlobalLoaderProps();
|
117
|
+
if (loaderProps == undefined || loaderProps.size === 0) {
|
118
|
+
return txProperties;
|
119
|
+
}
|
120
|
+
Array.from(loaderProps.entries()).forEach(([name, value]) => {
|
121
|
+
txProperties[name] = value;
|
122
|
+
});
|
116
123
|
return txProperties;
|
117
124
|
}
|
118
125
|
processRecords(dataUnit, fields, responseRecords) {
|
@@ -612,7 +612,7 @@ class DatasetStrategy {
|
|
612
612
|
tryJoinedFields: true,
|
613
613
|
parallelLoader: useParallelLoader,
|
614
614
|
crudListener: `br.com.sankhya.bff.${this.getModuleName()}.BFFDataUnitDatasetAdapter`,
|
615
|
-
txProperties: this.getTxProperties(
|
615
|
+
txProperties: this.getTxProperties(dataUnit, request, sorting),
|
616
616
|
useDefaultRowsLimit: false
|
617
617
|
}
|
618
618
|
};
|
@@ -623,10 +623,10 @@ class DatasetStrategy {
|
|
623
623
|
const moduleName = app.getModuleName();
|
624
624
|
return moduleName.replace("-bff", "");
|
625
625
|
}
|
626
|
-
getTxProperties(
|
626
|
+
getTxProperties(dataUnit, request, sorting) {
|
627
627
|
var _a, _b;
|
628
628
|
const txProperties = {
|
629
|
-
"__DATA_UNIT_ADAPTER__[dataUnitName]":
|
629
|
+
"__DATA_UNIT_ADAPTER__[dataUnitName]": dataUnit.name
|
630
630
|
};
|
631
631
|
const serverSideFilters = (_b = (_a = request.filters) === null || _a === void 0 ? void 0 : _a.filter(filter => !filter.name.startsWith("FILTRO_COLUNA_"))) !== null && _b !== void 0 ? _b : [];
|
632
632
|
if (serverSideFilters.length !== 0) {
|
@@ -638,6 +638,13 @@ class DatasetStrategy {
|
|
638
638
|
if (request.parentRecordId != undefined) {
|
639
639
|
txProperties["__DATA_UNIT_ADAPTER__[parentRecordId]"] = request.parentRecordId;
|
640
640
|
}
|
641
|
+
const loaderProps = dataUnit.getGlobalLoaderProps();
|
642
|
+
if (loaderProps == undefined || loaderProps.size === 0) {
|
643
|
+
return txProperties;
|
644
|
+
}
|
645
|
+
Array.from(loaderProps.entries()).forEach(([name, value]) => {
|
646
|
+
txProperties[name] = value;
|
647
|
+
});
|
641
648
|
return txProperties;
|
642
649
|
}
|
643
650
|
processRecords(dataUnit, fields, responseRecords) {
|
@@ -967,6 +974,19 @@ class DataUnitFetcher {
|
|
967
974
|
});
|
968
975
|
});
|
969
976
|
}
|
977
|
+
addTransientProperties(dataUnit, updatingFields) {
|
978
|
+
const loaderProps = dataUnit.getGlobalLoaderProps();
|
979
|
+
if (loaderProps == undefined || loaderProps.size === 0) {
|
980
|
+
return updatingFields;
|
981
|
+
}
|
982
|
+
if (updatingFields == undefined) {
|
983
|
+
updatingFields = {};
|
984
|
+
}
|
985
|
+
Array.from(loaderProps.entries()).forEach(([name, value]) => {
|
986
|
+
updatingFields[`transient.${name}`] = value;
|
987
|
+
});
|
988
|
+
return updatingFields;
|
989
|
+
}
|
970
990
|
saveData(dataUnit, duChanges) {
|
971
991
|
const updatedRecordsIds = [];
|
972
992
|
const addedRecordsIds = [];
|
@@ -975,7 +995,7 @@ class DataUnitFetcher {
|
|
975
995
|
const dataUnitInstance = DataUnitStorage.get(changeDU);
|
976
996
|
let parsedUpdatingFields;
|
977
997
|
if (updatingFields) {
|
978
|
-
parsedUpdatingFields = Object.entries(updatingFields).map(([fieldName, value]) => {
|
998
|
+
parsedUpdatingFields = Object.entries(this.addTransientProperties(dataUnit, updatingFields)).map(([fieldName, value]) => {
|
979
999
|
const descriptor = dataUnitInstance.getField(fieldName);
|
980
1000
|
const dataType = descriptor ? descriptor.dataType : DataType.TEXT;
|
981
1001
|
return { fieldName, dataType, value: dataUnitInstance.valueToString(fieldName, value) };
|
@@ -316,7 +316,7 @@ const SnkCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
316
316
|
return;
|
317
317
|
}
|
318
318
|
this._snkDataUnit.ignoreSaveMessage = this._currentViewMode === VIEW_MODE.GRID;
|
319
|
-
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, "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, selectionToastConfig: this.selectionToastConfig, useEnterLikeTab: this.useEnterLikeTab, canEdit: this._canEdit, resourceID: this._resourceID }, 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, resourceID: this._resourceID, detailTaskbarCustomContainerId: this.customContainerId }, 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" }))));
|
319
|
+
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, "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 }, 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 }, 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" }))));
|
320
320
|
}
|
321
321
|
get _element() { return this; }
|
322
322
|
static get watchers() { return {
|
@@ -234,7 +234,7 @@ class DatasetStrategy {
|
|
234
234
|
tryJoinedFields: true,
|
235
235
|
parallelLoader: useParallelLoader,
|
236
236
|
crudListener: `br.com.sankhya.bff.${this.getModuleName()}.BFFDataUnitDatasetAdapter`,
|
237
|
-
txProperties: this.getTxProperties(
|
237
|
+
txProperties: this.getTxProperties(dataUnit, request, sorting),
|
238
238
|
useDefaultRowsLimit: false
|
239
239
|
}
|
240
240
|
};
|
@@ -245,10 +245,10 @@ class DatasetStrategy {
|
|
245
245
|
const moduleName = app.getModuleName();
|
246
246
|
return moduleName.replace("-bff", "");
|
247
247
|
}
|
248
|
-
getTxProperties(
|
248
|
+
getTxProperties(dataUnit, request, sorting) {
|
249
249
|
var _a, _b;
|
250
250
|
const txProperties = {
|
251
|
-
"__DATA_UNIT_ADAPTER__[dataUnitName]":
|
251
|
+
"__DATA_UNIT_ADAPTER__[dataUnitName]": dataUnit.name
|
252
252
|
};
|
253
253
|
const serverSideFilters = (_b = (_a = request.filters) === null || _a === void 0 ? void 0 : _a.filter(filter => !filter.name.startsWith("FILTRO_COLUNA_"))) !== null && _b !== void 0 ? _b : [];
|
254
254
|
if (serverSideFilters.length !== 0) {
|
@@ -260,6 +260,13 @@ class DatasetStrategy {
|
|
260
260
|
if (request.parentRecordId != undefined) {
|
261
261
|
txProperties["__DATA_UNIT_ADAPTER__[parentRecordId]"] = request.parentRecordId;
|
262
262
|
}
|
263
|
+
const loaderProps = dataUnit.getGlobalLoaderProps();
|
264
|
+
if (loaderProps == undefined || loaderProps.size === 0) {
|
265
|
+
return txProperties;
|
266
|
+
}
|
267
|
+
Array.from(loaderProps.entries()).forEach(([name, value]) => {
|
268
|
+
txProperties[name] = value;
|
269
|
+
});
|
263
270
|
return txProperties;
|
264
271
|
}
|
265
272
|
processRecords(dataUnit, fields, responseRecords) {
|
@@ -589,6 +596,19 @@ class DataUnitFetcher {
|
|
589
596
|
});
|
590
597
|
});
|
591
598
|
}
|
599
|
+
addTransientProperties(dataUnit, updatingFields) {
|
600
|
+
const loaderProps = dataUnit.getGlobalLoaderProps();
|
601
|
+
if (loaderProps == undefined || loaderProps.size === 0) {
|
602
|
+
return updatingFields;
|
603
|
+
}
|
604
|
+
if (updatingFields == undefined) {
|
605
|
+
updatingFields = {};
|
606
|
+
}
|
607
|
+
Array.from(loaderProps.entries()).forEach(([name, value]) => {
|
608
|
+
updatingFields[`transient.${name}`] = value;
|
609
|
+
});
|
610
|
+
return updatingFields;
|
611
|
+
}
|
592
612
|
saveData(dataUnit, duChanges) {
|
593
613
|
const updatedRecordsIds = [];
|
594
614
|
const addedRecordsIds = [];
|
@@ -597,7 +617,7 @@ class DataUnitFetcher {
|
|
597
617
|
const dataUnitInstance = DataUnitStorage.get(changeDU);
|
598
618
|
let parsedUpdatingFields;
|
599
619
|
if (updatingFields) {
|
600
|
-
parsedUpdatingFields = Object.entries(updatingFields).map(([fieldName, value]) => {
|
620
|
+
parsedUpdatingFields = Object.entries(this.addTransientProperties(dataUnit, updatingFields)).map(([fieldName, value]) => {
|
601
621
|
const descriptor = dataUnitInstance.getField(fieldName);
|
602
622
|
const dataType = descriptor ? descriptor.dataType : DataType.TEXT;
|
603
623
|
return { fieldName, dataType, value: dataUnitInstance.valueToString(fieldName, value) };
|
@@ -7,7 +7,7 @@ import './index-1564817d.js';
|
|
7
7
|
import './ISave-4412b20c.js';
|
8
8
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
9
9
|
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
10
|
-
import './dataunit-fetcher-
|
10
|
+
import './dataunit-fetcher-cf01a8f4.js';
|
11
11
|
import './PreloadManager-c1c2f2b4.js';
|
12
12
|
import './filter-item-type.enum-d45e026f.js';
|
13
13
|
import './form-config-fetcher-36219cd3.js';
|
@@ -4,7 +4,7 @@ import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
|
|
4
4
|
import { C as ConfigStorage } from './ConfigStorage-1244b8b0.js';
|
5
5
|
import { d as dist, D as DataFetcher, U as UrlUtils } from './DataFetcher-aa159c5a.js';
|
6
6
|
import { A as AutorizationType, a as AuthFetcher } from './auth-fetcher-c05dc474.js';
|
7
|
-
import { D as DataUnitFetcher } from './dataunit-fetcher-
|
7
|
+
import { D as DataUnitFetcher } from './dataunit-fetcher-cf01a8f4.js';
|
8
8
|
import { P as PesquisaFetcher } from './pesquisa-fetcher-dd3ca0a5.js';
|
9
9
|
import { S as SnkMessageBuilder } from './SnkMessageBuilder-ca843d1b.js';
|
10
10
|
import './form-config-fetcher-36219cd3.js';
|
@@ -3,7 +3,7 @@ import { ApplicationContext, DataType, Action } from '@sankhyalabs/core';
|
|
3
3
|
import { D as DataFetcher } from './DataFetcher-aa159c5a.js';
|
4
4
|
import { S as SaveErrorsEnum } from './ISave-4412b20c.js';
|
5
5
|
import { d as VIEW_MODE } from './constants-8457af36.js';
|
6
|
-
import { D as DataUnitFetcher } from './dataunit-fetcher-
|
6
|
+
import { D as DataUnitFetcher } from './dataunit-fetcher-cf01a8f4.js';
|
7
7
|
import { P as PreloadManager } from './PreloadManager-c1c2f2b4.js';
|
8
8
|
import { T as TaskbarElement } from './taskbar-elements-0a6b8b95.js';
|
9
9
|
import './PrintUtils-3e4ff0f5.js';
|
@@ -7,7 +7,7 @@ import { P as PresentationMode } from './index-1564817d.js';
|
|
7
7
|
import './ISave-4412b20c.js';
|
8
8
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
9
9
|
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
10
|
-
import './dataunit-fetcher-
|
10
|
+
import './dataunit-fetcher-cf01a8f4.js';
|
11
11
|
import './PreloadManager-c1c2f2b4.js';
|
12
12
|
import './filter-item-type.enum-d45e026f.js';
|
13
13
|
import './form-config-fetcher-36219cd3.js';
|
@@ -294,7 +294,7 @@ const SnkCrud = class {
|
|
294
294
|
return;
|
295
295
|
}
|
296
296
|
this._snkDataUnit.ignoreSaveMessage = this._currentViewMode === VIEW_MODE.GRID;
|
297
|
-
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, "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, selectionToastConfig: this.selectionToastConfig, useEnterLikeTab: this.useEnterLikeTab, canEdit: this._canEdit, resourceID: this._resourceID }, 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, resourceID: this._resourceID, detailTaskbarCustomContainerId: this.customContainerId }, 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" }))));
|
297
|
+
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, "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 }, 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 }, 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" }))));
|
298
298
|
}
|
299
299
|
get _element() { return getElement(this); }
|
300
300
|
static get watchers() { return {
|
@@ -8,13 +8,13 @@ import { P as PresentationMode } from './index-1564817d.js';
|
|
8
8
|
import './ISave-4412b20c.js';
|
9
9
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
10
10
|
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
11
|
-
import './dataunit-fetcher-
|
11
|
+
import './dataunit-fetcher-cf01a8f4.js';
|
12
12
|
import './PreloadManager-c1c2f2b4.js';
|
13
13
|
import './filter-item-type.enum-d45e026f.js';
|
14
14
|
import './form-config-fetcher-36219cd3.js';
|
15
15
|
import { T as TaskbarElement } from './taskbar-elements-0a6b8b95.js';
|
16
16
|
import { d as VIEW_MODE } from './constants-8457af36.js';
|
17
|
-
import { S as SnkGuidesViewer } from './snk-guides-viewer-
|
17
|
+
import { S as SnkGuidesViewer } from './snk-guides-viewer-fde509bf.js';
|
18
18
|
import { S as SnkMessageBuilder } from './SnkMessageBuilder-ca843d1b.js';
|
19
19
|
import './ConfigStorage-1244b8b0.js';
|
20
20
|
import './PrintUtils-3e4ff0f5.js';
|
@@ -11,7 +11,7 @@ import { P as PresentationMode } from './index-1564817d.js';
|
|
11
11
|
import './ISave-4412b20c.js';
|
12
12
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
13
13
|
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
14
|
-
import './dataunit-fetcher-
|
14
|
+
import './dataunit-fetcher-cf01a8f4.js';
|
15
15
|
import './PreloadManager-c1c2f2b4.js';
|
16
16
|
import './filter-item-type.enum-d45e026f.js';
|
17
17
|
import './form-config-fetcher-36219cd3.js';
|
@@ -1,4 +1,4 @@
|
|
1
|
-
export { S as snk_guides_viewer } from './snk-guides-viewer-
|
1
|
+
export { S as snk_guides_viewer } from './snk-guides-viewer-fde509bf.js';
|
2
2
|
import './index-a7d3d3f1.js';
|
3
3
|
import '@sankhyalabs/core';
|
4
4
|
import './SnkFormConfigManager-9be0e7d4.js';
|
@@ -17,7 +17,7 @@ import './constants-8457af36.js';
|
|
17
17
|
import './pesquisa-fetcher-dd3ca0a5.js';
|
18
18
|
import './ISave-4412b20c.js';
|
19
19
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
20
|
-
import './dataunit-fetcher-
|
20
|
+
import './dataunit-fetcher-cf01a8f4.js';
|
21
21
|
import './PreloadManager-c1c2f2b4.js';
|
22
22
|
import '@sankhyalabs/ezui/dist/collection/components/ez-grid/utils';
|
23
23
|
import './ResourceIDUtils-a114189a.js';
|
@@ -8,7 +8,7 @@ import { P as PresentationMode } from './index-1564817d.js';
|
|
8
8
|
import './ISave-4412b20c.js';
|
9
9
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
10
10
|
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
11
|
-
import { I as InMemoryLoader } from './dataunit-fetcher-
|
11
|
+
import { I as InMemoryLoader } from './dataunit-fetcher-cf01a8f4.js';
|
12
12
|
import './PreloadManager-c1c2f2b4.js';
|
13
13
|
import './filter-item-type.enum-d45e026f.js';
|
14
14
|
import './form-config-fetcher-36219cd3.js';
|
@@ -1 +1 @@
|
|
1
|
-
import{r as i,c as t,h as s,g as e}from"./p-d2d301a6.js";import{ObjectUtils as a,ApplicationContext as n,DataType as o,UserInterface as r,JSUtils as l,FloatingManager as h}from"@sankhyalabs/core";import{d,S as u}from"./p-b0ef4383.js";import{T as m}from"./p-c9841939.js";import"./p-9695f78b.js";import"./p-d9bb09b3.js";import{P as c}from"./p-5534e08c.js";import"./p-9e7d65a4.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import{I as p}from"./p-0648947b.js";import"./p-c22c1d8e.js";import"./p-ff1990ad.js";import"./p-0d7863ed.js";import{T as v,b}from"./p-3ecd72a4.js";import{S as k}from"./p-094c30cb.js";import"./p-6dc031de.js";import"./p-8d884fab.js";import"./p-688dcb4c.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource";const f=class{constructor(s){i(this,s),this.dataStateChange=t(this,"dataStateChange",3),this.dataUnitReady=t(this,"dataUnitReady",3),this.actionClick=t(this,"actionClick",7),this.formItemsReady=t(this,"formItemsReady",7),this.REGULAR_DEFAULT_BTNS=["INSERT","REFRESH","PREVIOUS","NEXT","DIVIDER","MORE_OPTIONS"],this.REGULAR_SELECTED_BTNS=["INSERT","REFRESH","PREVIOUS","NEXT","DIVIDER","CLONE","REMOVE","DIVIDER","MORE_OPTIONS"],this._multiSelectionListDataSource=new k,this._keyDownHandler=i=>this.keyDownListener(i),this._taskbarProcessor=new v({"snkSimpleCrudTaskbar.form_regular":this.resolveInMemoryBtns(this.REGULAR_DEFAULT_BTNS).concat(m.GRID_MODE),"snkSimpleCrudTaskbar.grid_regular":this.resolveInMemoryBtns(this.REGULAR_DEFAULT_BTNS).concat(m.FORM_MODE),"snkSimpleCrudTaskbar.form_selected":this.resolveInMemoryBtns(this.REGULAR_SELECTED_BTNS).concat(m.GRID_MODE),"snkSimpleCrudTaskbar.grid_selected":this.resolveInMemoryBtns(this.REGULAR_SELECTED_BTNS).concat(m.FORM_MODE),"snkSimpleCrudTaskbar.finish_edition":["CANCEL","SAVE"]}),this._currentViewMode=d.GRID,this._config=void 0,this._fieldToGetFocus=void 0,this.dataState=void 0,this.dataUnit=void 0,this.mode=u.SERVER,this.gridConfig=void 0,this.formConfig=void 0,this._formFields=[],this.multipleSelection=void 0,this.useCancelConfirm=!0,this.taskbarManager=void 0,this.messagesBuilder=void 0,this.useEnterLikeTab=!1}resolveInMemoryBtns(i){const t=[...i];return this.mode===u.IN_MEMORY&&t.splice(1,1),t}async goToView(i){this._currentViewMode=i,this._viewStack&&this._viewStack.show(i)}actionClickListener(i){const t=i.detail;t===m.GRID_MODE?this.goToView(d.GRID):t===m.FORM_MODE&&this.goToView(d.FORM),i.stopPropagation()}onModeChange(){this.mode==u.IN_MEMORY&&this.initInMemoryDataUnit()}observeDataState(i,t){a.objectToString(t)!=a.objectToString(i)&&this.dataStateChange.emit(i)}componentWillRender(){this._taskbarProcessor.process(this.getTaskBarId(),this.taskbarManager,this.dataState,this.getTaskBarDisabledButtons())}componentWillLoad(){this.processMetadata(),this.onModeChange(),this.configDatasource()}configDatasource(){const i=n.getContextValue("__SNK__APPLICATION__");this._multiSelectionListDataSource.setApplication(i),this._multiSelectionListDataSource.setDataUnit(this.dataUnit)}getTaskBarId(){var i,t,s;return(null===(i=this.dataState)||void 0===i?void 0:i.isDirty)?"snkSimpleCrudTaskbar.finish_edition":(null===(t=this.dataState)||void 0===t?void 0:t.selectionInfo)&&!this.dataState.selectionInfo.isAllRecords()&&(null===(s=this.dataState.selectionInfo.records)||void 0===s?void 0:s.length)>0?this._currentViewMode===d.GRID?"snkSimpleCrudTaskbar.grid_selected":"snkSimpleCrudTaskbar.form_selected":this._currentViewMode===d.GRID?"snkSimpleCrudTaskbar.grid_regular":"snkSimpleCrudTaskbar.form_regular"}initInMemoryDataUnit(){this._inMemoryLoader=new p(this._metadata),this.dataUnit=this._inMemoryLoader.dataUnit,this.dataUnitReady.emit(this.dataUnit)}setMetadata(i){return this._inMemoryLoader?this._inMemoryLoader.metadata=i:this.dataUnit&&(this.dataUnit.metadata=i),Promise.resolve()}setRecords(i){return this._inMemoryLoader?this._inMemoryLoader.records=i:this.dataUnit&&(this.dataUnit.records=i),Promise.resolve()}getRecords(){return Promise.resolve(this.dataUnit.records)}processMetadata(){const i=this._element.querySelectorAll("snk-field-metadata"),t=[],s={fields:[],emptyConfig:!1};i.forEach((i=>{const e={name:i.getAttribute("name")||i.getAttribute("label"),label:i.getAttribute("label"),dataType:o[i.getAttribute("dataType")]||o.TEXT,userInterface:r[i.getAttribute("userInterface")]||r.SHORTTEXT,readOnly:"true"==i.getAttribute("readOnly"),required:"true"==i.getAttribute("required"),tab:i.getAttribute("tab")||void 0,visible:"false"!=i.getAttribute("visible")};s.fields.push({name:e.name,tab:e.tab,visible:e.visible}),t.push(e)})),t.length>0&&(this.formConfig||(this.formConfig=s),this._metadata={name:"SimpleCrud",label:"SimpleCrud",fields:t})}onDataStateChange(i){this.dataState=Object.assign({},i.detail)}getTaskBarDisabledButtons(){var i,t,s,e;const a=[];return(null===(i=this.dataState)||void 0===i?void 0:i.hasNext)||a.push(m.NEXT),(null===(t=this.dataState)||void 0===t?void 0:t.hasPrevious)||a.push(m.PREVIOUS),(null===(e=null===(s=this.dataState)||void 0===s?void 0:s.selectionInfo)||void 0===e?void 0:e.isEmpty())&&a.push(m.FORM_MODE),a}handleCancelEdit(){var i;(null===(i=this.dataState)||void 0===i?void 0:i.recordsIsEmpty)&&(this.goToView(d.GRID),this.dataUnit.clearSelection())}getColumnSearch(i,t){return null!=this._columnSearch||(i.addEventListener("ezPopoverOpen",(()=>{this._columnSearch&&(this._columnSearch.i.value=null)})),this._moreOptions=i,this._columnSearch=b(t,(({argument:i})=>new Promise((t=>{this._grid.filterColumns(i).then((i=>{t(i.filter((i=>!i.hidden)).map((i=>({label:i.label,value:i.name}))))}))}))),(t=>{null!=t&&(this._grid.locateColumn(t.value),i.hideActions())}))),this._columnSearch}onSelectField(i,t){null!=i&&(this._fieldToGetFocus=i.value,t.hideActions())}getFieldSearch(i,t){return null!=this._fieldSearch||(this._moreOptions=i,i.addEventListener("ezPopoverOpen",(()=>this.findField())),this._fieldSearch=b(t,(({argument:i})=>this.fieldsOptionLoader(i)),(t=>this.onSelectField(t,i)))),this._fieldSearch}getFormFields(){var i,t;return null!==(t=null===(i=this.formConfig)||void 0===i?void 0:i.fields)&&void 0!==t?t:this._formFields}handleFormSetFields(i){this._formFields=null!=i?i:[]}fieldsOptionLoader(i){const t=null==i?void 0:i.toLowerCase(),s=this.getFormFields().map((i=>{var t;return null===(t=this.dataUnit)||void 0===t?void 0:t.getField(i.name)})).filter((i=>{var s,e;return(null===(s=i.name)||void 0===s?void 0:s.toLowerCase().includes(t))||(null===(e=i.label)||void 0===e?void 0:e.toLowerCase().includes(t))})).map((i=>({value:i.name,label:i.label})));return Promise.resolve(s)}getActionsList(){var i,t;return[{value:"",label:null!==(t=null===(i=this.messagesBuilder)||void 0===i?void 0:i.getMessage("snkSimpleCrud.findColumn",void 0))&&void 0!==t?t:"Buscar",itemBuilder:(i,t)=>this._currentViewMode===d.GRID?this.getColumnSearch(i,t):this.getFieldSearch(i,t)}]}keyDownListener(i){i.ctrlKey&&null!=i.key&&"F"===i.key.toUpperCase()&&null!=this._element&&(l.isHiddenElement(this._element)||(h.closeAll(),this._currentViewMode===d.GRID?this.findColumn():this.findField(),i.preventDefault()))}async findField(){if(this._moreOptions)if(await this._moreOptions.isOpened()){if(this._fieldSearch){const i=this._fieldSearch.i;i.value=null,requestAnimationFrame((()=>i.setFocus()))}}else this._moreOptions.showActions()}async findColumn(){if(this._moreOptions&&(await this._moreOptions.isOpened()||this._moreOptions.showActions(),this._columnSearch)){const i=this._columnSearch.i;i.value=null,requestAnimationFrame((()=>i.setFocus()))}}clearFieldToFocusHandler(){this._fieldToGetFocus=void 0}connectedCallback(){window.addEventListener("keydown",this._keyDownHandler,{capture:!0})}disconnectedCallback(){window.removeEventListener("keydown",this._keyDownHandler)}render(){var i;return s("snk-data-unit",{class:"simple-crud__container",dataUnit:this.dataUnit,useCancelConfirm:this.useCancelConfirm,onDataStateChange:i=>this.onDataStateChange(i),onCancelEdition:this.handleCancelEdit.bind(this),onInsertionMode:()=>this.goToView(d.FORM),onDataUnitReady:i=>this.dataUnitReady.emit(i.detail),ignoreSaveMessage:this._currentViewMode===d.GRID,onMessagesBuilderUpdated:i=>this.messagesBuilder=i.detail},s("header",null,s("slot",{name:"snkSimpleCrudHeader"})),s("section",{class:"ez-box ez-box--shadow simple-crud__container-section"},s("snk-taskbar",{class:"ez-box ez-box--shadow ez-padding--medium ez-margin-bottom--large",dataUnit:this.dataUnit,primaryButton:(null===(i=this.dataState)||void 0===i?void 0:i.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,slot:"leftButtons",presentationMode:c.SECONDARY},s("slot",{name:"TASKBAR_CUSTOM_ELEMENTS"})),s("ez-view-stack",{ref:i=>this._viewStack=i,"data-element-id":"simple-crud"},s("stack-item",null,s("ez-grid",{ref:i=>this._grid=i,dataUnit:this.dataUnit,config:this.gridConfig,"no-header":!0,multipleSelection:this.multipleSelection,onEzDoubleClick:()=>this.goToView(d.FORM),columnfilterDataSource:this.dataUnit.name.includes(p.IN_MEMORY_DATA_UNIT_NAME)?void 0:this._multiSelectionListDataSource,useEnterLikeTab:this.useEnterLikeTab},s("div",{slot:"footer"},s("slot",{name:"snkSimpleCrudFooter"})))),s("stack-item",null,s("ez-form",{dataUnit:this.dataUnit,config:this.formConfig,fieldToFocus:this._fieldToGetFocus,onEzFormSetFields:i=>this.handleFormSetFields(i.detail),onEzFormRequestClearFieldToFocus:this.clearFieldToFocusHandler.bind(this)})))))}get _element(){return e(this)}static get watchers(){return{mode:["onModeChange"],dataState:["observeDataState"]}}};f.style=".sc-snk-simple-crud-h{display:flex;height:100%;width:100%}.simple-crud__container.sc-snk-simple-crud{display:grid;grid-template-rows:max-content;row-gap:12px;height:100%;width:100%}.simple-crud__container-section.sc-snk-simple-crud{flex-wrap:unset;flex-direction:column}ez-grid.sc-snk-simple-crud{--ez-grid__container--shadow:none;min-height:300px}ez-form.sc-snk-simple-crud{min-height:300px}";export{f as snk_simple_crud}
|
1
|
+
import{r as i,c as t,h as s,g as e}from"./p-d2d301a6.js";import{ObjectUtils as a,ApplicationContext as n,DataType as o,UserInterface as r,JSUtils as l,FloatingManager as h}from"@sankhyalabs/core";import{d,S as u}from"./p-b0ef4383.js";import{T as m}from"./p-c9841939.js";import"./p-9695f78b.js";import"./p-d9bb09b3.js";import{P as c}from"./p-5534e08c.js";import"./p-9e7d65a4.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import{I as p}from"./p-3160fa64.js";import"./p-c22c1d8e.js";import"./p-ff1990ad.js";import"./p-0d7863ed.js";import{T as v,b}from"./p-3ecd72a4.js";import{S as f}from"./p-094c30cb.js";import"./p-6dc031de.js";import"./p-8d884fab.js";import"./p-688dcb4c.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource";const k=class{constructor(s){i(this,s),this.dataStateChange=t(this,"dataStateChange",3),this.dataUnitReady=t(this,"dataUnitReady",3),this.actionClick=t(this,"actionClick",7),this.formItemsReady=t(this,"formItemsReady",7),this.REGULAR_DEFAULT_BTNS=["INSERT","REFRESH","PREVIOUS","NEXT","DIVIDER","MORE_OPTIONS"],this.REGULAR_SELECTED_BTNS=["INSERT","REFRESH","PREVIOUS","NEXT","DIVIDER","CLONE","REMOVE","DIVIDER","MORE_OPTIONS"],this._multiSelectionListDataSource=new f,this._keyDownHandler=i=>this.keyDownListener(i),this._taskbarProcessor=new v({"snkSimpleCrudTaskbar.form_regular":this.resolveInMemoryBtns(this.REGULAR_DEFAULT_BTNS).concat(m.GRID_MODE),"snkSimpleCrudTaskbar.grid_regular":this.resolveInMemoryBtns(this.REGULAR_DEFAULT_BTNS).concat(m.FORM_MODE),"snkSimpleCrudTaskbar.form_selected":this.resolveInMemoryBtns(this.REGULAR_SELECTED_BTNS).concat(m.GRID_MODE),"snkSimpleCrudTaskbar.grid_selected":this.resolveInMemoryBtns(this.REGULAR_SELECTED_BTNS).concat(m.FORM_MODE),"snkSimpleCrudTaskbar.finish_edition":["CANCEL","SAVE"]}),this._currentViewMode=d.GRID,this._config=void 0,this._fieldToGetFocus=void 0,this.dataState=void 0,this.dataUnit=void 0,this.mode=u.SERVER,this.gridConfig=void 0,this.formConfig=void 0,this._formFields=[],this.multipleSelection=void 0,this.useCancelConfirm=!0,this.taskbarManager=void 0,this.messagesBuilder=void 0,this.useEnterLikeTab=!1}resolveInMemoryBtns(i){const t=[...i];return this.mode===u.IN_MEMORY&&t.splice(1,1),t}async goToView(i){this._currentViewMode=i,this._viewStack&&this._viewStack.show(i)}actionClickListener(i){const t=i.detail;t===m.GRID_MODE?this.goToView(d.GRID):t===m.FORM_MODE&&this.goToView(d.FORM),i.stopPropagation()}onModeChange(){this.mode==u.IN_MEMORY&&this.initInMemoryDataUnit()}observeDataState(i,t){a.objectToString(t)!=a.objectToString(i)&&this.dataStateChange.emit(i)}componentWillRender(){this._taskbarProcessor.process(this.getTaskBarId(),this.taskbarManager,this.dataState,this.getTaskBarDisabledButtons())}componentWillLoad(){this.processMetadata(),this.onModeChange(),this.configDatasource()}configDatasource(){const i=n.getContextValue("__SNK__APPLICATION__");this._multiSelectionListDataSource.setApplication(i),this._multiSelectionListDataSource.setDataUnit(this.dataUnit)}getTaskBarId(){var i,t,s;return(null===(i=this.dataState)||void 0===i?void 0:i.isDirty)?"snkSimpleCrudTaskbar.finish_edition":(null===(t=this.dataState)||void 0===t?void 0:t.selectionInfo)&&!this.dataState.selectionInfo.isAllRecords()&&(null===(s=this.dataState.selectionInfo.records)||void 0===s?void 0:s.length)>0?this._currentViewMode===d.GRID?"snkSimpleCrudTaskbar.grid_selected":"snkSimpleCrudTaskbar.form_selected":this._currentViewMode===d.GRID?"snkSimpleCrudTaskbar.grid_regular":"snkSimpleCrudTaskbar.form_regular"}initInMemoryDataUnit(){this._inMemoryLoader=new p(this._metadata),this.dataUnit=this._inMemoryLoader.dataUnit,this.dataUnitReady.emit(this.dataUnit)}setMetadata(i){return this._inMemoryLoader?this._inMemoryLoader.metadata=i:this.dataUnit&&(this.dataUnit.metadata=i),Promise.resolve()}setRecords(i){return this._inMemoryLoader?this._inMemoryLoader.records=i:this.dataUnit&&(this.dataUnit.records=i),Promise.resolve()}getRecords(){return Promise.resolve(this.dataUnit.records)}processMetadata(){const i=this._element.querySelectorAll("snk-field-metadata"),t=[],s={fields:[],emptyConfig:!1};i.forEach((i=>{const e={name:i.getAttribute("name")||i.getAttribute("label"),label:i.getAttribute("label"),dataType:o[i.getAttribute("dataType")]||o.TEXT,userInterface:r[i.getAttribute("userInterface")]||r.SHORTTEXT,readOnly:"true"==i.getAttribute("readOnly"),required:"true"==i.getAttribute("required"),tab:i.getAttribute("tab")||void 0,visible:"false"!=i.getAttribute("visible")};s.fields.push({name:e.name,tab:e.tab,visible:e.visible}),t.push(e)})),t.length>0&&(this.formConfig||(this.formConfig=s),this._metadata={name:"SimpleCrud",label:"SimpleCrud",fields:t})}onDataStateChange(i){this.dataState=Object.assign({},i.detail)}getTaskBarDisabledButtons(){var i,t,s,e;const a=[];return(null===(i=this.dataState)||void 0===i?void 0:i.hasNext)||a.push(m.NEXT),(null===(t=this.dataState)||void 0===t?void 0:t.hasPrevious)||a.push(m.PREVIOUS),(null===(e=null===(s=this.dataState)||void 0===s?void 0:s.selectionInfo)||void 0===e?void 0:e.isEmpty())&&a.push(m.FORM_MODE),a}handleCancelEdit(){var i;(null===(i=this.dataState)||void 0===i?void 0:i.recordsIsEmpty)&&(this.goToView(d.GRID),this.dataUnit.clearSelection())}getColumnSearch(i,t){return null!=this._columnSearch||(i.addEventListener("ezPopoverOpen",(()=>{this._columnSearch&&(this._columnSearch.i.value=null)})),this._moreOptions=i,this._columnSearch=b(t,(({argument:i})=>new Promise((t=>{this._grid.filterColumns(i).then((i=>{t(i.filter((i=>!i.hidden)).map((i=>({label:i.label,value:i.name}))))}))}))),(t=>{null!=t&&(this._grid.locateColumn(t.value),i.hideActions())}))),this._columnSearch}onSelectField(i,t){null!=i&&(this._fieldToGetFocus=i.value,t.hideActions())}getFieldSearch(i,t){return null!=this._fieldSearch||(this._moreOptions=i,i.addEventListener("ezPopoverOpen",(()=>this.findField())),this._fieldSearch=b(t,(({argument:i})=>this.fieldsOptionLoader(i)),(t=>this.onSelectField(t,i)))),this._fieldSearch}getFormFields(){var i,t;return null!==(t=null===(i=this.formConfig)||void 0===i?void 0:i.fields)&&void 0!==t?t:this._formFields}handleFormSetFields(i){this._formFields=null!=i?i:[]}fieldsOptionLoader(i){const t=null==i?void 0:i.toLowerCase(),s=this.getFormFields().map((i=>{var t;return null===(t=this.dataUnit)||void 0===t?void 0:t.getField(i.name)})).filter((i=>{var s,e;return(null===(s=i.name)||void 0===s?void 0:s.toLowerCase().includes(t))||(null===(e=i.label)||void 0===e?void 0:e.toLowerCase().includes(t))})).map((i=>({value:i.name,label:i.label})));return Promise.resolve(s)}getActionsList(){var i,t;return[{value:"",label:null!==(t=null===(i=this.messagesBuilder)||void 0===i?void 0:i.getMessage("snkSimpleCrud.findColumn",void 0))&&void 0!==t?t:"Buscar",itemBuilder:(i,t)=>this._currentViewMode===d.GRID?this.getColumnSearch(i,t):this.getFieldSearch(i,t)}]}keyDownListener(i){i.ctrlKey&&null!=i.key&&"F"===i.key.toUpperCase()&&null!=this._element&&(l.isHiddenElement(this._element)||(h.closeAll(),this._currentViewMode===d.GRID?this.findColumn():this.findField(),i.preventDefault()))}async findField(){if(this._moreOptions)if(await this._moreOptions.isOpened()){if(this._fieldSearch){const i=this._fieldSearch.i;i.value=null,requestAnimationFrame((()=>i.setFocus()))}}else this._moreOptions.showActions()}async findColumn(){if(this._moreOptions&&(await this._moreOptions.isOpened()||this._moreOptions.showActions(),this._columnSearch)){const i=this._columnSearch.i;i.value=null,requestAnimationFrame((()=>i.setFocus()))}}clearFieldToFocusHandler(){this._fieldToGetFocus=void 0}connectedCallback(){window.addEventListener("keydown",this._keyDownHandler,{capture:!0})}disconnectedCallback(){window.removeEventListener("keydown",this._keyDownHandler)}render(){var i;return s("snk-data-unit",{class:"simple-crud__container",dataUnit:this.dataUnit,useCancelConfirm:this.useCancelConfirm,onDataStateChange:i=>this.onDataStateChange(i),onCancelEdition:this.handleCancelEdit.bind(this),onInsertionMode:()=>this.goToView(d.FORM),onDataUnitReady:i=>this.dataUnitReady.emit(i.detail),ignoreSaveMessage:this._currentViewMode===d.GRID,onMessagesBuilderUpdated:i=>this.messagesBuilder=i.detail},s("header",null,s("slot",{name:"snkSimpleCrudHeader"})),s("section",{class:"ez-box ez-box--shadow simple-crud__container-section"},s("snk-taskbar",{class:"ez-box ez-box--shadow ez-padding--medium ez-margin-bottom--large",dataUnit:this.dataUnit,primaryButton:(null===(i=this.dataState)||void 0===i?void 0:i.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,slot:"leftButtons",presentationMode:c.SECONDARY},s("slot",{name:"TASKBAR_CUSTOM_ELEMENTS"})),s("ez-view-stack",{ref:i=>this._viewStack=i,"data-element-id":"simple-crud"},s("stack-item",null,s("ez-grid",{ref:i=>this._grid=i,dataUnit:this.dataUnit,config:this.gridConfig,"no-header":!0,multipleSelection:this.multipleSelection,onEzDoubleClick:()=>this.goToView(d.FORM),columnfilterDataSource:this.dataUnit.name.includes(p.IN_MEMORY_DATA_UNIT_NAME)?void 0:this._multiSelectionListDataSource,useEnterLikeTab:this.useEnterLikeTab},s("div",{slot:"footer"},s("slot",{name:"snkSimpleCrudFooter"})))),s("stack-item",null,s("ez-form",{dataUnit:this.dataUnit,config:this.formConfig,fieldToFocus:this._fieldToGetFocus,onEzFormSetFields:i=>this.handleFormSetFields(i.detail),onEzFormRequestClearFieldToFocus:this.clearFieldToFocusHandler.bind(this)})))))}get _element(){return e(this)}static get watchers(){return{mode:["onModeChange"],dataState:["observeDataState"]}}};k.style=".sc-snk-simple-crud-h{display:flex;height:100%;width:100%}.simple-crud__container.sc-snk-simple-crud{display:grid;grid-template-rows:max-content;row-gap:12px;height:100%;width:100%}.simple-crud__container-section.sc-snk-simple-crud{flex-wrap:unset;flex-direction:column}ez-grid.sc-snk-simple-crud{--ez-grid__container--shadow:none;min-height:300px}ez-form.sc-snk-simple-crud{min-height:300px}";export{k as snk_simple_crud}
|