@sankhyalabs/sankhyablocks 0.0.0-bugfix-dev-KB-74406.1 → 0.0.0-bugfix-dev-KB-83855.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/{ClientSideExporterProvider-6b781452.js → ClientSideExporterProvider-2f5f350c.js} +1 -1
- package/dist/cjs/{dataunit-fetcher-8291ac21.js → dataunit-fetcher-449d51a3.js} +11 -161
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/pesquisa-grid_2.cjs.entry.js +1 -1
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-actions-button_5.cjs.entry.js +1 -1
- package/dist/cjs/snk-application.cjs.entry.js +1 -1
- package/dist/cjs/snk-attach.cjs.entry.js +2 -2
- package/dist/cjs/snk-crud.cjs.entry.js +3 -2
- package/dist/cjs/snk-data-exporter.cjs.entry.js +2 -2
- package/dist/cjs/{snk-data-unit-d75e6220.js → snk-data-unit-bbd384bf.js} +4 -2
- package/dist/cjs/snk-data-unit.cjs.entry.js +2 -2
- package/dist/cjs/snk-detail-view.cjs.entry.js +5 -4
- package/dist/cjs/snk-grid.cjs.entry.js +2 -2
- package/dist/cjs/{snk-guides-viewer-a029ff50.js → snk-guides-viewer-495a2d2f.js} +2 -2
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +2 -2
- package/dist/cjs/snk-pesquisa.cjs.entry.js +1 -1
- package/dist/cjs/snk-simple-crud.cjs.entry.js +2 -2
- package/dist/collection/components/snk-attach/structure/fetcher/factory/attach-fetcher-data-unit.factory.js +2 -3
- package/dist/collection/components/snk-crud/snk-crud.js +26 -1
- package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.css +10 -1
- package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +25 -1
- package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +1 -1
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +3 -1
- package/dist/collection/lib/dataUnit/InMemoryLoader.js +12 -101
- package/dist/collection/lib/dataUnit/dataUnitInMemoryUtils.js +7 -53
- package/dist/components/dataunit-fetcher.js +30 -179
- package/dist/components/snk-attach2.js +3 -3
- package/dist/components/snk-crud.js +4 -2
- package/dist/components/snk-data-unit2.js +3 -1
- package/dist/components/snk-detail-view2.js +5 -3
- package/dist/esm/{ClientSideExporterProvider-ff89c7e9.js → ClientSideExporterProvider-3537805a.js} +1 -1
- package/dist/esm/{dataunit-fetcher-5247a708.js → dataunit-fetcher-91b094f2.js} +13 -162
- package/dist/esm/loader.js +1 -1
- package/dist/esm/pesquisa-grid_2.entry.js +1 -1
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-actions-button_5.entry.js +1 -1
- package/dist/esm/snk-application.entry.js +1 -1
- package/dist/esm/snk-attach.entry.js +3 -3
- package/dist/esm/snk-crud.entry.js +4 -3
- package/dist/esm/snk-data-exporter.entry.js +2 -2
- package/dist/esm/{snk-data-unit-bfd10c71.js → snk-data-unit-b03bb5cf.js} +4 -2
- package/dist/esm/snk-data-unit.entry.js +2 -2
- package/dist/esm/snk-detail-view.entry.js +5 -4
- package/dist/esm/snk-grid.entry.js +2 -2
- package/dist/esm/{snk-guides-viewer-fa45714d.js → snk-guides-viewer-cd2814a0.js} +2 -2
- package/dist/esm/snk-guides-viewer.entry.js +2 -2
- package/dist/esm/snk-pesquisa.entry.js +1 -1
- package/dist/esm/snk-simple-crud.entry.js +2 -2
- package/dist/sankhyablocks/{p-b0ff53b7.entry.js → p-13391b3d.entry.js} +1 -1
- package/dist/sankhyablocks/p-23b47a92.js +1 -0
- package/dist/sankhyablocks/p-3653374d.js +60 -0
- package/dist/sankhyablocks/{p-c82deea7.entry.js → p-389ba782.entry.js} +1 -1
- package/dist/sankhyablocks/{p-f8db6795.entry.js → p-44efbeed.entry.js} +1 -1
- package/dist/sankhyablocks/p-4d87cd45.entry.js +1 -0
- package/dist/sankhyablocks/{p-e36f89d1.entry.js → p-4fa79d68.entry.js} +1 -1
- package/dist/sankhyablocks/p-51e88546.js +1 -0
- package/dist/sankhyablocks/{p-40e323f9.js → p-5dd7f4c7.js} +1 -1
- package/dist/sankhyablocks/{p-aa1a0f3e.entry.js → p-6234bda8.entry.js} +1 -1
- package/dist/sankhyablocks/p-64230808.entry.js +1 -0
- package/dist/sankhyablocks/{p-e10faff0.entry.js → p-647f9830.entry.js} +1 -1
- package/dist/sankhyablocks/{p-172848d4.entry.js → p-8ecac412.entry.js} +1 -1
- package/dist/sankhyablocks/{p-d2d0535f.entry.js → p-ad5e4f9d.entry.js} +1 -1
- package/dist/sankhyablocks/p-ca316523.entry.js +1 -0
- package/dist/sankhyablocks/{p-700a4cc3.entry.js → p-ee53b000.entry.js} +1 -1
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-crud/snk-crud.d.ts +5 -0
- package/dist/types/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.d.ts +5 -0
- package/dist/types/components.d.ts +17 -1
- package/dist/types/lib/dataUnit/InMemoryLoader.d.ts +4 -11
- package/dist/types/lib/dataUnit/dataUnitInMemoryUtils.d.ts +3 -6
- package/dist/types/lib/dataUnit/interfaces/InMemoryLoaderConfig.d.ts +2 -2
- package/package.json +1 -1
- package/dist/sankhyablocks/p-0b00d69c.entry.js +0 -1
- package/dist/sankhyablocks/p-29d08446.entry.js +0 -1
- package/dist/sankhyablocks/p-38179225.js +0 -60
- package/dist/sankhyablocks/p-655bdd60.js +0 -1
- package/dist/sankhyablocks/p-b02e58fd.entry.js +0 -1
- package/dist/sankhyablocks/p-de9da2f2.js +0 -1
|
@@ -4,7 +4,7 @@ const index = require('./index-f9e81701.js');
|
|
|
4
4
|
const core = require('@sankhyalabs/core');
|
|
5
5
|
const utils = require('@sankhyalabs/ezui/dist/collection/utils');
|
|
6
6
|
const SnkMessageBuilder = require('./SnkMessageBuilder-bae64d0d.js');
|
|
7
|
-
const dataunitFetcher = require('./dataunit-fetcher-
|
|
7
|
+
const dataunitFetcher = require('./dataunit-fetcher-449d51a3.js');
|
|
8
8
|
const DataType = require('@sankhyalabs/core/dist/dataunit/metadata/DataType');
|
|
9
9
|
const GetSelectedRecordsIDsInfo = require('./GetSelectedRecordsIDsInfo-bd50caf1.js');
|
|
10
10
|
|
|
@@ -258,7 +258,9 @@ const SnkDataUnit = class {
|
|
|
258
258
|
return new core.DataUnitAction(core.Action.RECORDS_COPIED, this.handleRecordsCopied(action.payload));
|
|
259
259
|
}
|
|
260
260
|
async interceptDataChange(action) {
|
|
261
|
-
|
|
261
|
+
var _a;
|
|
262
|
+
const recordId = (_a = this.dataUnit.getSelectedRecord()) === null || _a === void 0 ? void 0 : _a.__record__id__;
|
|
263
|
+
if (this.isAllowed("UPDATE") || this.dataUnit.isNewRecord(recordId)) {
|
|
262
264
|
return action;
|
|
263
265
|
}
|
|
264
266
|
if (this._openedAlert) {
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const snkDataUnit = require('./snk-data-unit-
|
|
5
|
+
const snkDataUnit = require('./snk-data-unit-bbd384bf.js');
|
|
6
6
|
require('./index-f9e81701.js');
|
|
7
7
|
require('@sankhyalabs/core');
|
|
8
8
|
require('@sankhyalabs/ezui/dist/collection/utils');
|
|
9
9
|
require('./SnkMessageBuilder-bae64d0d.js');
|
|
10
|
-
require('./dataunit-fetcher-
|
|
10
|
+
require('./dataunit-fetcher-449d51a3.js');
|
|
11
11
|
require('./DataFetcher-65879b2c.js');
|
|
12
12
|
require('./PrintUtils-bcaeb82f.js');
|
|
13
13
|
require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
|
|
@@ -12,12 +12,12 @@ const index$1 = require('./index-e3e39724.js');
|
|
|
12
12
|
require('./ISave-e91b70a7.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-449d51a3.js');
|
|
16
16
|
require('./filter-item-type.enum-a7ffdaa6.js');
|
|
17
17
|
require('./form-config-fetcher-90126e4c.js');
|
|
18
18
|
const constants = require('./constants-241934b3.js');
|
|
19
19
|
const taskbarElements = require('./taskbar-elements-7e19882d.js');
|
|
20
|
-
const snkGuidesViewer = require('./snk-guides-viewer-
|
|
20
|
+
const snkGuidesViewer = require('./snk-guides-viewer-495a2d2f.js');
|
|
21
21
|
const SnkMessageBuilder = require('./SnkMessageBuilder-bae64d0d.js');
|
|
22
22
|
require('./ConfigStorage-d024aec8.js');
|
|
23
23
|
require('./PrintUtils-bcaeb82f.js');
|
|
@@ -71,7 +71,7 @@ class GuideBuilder {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
const snkDetailViewCss = ".sc-snk-detail-view-h{display:flex;row-gap:24px;flex-direction:column;width:100%;height:100%}.level-path.sc-snk-detail-view{color:var(--color--title-primary, #2B3A54);font-weight:var(--text-weight--medium, 400);padding-right:3px}.form-taskbar.sc-snk-detail-view{padding-bottom:var(--space--medium)}.grid-container.sc-snk-detail-view{background-color:#FFF;min-height:100px}.detail-header.sc-snk-detail-view{padding-bottom:0}";
|
|
74
|
+
const snkDetailViewCss = ".sc-snk-detail-view-h{display:flex;row-gap:24px;flex-direction:column;width:100%;height:100%}.level-path.sc-snk-detail-view{color:var(--color--title-primary, #2B3A54);font-weight:var(--text-weight--medium, 400);padding-right:3px}.form-taskbar.sc-snk-detail-view{padding-bottom:var(--space--medium)}.grid-container.sc-snk-detail-view{background-color:#FFF;min-height:100px;height:100%}.detail-header.sc-snk-detail-view{padding-bottom:0}snk-data-unit.sc-snk-detail-view{flex:1}snk-grid.sc-snk-detail-view{height:calc(100% - 43px)}";
|
|
75
75
|
|
|
76
76
|
const SnkDetailView = class {
|
|
77
77
|
constructor(hostRef) {
|
|
@@ -97,6 +97,7 @@ const SnkDetailView = class {
|
|
|
97
97
|
this.taskbarCustomContainerId = undefined;
|
|
98
98
|
this.customEditors = undefined;
|
|
99
99
|
this.customRenders = undefined;
|
|
100
|
+
this.presentationMode = index$1.PresentationMode.SECONDARY;
|
|
100
101
|
}
|
|
101
102
|
observeDataUnit(newDataUnit, oldDataUnit) {
|
|
102
103
|
newDataUnit === null || newDataUnit === void 0 ? void 0 : newDataUnit.subscribe(this.dataUnitActionHandler.bind(this));
|
|
@@ -316,7 +317,7 @@ const SnkDetailView = class {
|
|
|
316
317
|
render() {
|
|
317
318
|
this.updateLabel();
|
|
318
319
|
//const cardConfig: IFormCardConfig = this._cardsState?.get(this.selectedForm);
|
|
319
|
-
return (index.h(index.Host, null, index.h("snk-data-unit", { ref: (el) => this._snkDataUnit = el, dataUnitName: `${this.dataUnitName}`, onDataUnitReady: evt => this.dataUnitReadyHandler(evt), entityName: this.entityName, onDataStateChange: this.handleDataStateChange.bind(this), ignoreSaveMessage: this._currentView === constants.VIEW_MODE.GRID, messagesBuilder: this.messagesBuilder, configName: this._configName }, index.h("ez-view-stack", { ref: (ref) => this.updateViewStack(ref) }, index.h("stack-item", null, index.h("div", { class: "ez-box ez-box--shadow grid-container" }, index.h("div", { class: "ez-
|
|
320
|
+
return (index.h(index.Host, null, index.h("snk-data-unit", { ref: (el) => this._snkDataUnit = el, dataUnitName: `${this.dataUnitName}`, onDataUnitReady: evt => this.dataUnitReadyHandler(evt), entityName: this.entityName, onDataStateChange: this.handleDataStateChange.bind(this), ignoreSaveMessage: this._currentView === constants.VIEW_MODE.GRID, messagesBuilder: this.messagesBuilder, configName: this._configName }, index.h("ez-view-stack", { ref: (ref) => this.updateViewStack(ref) }, index.h("stack-item", null, index.h("div", { class: "ez-box ez-box--shadow grid-container" }, index.h("div", { class: "ez-title--primary ez-size-width--full ez-padding--large detail-header" }, index.h("div", { class: "ez-flex ez-text ez-text--bold ez-flex--justify-start ez-flex--align-items-center" }, this._levelPath ? index.h("span", { class: "level-path" }, this._levelPath + " /") : undefined, this.label)), index.h("snk-grid", { class: "ez-size-width--full", ref: (ref) => this._snkGrid = ref, configName: this._configName, messagesBuilder: this.messagesBuilder, onGridDoubleClick: () => this.emitSwitchEvent(constants.VIEW_MODE.FORM), onActionClick: (evt) => this.executeActionHandler(evt), presentationMode: this.presentationMode, canEdit: this.canEdit, isDetail: true, taskbarCustomContainerId: this.taskbarCustomContainerId, gridHeaderCustomSlotId: "DETAIL_GRID_HEADER_CUSTOM_ELEMENTS", topTaskbarCustomSlotId: "DETAIL_GRID_TASKBAR_CUSTOM_ELEMENTS", outlineMode: false }))), index.h("stack-item", null, index.h("snk-form-view", { ref: (ref) => this._snkFormView = ref, canExpand: false, canFix: false, name: this.selectedForm, formMetadata: this._formMetadata, dataUnit: this.dataUnit, fields: this.getFormFields(), label: this.label, levelPath: this._levelPath, onFormItemsReady: ({ detail: formItems }) => this.formItemsReady.emit(formItems) }, index.h("snk-taskbar", { key: "guideViewerTaskbar", class: "form-taskbar", "data-element-id": "guideViewer", configName: this._configName, messagesBuilder: this.messagesBuilder, disabledButtons: this._disabledButtons, buttons: "INSERT,PREVIOUS,NEXT,DIVIDER,CLONE,REMOVE,MORE_OPTIONS,DIVIDER,GRID_MODE,CONFIGURATOR", primaryButton: "INSERT", presentationMode: this.presentationMode, onActionClick: evt => this.executeActionHandler(evt), dataUnit: this.dataUnit, resourceID: this.resourceID, customContainerId: this.taskbarCustomContainerId, customSlotId: "DETAIL_TASKBAR_CUSTOM_ELEMENTS" }, index.h("slot", { name: "DETAIL_TASKBAR_CUSTOM_ELEMENTS" })))), index.h("stack-item", null, index.h("snk-attach", { registerKey: this.attachmentRegisterKey, messagesBuilder: this.messagesBuilder, entityName: this.entityName, onBack: this.handleAttachBack.bind(this) }))))));
|
|
320
321
|
}
|
|
321
322
|
static get watchers() { return {
|
|
322
323
|
"dataUnit": ["observeDataUnit"],
|
|
@@ -9,14 +9,14 @@ const ConfigStorage = require('./ConfigStorage-d024aec8.js');
|
|
|
9
9
|
const index$1 = require('./index-e3e39724.js');
|
|
10
10
|
const fieldSearch = require('./field-search-68e34bf4.js');
|
|
11
11
|
const index$2 = require('./index-102ba62d.js');
|
|
12
|
-
const ClientSideExporterProvider = require('./ClientSideExporterProvider-
|
|
12
|
+
const ClientSideExporterProvider = require('./ClientSideExporterProvider-2f5f350c.js');
|
|
13
13
|
const DataUnit = require('@sankhyalabs/core/dist/dataunit/DataUnit');
|
|
14
14
|
require('./DataFetcher-65879b2c.js');
|
|
15
15
|
require('./pesquisa-fetcher-5c583c93.js');
|
|
16
16
|
require('./ISave-e91b70a7.js');
|
|
17
17
|
require('@sankhyalabs/ezui/dist/collection/utils/constants');
|
|
18
18
|
require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
|
|
19
|
-
require('./dataunit-fetcher-
|
|
19
|
+
require('./dataunit-fetcher-449d51a3.js');
|
|
20
20
|
require('./filter-item-type.enum-a7ffdaa6.js');
|
|
21
21
|
require('./form-config-fetcher-90126e4c.js');
|
|
22
22
|
require('./constants-241934b3.js');
|
|
@@ -13,7 +13,7 @@ const index$1 = require('./index-e3e39724.js');
|
|
|
13
13
|
require('./ISave-e91b70a7.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-449d51a3.js');
|
|
17
17
|
require('./filter-item-type.enum-a7ffdaa6.js');
|
|
18
18
|
require('./form-config-fetcher-90126e4c.js');
|
|
19
19
|
const DataUnit = require('@sankhyalabs/core/dist/dataunit/DataUnit');
|
|
@@ -300,7 +300,7 @@ const SnkGuidesViewer = class {
|
|
|
300
300
|
else {
|
|
301
301
|
detailBranch = this.selectedGuide;
|
|
302
302
|
}
|
|
303
|
-
content = this.wrapDetail(levels, index.h("snk-detail-view", { ref: (ref) => this._currentDetail = ref, dataUnitName: this.getDataUnitName(levels, childEntityName), onSnkDetailGuidesChange: (evt) => this.updateGuide(evt.detail), entityName: childEntityName, selectedForm: formName, branchGuide: detailBranch, guideItemPath: this._breadcrumbItems, key: `detail${detailId}`, canEdit: this.canEdit, onSnkSwitchGuide: evt => this._guideNavigator.selectGuide(evt.detail), resourceID: this.resourceID, taskbarCustomContainerId: this.detailTaskbarCustomContainerId, customEditors: this._customEditors, customRenders: this._customRenders }));
|
|
303
|
+
content = this.wrapDetail(levels, index.h("snk-detail-view", { ref: (ref) => this._currentDetail = ref, dataUnitName: this.getDataUnitName(levels, childEntityName), onSnkDetailGuidesChange: (evt) => this.updateGuide(evt.detail), entityName: childEntityName, selectedForm: formName, branchGuide: detailBranch, guideItemPath: this._breadcrumbItems, key: `detail${detailId}`, canEdit: this.canEdit, onSnkSwitchGuide: evt => this._guideNavigator.selectGuide(evt.detail), resourceID: this.resourceID, taskbarCustomContainerId: this.detailTaskbarCustomContainerId, customEditors: this._customEditors, customRenders: this._customRenders, presentationMode: this.presentationMode }));
|
|
304
304
|
}
|
|
305
305
|
else {
|
|
306
306
|
const cardId = this.selectedGuide.id;
|
|
@@ -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-495a2d2f.js');
|
|
6
6
|
require('./index-f9e81701.js');
|
|
7
7
|
require('@sankhyalabs/core');
|
|
8
8
|
require('./SnkFormConfigManager-c11d8468.js');
|
|
@@ -21,7 +21,7 @@ require('./index-102ba62d.js');
|
|
|
21
21
|
require('./pesquisa-fetcher-5c583c93.js');
|
|
22
22
|
require('./ISave-e91b70a7.js');
|
|
23
23
|
require('@sankhyalabs/ezui/dist/collection/utils/constants');
|
|
24
|
-
require('./dataunit-fetcher-
|
|
24
|
+
require('./dataunit-fetcher-449d51a3.js');
|
|
25
25
|
require('@sankhyalabs/ezui/dist/collection/components/ez-grid/utils');
|
|
26
26
|
require('@sankhyalabs/core/dist/utils/SortingUtils');
|
|
27
27
|
require('./ResourceIDUtils-5ff86aa7.js');
|
|
@@ -10,7 +10,7 @@ require('./index-e3e39724.js');
|
|
|
10
10
|
require('./ISave-e91b70a7.js');
|
|
11
11
|
require('@sankhyalabs/ezui/dist/collection/utils/constants');
|
|
12
12
|
require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
|
|
13
|
-
require('./dataunit-fetcher-
|
|
13
|
+
require('./dataunit-fetcher-449d51a3.js');
|
|
14
14
|
require('./filter-item-type.enum-a7ffdaa6.js');
|
|
15
15
|
require('./form-config-fetcher-90126e4c.js');
|
|
16
16
|
require('./constants-241934b3.js');
|
|
@@ -9,12 +9,12 @@ const constants = require('./constants-241934b3.js');
|
|
|
9
9
|
const taskbarElements = require('./taskbar-elements-7e19882d.js');
|
|
10
10
|
require('./DataFetcher-65879b2c.js');
|
|
11
11
|
require('./pesquisa-fetcher-5c583c93.js');
|
|
12
|
-
const ClientSideExporterProvider = require('./ClientSideExporterProvider-
|
|
12
|
+
const ClientSideExporterProvider = require('./ClientSideExporterProvider-2f5f350c.js');
|
|
13
13
|
const index$1 = require('./index-e3e39724.js');
|
|
14
14
|
require('./ISave-e91b70a7.js');
|
|
15
15
|
require('@sankhyalabs/ezui/dist/collection/utils/constants');
|
|
16
16
|
require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
|
|
17
|
-
const dataunitFetcher = require('./dataunit-fetcher-
|
|
17
|
+
const dataunitFetcher = require('./dataunit-fetcher-449d51a3.js');
|
|
18
18
|
require('./filter-item-type.enum-a7ffdaa6.js');
|
|
19
19
|
const formConfigFetcher = require('./form-config-fetcher-90126e4c.js');
|
|
20
20
|
const fieldSearch = require('./field-search-68e34bf4.js');
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { Action, ApplicationContext, StringUtils, } from '@sankhyalabs/core';
|
|
1
|
+
import { Action, ApplicationContext, DataUnitLoaderUtils, StringUtils, } from '@sankhyalabs/core';
|
|
2
2
|
import { SaveErrorsEnum } from '../../../../../lib/http/data-fetcher/fetchers/AttachFetcher/interfaces';
|
|
3
3
|
import { AutorizationType } from '../../../../../lib/http/data-fetcher/fetchers/auth-fetcher';
|
|
4
4
|
import { attachFetcherMetadataBuilder } from '../../builder/attach-crud-config.builder';
|
|
5
5
|
import { VIEW_MODE } from '../../../../../lib/utils/constants';
|
|
6
|
-
import { buildLoadDataResponse } from '../../../../../lib/dataUnit/dataUnitInMemoryUtils';
|
|
7
6
|
const SERVICE_LOAD = "Attach.load";
|
|
8
7
|
export class AttachFetcherDataUnitFactory {
|
|
9
8
|
constructor(getMessage) {
|
|
@@ -49,7 +48,7 @@ export class AttachFetcherDataUnitFactory {
|
|
|
49
48
|
});
|
|
50
49
|
this._records = records;
|
|
51
50
|
}
|
|
52
|
-
return buildLoadDataResponse(this._records, dataUnit, request);
|
|
51
|
+
return DataUnitLoaderUtils.buildLoadDataResponse(this._records, dataUnit, request);
|
|
53
52
|
}
|
|
54
53
|
saveLoader(changes, fetcher) {
|
|
55
54
|
return new Promise((resolve) => {
|
|
@@ -4,6 +4,7 @@ import { TaskbarElement } from '../snk-taskbar/elements/taskbar-elements';
|
|
|
4
4
|
import { PresentationMode } from '../../lib';
|
|
5
5
|
import { VIEW_MODE } from '../../lib/utils/constants';
|
|
6
6
|
import { AutorizationType } from '../../lib/http/data-fetcher/fetchers/auth-fetcher';
|
|
7
|
+
import { ExporterStrategy } from '../../lib/@types';
|
|
7
8
|
/**
|
|
8
9
|
* É possível customizar as mensagens dos blocos de construção através de um pequeno modulo na estrutura da aplicação:
|
|
9
10
|
* - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
|
|
@@ -45,6 +46,7 @@ export class SnkCrud {
|
|
|
45
46
|
this.domainMessagesBuilder = undefined;
|
|
46
47
|
this.ignoreReadOnlyFormFields = undefined;
|
|
47
48
|
this.setCustomFormTitle = undefined;
|
|
49
|
+
this.strategyExporter = ExporterStrategy.SERVER_SIDE;
|
|
48
50
|
this.customContainerId = `SNK-CRUD-CUSTOM-CONTAINER-${StringUtils.generateUUID()}`;
|
|
49
51
|
}
|
|
50
52
|
/**
|
|
@@ -380,7 +382,7 @@ export class SnkCrud {
|
|
|
380
382
|
return;
|
|
381
383
|
}
|
|
382
384
|
this._snkDataUnit.ignoreSaveMessage = (this._currentViewMode === VIEW_MODE.GRID && !this.enableGridInsert);
|
|
383
|
-
return (h(Host, null, h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "crud" }, h("stack-item", { class: 'ez-flex ez-flex--column ez-size-height--full ez-size-width--full ez-padding--medium' }, h("snk-grid", { ref: (ref) => this._snkGrid = ref, class: 'ez-flex ez-flex--column ez-size-height--full ez-size-width--full', 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, enableLockManagerTaskbarClick: this.enableLockManagerTaskbarClick, enableLockManagerLoadingComp: this.enableLockManagerLoadingComp }, 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, ignoreReadOnlyFormFields: this.ignoreReadOnlyFormFields }, 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" }))));
|
|
385
|
+
return (h(Host, null, h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "crud" }, h("stack-item", { class: 'ez-flex ez-flex--column ez-size-height--full ez-size-width--full ez-padding--medium' }, h("snk-grid", { ref: (ref) => this._snkGrid = ref, class: 'ez-flex ez-flex--column ez-size-height--full ez-size-width--full', 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, enableLockManagerTaskbarClick: this.enableLockManagerTaskbarClick, enableLockManagerLoadingComp: this.enableLockManagerLoadingComp, strategyExporter: this.strategyExporter }, 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, ignoreReadOnlyFormFields: this.ignoreReadOnlyFormFields }, 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" }))));
|
|
384
386
|
}
|
|
385
387
|
static get is() { return "snk-crud"; }
|
|
386
388
|
static get encapsulation() { return "scoped"; }
|
|
@@ -839,6 +841,29 @@ export class SnkCrud {
|
|
|
839
841
|
"tags": [],
|
|
840
842
|
"text": "Define uma fun\u00E7\u00E3o para configurar um t\u00EDtulo cusotmizado no modo formul\u00E1rio."
|
|
841
843
|
}
|
|
844
|
+
},
|
|
845
|
+
"strategyExporter": {
|
|
846
|
+
"type": "string",
|
|
847
|
+
"mutable": true,
|
|
848
|
+
"complexType": {
|
|
849
|
+
"original": "IExporterStrategyMode",
|
|
850
|
+
"resolved": "\"ClientSideExporterStrategy\" | \"ServerSideExporterStrategy\"",
|
|
851
|
+
"references": {
|
|
852
|
+
"IExporterStrategyMode": {
|
|
853
|
+
"location": "import",
|
|
854
|
+
"path": "../snk-data-exporter/interfaces/IRecordID"
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
},
|
|
858
|
+
"required": false,
|
|
859
|
+
"optional": false,
|
|
860
|
+
"docs": {
|
|
861
|
+
"tags": [],
|
|
862
|
+
"text": "Modo de exporta\u00E7\u00E3o dos dados."
|
|
863
|
+
},
|
|
864
|
+
"attribute": "strategy-exporter",
|
|
865
|
+
"reflect": false,
|
|
866
|
+
"defaultValue": "ExporterStrategy.SERVER_SIDE"
|
|
842
867
|
}
|
|
843
868
|
};
|
|
844
869
|
}
|
package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js
CHANGED
|
@@ -28,6 +28,7 @@ export class SnkDetailView {
|
|
|
28
28
|
this.taskbarCustomContainerId = undefined;
|
|
29
29
|
this.customEditors = undefined;
|
|
30
30
|
this.customRenders = undefined;
|
|
31
|
+
this.presentationMode = PresentationMode.SECONDARY;
|
|
31
32
|
}
|
|
32
33
|
observeDataUnit(newDataUnit, oldDataUnit) {
|
|
33
34
|
newDataUnit === null || newDataUnit === void 0 ? void 0 : newDataUnit.subscribe(this.dataUnitActionHandler.bind(this));
|
|
@@ -247,7 +248,7 @@ export class SnkDetailView {
|
|
|
247
248
|
render() {
|
|
248
249
|
this.updateLabel();
|
|
249
250
|
//const cardConfig: IFormCardConfig = this._cardsState?.get(this.selectedForm);
|
|
250
|
-
return (h(Host, null, h("snk-data-unit", { ref: (el) => this._snkDataUnit = el, dataUnitName: `${this.dataUnitName}`, onDataUnitReady: evt => this.dataUnitReadyHandler(evt), entityName: this.entityName, onDataStateChange: this.handleDataStateChange.bind(this), ignoreSaveMessage: this._currentView === VIEW_MODE.GRID, messagesBuilder: this.messagesBuilder, configName: this._configName }, h("ez-view-stack", { ref: (ref) => this.updateViewStack(ref) }, h("stack-item", null, h("div", { class: "ez-box ez-box--shadow grid-container" }, h("div", { class: "ez-
|
|
251
|
+
return (h(Host, null, h("snk-data-unit", { ref: (el) => this._snkDataUnit = el, dataUnitName: `${this.dataUnitName}`, onDataUnitReady: evt => this.dataUnitReadyHandler(evt), entityName: this.entityName, onDataStateChange: this.handleDataStateChange.bind(this), ignoreSaveMessage: this._currentView === VIEW_MODE.GRID, messagesBuilder: this.messagesBuilder, configName: this._configName }, h("ez-view-stack", { ref: (ref) => this.updateViewStack(ref) }, h("stack-item", null, h("div", { class: "ez-box ez-box--shadow grid-container" }, h("div", { class: "ez-title--primary ez-size-width--full ez-padding--large detail-header" }, h("div", { class: "ez-flex ez-text ez-text--bold ez-flex--justify-start ez-flex--align-items-center" }, this._levelPath ? h("span", { class: "level-path" }, this._levelPath + " /") : undefined, this.label)), h("snk-grid", { class: "ez-size-width--full", ref: (ref) => this._snkGrid = ref, configName: this._configName, messagesBuilder: this.messagesBuilder, onGridDoubleClick: () => this.emitSwitchEvent(VIEW_MODE.FORM), onActionClick: (evt) => this.executeActionHandler(evt), presentationMode: this.presentationMode, canEdit: this.canEdit, isDetail: true, taskbarCustomContainerId: this.taskbarCustomContainerId, gridHeaderCustomSlotId: "DETAIL_GRID_HEADER_CUSTOM_ELEMENTS", topTaskbarCustomSlotId: "DETAIL_GRID_TASKBAR_CUSTOM_ELEMENTS", outlineMode: false }))), h("stack-item", null, h("snk-form-view", { ref: (ref) => this._snkFormView = ref, canExpand: false, canFix: false, name: this.selectedForm, formMetadata: this._formMetadata, dataUnit: this.dataUnit, fields: this.getFormFields(), label: this.label, levelPath: this._levelPath, onFormItemsReady: ({ detail: formItems }) => this.formItemsReady.emit(formItems) }, h("snk-taskbar", { key: "guideViewerTaskbar", class: "form-taskbar", "data-element-id": "guideViewer", configName: this._configName, messagesBuilder: this.messagesBuilder, disabledButtons: this._disabledButtons, buttons: "INSERT,PREVIOUS,NEXT,DIVIDER,CLONE,REMOVE,MORE_OPTIONS,DIVIDER,GRID_MODE,CONFIGURATOR", primaryButton: "INSERT", presentationMode: this.presentationMode, onActionClick: evt => this.executeActionHandler(evt), dataUnit: this.dataUnit, resourceID: this.resourceID, customContainerId: this.taskbarCustomContainerId, customSlotId: "DETAIL_TASKBAR_CUSTOM_ELEMENTS" }, h("slot", { name: "DETAIL_TASKBAR_CUSTOM_ELEMENTS" })))), h("stack-item", null, h("snk-attach", { registerKey: this.attachmentRegisterKey, messagesBuilder: this.messagesBuilder, entityName: this.entityName, onBack: this.handleAttachBack.bind(this) }))))));
|
|
251
252
|
}
|
|
252
253
|
static get is() { return "snk-detail-view"; }
|
|
253
254
|
static get encapsulation() { return "scoped"; }
|
|
@@ -545,6 +546,29 @@ export class SnkDetailView {
|
|
|
545
546
|
"tags": [],
|
|
546
547
|
"text": "Render customizados da grade."
|
|
547
548
|
}
|
|
549
|
+
},
|
|
550
|
+
"presentationMode": {
|
|
551
|
+
"type": "string",
|
|
552
|
+
"mutable": false,
|
|
553
|
+
"complexType": {
|
|
554
|
+
"original": "PresentationMode",
|
|
555
|
+
"resolved": "PresentationMode.PRIMARY | PresentationMode.SECONDARY | PresentationMode.SINGLE_TASKBAR",
|
|
556
|
+
"references": {
|
|
557
|
+
"PresentationMode": {
|
|
558
|
+
"location": "import",
|
|
559
|
+
"path": "../../../../lib"
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
},
|
|
563
|
+
"required": false,
|
|
564
|
+
"optional": false,
|
|
565
|
+
"docs": {
|
|
566
|
+
"tags": [],
|
|
567
|
+
"text": "Altera o modo de apresenta\u00E7\u00E3o dos bot\u00F5es do snk-taskbar."
|
|
568
|
+
},
|
|
569
|
+
"attribute": "presentation-mode",
|
|
570
|
+
"reflect": false,
|
|
571
|
+
"defaultValue": "PresentationMode.SECONDARY"
|
|
548
572
|
}
|
|
549
573
|
};
|
|
550
574
|
}
|
|
@@ -284,7 +284,7 @@ export class SnkGuidesViewer {
|
|
|
284
284
|
else {
|
|
285
285
|
detailBranch = this.selectedGuide;
|
|
286
286
|
}
|
|
287
|
-
content = this.wrapDetail(levels, h("snk-detail-view", { ref: (ref) => this._currentDetail = ref, dataUnitName: this.getDataUnitName(levels, childEntityName), onSnkDetailGuidesChange: (evt) => this.updateGuide(evt.detail), entityName: childEntityName, selectedForm: formName, branchGuide: detailBranch, guideItemPath: this._breadcrumbItems, key: `detail${detailId}`, canEdit: this.canEdit, onSnkSwitchGuide: evt => this._guideNavigator.selectGuide(evt.detail), resourceID: this.resourceID, taskbarCustomContainerId: this.detailTaskbarCustomContainerId, customEditors: this._customEditors, customRenders: this._customRenders }));
|
|
287
|
+
content = this.wrapDetail(levels, h("snk-detail-view", { ref: (ref) => this._currentDetail = ref, dataUnitName: this.getDataUnitName(levels, childEntityName), onSnkDetailGuidesChange: (evt) => this.updateGuide(evt.detail), entityName: childEntityName, selectedForm: formName, branchGuide: detailBranch, guideItemPath: this._breadcrumbItems, key: `detail${detailId}`, canEdit: this.canEdit, onSnkSwitchGuide: evt => this._guideNavigator.selectGuide(evt.detail), resourceID: this.resourceID, taskbarCustomContainerId: this.detailTaskbarCustomContainerId, customEditors: this._customEditors, customRenders: this._customRenders, presentationMode: this.presentationMode }));
|
|
288
288
|
}
|
|
289
289
|
else {
|
|
290
290
|
const cardId = this.selectedGuide.id;
|
|
@@ -251,7 +251,9 @@ export class SnkDataUnit {
|
|
|
251
251
|
return new DataUnitAction(Action.RECORDS_COPIED, this.handleRecordsCopied(action.payload));
|
|
252
252
|
}
|
|
253
253
|
async interceptDataChange(action) {
|
|
254
|
-
|
|
254
|
+
var _a;
|
|
255
|
+
const recordId = (_a = this.dataUnit.getSelectedRecord()) === null || _a === void 0 ? void 0 : _a.__record__id__;
|
|
256
|
+
if (this.isAllowed("UPDATE") || this.dataUnit.isNewRecord(recordId)) {
|
|
255
257
|
return action;
|
|
256
258
|
}
|
|
257
259
|
if (this._openedAlert) {
|
|
@@ -1,117 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { buildLoadDataResponse } from './dataUnitInMemoryUtils';
|
|
1
|
+
import { DataUnitInMemoryLoader } from '@sankhyalabs/core';
|
|
3
2
|
export default class InMemoryLoader {
|
|
4
3
|
constructor(metadata, records, config) {
|
|
5
|
-
this.
|
|
6
|
-
this.records = records;
|
|
7
|
-
this._dataUnit = new DataUnit(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME);
|
|
8
|
-
this._dataUnit.pageSize = 150;
|
|
9
|
-
this._dataUnit.metadataLoader = () => this.metadaLoader();
|
|
10
|
-
this._dataUnit.dataLoader = (dataUnit, request) => this.inMemoryLoader(dataUnit, request, this.getRecordsToLoad());
|
|
11
|
-
this._dataUnit.saveLoader = (_dataUnit, changes) => this.saveLoader(_dataUnit, changes);
|
|
12
|
-
this._dataUnit.removeLoader = (_dataUnit, recordIds) => this.removeLoader(_dataUnit, recordIds);
|
|
13
|
-
this.dataUnit.loadMetadata().then(() => {
|
|
14
|
-
if ((config === null || config === void 0 ? void 0 : config.autoLoad) !== false) {
|
|
15
|
-
this.dataUnit.loadData();
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
getRecordsToLoad() {
|
|
20
|
-
if (this._initialRecords == undefined && this.dataUnit.records.length > 0) {
|
|
21
|
-
this._initialRecords = this.dataUnit.records;
|
|
22
|
-
}
|
|
23
|
-
const addedRecords = this.dataUnit.getAddedRecords();
|
|
24
|
-
if (addedRecords) {
|
|
25
|
-
return [...this._initialRecords, ...addedRecords];
|
|
26
|
-
}
|
|
27
|
-
return this._initialRecords;
|
|
4
|
+
this._dataUnitInMemoryLoader = new DataUnitInMemoryLoader(metadata, records, config);
|
|
28
5
|
}
|
|
29
6
|
get dataUnit() {
|
|
30
|
-
return this.
|
|
7
|
+
return this._dataUnitInMemoryLoader.dataUnit;
|
|
31
8
|
}
|
|
32
9
|
get records() {
|
|
33
|
-
return this.
|
|
34
|
-
}
|
|
35
|
-
static getConvertedValue(descriptor, strValue) {
|
|
36
|
-
if (descriptor.dataType === DataType.BOOLEAN) {
|
|
37
|
-
return strValue === "S";
|
|
38
|
-
}
|
|
39
|
-
if (descriptor.dataType === DataType.NUMBER) {
|
|
40
|
-
return Number(strValue);
|
|
41
|
-
}
|
|
42
|
-
if (descriptor.dataType === DataType.DATE) {
|
|
43
|
-
return DateUtils.strToDate(strValue, true);
|
|
44
|
-
}
|
|
45
|
-
if (descriptor.dataType === DataType.OBJECT) {
|
|
46
|
-
return JSON.parse(strValue);
|
|
47
|
-
}
|
|
48
|
-
return strValue;
|
|
10
|
+
return this._dataUnitInMemoryLoader.records;
|
|
49
11
|
}
|
|
50
12
|
set records(records) {
|
|
51
|
-
|
|
52
|
-
const newRecords = records === null || records === void 0 ? void 0 : records.map(record => {
|
|
53
|
-
if (!record["__record__id__"]) {
|
|
54
|
-
record["__record__id__"] = this.generateUniqueId();
|
|
55
|
-
}
|
|
56
|
-
if (columns != undefined) {
|
|
57
|
-
for (const name in record) {
|
|
58
|
-
const value = record[name];
|
|
59
|
-
if (typeof value === "string" && columns.has(name)) {
|
|
60
|
-
record[name] = InMemoryLoader.getConvertedValue(columns.get(name), value);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return record;
|
|
65
|
-
});
|
|
66
|
-
this._initialRecords = newRecords;
|
|
67
|
-
if (this._dataUnit) {
|
|
68
|
-
//Isso força o refresh internamente no datunit
|
|
69
|
-
this._dataUnit.loadData();
|
|
70
|
-
}
|
|
13
|
+
this._dataUnitInMemoryLoader.records = records;
|
|
71
14
|
}
|
|
72
15
|
get metadata() {
|
|
73
|
-
return this.
|
|
16
|
+
return this._dataUnitInMemoryLoader.metadata;
|
|
74
17
|
}
|
|
75
18
|
set metadata(metadata) {
|
|
76
|
-
this.
|
|
77
|
-
if (this._dataUnit) {
|
|
78
|
-
this._dataUnit.metadata = this._metadata;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
generateUniqueId() {
|
|
82
|
-
return StringUtils.generateUUID();
|
|
83
|
-
}
|
|
84
|
-
inMemoryLoader(dataUnit, request, recordsIn) {
|
|
85
|
-
return buildLoadDataResponse(recordsIn, dataUnit, request);
|
|
86
|
-
}
|
|
87
|
-
metadaLoader() {
|
|
88
|
-
return Promise.resolve(this._metadata);
|
|
89
|
-
}
|
|
90
|
-
saveLoader(_dataUnit, changes) {
|
|
91
|
-
return new Promise((resolve) => {
|
|
92
|
-
let dataUnitRecords = [];
|
|
93
|
-
changes.forEach(change => {
|
|
94
|
-
let { record, updatingFields, operation } = change;
|
|
95
|
-
const changedRecord = Object.assign(Object.assign({}, record), updatingFields);
|
|
96
|
-
if (operation === ChangeOperation.INSERT ||
|
|
97
|
-
operation === ChangeOperation.COPY) {
|
|
98
|
-
changedRecord["__old__id__"] = record["__record__id__"];
|
|
99
|
-
changedRecord["__record__id__"] = this.generateUniqueId();
|
|
100
|
-
this.records.push(changedRecord);
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
const recordIndex = this.records.findIndex(r => r["__record__id__"] == changedRecord["__record__id__"]);
|
|
104
|
-
this.records[recordIndex] = changedRecord;
|
|
105
|
-
}
|
|
106
|
-
dataUnitRecords.push(changedRecord);
|
|
107
|
-
});
|
|
108
|
-
resolve(dataUnitRecords);
|
|
109
|
-
});
|
|
19
|
+
this._dataUnitInMemoryLoader.metadata = metadata;
|
|
110
20
|
}
|
|
111
21
|
removeLoader(_dataUnit, recordIds) {
|
|
112
|
-
return
|
|
113
|
-
|
|
114
|
-
|
|
22
|
+
return this._dataUnitInMemoryLoader.removeLoader(_dataUnit, recordIds);
|
|
23
|
+
}
|
|
24
|
+
static getConvertedValue(descriptor, strValue, dateFormat) {
|
|
25
|
+
return DataUnitInMemoryLoader.getConvertedValue(descriptor, strValue, dateFormat);
|
|
115
26
|
}
|
|
116
27
|
}
|
|
117
|
-
InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME =
|
|
28
|
+
InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME = DataUnitInMemoryLoader.IN_MEMORY_DATA_UNIT_NAME;
|
|
@@ -1,62 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import PreloadManager from '../http/data-fetcher/fetchers/data-unit/cache/PreloadManager';
|
|
1
|
+
import { DataUnitLoaderUtils, } from '@sankhyalabs/core';
|
|
3
2
|
export function applyFilter(records, dataUnit, filters) {
|
|
4
|
-
|
|
5
|
-
if (!(columnFilters === null || columnFilters === void 0 ? void 0 : columnFilters.size)) {
|
|
6
|
-
return records;
|
|
7
|
-
}
|
|
8
|
-
const filterFunction = ColumnFilterManager.getFilterFunction(dataUnit, Array.from(columnFilters.values()));
|
|
9
|
-
if (filterFunction == undefined) {
|
|
10
|
-
return records;
|
|
11
|
-
}
|
|
12
|
-
return records.filter(filterFunction);
|
|
3
|
+
return DataUnitLoaderUtils.applyFilter(records, dataUnit, filters);
|
|
13
4
|
}
|
|
14
5
|
export function buildLoadDataResponse(recordsIn, dataUnit, request) {
|
|
15
|
-
|
|
16
|
-
records = applyFilter(records, dataUnit, request.filters);
|
|
17
|
-
records = applySorting(records, dataUnit, request.sort);
|
|
18
|
-
const { offset, limit } = request;
|
|
19
|
-
const paginationInfoBuilderParams = {
|
|
20
|
-
recordsLength: records.length,
|
|
21
|
-
offset,
|
|
22
|
-
recordsPerPage: limit,
|
|
23
|
-
};
|
|
24
|
-
return Promise.resolve({
|
|
25
|
-
records: getPagesByRecords(records, offset, limit),
|
|
26
|
-
paginationInfo: dataUnit.pageSize ? buildPaginationInfo(paginationInfoBuilderParams) : undefined,
|
|
27
|
-
});
|
|
6
|
+
return DataUnitLoaderUtils.buildLoadDataResponse(recordsIn, dataUnit, request);
|
|
28
7
|
}
|
|
29
8
|
export function applySorting(records, dataUnit, sorting) {
|
|
30
|
-
|
|
31
|
-
return records;
|
|
32
|
-
}
|
|
33
|
-
const sortingFunction = PreloadManager.getSortingFunction(dataUnit, sorting);
|
|
34
|
-
if (sortingFunction == undefined) {
|
|
35
|
-
return records;
|
|
36
|
-
}
|
|
37
|
-
return records.sort(sortingFunction);
|
|
38
|
-
}
|
|
39
|
-
function hasValidLimitAndOffset(offset, limit) {
|
|
40
|
-
return offset >= 0 && limit >= 0;
|
|
9
|
+
return DataUnitLoaderUtils.applySorting(records, dataUnit, sorting);
|
|
41
10
|
}
|
|
42
11
|
export function getPagesByRecords(records, offset = 0, limit = 0) {
|
|
43
|
-
|
|
44
|
-
return [];
|
|
45
|
-
if (limit === 0 && offset === 0)
|
|
46
|
-
return records;
|
|
47
|
-
return records.slice(offset, offset + limit);
|
|
12
|
+
return DataUnitLoaderUtils.getPagesByRecords(records, offset, limit);
|
|
48
13
|
}
|
|
49
|
-
export function buildPaginationInfo({ recordsLength = 0, offset = 0, recordsPerPage = 0 }) {
|
|
50
|
-
|
|
51
|
-
return { currentPage: 0, firstRecord: 0, lastRecord: 0, total: 0, hasMore: false };
|
|
52
|
-
}
|
|
53
|
-
const lastRecordIndex = offset + recordsPerPage;
|
|
54
|
-
const lastRecord = lastRecordIndex ? Math.min(lastRecordIndex, recordsLength) : recordsLength;
|
|
55
|
-
return {
|
|
56
|
-
currentPage: recordsPerPage === 0 ? 0 : Math.ceil(offset / recordsPerPage),
|
|
57
|
-
firstRecord: offset + 1,
|
|
58
|
-
lastRecord: lastRecord,
|
|
59
|
-
total: recordsLength,
|
|
60
|
-
hasMore: lastRecord < recordsLength,
|
|
61
|
-
};
|
|
14
|
+
export function buildPaginationInfo({ recordsLength = 0, offset = 0, recordsPerPage = 0, }) {
|
|
15
|
+
return DataUnitLoaderUtils.buildPaginationInfo({ recordsLength, offset, recordsPerPage });
|
|
62
16
|
}
|