@sankhyalabs/sankhyablocks 8.3.2 → 8.4.0-dev.2
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/{ConfigStorage-4dd5e72c.js → ConfigStorage-0e4275f5.js} +163 -51
- package/dist/cjs/{DataFetcher-65199c00.js → DataFetcher-bd3d53a8.js} +78 -234
- package/dist/cjs/ISave-d68ce3cd.js +8 -0
- package/dist/cjs/PrintUtils-bcaeb82f.js +215 -0
- package/dist/cjs/ResourceIDUtils-5ff86aa7.js +12 -0
- package/dist/cjs/{SnkFormConfigManager-44717597.js → SnkFormConfigManager-5b485cd4.js} +19 -21
- package/dist/cjs/{auth-fetcher-7ed6d3e3.js → auth-fetcher-1583fe43.js} +2 -2
- package/dist/cjs/{dataunit-fetcher-102030d8.js → dataunit-fetcher-910be4ce.js} +1 -1
- package/dist/cjs/{form-config-fetcher-49993843.js → form-config-fetcher-f6cb55e6.js} +66 -3
- package/dist/cjs/index-f9e81701.js +4 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{pesquisa-fetcher-23adae20.js → pesquisa-fetcher-3356b3df.js} +1 -1
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-actions-button.cjs.entry.js +19 -11
- package/dist/cjs/snk-application.cjs.entry.js +60 -44
- package/dist/cjs/snk-attach.cjs.entry.js +9 -14
- package/dist/cjs/snk-configurator.cjs.entry.js +2 -1
- package/dist/cjs/snk-crud.cjs.entry.js +28 -11
- package/dist/cjs/snk-data-exporter.cjs.entry.js +3 -2
- package/dist/cjs/{snk-data-unit-e89e07bd.js → snk-data-unit-7cc1846d.js} +5 -5
- package/dist/cjs/snk-data-unit.cjs.entry.js +1 -1
- package/dist/cjs/snk-detail-view.cjs.entry.js +17 -13
- package/dist/cjs/snk-entity-list.cjs.entry.js +0 -4
- package/dist/cjs/snk-filter-bar.cjs.entry.js +15 -17
- package/dist/cjs/snk-filter-detail.cjs.entry.js +7 -16
- package/dist/cjs/snk-filter-modal-item.cjs.entry.js +6 -19
- package/dist/cjs/snk-form-config.cjs.entry.js +7 -17
- package/dist/cjs/snk-form-view.cjs.entry.js +6 -1
- package/dist/cjs/snk-form.cjs.entry.js +13 -8
- package/dist/cjs/snk-grid-config.cjs.entry.js +6 -6
- package/dist/cjs/snk-grid.cjs.entry.js +23 -22
- package/dist/cjs/{snk-guides-viewer-83cd2f15.js → snk-guides-viewer-5e22097d.js} +19 -8
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +10 -9
- package/dist/cjs/snk-personalized-filter.cjs.entry.js +14 -16
- package/dist/cjs/snk-print-selector.cjs.entry.js +2 -4
- package/dist/cjs/snk-simple-crud.cjs.entry.js +43 -85
- package/dist/cjs/snk-taskbar-custom-elements.cjs.entry.js +20 -0
- package/dist/cjs/snk-taskbar.cjs.entry.js +71 -5
- package/dist/cjs/{taskbar-elements-b98dd6e9.js → taskbar-elements-39949c7a.js} +4 -4
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/snk-actions-button/actions/index.js +3 -4
- package/dist/collection/components/snk-actions-button/snk-actions-button.js +8 -4
- package/dist/collection/components/snk-application/snk-application.js +120 -65
- package/dist/collection/components/snk-configurator/snk-configurator.js +19 -1
- package/dist/collection/components/snk-crud/snk-crud.js +44 -8
- package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +60 -2
- package/dist/collection/components/snk-crud/subcomponents/snk-form-view.js +27 -1
- package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +65 -28
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +22 -6
- package/dist/collection/components/snk-entity-list/snk-entity-list.js +0 -23
- package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-detail.js +8 -13
- package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.js +1 -1
- package/dist/collection/components/snk-filter-bar/filter-modal/subcomponents/snk-filter-modal-item.js +21 -16
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +28 -12
- package/dist/collection/components/snk-form/SnkFormConfigManager.js +17 -19
- package/dist/collection/components/snk-form/snk-form.js +46 -2
- package/dist/collection/components/snk-form/subcomponents/snk-form-config/snk-form-config.js +5 -15
- package/dist/collection/components/snk-grid/snk-grid.js +108 -16
- package/dist/collection/components/snk-grid/subcomponents/snk-grid-config/snk-grid-config.js +19 -1
- package/dist/collection/components/snk-personalized-filter/snk-personalized-filter.js +28 -12
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +23 -1
- package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +4 -4
- package/dist/collection/components/snk-taskbar/snk-taskbar-custom-elements.js +43 -0
- package/dist/collection/components/snk-taskbar/snk-taskbar.css +4 -0
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +126 -5
- package/dist/collection/lib/configs/ConfigStorage.js +33 -44
- package/dist/collection/lib/dataUnit/InMemoryLoader.js +23 -71
- package/dist/collection/lib/http/data-fetcher/DataFetcher.js +47 -32
- package/dist/collection/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.js +0 -24
- package/dist/collection/lib/index.js +10 -0
- package/dist/collection/lib/resourceid/ResourceIDUtils.js +7 -0
- package/dist/collection/lib/utils/PrintUtils.js +18 -9
- package/dist/collection/lib/utils/urlutils.js +29 -0
- package/dist/components/ConfigStorage.js +161 -48
- package/dist/components/DataFetcher.js +79 -234
- package/dist/components/PrintUtils.js +213 -0
- package/dist/components/ResourceIDUtils.js +10 -0
- package/dist/components/SnkFormConfigManager.js +17 -19
- package/dist/components/auth-fetcher.js +1 -1
- package/dist/components/form-config-fetcher.js +64 -2
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/snk-actions-button2.js +23 -9
- package/dist/components/snk-application2.js +145 -129
- package/dist/components/snk-attach2.js +1 -8
- package/dist/components/snk-configurator2.js +3 -1
- package/dist/components/snk-crud.js +27 -8
- package/dist/components/snk-data-unit2.js +6 -5
- package/dist/components/snk-detail-view2.js +26 -10
- package/dist/components/snk-entity-list.js +0 -4
- package/dist/components/snk-filter-bar2.js +12 -12
- package/dist/components/snk-filter-detail2.js +8 -13
- package/dist/components/snk-filter-modal-item2.js +5 -16
- package/dist/components/snk-form-config2.js +5 -15
- package/dist/components/snk-form-view2.js +6 -1
- package/dist/components/snk-form.js +9 -2
- package/dist/components/snk-grid-config2.js +4 -2
- package/dist/components/snk-grid2.js +24 -17
- package/dist/components/snk-personalized-filter2.js +11 -11
- package/dist/components/snk-print-selector.js +1 -1
- package/dist/components/snk-simple-crud2.js +30 -73
- package/dist/components/snk-taskbar-custom-elements.d.ts +11 -0
- package/dist/components/snk-taskbar-custom-elements.js +35 -0
- package/dist/components/snk-taskbar2.js +81 -9
- package/dist/esm/{ConfigStorage-d0e26692.js → ConfigStorage-f359573c.js} +162 -49
- package/dist/esm/{DataFetcher-4f5ad71c.js → DataFetcher-8daff9ad.js} +79 -234
- package/dist/esm/ISave-4412b20c.js +8 -0
- package/dist/esm/PrintUtils-3e4ff0f5.js +213 -0
- package/dist/esm/ResourceIDUtils-a114189a.js +10 -0
- package/dist/esm/{SnkFormConfigManager-457554ca.js → SnkFormConfigManager-35876bad.js} +19 -21
- package/dist/esm/{auth-fetcher-852e26c9.js → auth-fetcher-299fed55.js} +1 -1
- package/dist/esm/{dataunit-fetcher-97dd5148.js → dataunit-fetcher-bd8f9572.js} +1 -1
- package/dist/esm/{form-config-fetcher-ff72a867.js → form-config-fetcher-8ef7be16.js} +65 -3
- package/dist/esm/index-a7d3d3f1.js +4 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{pesquisa-fetcher-d82df64b.js → pesquisa-fetcher-27819123.js} +1 -1
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-actions-button.entry.js +19 -11
- package/dist/esm/snk-application.entry.js +60 -44
- package/dist/esm/snk-attach.entry.js +5 -10
- package/dist/esm/snk-configurator.entry.js +2 -1
- package/dist/esm/snk-crud.entry.js +30 -13
- package/dist/esm/snk-data-exporter.entry.js +3 -2
- package/dist/esm/{snk-data-unit-8c4d944d.js → snk-data-unit-1715d2f1.js} +5 -5
- package/dist/esm/snk-data-unit.entry.js +1 -1
- package/dist/esm/snk-detail-view.entry.js +17 -13
- package/dist/esm/snk-entity-list.entry.js +0 -4
- package/dist/esm/snk-filter-bar.entry.js +15 -17
- package/dist/esm/snk-filter-detail.entry.js +8 -17
- package/dist/esm/snk-filter-modal-item.entry.js +7 -20
- package/dist/esm/snk-form-config.entry.js +8 -18
- package/dist/esm/snk-form-view.entry.js +6 -1
- package/dist/esm/snk-form.entry.js +13 -8
- package/dist/esm/snk-grid-config.entry.js +6 -6
- package/dist/esm/snk-grid.entry.js +23 -22
- package/dist/esm/{snk-guides-viewer-202c3c4d.js → snk-guides-viewer-b0e32a7d.js} +19 -8
- package/dist/esm/snk-guides-viewer.entry.js +10 -9
- package/dist/esm/snk-personalized-filter.entry.js +14 -16
- package/dist/esm/snk-print-selector.entry.js +1 -3
- package/dist/esm/snk-simple-crud.entry.js +34 -76
- package/dist/esm/snk-taskbar-custom-elements.entry.js +16 -0
- package/dist/esm/snk-taskbar.entry.js +71 -5
- package/dist/esm/{taskbar-elements-2c761819.js → taskbar-elements-0a6b8b95.js} +4 -4
- package/dist/sankhyablocks/p-0df2ead8.entry.js +11 -0
- package/dist/sankhyablocks/p-324ce41e.entry.js +1 -0
- package/dist/sankhyablocks/p-34604220.entry.js +1 -0
- package/dist/sankhyablocks/p-648a7c72.entry.js +1 -0
- package/dist/sankhyablocks/p-688dcb4c.js +1 -0
- package/dist/sankhyablocks/p-6a38bda5.entry.js +1 -0
- package/dist/sankhyablocks/p-72fc257b.entry.js +1 -0
- package/dist/sankhyablocks/p-7bcd2f89.js +56 -0
- package/dist/sankhyablocks/p-7bd5aea7.js +1 -0
- package/dist/sankhyablocks/p-8014cc25.entry.js +1 -0
- package/dist/sankhyablocks/p-8d884fab.js +1 -0
- package/dist/sankhyablocks/p-928efcaa.entry.js +1 -0
- package/dist/sankhyablocks/p-989937ee.entry.js +1 -0
- package/dist/sankhyablocks/p-9a270401.entry.js +1 -0
- package/dist/sankhyablocks/p-9e7d65a4.js +1 -0
- package/dist/sankhyablocks/p-a7ee0e6f.entry.js +1 -0
- package/dist/sankhyablocks/p-ac0556a3.js +1 -0
- package/dist/sankhyablocks/p-af2d9aea.entry.js +1 -0
- package/dist/sankhyablocks/{p-435259af.js → p-b13cb8b5.js} +2 -2
- package/dist/sankhyablocks/p-b244640b.js +1 -0
- package/dist/sankhyablocks/p-bba91710.entry.js +1 -0
- package/dist/sankhyablocks/p-c555075c.entry.js +1 -0
- package/dist/sankhyablocks/p-c870b530.js +26 -0
- package/dist/sankhyablocks/{p-a2493d11.js → p-c9841939.js} +1 -1
- package/dist/sankhyablocks/p-d4f9ee17.entry.js +1 -0
- package/dist/sankhyablocks/p-d708b4ab.entry.js +1 -0
- package/dist/sankhyablocks/p-d84bc5c1.js +1 -0
- package/dist/sankhyablocks/{p-7d9302e2.js → p-de76b8a8.js} +1 -1
- package/dist/sankhyablocks/p-e19014a9.entry.js +1 -0
- package/dist/sankhyablocks/p-e1cb1f0b.js +1 -0
- package/dist/sankhyablocks/p-e9b53a9a.entry.js +1 -0
- package/dist/sankhyablocks/p-ebf8c5df.entry.js +1 -0
- package/dist/sankhyablocks/p-ed5f1204.entry.js +1 -0
- package/dist/sankhyablocks/p-f94b999e.entry.js +1 -0
- package/dist/sankhyablocks/p-fb1ecd0b.entry.js +1 -0
- package/dist/sankhyablocks/p-fd15aaac.entry.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-actions-button/actions/index.d.ts +2 -1
- package/dist/types/components/snk-application/snk-application.d.ts +9 -22
- package/dist/types/components/snk-configurator/snk-configurator.d.ts +4 -0
- package/dist/types/components/snk-crud/snk-crud.d.ts +6 -0
- package/dist/types/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.d.ts +12 -0
- package/dist/types/components/snk-crud/subcomponents/snk-form-view.d.ts +5 -0
- package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +13 -2
- package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +4 -0
- package/dist/types/components/snk-entity-list/snk-entity-list.d.ts +0 -4
- package/dist/types/components/snk-filter-bar/filter-item/snk-filter-detail.d.ts +0 -3
- package/dist/types/components/snk-filter-bar/filter-modal/snk-filter-modal.d.ts +1 -1
- package/dist/types/components/snk-filter-bar/filter-modal/subcomponents/snk-filter-modal-item.d.ts +5 -4
- package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +4 -0
- package/dist/types/components/snk-form/SnkFormConfigManager.d.ts +5 -4
- package/dist/types/components/snk-form/snk-form.d.ts +9 -1
- package/dist/types/components/snk-form/subcomponents/snk-form-config/snk-form-config.d.ts +0 -2
- package/dist/types/components/snk-grid/snk-grid.d.ts +17 -1
- package/dist/types/components/snk-grid/subcomponents/snk-grid-config/snk-grid-config.d.ts +4 -0
- package/dist/types/components/snk-personalized-filter/snk-personalized-filter.d.ts +5 -1
- package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +4 -0
- package/dist/types/components/snk-taskbar/processor/taskbar-processor.d.ts +2 -2
- package/dist/types/components/snk-taskbar/snk-taskbar-custom-elements.d.ts +7 -0
- package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +27 -0
- package/dist/types/components.d.ts +203 -22
- package/dist/types/lib/configs/ConfigStorage.d.ts +11 -13
- package/dist/types/lib/dataUnit/InMemoryLoader.d.ts +2 -8
- package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +1 -1
- package/dist/types/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.d.ts +0 -1
- package/dist/types/lib/index.d.ts +11 -0
- package/dist/types/lib/resourceid/ResourceIDUtils.d.ts +3 -0
- package/dist/types/lib/utils/PrintUtils.d.ts +1 -0
- package/dist/types/lib/utils/urlutils.d.ts +14 -0
- package/package.json +2 -2
- package/react/components.d.ts +1 -0
- package/react/components.js +1 -0
- package/react/components.js.map +1 -1
- package/dist/cjs/filter-bar-config-fetcher-2ab64f92.js +0 -155
- package/dist/cjs/resource-fetcher-8d12fee7.js +0 -68
- package/dist/components/filter-bar-config-fetcher.js +0 -153
- package/dist/components/resource-fetcher.js +0 -66
- package/dist/esm/filter-bar-config-fetcher-1093db95.js +0 -153
- package/dist/esm/resource-fetcher-be4d1ba4.js +0 -66
- package/dist/sankhyablocks/p-030a2da4.entry.js +0 -1
- package/dist/sankhyablocks/p-1208becf.entry.js +0 -1
- package/dist/sankhyablocks/p-17724bee.entry.js +0 -1
- package/dist/sankhyablocks/p-216f081a.entry.js +0 -1
- package/dist/sankhyablocks/p-37b17041.js +0 -1
- package/dist/sankhyablocks/p-3916c825.entry.js +0 -1
- package/dist/sankhyablocks/p-3ffad8ca.entry.js +0 -1
- package/dist/sankhyablocks/p-44fe945a.entry.js +0 -1
- package/dist/sankhyablocks/p-4fc5a0db.entry.js +0 -1
- package/dist/sankhyablocks/p-564efc43.js +0 -1
- package/dist/sankhyablocks/p-5add4151.entry.js +0 -1
- package/dist/sankhyablocks/p-5de83141.entry.js +0 -1
- package/dist/sankhyablocks/p-6be9191f.entry.js +0 -1
- package/dist/sankhyablocks/p-6ee5d42c.js +0 -1
- package/dist/sankhyablocks/p-72d7f00c.js +0 -56
- package/dist/sankhyablocks/p-7352acf8.entry.js +0 -1
- package/dist/sankhyablocks/p-8115f7a2.js +0 -1
- package/dist/sankhyablocks/p-8903ffc6.js +0 -1
- package/dist/sankhyablocks/p-8dbb4c6c.entry.js +0 -11
- package/dist/sankhyablocks/p-935bfc1c.entry.js +0 -1
- package/dist/sankhyablocks/p-9395cf73.entry.js +0 -1
- package/dist/sankhyablocks/p-9d36d914.js +0 -17
- package/dist/sankhyablocks/p-aa6f27bd.entry.js +0 -1
- package/dist/sankhyablocks/p-aeaa5253.js +0 -10
- package/dist/sankhyablocks/p-befbc9ee.entry.js +0 -1
- package/dist/sankhyablocks/p-c1273e40.js +0 -1
- package/dist/sankhyablocks/p-c32b9d7c.entry.js +0 -1
- package/dist/sankhyablocks/p-c6380ea2.entry.js +0 -1
- package/dist/sankhyablocks/p-de69b4b0.entry.js +0 -1
- package/dist/sankhyablocks/p-f5c33da3.entry.js +0 -1
- package/dist/sankhyablocks/p-f847d53a.entry.js +0 -1
@@ -174,7 +174,7 @@ export class SnkSimpleCrud {
|
|
174
174
|
}
|
175
175
|
render() {
|
176
176
|
var _a;
|
177
|
-
return (h("snk-data-unit", { class: "simple-crud__container", dataUnit: this.dataUnit, useCancelConfirm: this.useCancelConfirm, onDataStateChange: evt => this.onDataStateChange(evt), onCancelEdition: this.handleCancelEdit.bind(this), onInsertionMode: () => this.goToView(VIEW_MODE.FORM), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail), ignoreSaveMessage: this._currentViewMode === VIEW_MODE.GRID, onMessagesBuilderUpdated: evt => this.messagesBuilder = evt.detail }, h("header", null, h("slot", { name: "snkSimpleCrudHeader" })), h("section", { class: "ez-flex ez-box ez-box--shadow" }, h("snk-taskbar", { class: "ez-box ez-box--shadow ez-padding--medium ez-margin-bottom--large", dataUnit: this.dataUnit, primaryButton: ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? "SAVE" : "INSERT", "data-element-id": "grid_left", messagesBuilder: this.messagesBuilder, buttons: this._taskbarProcessor.buttons, disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, slot: "leftButtons", presentationMode: PresentationMode.SECONDARY }), h("ez-view-stack", { class: "ez-flex ez-flex--column", ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, h("stack-item", null, h("ez-grid", { dataUnit: this.dataUnit, config: this.gridConfig, "no-header": true, multipleSelection: this.multipleSelection, onEzDoubleClick: () => this.goToView(VIEW_MODE.FORM), columnfilterDataSource: this.dataUnit.name.includes(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME)
|
177
|
+
return (h("snk-data-unit", { class: "simple-crud__container", dataUnit: this.dataUnit, useCancelConfirm: this.useCancelConfirm, onDataStateChange: evt => this.onDataStateChange(evt), onCancelEdition: this.handleCancelEdit.bind(this), onInsertionMode: () => this.goToView(VIEW_MODE.FORM), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail), ignoreSaveMessage: this._currentViewMode === VIEW_MODE.GRID, onMessagesBuilderUpdated: evt => this.messagesBuilder = evt.detail }, h("header", null, h("slot", { name: "snkSimpleCrudHeader" })), h("section", { class: "ez-flex ez-box ez-box--shadow" }, h("snk-taskbar", { class: "ez-box ez-box--shadow ez-padding--medium ez-margin-bottom--large", dataUnit: this.dataUnit, primaryButton: ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? "SAVE" : "INSERT", "data-element-id": "grid_left", messagesBuilder: this.messagesBuilder, buttons: this._taskbarProcessor.buttons, disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, slot: "leftButtons", presentationMode: PresentationMode.SECONDARY }, h("slot", { name: "TASKBAR_CUSTOM_ELEMENTS" })), h("ez-view-stack", { class: "ez-flex ez-flex--column", ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, h("stack-item", null, h("ez-grid", { dataUnit: this.dataUnit, config: this.gridConfig, "no-header": true, multipleSelection: this.multipleSelection, onEzDoubleClick: () => this.goToView(VIEW_MODE.FORM), columnfilterDataSource: this.dataUnit.name.includes(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME)
|
178
178
|
? undefined
|
179
179
|
: this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab }, h("div", { slot: "footer" }, h("slot", { name: "snkSimpleCrudFooter" })))), h("stack-item", null, h("ez-form", { dataUnit: this.dataUnit, config: this.formConfig }))))));
|
180
180
|
}
|
@@ -452,6 +452,28 @@ export class SnkSimpleCrud {
|
|
452
452
|
"resolved": "string",
|
453
453
|
"references": {}
|
454
454
|
}
|
455
|
+
}, {
|
456
|
+
"method": "formItemsReady",
|
457
|
+
"name": "formItemsReady",
|
458
|
+
"bubbles": true,
|
459
|
+
"cancelable": true,
|
460
|
+
"composed": true,
|
461
|
+
"docs": {
|
462
|
+
"tags": [],
|
463
|
+
"text": "Respons\u00E1vel por notificar quando ocorrer a renderiza\u00E7\u00E3o de itens do formul\u00E1rio."
|
464
|
+
},
|
465
|
+
"complexType": {
|
466
|
+
"original": "Array<HTMLElement>",
|
467
|
+
"resolved": "HTMLElement[]",
|
468
|
+
"references": {
|
469
|
+
"Array": {
|
470
|
+
"location": "global"
|
471
|
+
},
|
472
|
+
"HTMLElement": {
|
473
|
+
"location": "global"
|
474
|
+
}
|
475
|
+
}
|
476
|
+
}
|
455
477
|
}];
|
456
478
|
}
|
457
479
|
static get methods() {
|
@@ -99,16 +99,16 @@ export const buildElem = (element, className, dataElementId, getTitle, action, i
|
|
99
99
|
}
|
100
100
|
};
|
101
101
|
function textButton(name, className, dataElementId, text, title, action, isEnabled) {
|
102
|
-
return h("ez-button", { title: title, label: text, size: "small", class: className, "data-element-id": dataElementId, enabled: isEnabled(name), onClick: () => action(name) });
|
102
|
+
return h("ez-button", { key: dataElementId, title: title, label: text, size: "small", class: className, "data-element-id": dataElementId, enabled: isEnabled(name), onClick: () => action(name) });
|
103
103
|
}
|
104
104
|
function iconButton(iconName, name, className, dataElementId, title, action, isEnabled) {
|
105
|
-
return h("ez-button", { title: title, mode: "icon", size: "small", class: className, "data-element-id": dataElementId, iconName: iconName, enabled: isEnabled(name), onClick: () => action(name) });
|
105
|
+
return h("ez-button", { key: dataElementId, title: title, mode: "icon", size: "small", class: className, "data-element-id": dataElementId, iconName: iconName, enabled: isEnabled(name), onClick: () => action(name) });
|
106
106
|
}
|
107
107
|
function iconTextButton(iconName, name, className, dataElementId, text, title, action, isEnabled) {
|
108
|
-
return h("ez-button", { title: title, label: text, size: "small", class: className, "data-element-id": dataElementId, enabled: isEnabled(name), onClick: () => action(name) }, h("ez-icon", { class: "ez-padding-right--small", slot: "leftIcon", iconName: iconName }));
|
108
|
+
return h("ez-button", { key: dataElementId, title: title, label: text, size: "small", class: className, "data-element-id": dataElementId, enabled: isEnabled(name), onClick: () => action(name) }, h("ez-icon", { class: "ez-padding-right--small", slot: "leftIcon", iconName: iconName }));
|
109
109
|
}
|
110
110
|
function actionButton(element, className, dataElementId, title, action, isEnabled, actions) {
|
111
111
|
return actions && actions.length > 0
|
112
|
-
? h("ez-actions-button", { title: title, size: "small", "data-element-id": dataElementId, arrowActive: true, class: className, enabled: isEnabled(element), onEzAction: (evt) => action(evt.detail.value), actions: actions })
|
112
|
+
? h("ez-actions-button", { key: dataElementId, title: title, size: "small", "data-element-id": dataElementId, arrowActive: true, class: className, enabled: isEnabled(element), onEzAction: (evt) => action(evt.detail.value), actions: actions })
|
113
113
|
: undefined;
|
114
114
|
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import { h, Host } from '@stencil/core';
|
2
|
+
export class SnkTaskbarCustomElements {
|
3
|
+
constructor() {
|
4
|
+
this.slot = 'TASKBAR_CUSTOM_ELEMENTS';
|
5
|
+
}
|
6
|
+
render() {
|
7
|
+
return (h(Host, { slot: this.slot }, h("div", { id: this.slot, class: "taskbar-custom-elements-container" }, h("slot", null))));
|
8
|
+
}
|
9
|
+
static get is() { return "snk-taskbar-custom-elements"; }
|
10
|
+
static get encapsulation() { return "scoped"; }
|
11
|
+
static get originalStyleUrls() {
|
12
|
+
return {
|
13
|
+
"$": ["snk-taskbar.css"]
|
14
|
+
};
|
15
|
+
}
|
16
|
+
static get styleUrls() {
|
17
|
+
return {
|
18
|
+
"$": ["snk-taskbar.css"]
|
19
|
+
};
|
20
|
+
}
|
21
|
+
static get properties() {
|
22
|
+
return {
|
23
|
+
"slot": {
|
24
|
+
"type": "string",
|
25
|
+
"mutable": false,
|
26
|
+
"complexType": {
|
27
|
+
"original": "string",
|
28
|
+
"resolved": "string",
|
29
|
+
"references": {}
|
30
|
+
},
|
31
|
+
"required": false,
|
32
|
+
"optional": false,
|
33
|
+
"docs": {
|
34
|
+
"tags": [],
|
35
|
+
"text": "Nome do slot da Taskbar onde os elementos customizados dever\u00E3o aparecer."
|
36
|
+
},
|
37
|
+
"attribute": "slot",
|
38
|
+
"reflect": false,
|
39
|
+
"defaultValue": "'TASKBAR_CUSTOM_ELEMENTS'"
|
40
|
+
}
|
41
|
+
};
|
42
|
+
}
|
43
|
+
}
|
@@ -1,10 +1,11 @@
|
|
1
1
|
import { ApplicationContext, ElementIDUtils, StringUtils } from '@sankhyalabs/core';
|
2
2
|
import { h, Host } from '@stencil/core';
|
3
3
|
import { AuthorizationConfig } from '../snk-configurator/AuthorizationConfig';
|
4
|
-
import {
|
4
|
+
import { AuthorizationElements, buildCustomButton, buildElem, TaskbarElement, VisibleWhenForbidden, } from './elements/taskbar-elements';
|
5
5
|
import { PresentationMode } from '../../lib/@types';
|
6
6
|
export class SnkTaskbar {
|
7
7
|
constructor() {
|
8
|
+
this.TASKBAR_ITEM_ID_PREFIX = 'TASKBAR_ITEM_';
|
8
9
|
this._titleKeyByElement = {
|
9
10
|
[TaskbarElement.UPDATE]: "snkTaskbar.titleUpdate",
|
10
11
|
[TaskbarElement.PREVIOUS]: "snkTaskbar.titlePrevious",
|
@@ -22,7 +23,13 @@ export class SnkTaskbar {
|
|
22
23
|
[TaskbarElement.ATTACH]: "snkTaskbar.titleAttach",
|
23
24
|
};
|
24
25
|
this._permissions = undefined;
|
26
|
+
this._customElements = undefined;
|
27
|
+
this._customElementsId = undefined;
|
28
|
+
this._slotContainer = undefined;
|
29
|
+
this.customSlotId = "TASKBAR_CUSTOM_ELEMENTS";
|
30
|
+
this.customContainerId = undefined;
|
25
31
|
this.configName = undefined;
|
32
|
+
this.resourceID = undefined;
|
26
33
|
this.buttons = undefined;
|
27
34
|
this.customButtons = undefined;
|
28
35
|
this.actionsList = undefined;
|
@@ -161,14 +168,52 @@ export class SnkTaskbar {
|
|
161
168
|
return true;
|
162
169
|
});
|
163
170
|
}
|
171
|
+
appendCustomElementsInTaskbar() {
|
172
|
+
this._customElementsId.forEach(id => {
|
173
|
+
const elementId = id.replace(this.TASKBAR_ITEM_ID_PREFIX, '');
|
174
|
+
const customElement = this._customElements.get(elementId);
|
175
|
+
const container = this._element.querySelector(`#${id}`);
|
176
|
+
if (container) {
|
177
|
+
container === null || container === void 0 ? void 0 : container.appendChild(customElement);
|
178
|
+
}
|
179
|
+
else {
|
180
|
+
this.unlinkCustomElementFromTaskbar(customElement);
|
181
|
+
}
|
182
|
+
});
|
183
|
+
}
|
184
|
+
addCustomElementContainer(elem) {
|
185
|
+
const elementId = `${this.TASKBAR_ITEM_ID_PREFIX}${elem}`;
|
186
|
+
if (!this._customElementsId.includes(elementId)) {
|
187
|
+
this._customElementsId.push(elementId);
|
188
|
+
}
|
189
|
+
return h("span", { key: elementId, id: elementId });
|
190
|
+
}
|
191
|
+
getCustomElements() {
|
192
|
+
var _a, _b;
|
193
|
+
this._customElementsId = [];
|
194
|
+
this._customElements = new Map();
|
195
|
+
this._slotContainer = this.buildSlotContainer();
|
196
|
+
const customElementsArray = Array.from((_b = (_a = this._slotContainer) === null || _a === void 0 ? void 0 : _a.children) !== null && _b !== void 0 ? _b : []);
|
197
|
+
customElementsArray.forEach(item => this._customElements.set(item.id, item));
|
198
|
+
}
|
199
|
+
buildSlotContainer() {
|
200
|
+
if (this.customContainerId) {
|
201
|
+
const container = document.querySelector(`#${this.customContainerId}`);
|
202
|
+
return container === null || container === void 0 ? void 0 : container.querySelector(`#${this.customSlotId}`);
|
203
|
+
}
|
204
|
+
else {
|
205
|
+
return this._element.querySelector(`#${this.customSlotId}`);
|
206
|
+
}
|
207
|
+
}
|
164
208
|
componentWillLoad() {
|
165
209
|
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
166
210
|
if (this._application) {
|
167
|
-
this._application.getAllAccess().then(access => this._permissions = access);
|
211
|
+
this._application.getAllAccess(this.resourceID).then(access => this._permissions = access);
|
168
212
|
}
|
169
213
|
else {
|
170
214
|
this._permissions = {};
|
171
215
|
}
|
216
|
+
this.getCustomElements();
|
172
217
|
}
|
173
218
|
componentWillRender() {
|
174
219
|
if (this._definitions == undefined && this._permissions) {
|
@@ -180,12 +225,30 @@ export class SnkTaskbar {
|
|
180
225
|
const dataInfo = { dataUnit: this.dataUnit };
|
181
226
|
ElementIDUtils.addIDInfo(this._element, null, dataInfo);
|
182
227
|
}
|
228
|
+
componentDidRender() {
|
229
|
+
this.appendCustomElementsInTaskbar();
|
230
|
+
}
|
231
|
+
disconnectedCallback() {
|
232
|
+
this.unlinkAllCustomElements();
|
233
|
+
}
|
234
|
+
unlinkAllCustomElements() {
|
235
|
+
var _a;
|
236
|
+
(_a = this._customElementsId) === null || _a === void 0 ? void 0 : _a.forEach(id => {
|
237
|
+
const elementId = id.replace(this.TASKBAR_ITEM_ID_PREFIX, '');
|
238
|
+
const customElement = this._customElements.get(elementId);
|
239
|
+
this.unlinkCustomElementFromTaskbar(customElement);
|
240
|
+
});
|
241
|
+
}
|
242
|
+
unlinkCustomElementFromTaskbar(customElement) {
|
243
|
+
this._slotContainer.appendChild(customElement);
|
244
|
+
}
|
183
245
|
render() {
|
184
246
|
if (this._definitions === undefined) {
|
185
247
|
return undefined;
|
186
248
|
}
|
187
249
|
let index = 0;
|
188
250
|
return (h(Host, null, this.removeEmpty(this._definitions.map((elem) => {
|
251
|
+
var _a;
|
189
252
|
if (elem === TaskbarElement.DIVIDER) {
|
190
253
|
index = 0;
|
191
254
|
}
|
@@ -195,11 +258,14 @@ export class SnkTaskbar {
|
|
195
258
|
if (TaskbarElement[elem]) {
|
196
259
|
return this.getElement(index, TaskbarElement[elem]);
|
197
260
|
}
|
198
|
-
if (this.customButtons.has(elem)) {
|
261
|
+
if ((_a = this.customButtons) === null || _a === void 0 ? void 0 : _a.has(elem)) {
|
199
262
|
return this.getElement(index, this.customButtons.get(elem));
|
200
263
|
}
|
264
|
+
if (this._customElements.has(elem)) {
|
265
|
+
return this.addCustomElementContainer(elem);
|
266
|
+
}
|
201
267
|
return h("slot", { name: elem });
|
202
|
-
}))));
|
268
|
+
})), h("div", { class: "taskbar-custom-elements-container" }, h("slot", { name: this.customSlotId }))));
|
203
269
|
}
|
204
270
|
static get is() { return "snk-taskbar"; }
|
205
271
|
static get encapsulation() { return "scoped"; }
|
@@ -215,6 +281,41 @@ export class SnkTaskbar {
|
|
215
281
|
}
|
216
282
|
static get properties() {
|
217
283
|
return {
|
284
|
+
"customSlotId": {
|
285
|
+
"type": "string",
|
286
|
+
"mutable": false,
|
287
|
+
"complexType": {
|
288
|
+
"original": "string",
|
289
|
+
"resolved": "string",
|
290
|
+
"references": {}
|
291
|
+
},
|
292
|
+
"required": false,
|
293
|
+
"optional": false,
|
294
|
+
"docs": {
|
295
|
+
"tags": [],
|
296
|
+
"text": "Usado para determinar o identificador do slot que recebe elementos personalizados."
|
297
|
+
},
|
298
|
+
"attribute": "custom-slot-id",
|
299
|
+
"reflect": false,
|
300
|
+
"defaultValue": "\"TASKBAR_CUSTOM_ELEMENTS\""
|
301
|
+
},
|
302
|
+
"customContainerId": {
|
303
|
+
"type": "string",
|
304
|
+
"mutable": false,
|
305
|
+
"complexType": {
|
306
|
+
"original": "string",
|
307
|
+
"resolved": "string",
|
308
|
+
"references": {}
|
309
|
+
},
|
310
|
+
"required": false,
|
311
|
+
"optional": false,
|
312
|
+
"docs": {
|
313
|
+
"tags": [],
|
314
|
+
"text": "Usado para determinar o identificador do container na DOM que \u00E9 responsavel por guardar os elementos personalizados\nque n\u00E3o podem ser passados por slot.\n\nExemplo: Elementos customizados na Taskbar da aba de detalhes."
|
315
|
+
},
|
316
|
+
"attribute": "custom-container-id",
|
317
|
+
"reflect": false
|
318
|
+
},
|
218
319
|
"configName": {
|
219
320
|
"type": "string",
|
220
321
|
"mutable": false,
|
@@ -232,6 +333,23 @@ export class SnkTaskbar {
|
|
232
333
|
"attribute": "config-name",
|
233
334
|
"reflect": false
|
234
335
|
},
|
336
|
+
"resourceID": {
|
337
|
+
"type": "string",
|
338
|
+
"mutable": false,
|
339
|
+
"complexType": {
|
340
|
+
"original": "string",
|
341
|
+
"resolved": "string",
|
342
|
+
"references": {}
|
343
|
+
},
|
344
|
+
"required": false,
|
345
|
+
"optional": false,
|
346
|
+
"docs": {
|
347
|
+
"tags": [],
|
348
|
+
"text": "Identificador de recursos como configura\u00E7\u00F5es e acesso."
|
349
|
+
},
|
350
|
+
"attribute": "resource-i-d",
|
351
|
+
"reflect": false
|
352
|
+
},
|
235
353
|
"buttons": {
|
236
354
|
"type": "string",
|
237
355
|
"mutable": false,
|
@@ -396,7 +514,10 @@ export class SnkTaskbar {
|
|
396
514
|
}
|
397
515
|
static get states() {
|
398
516
|
return {
|
399
|
-
"_permissions": {}
|
517
|
+
"_permissions": {},
|
518
|
+
"_customElements": {},
|
519
|
+
"_customElementsId": {},
|
520
|
+
"_slotContainer": {}
|
400
521
|
};
|
401
522
|
}
|
402
523
|
static get events() {
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import { ApplicationContext } from "@sankhyalabs/core";
|
2
1
|
import { FormConfigFetcher } from "../http/data-fetcher/fetchers/form-config-fetcher";
|
3
2
|
import GridConfigFetcher from "../http/data-fetcher/fetchers/grid-config-fetcher";
|
4
3
|
import FilterBarConfigFetcher from "../http/data-fetcher/fetchers/filter-bar-config-fetcher";
|
@@ -9,83 +8,73 @@ const CONFIG_SOURCE = {
|
|
9
8
|
filterBar: "filterBar"
|
10
9
|
};
|
11
10
|
export class ConfigStorage {
|
12
|
-
static
|
13
|
-
|
14
|
-
|
15
|
-
if (application != undefined) {
|
16
|
-
const configName = application.configName;
|
17
|
-
const resourceID = await application.getResourceID();
|
18
|
-
ConfigStorage.instance = new ConfigStorage();
|
19
|
-
ConfigStorage.resourceID = resourceID;
|
20
|
-
ConfigStorage.instance.loadFormConfig(configName);
|
21
|
-
ConfigStorage.instance.loadGridConfig(configName);
|
22
|
-
}
|
23
|
-
}
|
24
|
-
return this.instance;
|
11
|
+
static preload(resourceID, configName) {
|
12
|
+
ConfigStorage.loadFormConfig(configName, resourceID);
|
13
|
+
ConfigStorage.loadGridConfig(configName, resourceID);
|
25
14
|
}
|
26
|
-
async loadFilterBarConfig(name, urlParams) {
|
27
|
-
const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.filterBar);
|
15
|
+
static async loadFilterBarConfig(name, resourceID, urlParams) {
|
16
|
+
const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.filterBar, resourceID);
|
28
17
|
if (!ConfigStorage.configById.has(cacheID)) {
|
29
|
-
ConfigStorage.configById.set(cacheID, ConfigStorage.filterBarConfigFetcher.getConfig(
|
18
|
+
ConfigStorage.configById.set(cacheID, ConfigStorage.filterBarConfigFetcher.getConfig(resourceID, name, urlParams));
|
30
19
|
}
|
31
20
|
return ConfigStorage.configById.get(cacheID);
|
32
21
|
}
|
33
|
-
async loadFormConfig(name) {
|
34
|
-
const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.form);
|
22
|
+
static async loadFormConfig(name, resourceID) {
|
23
|
+
const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.form, resourceID);
|
35
24
|
if (!ConfigStorage.configById.has(cacheID)) {
|
36
|
-
ConfigStorage.configById.set(cacheID, ConfigStorage.formConfigFetcher.loadFormConfig(name,
|
25
|
+
ConfigStorage.configById.set(cacheID, ConfigStorage.formConfigFetcher.loadFormConfig(name, resourceID));
|
37
26
|
}
|
38
27
|
return ConfigStorage.configById.get(cacheID);
|
39
28
|
}
|
40
|
-
async loadGridConfig(name) {
|
41
|
-
const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.grid);
|
29
|
+
static async loadGridConfig(name, resourceID) {
|
30
|
+
const cacheID = ConfigStorage.buildCacheID(name, CONFIG_SOURCE.grid, resourceID);
|
42
31
|
if (!ConfigStorage.configById.has(cacheID)) {
|
43
|
-
ConfigStorage.configById.set(cacheID, ConfigStorage.gridConfigFetcher.getConfig(name,
|
32
|
+
ConfigStorage.configById.set(cacheID, ConfigStorage.gridConfigFetcher.getConfig(name, resourceID));
|
44
33
|
}
|
45
34
|
return ConfigStorage.configById.get(cacheID);
|
46
35
|
}
|
47
|
-
static async saveFilterBarConfig(config, name) {
|
48
|
-
const cacheID = this.buildCacheID(name, CONFIG_SOURCE.filterBar);
|
36
|
+
static async saveFilterBarConfig(config, name, resourceID) {
|
37
|
+
const cacheID = this.buildCacheID(name, CONFIG_SOURCE.filterBar, resourceID);
|
49
38
|
this.configById.delete(cacheID);
|
50
|
-
return this.filterBarConfigFetcher.saveConfig(config,
|
39
|
+
return this.filterBarConfigFetcher.saveConfig(config, resourceID, name);
|
51
40
|
}
|
52
|
-
static async saveFormConfig(config, name) {
|
53
|
-
const cacheID = this.buildCacheID(name, CONFIG_SOURCE.form);
|
41
|
+
static async saveFormConfig(config, name, resourceID) {
|
42
|
+
const cacheID = this.buildCacheID(name, CONFIG_SOURCE.form, resourceID);
|
54
43
|
this.configById.delete(cacheID);
|
55
|
-
return this.formConfigFetcher.saveConfig(config, name,
|
44
|
+
return this.formConfigFetcher.saveConfig(config, name, resourceID);
|
56
45
|
}
|
57
|
-
static async saveCardState(config, name) {
|
58
|
-
return this.formConfigFetcher.saveCardState(config, name,
|
46
|
+
static async saveCardState(config, name, resourceID) {
|
47
|
+
return this.formConfigFetcher.saveCardState(config, name, resourceID);
|
59
48
|
}
|
60
|
-
static async saveGridConfig(config, name) {
|
49
|
+
static async saveGridConfig(config, name, resourceID) {
|
61
50
|
if (config == undefined) {
|
62
51
|
return;
|
63
52
|
}
|
64
|
-
const cacheID = this.buildCacheID(name, CONFIG_SOURCE.grid);
|
53
|
+
const cacheID = this.buildCacheID(name, CONFIG_SOURCE.grid, resourceID);
|
65
54
|
this.configById.delete(cacheID);
|
66
|
-
return this.gridConfigFetcher.saveConfig(config, name,
|
55
|
+
return this.gridConfigFetcher.saveConfig(config, name, resourceID);
|
67
56
|
}
|
68
|
-
static async loadPersonalizedFilter(filterId, configName) {
|
69
|
-
return this.personalizedFilterFetcher.loadPersonalizedFilter(
|
57
|
+
static async loadPersonalizedFilter(filterId, resourceID, configName) {
|
58
|
+
return this.personalizedFilterFetcher.loadPersonalizedFilter(resourceID, filterId, configName);
|
70
59
|
}
|
71
|
-
static async savePersonalizedFilter(personalizedFilter, configName) {
|
60
|
+
static async savePersonalizedFilter(personalizedFilter, resourceID, configName) {
|
72
61
|
//Ao criar ou alterar um filtro personalizado,
|
73
62
|
//precisamos remover o cache do status da filterbar.
|
74
|
-
const cacheID = this.buildCacheID(configName, CONFIG_SOURCE.filterBar);
|
63
|
+
const cacheID = this.buildCacheID(configName, CONFIG_SOURCE.filterBar, resourceID);
|
75
64
|
this.configById.delete(cacheID);
|
76
|
-
return this.personalizedFilterFetcher.savePersonalizedFilter(personalizedFilter,
|
65
|
+
return this.personalizedFilterFetcher.savePersonalizedFilter(personalizedFilter, resourceID, configName);
|
77
66
|
}
|
78
|
-
static async removePersonalizedFilter(personalizedFilter, configName) {
|
79
|
-
return this.personalizedFilterFetcher.removePersonalizedFilter(personalizedFilter,
|
67
|
+
static async removePersonalizedFilter(personalizedFilter, resourceID, configName) {
|
68
|
+
return this.personalizedFilterFetcher.removePersonalizedFilter(personalizedFilter, resourceID, configName);
|
80
69
|
}
|
81
70
|
static async validatePersonalizedFilter(dataUnitName, expression) {
|
82
71
|
return this.personalizedFilterFetcher.validatePersonalizedFilter(dataUnitName, expression);
|
83
72
|
}
|
84
|
-
static buildCacheID(name, source) {
|
73
|
+
static buildCacheID(name, source, resourceID) {
|
85
74
|
if (name == undefined) {
|
86
|
-
return `req_${source}_${
|
75
|
+
return `req_${source}_${resourceID}`;
|
87
76
|
}
|
88
|
-
return `req_${source}_${name}_${
|
77
|
+
return `req_${source}_${name}_${resourceID}`;
|
89
78
|
}
|
90
79
|
}
|
91
80
|
ConfigStorage.configById = new Map();
|
@@ -1,31 +1,44 @@
|
|
1
|
-
import { ChangeOperation,
|
2
|
-
import { DISTINCT_FILTER_NAME_PREFIX } from "@sankhyalabs/ezui/dist/collection/utils/constants";
|
1
|
+
import { ChangeOperation, DataUnit, defaultDataLoader, StringUtils, } from '@sankhyalabs/core';
|
3
2
|
export default class InMemoryLoader {
|
4
3
|
constructor(metadata, records) {
|
5
|
-
this.records = records
|
4
|
+
this.records = records;
|
6
5
|
this.metadata = metadata;
|
7
6
|
this._dataUnit = new DataUnit(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME);
|
8
7
|
this._dataUnit.metadataLoader = () => this.metadaLoader();
|
9
|
-
this._dataUnit.dataLoader = (dataUnit, request) =>
|
8
|
+
this._dataUnit.dataLoader = (dataUnit, request) => defaultDataLoader(dataUnit, request, this.getRecordsToLoad());
|
10
9
|
this._dataUnit.saveLoader = (_dataUnit, changes) => this.saveLoader(_dataUnit, changes);
|
11
10
|
this._dataUnit.removeLoader = (_dataUnit, recordIds) => this.removeLoader(_dataUnit, recordIds);
|
12
11
|
this.dataUnit.loadMetadata().then(() => this.dataUnit.loadData());
|
13
12
|
}
|
13
|
+
getRecordsToLoad() {
|
14
|
+
if (this._initialRecords) {
|
15
|
+
try {
|
16
|
+
return this._initialRecords;
|
17
|
+
}
|
18
|
+
finally {
|
19
|
+
this._initialRecords = undefined;
|
20
|
+
}
|
21
|
+
}
|
22
|
+
return this.dataUnit.records;
|
23
|
+
}
|
14
24
|
get dataUnit() {
|
15
25
|
return this._dataUnit;
|
16
26
|
}
|
17
27
|
get records() {
|
18
|
-
return this.
|
28
|
+
return this.dataUnit.records;
|
19
29
|
}
|
20
30
|
set records(records) {
|
21
|
-
|
31
|
+
const newRecords = records === null || records === void 0 ? void 0 : records.map(record => {
|
22
32
|
if (!record["__record__id__"]) {
|
23
33
|
record["__record__id__"] = this.generateUniqueId();
|
24
34
|
}
|
25
35
|
return record;
|
26
36
|
});
|
27
37
|
if (this._dataUnit) {
|
28
|
-
this._dataUnit.records =
|
38
|
+
this._dataUnit.records = newRecords;
|
39
|
+
}
|
40
|
+
else {
|
41
|
+
this._initialRecords = newRecords;
|
29
42
|
}
|
30
43
|
}
|
31
44
|
get metadata() {
|
@@ -43,76 +56,16 @@ export default class InMemoryLoader {
|
|
43
56
|
metadaLoader() {
|
44
57
|
return Promise.resolve(this._metadata);
|
45
58
|
}
|
46
|
-
dataLoader(dataUnit, request) {
|
47
|
-
const filters = this.getColumnFilters(dataUnit);
|
48
|
-
let records = this.applyFilters(filters);
|
49
|
-
if (request.sort) {
|
50
|
-
request.sort.forEach(sort => {
|
51
|
-
records = records.sort((recordA, recordB) => {
|
52
|
-
const fieldA = recordA[sort.field];
|
53
|
-
const fieldB = recordB[sort.field];
|
54
|
-
const sortFn = this.getSortFn(sort.dataType);
|
55
|
-
return sortFn(fieldA, fieldB) * (sort.mode == SortMode.ASC ? 1 : -1);
|
56
|
-
});
|
57
|
-
});
|
58
|
-
}
|
59
|
-
return Promise.resolve({ records: records });
|
60
|
-
}
|
61
|
-
applyFilters(filters) {
|
62
|
-
let records = [...this._records];
|
63
|
-
filters.forEach(filter => {
|
64
|
-
records = records.filter(record => { var _a; return filter.values.includes((_a = record[filter.column]) === null || _a === void 0 ? void 0 : _a.toString()); });
|
65
|
-
});
|
66
|
-
return records;
|
67
|
-
}
|
68
|
-
getColumnFilters(dataUnit) {
|
69
|
-
var _a, _b;
|
70
|
-
const allFilters = (_a = dataUnit.getFilters()) !== null && _a !== void 0 ? _a : [];
|
71
|
-
const columnFilters = (_b = allFilters.filter(filter => { var _a; return (_a = filter.name) === null || _a === void 0 ? void 0 : _a.includes(DISTINCT_FILTER_NAME_PREFIX); })) !== null && _b !== void 0 ? _b : [];
|
72
|
-
return columnFilters.map(filter => {
|
73
|
-
var _a, _b;
|
74
|
-
return {
|
75
|
-
column: (_b = (_a = filter.name) === null || _a === void 0 ? void 0 : _a.replace(DISTINCT_FILTER_NAME_PREFIX, "")) !== null && _b !== void 0 ? _b : "",
|
76
|
-
values: filter.params.map(param => param.value),
|
77
|
-
};
|
78
|
-
});
|
79
|
-
}
|
80
|
-
getSortFn(type) {
|
81
|
-
switch (type) {
|
82
|
-
case DataType.NUMBER:
|
83
|
-
return this.sortNumber;
|
84
|
-
case DataType.DATE:
|
85
|
-
return this.sortDate;
|
86
|
-
case DataType.OBJECT:
|
87
|
-
return this.sortObject;
|
88
|
-
default:
|
89
|
-
return StringUtils.compare;
|
90
|
-
}
|
91
|
-
}
|
92
|
-
sortObject(a, b) {
|
93
|
-
return StringUtils.compare(a === null || a === void 0 ? void 0 : a["label"], b === null || b === void 0 ? void 0 : b["label"]);
|
94
|
-
}
|
95
|
-
sortNumber(a, b) {
|
96
|
-
return a - b;
|
97
|
-
}
|
98
|
-
sortDate(a, b) {
|
99
|
-
let timeA = a.getTime(), timeB = b.getTime();
|
100
|
-
return timeA === timeB ? 0 : (timeA < timeB ? -1 : 1);
|
101
|
-
}
|
102
59
|
saveLoader(_dataUnit, changes) {
|
103
60
|
return new Promise((resolve) => {
|
104
61
|
let dataUnitRecords = [];
|
105
62
|
changes.forEach(change => {
|
106
63
|
let { record, updatingFields, operation } = change;
|
107
|
-
|
64
|
+
const changedRecord = Object.assign(Object.assign({}, record), updatingFields);
|
108
65
|
if (operation === ChangeOperation.INSERT ||
|
109
66
|
operation === ChangeOperation.COPY) {
|
110
|
-
|
111
|
-
|
112
|
-
isAdd = true;
|
113
|
-
}
|
114
|
-
const changedRecord = Object.assign(Object.assign({}, record), updatingFields);
|
115
|
-
if (isAdd) {
|
67
|
+
changedRecord["__old__id__"] = record["__record__id__"];
|
68
|
+
changedRecord["__record__id__"] = this.generateUniqueId();
|
116
69
|
this.records.push(changedRecord);
|
117
70
|
}
|
118
71
|
else {
|
@@ -126,7 +79,6 @@ export default class InMemoryLoader {
|
|
126
79
|
}
|
127
80
|
removeLoader(_dataUnit, recordIds) {
|
128
81
|
return new Promise((resolve) => {
|
129
|
-
this._records = this._records.filter(record => !recordIds.includes(record["__record__id__"]));
|
130
82
|
resolve(recordIds);
|
131
83
|
});
|
132
84
|
}
|