@sankhyalabs/sankhyablocks 8.16.0-rc.2 → 8.16.0-rc.21
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/{ConfigStorage-a343e418.js → ConfigStorage-ecc0ed20.js} +2 -2
- package/dist/cjs/{IExporterProvider-597949f9.js → ContinuousInsertUtils-29b65619.js} +39 -6
- package/dist/cjs/{DataFetcher-313debd8.js → DataFetcher-cadeef8e.js} +21 -15
- package/dist/cjs/{RecordIDUtils-3735135c.js → GetSelectedRecordsIDsInfo-bd50caf1.js} +10 -10
- package/dist/cjs/{SnkFormConfigManager-166cbd1f.js → SnkFormConfigManager-f1c92f79.js} +72 -16
- package/dist/cjs/{SnkMessageBuilder-897ffd08.js → SnkMessageBuilder-bae64d0d.js} +6 -2
- package/dist/cjs/{auth-fetcher-54f5ff9d.js → auth-fetcher-d68841bc.js} +1 -1
- package/dist/cjs/{dataunit-fetcher-688d3f05.js → dataunit-fetcher-f89461c1.js} +46 -18
- package/dist/cjs/{field-search-f56aa7d6.js → field-search-68e34bf4.js} +5 -1
- package/dist/cjs/{form-config-fetcher-2dd00e5b.js → form-config-fetcher-ed497282.js} +5 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{pesquisa-fetcher-680e198f.js → pesquisa-fetcher-ca89181c.js} +1 -1
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-actions-button_4.cjs.entry.js +17 -14
- package/dist/cjs/snk-application.cjs.entry.js +17 -7
- package/dist/cjs/snk-attach.cjs.entry.js +38 -29
- package/dist/cjs/snk-crud.cjs.entry.js +21 -8
- package/dist/cjs/snk-data-exporter.cjs.entry.js +9 -9
- package/dist/cjs/{snk-data-unit-8fa7917a.js → snk-data-unit-d8279f5f.js} +43 -22
- package/dist/cjs/snk-data-unit.cjs.entry.js +5 -5
- package/dist/cjs/snk-detail-view.cjs.entry.js +11 -11
- package/dist/cjs/snk-exporter-email-sender.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-bar.cjs.entry.js +40 -25
- package/dist/cjs/snk-filter-binary-select.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-checkbox-list.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-modal-item.cjs.entry.js +3 -3
- package/dist/cjs/snk-form-config.cjs.entry.js +17 -5
- package/dist/cjs/snk-form.cjs.entry.js +7 -6
- package/dist/cjs/snk-grid.cjs.entry.js +66 -21
- package/dist/cjs/{snk-guides-viewer-bdc41281.js → snk-guides-viewer-b9920385.js} +29 -13
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +9 -9
- package/dist/cjs/snk-personalized-filter-editor.cjs.entry.js +1 -1
- package/dist/cjs/snk-personalized-filter.cjs.entry.js +3 -3
- package/dist/cjs/snk-print-selector.cjs.entry.js +1 -1
- package/dist/cjs/snk-simple-bar.cjs.entry.js +1 -1
- package/dist/cjs/snk-simple-crud.cjs.entry.js +56 -21
- package/dist/cjs/snk-taskbar.cjs.entry.js +61 -36
- package/dist/collection/components/snk-actions-button/actions/index.js +12 -9
- package/dist/collection/components/snk-application/snk-application.js +41 -1
- package/dist/collection/components/snk-attach/snk-attach.js +25 -16
- package/dist/collection/components/snk-attach/structure/fetcher/factory/attach-fetcher-data-unit.factory.js +2 -4
- package/dist/collection/components/snk-crud/snk-crud.js +103 -3
- package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +2 -2
- package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.css +6 -6
- package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +72 -6
- package/dist/collection/components/snk-data-exporter/exporter-email-sender/options-step.js +1 -1
- package/dist/collection/components/snk-data-exporter/providers/ClientSideExporterProvider.js +1 -1
- package/dist/collection/components/snk-data-exporter/providers/ServerSideExporterProvider.js +1 -1
- package/dist/collection/components/snk-data-exporter/structure/ItemBuilder.js +2 -2
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +41 -20
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-binary-select.js +1 -1
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-checkbox-list.js +1 -1
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-personalized-filter-editor/snk-personalized-filter-editor.js +1 -1
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.css +1 -1
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +77 -21
- package/dist/collection/components/snk-form/snk-form.js +2 -2
- package/dist/collection/components/snk-form-config/SnkFormConfigManager.js +70 -14
- package/dist/collection/components/snk-form-config/snk-form-config.js +32 -3
- package/dist/collection/components/snk-grid/snk-grid.css +2 -0
- package/dist/collection/components/snk-grid/snk-grid.js +100 -8
- package/dist/collection/components/snk-print-selector/snk-print-selector.js +1 -1
- package/dist/collection/components/snk-simple-bar/snk-simple-bar.js +1 -1
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.css +0 -1
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +82 -10
- package/dist/collection/components/snk-taskbar/processor/taskbar-processor.js +5 -1
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +103 -36
- package/dist/collection/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.js +3 -3
- package/dist/collection/lib/dataUnit/InMemoryLoader.js +2 -4
- package/dist/collection/lib/dataUnit/dataUnitInMemoryUtils.js +34 -9
- package/dist/collection/lib/http/data-fetcher/DataFetcher.js +22 -16
- package/dist/collection/lib/http/data-fetcher/fetchers/AttachFetcher/anexo-sistema-fetcher.js +7 -5
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js +9 -2
- package/dist/collection/lib/http/data-fetcher/fetchers/form-config-fetcher.js +4 -1
- package/dist/collection/lib/message/resources/snk-exporter.msg.js +1 -1
- package/dist/collection/lib/message/resources/snk-grid.msg.js +5 -1
- package/dist/collection/lib/utils/ContinuousInsertUtils.js +31 -0
- package/dist/collection/{components/snk-data-exporter/utils/RecordIDUtils.js → lib/utils/GetSelectedRecordsIDsInfo.js} +9 -9
- package/dist/components/{IExporterProvider.js → ContinuousInsertUtils.js} +40 -5
- package/dist/components/DataFetcher.js +22 -16
- package/dist/{esm/RecordIDUtils-87d02110.js → components/GetSelectedRecordsIDsInfo.js} +10 -10
- package/dist/components/SnkFormConfigManager.js +70 -14
- package/dist/components/SnkMessageBuilder.js +6 -2
- package/dist/components/dataunit-fetcher.js +45 -15
- package/dist/components/form-config-fetcher.js +4 -1
- package/dist/components/snk-actions-button2.js +12 -9
- package/dist/components/snk-application2.js +12 -1
- package/dist/components/snk-attach2.js +34 -25
- package/dist/components/snk-crud.js +20 -3
- package/dist/components/snk-data-exporter2.js +2 -2
- package/dist/components/snk-data-unit2.js +44 -60
- package/dist/components/snk-detail-view2.js +29 -10
- package/dist/components/snk-exporter-email-sender2.js +1 -1
- package/dist/components/snk-filter-bar2.js +39 -22
- package/dist/components/snk-filter-binary-select.js +1 -1
- package/dist/components/snk-filter-checkbox-list.js +1 -1
- package/dist/components/snk-form-config2.js +16 -3
- package/dist/components/snk-form.js +2 -2
- package/dist/components/snk-grid2.js +60 -12
- package/dist/components/snk-personalized-filter-editor.js +1 -1
- package/dist/components/snk-print-selector.js +1 -1
- package/dist/components/snk-simple-bar2.js +1 -1
- package/dist/components/snk-simple-crud2.js +49 -10
- package/dist/components/snk-taskbar2.js +63 -38
- package/dist/esm/{ConfigStorage-3806514e.js → ConfigStorage-7b36d041.js} +2 -2
- package/dist/esm/{IExporterProvider-63a188b6.js → ContinuousInsertUtils-30caa626.js} +40 -8
- package/dist/esm/{DataFetcher-c1baf61d.js → DataFetcher-a9c598f2.js} +22 -16
- package/dist/esm/GetSelectedRecordsIDsInfo-9fa41508.js +41 -0
- package/dist/esm/{SnkFormConfigManager-31b24066.js → SnkFormConfigManager-139f09fa.js} +72 -16
- package/dist/esm/{SnkMessageBuilder-571462fb.js → SnkMessageBuilder-6fff4a4c.js} +6 -2
- package/dist/esm/{auth-fetcher-039abba3.js → auth-fetcher-749d880f.js} +1 -1
- package/dist/esm/{dataunit-fetcher-264191b2.js → dataunit-fetcher-c24c76c6.js} +46 -16
- package/dist/esm/{field-search-efbe307f.js → field-search-f8b1d91e.js} +5 -1
- package/dist/esm/{form-config-fetcher-30fb808f.js → form-config-fetcher-adbe5d34.js} +5 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{pesquisa-fetcher-03c8f919.js → pesquisa-fetcher-8edaa8cd.js} +1 -1
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-actions-button_4.entry.js +17 -14
- package/dist/esm/snk-application.entry.js +17 -7
- package/dist/esm/snk-attach.entry.js +38 -29
- package/dist/esm/snk-crud.entry.js +21 -8
- package/dist/esm/snk-data-exporter.entry.js +9 -9
- package/dist/esm/{snk-data-unit-f5cbe64b.js → snk-data-unit-d10910d9.js} +43 -22
- package/dist/esm/snk-data-unit.entry.js +5 -5
- package/dist/esm/snk-detail-view.entry.js +11 -11
- package/dist/esm/snk-exporter-email-sender.entry.js +1 -1
- package/dist/esm/snk-filter-bar.entry.js +40 -25
- package/dist/esm/snk-filter-binary-select.entry.js +1 -1
- package/dist/esm/snk-filter-checkbox-list.entry.js +1 -1
- package/dist/esm/snk-filter-modal-item.entry.js +3 -3
- package/dist/esm/snk-form-config.entry.js +17 -5
- package/dist/esm/snk-form.entry.js +7 -6
- package/dist/esm/snk-grid.entry.js +61 -16
- package/dist/esm/{snk-guides-viewer-dda0fede.js → snk-guides-viewer-beb6baef.js} +29 -13
- package/dist/esm/snk-guides-viewer.entry.js +9 -9
- package/dist/esm/snk-personalized-filter-editor.entry.js +1 -1
- package/dist/esm/snk-personalized-filter.entry.js +3 -3
- package/dist/esm/snk-print-selector.entry.js +1 -1
- package/dist/esm/snk-simple-bar.entry.js +1 -1
- package/dist/esm/snk-simple-crud.entry.js +52 -17
- package/dist/esm/snk-taskbar.entry.js +62 -37
- package/dist/sankhyablocks/{p-df5451c7.js → p-06421fdb.js} +2 -2
- package/dist/sankhyablocks/p-16a1dd18.entry.js +1 -0
- package/dist/sankhyablocks/p-17425c72.js +1 -0
- package/dist/sankhyablocks/{p-af8efd95.js → p-1bf06cd3.js} +2 -2
- package/dist/sankhyablocks/{p-47db7e88.entry.js → p-212213d9.entry.js} +1 -1
- package/dist/sankhyablocks/p-23736d75.js +1 -0
- package/dist/sankhyablocks/p-2923c1b5.js +1 -0
- package/dist/sankhyablocks/{p-871aa14e.entry.js → p-31e74634.entry.js} +1 -1
- package/dist/sankhyablocks/p-38b85e5a.entry.js +1 -0
- package/dist/sankhyablocks/{p-72fc257b.entry.js → p-434817f0.entry.js} +1 -1
- package/dist/sankhyablocks/p-43acd479.entry.js +11 -0
- package/dist/sankhyablocks/{p-52920496.js → p-4d9549cf.js} +1 -1
- package/dist/sankhyablocks/p-50a3623b.entry.js +1 -0
- package/dist/sankhyablocks/p-520c7c38.entry.js +1 -0
- package/dist/sankhyablocks/p-52816250.entry.js +1 -0
- package/dist/sankhyablocks/p-5b51491f.entry.js +1 -0
- package/dist/sankhyablocks/{p-aaa3ee68.entry.js → p-5f157b09.entry.js} +1 -1
- package/dist/sankhyablocks/p-60b29483.entry.js +1 -0
- package/dist/sankhyablocks/p-62f5f14b.entry.js +1 -0
- package/dist/sankhyablocks/p-7ac7932c.js +60 -0
- package/dist/sankhyablocks/p-7dd49d15.js +1 -0
- package/dist/sankhyablocks/{p-41f8bfa3.entry.js → p-8c235d4c.entry.js} +1 -1
- package/dist/sankhyablocks/p-93592aae.js +1 -0
- package/dist/sankhyablocks/p-afbb070d.js +1 -0
- package/dist/sankhyablocks/p-bd1a1ca6.entry.js +1 -0
- package/dist/sankhyablocks/p-c2e468c9.entry.js +1 -0
- package/dist/sankhyablocks/p-c5546f92.js +1 -0
- package/dist/sankhyablocks/p-c6db5eeb.entry.js +1 -0
- package/dist/sankhyablocks/{p-913a9979.js → p-ca5ec380.js} +1 -1
- package/dist/sankhyablocks/p-d0a6fc0f.entry.js +1 -0
- package/dist/sankhyablocks/p-dcead955.entry.js +1 -0
- package/dist/sankhyablocks/p-eb9f0407.entry.js +1 -0
- package/dist/sankhyablocks/p-f3434fc4.js +1 -0
- package/dist/sankhyablocks/{p-2c68b3ae.entry.js → p-fb34e0cf.entry.js} +1 -1
- package/dist/sankhyablocks/p-fbb1b675.entry.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-actions-button/actions/index.d.ts +1 -0
- package/dist/types/components/snk-application/snk-application.d.ts +6 -1
- package/dist/types/components/snk-attach/snk-attach.d.ts +1 -0
- package/dist/types/components/snk-crud/snk-crud.d.ts +17 -0
- package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +15 -0
- package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +1 -0
- package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +9 -0
- package/dist/types/components/snk-form-config/SnkFormConfigManager.d.ts +7 -2
- package/dist/types/components/snk-form-config/snk-form-config.d.ts +4 -0
- package/dist/types/components/snk-grid/snk-grid.d.ts +15 -0
- package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +10 -0
- package/dist/types/components/snk-taskbar/processor/taskbar-processor.d.ts +1 -0
- package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +11 -0
- package/dist/types/components.d.ts +119 -0
- package/dist/types/lib/dataUnit/dataUnitInMemoryUtils.d.ts +12 -2
- package/dist/types/lib/http/data-fetcher/fetchers/AttachFetcher/anexo-sistema-fetcher.d.ts +3 -2
- package/dist/types/lib/utils/ContinuousInsertUtils.d.ts +10 -0
- package/dist/types/lib/utils/GetSelectedRecordsIDsInfo.d.ts +3 -0
- package/package.json +2 -2
- package/dist/sankhyablocks/p-17def7cd.js +0 -1
- package/dist/sankhyablocks/p-219f888d.entry.js +0 -1
- package/dist/sankhyablocks/p-2a408684.js +0 -1
- package/dist/sankhyablocks/p-3a212712.js +0 -1
- package/dist/sankhyablocks/p-450c60e4.entry.js +0 -1
- package/dist/sankhyablocks/p-4e5e1313.entry.js +0 -1
- package/dist/sankhyablocks/p-62ba211a.entry.js +0 -1
- package/dist/sankhyablocks/p-6bb2f3e9.entry.js +0 -1
- package/dist/sankhyablocks/p-7505da04.entry.js +0 -1
- package/dist/sankhyablocks/p-75e674ed.entry.js +0 -1
- package/dist/sankhyablocks/p-7619bdb1.entry.js +0 -11
- package/dist/sankhyablocks/p-7a85fd49.entry.js +0 -1
- package/dist/sankhyablocks/p-7ef9c55c.js +0 -1
- package/dist/sankhyablocks/p-80042dc6.entry.js +0 -1
- package/dist/sankhyablocks/p-88aa931b.entry.js +0 -1
- package/dist/sankhyablocks/p-8c59edd7.entry.js +0 -1
- package/dist/sankhyablocks/p-9863d682.js +0 -1
- package/dist/sankhyablocks/p-b05d8893.entry.js +0 -1
- package/dist/sankhyablocks/p-b11aa1e0.entry.js +0 -1
- package/dist/sankhyablocks/p-c2495304.js +0 -1
- package/dist/sankhyablocks/p-d6e26ea8.entry.js +0 -1
- package/dist/sankhyablocks/p-dc7c9047.js +0 -1
- package/dist/sankhyablocks/p-f2809746.entry.js +0 -1
- package/dist/sankhyablocks/p-fa4d8cb4.js +0 -1
- package/dist/sankhyablocks/p-fe79f83a.js +0 -60
- package/dist/types/components/snk-data-exporter/utils/RecordIDUtils.d.ts +0 -3
@@ -1,5 +1,5 @@
|
|
1
1
|
import { ApplicationContext, DataType, ElementIDUtils, FloatingManager, JSUtils, ObjectUtils, StringUtils, UserInterface, } from '@sankhyalabs/core';
|
2
|
-
import { CSSVarsUtils } from
|
2
|
+
import { CSSVarsUtils } from '@sankhyalabs/ezui/dist/collection/utils';
|
3
3
|
import { h } from '@stencil/core';
|
4
4
|
import { SIMPLE_CRUD_MODE, VIEW_MODE } from '../../lib/utils/constants';
|
5
5
|
import { TaskbarElement } from '../snk-taskbar/elements/taskbar-elements';
|
@@ -13,7 +13,8 @@ import { SnkFormConfigManager } from '../snk-form-config/SnkFormConfigManager';
|
|
13
13
|
import { REGULAR_DEFAULT_BTNS, REGULAR_SELECTED_BTNS } from './regular-buttons';
|
14
14
|
import RmPrecisionCustomValueFormatter from '../../lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter';
|
15
15
|
import ClientSideExporterProvider from '../snk-data-exporter/providers/ClientSideExporterProvider';
|
16
|
-
import store from
|
16
|
+
import store from '../../lib/store';
|
17
|
+
import { ContinuousInsertUtils } from '../../lib/utils/ContinuousInsertUtils';
|
17
18
|
export class SnkSimpleCrud {
|
18
19
|
constructor() {
|
19
20
|
this._multiSelectionListDataSource = new SnkMultiSelectionListDataSource();
|
@@ -26,7 +27,7 @@ export class SnkSimpleCrud {
|
|
26
27
|
"snkSimpleCrudTaskbar.grid_regular": this.getButtons(false, [TaskbarElement.DATA_EXPORTER, TaskbarElement.FORM_MODE]),
|
27
28
|
"snkSimpleCrudTaskbar.form_selected": this.getButtons(true, [TaskbarElement.GRID_MODE]),
|
28
29
|
"snkSimpleCrudTaskbar.grid_selected": this.getButtons(true, [TaskbarElement.DATA_EXPORTER, TaskbarElement.FORM_MODE]),
|
29
|
-
"snkSimpleCrudTaskbar.finish_edition":
|
30
|
+
"snkSimpleCrudTaskbar.finish_edition": this.getFinishEditionButtonsCallback.bind(this)
|
30
31
|
});
|
31
32
|
this._showPopUpGridConfig = false;
|
32
33
|
this._showFormConfig = false;
|
@@ -40,12 +41,15 @@ export class SnkSimpleCrud {
|
|
40
41
|
this.mode = SIMPLE_CRUD_MODE.SERVER;
|
41
42
|
this.gridConfig = undefined;
|
42
43
|
this.formConfig = undefined;
|
44
|
+
this.enableLockManger = false;
|
43
45
|
this._formFields = [];
|
44
46
|
this._fieldsProps = new Map();
|
47
|
+
this._enableContinuousInsert = true;
|
45
48
|
this.multipleSelection = undefined;
|
46
49
|
this.useCancelConfirm = true;
|
47
50
|
this.pageSize = 150;
|
48
51
|
this.resourceID = undefined;
|
52
|
+
this.enableGridInsert = false;
|
49
53
|
this.taskbarManager = undefined;
|
50
54
|
this.messagesBuilder = undefined;
|
51
55
|
this.useEnterLikeTab = false;
|
@@ -115,6 +119,13 @@ export class SnkSimpleCrud {
|
|
115
119
|
newCustomFieldProps.set(fieldName, Object.assign(Object.assign({}, currentProps), { [propName]: value }));
|
116
120
|
this._fieldsProps = newCustomFieldProps;
|
117
121
|
}
|
122
|
+
getFinishEditionButtonsCallback() {
|
123
|
+
const btns = ["CANCEL", "SAVE"];
|
124
|
+
if (this.enableGridInsert && this._currentViewMode !== VIEW_MODE.ATTACHMENT) {
|
125
|
+
btns.push(this._currentViewMode === VIEW_MODE.GRID ? TaskbarElement.FORM_MODE : TaskbarElement.GRID_MODE);
|
126
|
+
}
|
127
|
+
return btns;
|
128
|
+
}
|
118
129
|
getButtons(selected, extraButtons) {
|
119
130
|
return this.addConfigButton(this.resolveInMemoryBtns(selected ? REGULAR_SELECTED_BTNS : REGULAR_DEFAULT_BTNS)
|
120
131
|
.concat(extraButtons));
|
@@ -197,7 +208,6 @@ export class SnkSimpleCrud {
|
|
197
208
|
await this.setFieldProp(field, 'precision', rmPrecision);
|
198
209
|
await this.setFieldProp(field, 'prettyPrecision', rmPrecision);
|
199
210
|
}
|
200
|
-
;
|
201
211
|
this._rmPrecisionCustomValueFormatter.setDataState(this.dataState);
|
202
212
|
}
|
203
213
|
async handleUpdateGridLegacyConfig(newValue, oldValue) {
|
@@ -279,7 +289,7 @@ export class SnkSimpleCrud {
|
|
279
289
|
return;
|
280
290
|
}
|
281
291
|
if (this._formConfigManager == undefined) {
|
282
|
-
this._formConfigManager = new SnkFormConfigManager(this.configName, this.resolveResourceID());
|
292
|
+
this._formConfigManager = new SnkFormConfigManager(this.configName, this.resolveResourceID(), undefined, this.dataUnit);
|
283
293
|
this._formConfigManager.setConfig(this.formConfig);
|
284
294
|
}
|
285
295
|
if (this.formConfigIsLoaded() && !forceLoad) {
|
@@ -320,6 +330,10 @@ export class SnkSimpleCrud {
|
|
320
330
|
this.onModeChange();
|
321
331
|
this.configDatasource();
|
322
332
|
this._rmPrecisionCustomValueFormatter = new RmPrecisionCustomValueFormatter();
|
333
|
+
this._continuousInsertUtils = new ContinuousInsertUtils(this.application, this.resolveResourceID(), this.configName);
|
334
|
+
if (this.enableGridInsert) {
|
335
|
+
this._continuousInsertUtils.getConfig().then(value => this._enableContinuousInsert = value);
|
336
|
+
}
|
323
337
|
}
|
324
338
|
componentDidLoad() {
|
325
339
|
CSSVarsUtils.applyVarsGrid(this._element, this._grid);
|
@@ -554,6 +568,9 @@ export class SnkSimpleCrud {
|
|
554
568
|
const options = filteredFields.map(field => ({ value: field.name, label: field.label }));
|
555
569
|
return Promise.resolve(options);
|
556
570
|
}
|
571
|
+
isGridInsertActive() {
|
572
|
+
return this.enableGridInsert && this.dataUnit.hasNewRecord();
|
573
|
+
}
|
557
574
|
getActionsList() {
|
558
575
|
var _a, _b;
|
559
576
|
const hardList = [{
|
@@ -565,11 +582,21 @@ export class SnkSimpleCrud {
|
|
565
582
|
? this.getColumnSearch(actionButton, item)
|
566
583
|
: this.getFieldSearch(actionButton, item)
|
567
584
|
}];
|
585
|
+
if (this.enableGridInsert) {
|
586
|
+
hardList.push(this._continuousInsertUtils.actionContinuousInsert(this._enableContinuousInsert, () => {
|
587
|
+
this._enableContinuousInsert = !this._enableContinuousInsert;
|
588
|
+
this._continuousInsertUtils.handleSaveConfig(this._enableContinuousInsert);
|
589
|
+
}));
|
590
|
+
}
|
591
|
+
if (this.isGridInsertActive())
|
592
|
+
return hardList;
|
568
593
|
if (this.taskbarManager != undefined && this.taskbarManager.getMoreOptions != undefined) {
|
569
594
|
const taskbarID = this.getTopTaskBarId();
|
570
595
|
return hardList.concat(this.taskbarManager.getMoreOptions(taskbarID, this.configName, this.dataState, this.actionsList));
|
571
596
|
}
|
572
|
-
|
597
|
+
if (this.actionsList)
|
598
|
+
return hardList.concat(this.actionsList);
|
599
|
+
return hardList;
|
573
600
|
}
|
574
601
|
getTopTaskBarId() {
|
575
602
|
var _a;
|
@@ -614,9 +641,11 @@ export class SnkSimpleCrud {
|
|
614
641
|
window.removeEventListener("keydown", this._keyDownHandler);
|
615
642
|
}
|
616
643
|
gridConfigChangeHandler(evt) {
|
644
|
+
evt.stopPropagation();
|
645
|
+
if (!this.configName)
|
646
|
+
return;
|
617
647
|
const config = evt.detail;
|
618
648
|
ConfigStorage.saveGridConfig(config, this.configName, this.resolveResourceID());
|
619
|
-
evt.stopPropagation();
|
620
649
|
}
|
621
650
|
modalConfigChangeHandler(evt) {
|
622
651
|
const config = evt.detail;
|
@@ -688,15 +717,21 @@ export class SnkSimpleCrud {
|
|
688
717
|
}
|
689
718
|
this._formConfigManager.setConfig(this.formConfig);
|
690
719
|
}
|
720
|
+
handleDataUnitOnInsertionMode() {
|
721
|
+
if (this.enableGridInsert)
|
722
|
+
return;
|
723
|
+
this.goToView(VIEW_MODE.FORM);
|
724
|
+
}
|
691
725
|
/* istanbul ignore next */
|
692
726
|
render() {
|
693
727
|
var _a;
|
694
728
|
if (this.dataUnit == undefined) {
|
695
729
|
return;
|
696
730
|
}
|
697
|
-
|
731
|
+
const taskbarContent = (h("snk-taskbar", { class: this._currentViewMode === VIEW_MODE.FORM && "ez-box ez-box--shadow ez-padding--small", dataUnit: this.dataUnit, primaryButton: ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? "SAVE" : "INSERT", "data-element-id": "grid_left", messagesBuilder: this.messagesBuilder, buttons: this._taskbarProcessor.buttons, actionsList: this.getActionsList(), disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, "data-exporter-store-key": this.getDataExporterStoreKey(), slot: "leftButtons", presentationMode: PresentationMode.SECONDARY }, h("slot", { name: "TASKBAR_CUSTOM_ELEMENTS" })));
|
732
|
+
return (h("snk-data-unit", { ref: ref => this._snkDataUnit = ref, class: "simple-crud__container", dataUnit: this.dataUnit, useCancelConfirm: this.useCancelConfirm, onDataStateChange: evt => this.onDataStateChange(evt), onCancelEdition: this.handleCancelEdit.bind(this), pageSize: this.getPageSize(), onInsertionMode: this.handleDataUnitOnInsertionMode.bind(this), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail), ignoreSaveMessage: this._currentViewMode === VIEW_MODE.GRID, onMessagesBuilderUpdated: evt => this.messagesBuilder = evt.detail, onDataUnitFieldsHidded: this.updateFormConfig.bind(this), domainMessagesBuilder: this.domainMessagesBuilder }, h("header", null, h("slot", { name: "snkSimpleCrudHeader" })), h("section", { class: "ez-box ez-box--shadow simple-crud__container-section" }, this._currentViewMode === VIEW_MODE.FORM && taskbarContent, h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, h("stack-item", null, h("ez-grid", { class: "ez-margin-bottom--large", ref: ref => this._grid = ref, dataUnit: this.dataUnit, config: this.gridConfig, "no-header": true, multipleSelection: this.multipleSelection, onEzDoubleClick: () => this.goToView(VIEW_MODE.FORM), onConfigChange: evt => this.gridConfigChangeHandler(evt), columnfilterDataSource: this.dataUnit.name && this.dataUnit.name.includes(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME)
|
698
733
|
? undefined
|
699
|
-
: this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab, autoFocus: this.autoFocus }, h("div", { slot: "footer" }, h("slot", { name: "snkSimpleCrudFooter" })))), h("stack-item", null, h("ez-form", { ref: (ref) => this._form = ref, class: `ez-margin-top--large ${this.handleShowFormConfig() ? "simple-crud__form--hidden" : ""}`, dataUnit: this.dataUnit, config: this.getFormConfig(), fieldToFocus: this._fieldToGetFocus, onEzFormSetFields: (evt) => this.handleFormSetFields(evt.detail), onEzFormRequestClearFieldToFocus: this.clearFieldToFocusHandler.bind(this) }), this.handleShowFormConfig() && h("snk-form-config", { messagesBuilder: this.messagesBuilder, dataUnit: this.dataUnit, configManager: this._formConfigManager, onConfigClose: () => this.closeFormConfig() })), this.messagesBuilder && h("snk-configurator", { ref: (ref) => this._snkConfigurator = ref, viewMode: this._currentViewMode, messagesBuilder: this.messagesBuilder, onConfigSelected: (evt) => this.goToView(evt.detail), onOpenConfig: (evt) => this.openConfig(evt.detail), showActionButtons: this.showConfiguratorButtons, onSave: evt => this.handleConfiguratorEvent(evt, 'SAVE'), onCancel: evt => this.handleConfiguratorEvent(evt, 'CANCEL'), resourceID: this.resolveResourceID(), customContainerId: this._customContainerId })), h("div", { id: `${this._customContainerId}` }, h("slot", { name: "SnkConfigContainerSlot" }))), h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._showPopUpGridConfig, onEzCloseModal: () => this.closeGridConfig() }, h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this.gridConfig, "data-element-id": this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this.resolveResourceID() }))));
|
734
|
+
: this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab, autoFocus: this.autoFocus, enableGridInsert: this.enableGridInsert, enableContinuousInsert: this._enableContinuousInsert, enableLockManger: this.enableLockManger }, this._currentViewMode === VIEW_MODE.GRID && taskbarContent, h("div", { slot: "footer" }, h("slot", { name: "snkSimpleCrudFooter" })))), h("stack-item", null, h("ez-form", { ref: (ref) => this._form = ref, class: `ez-margin-top--large ${this.handleShowFormConfig() ? "simple-crud__form--hidden" : ""}`, dataUnit: this.dataUnit, config: this.getFormConfig(), fieldToFocus: this._fieldToGetFocus, onEzFormSetFields: (evt) => this.handleFormSetFields(evt.detail), onEzFormRequestClearFieldToFocus: this.clearFieldToFocusHandler.bind(this) }), this.handleShowFormConfig() && h("snk-form-config", { messagesBuilder: this.messagesBuilder, dataUnit: this.dataUnit, configManager: this._formConfigManager, onConfigClose: () => this.closeFormConfig() })), this.messagesBuilder && h("snk-configurator", { ref: (ref) => this._snkConfigurator = ref, viewMode: this._currentViewMode, messagesBuilder: this.messagesBuilder, onConfigSelected: (evt) => this.goToView(evt.detail), onOpenConfig: (evt) => this.openConfig(evt.detail), showActionButtons: this.showConfiguratorButtons, onSave: evt => this.handleConfiguratorEvent(evt, 'SAVE'), onCancel: evt => this.handleConfiguratorEvent(evt, 'CANCEL'), resourceID: this.resolveResourceID(), customContainerId: this._customContainerId })), h("div", { id: `${this._customContainerId}` }, h("slot", { name: "SnkConfigContainerSlot" }))), h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._showPopUpGridConfig, onEzCloseModal: () => this.closeGridConfig() }, h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this.gridConfig, "data-element-id": this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this.resolveResourceID() }))));
|
700
735
|
}
|
701
736
|
static get is() { return "snk-simple-crud"; }
|
702
737
|
static get encapsulation() { return "scoped"; }
|
@@ -832,6 +867,24 @@ export class SnkSimpleCrud {
|
|
832
867
|
"text": ""
|
833
868
|
}
|
834
869
|
},
|
870
|
+
"enableLockManger": {
|
871
|
+
"type": "boolean",
|
872
|
+
"mutable": false,
|
873
|
+
"complexType": {
|
874
|
+
"original": "boolean",
|
875
|
+
"resolved": "boolean",
|
876
|
+
"references": {}
|
877
|
+
},
|
878
|
+
"required": false,
|
879
|
+
"optional": true,
|
880
|
+
"docs": {
|
881
|
+
"tags": [],
|
882
|
+
"text": ""
|
883
|
+
},
|
884
|
+
"attribute": "enable-lock-manger",
|
885
|
+
"reflect": false,
|
886
|
+
"defaultValue": "false"
|
887
|
+
},
|
835
888
|
"multipleSelection": {
|
836
889
|
"type": "boolean",
|
837
890
|
"mutable": false,
|
@@ -902,6 +955,24 @@ export class SnkSimpleCrud {
|
|
902
955
|
"attribute": "resource-i-d",
|
903
956
|
"reflect": false
|
904
957
|
},
|
958
|
+
"enableGridInsert": {
|
959
|
+
"type": "boolean",
|
960
|
+
"mutable": false,
|
961
|
+
"complexType": {
|
962
|
+
"original": "boolean",
|
963
|
+
"resolved": "boolean",
|
964
|
+
"references": {}
|
965
|
+
},
|
966
|
+
"required": false,
|
967
|
+
"optional": true,
|
968
|
+
"docs": {
|
969
|
+
"tags": [],
|
970
|
+
"text": "Ativa inser\u00E7\u00E3o de registros no modo grade."
|
971
|
+
},
|
972
|
+
"attribute": "enable-grid-insert",
|
973
|
+
"reflect": false,
|
974
|
+
"defaultValue": "false"
|
975
|
+
},
|
905
976
|
"taskbarManager": {
|
906
977
|
"type": "unknown",
|
907
978
|
"mutable": false,
|
@@ -1132,7 +1203,8 @@ export class SnkSimpleCrud {
|
|
1132
1203
|
"_fieldToGetFocus": {},
|
1133
1204
|
"_customContainerId": {},
|
1134
1205
|
"_formFields": {},
|
1135
|
-
"_fieldsProps": {}
|
1206
|
+
"_fieldsProps": {},
|
1207
|
+
"_enableContinuousInsert": {}
|
1136
1208
|
};
|
1137
1209
|
}
|
1138
1210
|
static get events() {
|
@@ -29,12 +29,16 @@ export default class TaskbarProcessor {
|
|
29
29
|
});
|
30
30
|
}
|
31
31
|
getButtonsArray(taskbarId, taskbarManager, dataState) {
|
32
|
-
const defaults = this.
|
32
|
+
const defaults = this.getButtonsFromKey(taskbarId);
|
33
33
|
if (taskbarManager) {
|
34
34
|
return taskbarManager.getButtons(taskbarId, dataState, [...defaults]);
|
35
35
|
}
|
36
36
|
return defaults;
|
37
37
|
}
|
38
|
+
getButtonsFromKey(taskbarId) {
|
39
|
+
const btnsValue = this._defaultButtons[taskbarId];
|
40
|
+
return typeof btnsValue === 'function' ? btnsValue() : btnsValue;
|
41
|
+
}
|
38
42
|
isEnabled(taskbarId, taskbarManager, buttonName, dataState, disabled) {
|
39
43
|
const originalValue = disabled.includes(buttonName) ? false : true;
|
40
44
|
if (taskbarManager && taskbarManager.isEnabled) {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { ApplicationContext, ElementIDUtils, OverflowDirection, OverflowWatcher, StringUtils, OVERFLOWED_CLASS_NAME } from '@sankhyalabs/core';
|
1
|
+
import { ApplicationContext, ElementIDUtils, OverflowDirection, OverflowWatcher, StringUtils, OVERFLOWED_CLASS_NAME, LockManager, LockManagerOperation } from '@sankhyalabs/core';
|
2
2
|
import { h, Host } from '@stencil/core';
|
3
3
|
import { AuthorizationConfig } from '../snk-configurator/AuthorizationConfig';
|
4
4
|
import { AuthorizationElements, buildCustomButton, buildElem, TaskbarElement, VisibleWhenForbidden, } from './elements/taskbar-elements';
|
@@ -29,8 +29,10 @@ export class SnkTaskbar {
|
|
29
29
|
this.onSaveEvent = (action) => {
|
30
30
|
switch (action.type) {
|
31
31
|
case DUAction.FIELD_INVALIDATED:
|
32
|
+
case DUAction.INVALIDATE_CLEAN:
|
32
33
|
case DUAction.DATA_SAVED:
|
33
34
|
case DUAction.SAVING_ERROR:
|
35
|
+
case DUAction.SAVING_CANCELED:
|
34
36
|
this._isWaitingForSave = false;
|
35
37
|
break;
|
36
38
|
case DUAction.SAVING_DATA:
|
@@ -67,6 +69,16 @@ export class SnkTaskbar {
|
|
67
69
|
this.getCustomElements(true);
|
68
70
|
}
|
69
71
|
}
|
72
|
+
handleTaskbarSaveLocker() {
|
73
|
+
if (this._isWaitingForSave !== true) {
|
74
|
+
this._isWaitingForSave = true;
|
75
|
+
}
|
76
|
+
}
|
77
|
+
handleTaskbarSaveUnlocker() {
|
78
|
+
if (this._isWaitingForSave === true) {
|
79
|
+
this._isWaitingForSave = false;
|
80
|
+
}
|
81
|
+
}
|
70
82
|
hasToSearchCustomElements(event) {
|
71
83
|
return this.customSlotId === event.detail && !this._slotContainer;
|
72
84
|
}
|
@@ -85,6 +97,14 @@ export class SnkTaskbar {
|
|
85
97
|
this._hasToUpdateOverFlow = true;
|
86
98
|
}
|
87
99
|
}
|
100
|
+
observeIsWaitingForSave(newValue, oldValue) {
|
101
|
+
if (newValue == true && oldValue == false) {
|
102
|
+
this.taskbarSaveLocker.emit();
|
103
|
+
}
|
104
|
+
if (newValue == false && oldValue == true) {
|
105
|
+
this.taskbarSaveUnlocker.emit();
|
106
|
+
}
|
107
|
+
}
|
88
108
|
// Internal methods
|
89
109
|
elementsFromString(strButtons) {
|
90
110
|
const elements = [];
|
@@ -129,42 +149,44 @@ export class SnkTaskbar {
|
|
129
149
|
return key ? (_a = this.messagesBuilder) === null || _a === void 0 ? void 0 : _a.getMessage(key, {}) : "";
|
130
150
|
}
|
131
151
|
elementClick(elem) {
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
this._isWaitingForSave
|
158
|
-
|
159
|
-
.
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
152
|
+
LockManager.whenResolve(this._element, LockManagerOperation.TASKBAR_CLICK).then(() => {
|
153
|
+
if (this.dataUnit) {
|
154
|
+
switch (elem) {
|
155
|
+
case TaskbarElement.PREVIOUS:
|
156
|
+
this.dataUnit.previousRecord();
|
157
|
+
break;
|
158
|
+
case TaskbarElement.NEXT:
|
159
|
+
this.dataUnit.nextRecord();
|
160
|
+
break;
|
161
|
+
case TaskbarElement.REFRESH:
|
162
|
+
this.dataUnit.loadData();
|
163
|
+
break;
|
164
|
+
case TaskbarElement.CLONE:
|
165
|
+
this.dataUnit.copySelected();
|
166
|
+
break;
|
167
|
+
case TaskbarElement.REMOVE:
|
168
|
+
this.dataUnit.removeSelectedRecords();
|
169
|
+
break;
|
170
|
+
case TaskbarElement.INSERT:
|
171
|
+
this.dataUnit.addRecord();
|
172
|
+
break;
|
173
|
+
case TaskbarElement.CANCEL:
|
174
|
+
this.dataUnit.cancelEdition();
|
175
|
+
break;
|
176
|
+
case TaskbarElement.SAVE:
|
177
|
+
if (!this._isWaitingForSave) {
|
178
|
+
this._isWaitingForSave = true;
|
179
|
+
this.dataUnit.saveData()
|
180
|
+
.finally(() => {
|
181
|
+
this._isWaitingForSave = false;
|
182
|
+
});
|
183
|
+
}
|
184
|
+
break;
|
185
|
+
}
|
164
186
|
}
|
165
|
-
|
166
|
-
|
167
|
-
|
187
|
+
if (this.isEnabled(elem))
|
188
|
+
this.actionClick.emit(elem);
|
189
|
+
});
|
168
190
|
}
|
169
191
|
isEnabled(elem) {
|
170
192
|
if (!this.isAllowed(elem)) {
|
@@ -719,6 +741,36 @@ export class SnkTaskbar {
|
|
719
741
|
"resolved": "string",
|
720
742
|
"references": {}
|
721
743
|
}
|
744
|
+
}, {
|
745
|
+
"method": "taskbarSaveLocker",
|
746
|
+
"name": "taskbarSaveLocker",
|
747
|
+
"bubbles": true,
|
748
|
+
"cancelable": true,
|
749
|
+
"composed": true,
|
750
|
+
"docs": {
|
751
|
+
"tags": [],
|
752
|
+
"text": "Emitido sempre que um save \u00E9 iniciado pela taskbar."
|
753
|
+
},
|
754
|
+
"complexType": {
|
755
|
+
"original": "void",
|
756
|
+
"resolved": "void",
|
757
|
+
"references": {}
|
758
|
+
}
|
759
|
+
}, {
|
760
|
+
"method": "taskbarSaveUnlocker",
|
761
|
+
"name": "taskbarSaveUnlocker",
|
762
|
+
"bubbles": true,
|
763
|
+
"cancelable": true,
|
764
|
+
"composed": true,
|
765
|
+
"docs": {
|
766
|
+
"tags": [],
|
767
|
+
"text": "Emitido sempre que o ocorre alguma action que libera o save."
|
768
|
+
},
|
769
|
+
"complexType": {
|
770
|
+
"original": "void",
|
771
|
+
"resolved": "void",
|
772
|
+
"references": {}
|
773
|
+
}
|
722
774
|
}];
|
723
775
|
}
|
724
776
|
static get elementRef() { return "_element"; }
|
@@ -732,6 +784,9 @@ export class SnkTaskbar {
|
|
732
784
|
}, {
|
733
785
|
"propName": "_lastWidth",
|
734
786
|
"methodName": "observeLastWidth"
|
787
|
+
}, {
|
788
|
+
"propName": "_isWaitingForSave",
|
789
|
+
"methodName": "observeIsWaitingForSave"
|
735
790
|
}];
|
736
791
|
}
|
737
792
|
static get listeners() {
|
@@ -741,6 +796,18 @@ export class SnkTaskbar {
|
|
741
796
|
"target": "window",
|
742
797
|
"capture": false,
|
743
798
|
"passive": false
|
799
|
+
}, {
|
800
|
+
"name": "taskbarSaveLocker",
|
801
|
+
"method": "handleTaskbarSaveLocker",
|
802
|
+
"target": "window",
|
803
|
+
"capture": false,
|
804
|
+
"passive": false
|
805
|
+
}, {
|
806
|
+
"name": "taskbarSaveUnlocker",
|
807
|
+
"method": "handleTaskbarSaveUnlocker",
|
808
|
+
"target": "window",
|
809
|
+
"capture": false,
|
810
|
+
"passive": false
|
744
811
|
}];
|
745
812
|
}
|
746
813
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { NumberUtils, ObjectUtils } from "@sankhyalabs/core";
|
1
|
+
import { NumberUtils, ObjectUtils, StringUtils } from "@sankhyalabs/core";
|
2
2
|
export default class RmPrecisionCustomValueFormatter {
|
3
3
|
setGrid(grid) {
|
4
4
|
if (this._grid) {
|
@@ -8,7 +8,7 @@ export default class RmPrecisionCustomValueFormatter {
|
|
8
8
|
this.refreshSelectedRows();
|
9
9
|
}
|
10
10
|
setDataState(dataState) {
|
11
|
-
if (ObjectUtils.
|
11
|
+
if (this._dataState && ObjectUtils.equals(dataState === null || dataState === void 0 ? void 0 : dataState.metadataByRow, this._dataState.metadataByRow)) {
|
12
12
|
return;
|
13
13
|
}
|
14
14
|
this._dataState = dataState;
|
@@ -16,7 +16,7 @@ export default class RmPrecisionCustomValueFormatter {
|
|
16
16
|
}
|
17
17
|
format(currentValue, column, recordId) {
|
18
18
|
var _a;
|
19
|
-
if (
|
19
|
+
if (StringUtils.isEmpty(currentValue)) {
|
20
20
|
return currentValue;
|
21
21
|
}
|
22
22
|
const rowMetadata = (_a = this._dataState) === null || _a === void 0 ? void 0 : _a.metadataByRow.get(recordId);
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { ChangeOperation, DataType, DataUnit, DateUtils, StringUtils, } from '@sankhyalabs/core';
|
2
|
-
import {
|
2
|
+
import { buildLoadDataResponse } from './dataUnitInMemoryUtils';
|
3
3
|
export default class InMemoryLoader {
|
4
4
|
constructor(metadata, records, config) {
|
5
5
|
this.metadata = metadata;
|
@@ -82,9 +82,7 @@ export default class InMemoryLoader {
|
|
82
82
|
return StringUtils.generateUUID();
|
83
83
|
}
|
84
84
|
inMemoryLoader(dataUnit, request, recordsIn) {
|
85
|
-
|
86
|
-
records = applySorting(records, dataUnit, request.sort);
|
87
|
-
return Promise.resolve({ records, paginationInfo: buildPaginationInfo(records, request.offset, request.limit) });
|
85
|
+
return buildLoadDataResponse(recordsIn, dataUnit, request);
|
88
86
|
}
|
89
87
|
metadaLoader() {
|
90
88
|
return Promise.resolve(this._metadata);
|
@@ -11,6 +11,21 @@ export function applyFilter(records, dataUnit, filters) {
|
|
11
11
|
}
|
12
12
|
return records.filter(filterFunction);
|
13
13
|
}
|
14
|
+
export function buildLoadDataResponse(recordsIn, dataUnit, request) {
|
15
|
+
let records = recordsIn ? [...recordsIn] : [];
|
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: buildPaginationInfo(paginationInfoBuilderParams),
|
27
|
+
});
|
28
|
+
}
|
14
29
|
export function applySorting(records, dataUnit, sorting) {
|
15
30
|
if (sorting == undefined || sorting.length == 0) {
|
16
31
|
return records;
|
@@ -21,17 +36,27 @@ export function applySorting(records, dataUnit, sorting) {
|
|
21
36
|
}
|
22
37
|
return records.sort(sortingFunction);
|
23
38
|
}
|
24
|
-
|
25
|
-
|
26
|
-
|
39
|
+
function hasValidLimitAndOffset(offset, limit) {
|
40
|
+
return offset >= 0 && limit >= 0;
|
41
|
+
}
|
42
|
+
export function getPagesByRecords(records, offset = 0, limit = 0) {
|
43
|
+
if (!records || !records.length || !hasValidLimitAndOffset(offset, limit))
|
44
|
+
return [];
|
45
|
+
if (limit === 0 && offset === 0)
|
46
|
+
return records;
|
47
|
+
return records.slice(offset, offset + limit);
|
48
|
+
}
|
49
|
+
export function buildPaginationInfo({ recordsLength = 0, offset = 0, recordsPerPage = 0 }) {
|
50
|
+
if (!recordsLength) {
|
51
|
+
return { currentPage: 0, firstRecord: 0, lastRecord: 0, total: 0, hasMore: false };
|
27
52
|
}
|
28
|
-
const
|
29
|
-
const lastRecord = Math.min(
|
53
|
+
const lastRecordIndex = offset + recordsPerPage;
|
54
|
+
const lastRecord = lastRecordIndex ? Math.min(lastRecordIndex, recordsLength) : recordsLength;
|
30
55
|
return {
|
31
|
-
currentPage:
|
32
|
-
firstRecord: offset,
|
56
|
+
currentPage: recordsPerPage === 0 ? 0 : Math.ceil(offset / recordsPerPage),
|
57
|
+
firstRecord: offset + 1,
|
33
58
|
lastRecord: lastRecord,
|
34
|
-
total:
|
35
|
-
hasMore:
|
59
|
+
total: recordsLength,
|
60
|
+
hasMore: lastRecord < recordsLength,
|
36
61
|
};
|
37
62
|
}
|
@@ -6,7 +6,7 @@ var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
6
6
|
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
7
7
|
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
|
8
8
|
};
|
9
|
-
import { ApplicationContext, ErrorException, ObjectUtils, StringUtils, WarningException } from '@sankhyalabs/core';
|
9
|
+
import { ApplicationContext, ErrorException, ServiceCanceledException, ObjectUtils, StringUtils, WarningException } from '@sankhyalabs/core';
|
10
10
|
import { batchRequests } from 'graphql-request';
|
11
11
|
import UrlUtils from "../../../lib/utils/urlutils";
|
12
12
|
import { PrintUtils } from '../../utils/PrintUtils';
|
@@ -352,6 +352,7 @@ export class DataFetcher {
|
|
352
352
|
}
|
353
353
|
}
|
354
354
|
async executePendingRequest(watingRequestsById) {
|
355
|
+
var _a, _b;
|
355
356
|
const requestsBatch = [];
|
356
357
|
let quietMode = true;
|
357
358
|
watingRequestsById.forEach((waitingReq) => {
|
@@ -362,31 +363,36 @@ export class DataFetcher {
|
|
362
363
|
const response = await this.fecthGraphQL(requestsBatch, quietMode);
|
363
364
|
const { data: dataResponse, errors: errorsResponse, extensions } = response;
|
364
365
|
//Reject promises with errors from query
|
365
|
-
|
366
|
-
Object.
|
367
|
-
|
366
|
+
for (const errorResponse of errorsResponse) {
|
367
|
+
const values = Object.values(errorResponse);
|
368
|
+
for (const value of values) {
|
369
|
+
const waitingRequest = watingRequestsById.get(value.request.variables[value.index].queryID);
|
368
370
|
const hasClientEvent = await this.proccesGraphQLClientEvents(extensions, waitingRequest.request, waitingRequest.resolve, waitingRequest.reject);
|
369
|
-
Promise.race([
|
371
|
+
const data = await Promise.race([
|
370
372
|
waitingRequest.promise,
|
371
373
|
new Promise((resolve) => {
|
372
374
|
resolve(false);
|
373
375
|
})
|
374
|
-
])
|
375
|
-
|
376
|
-
if (
|
377
|
-
(((_a = watingRequestsById.get(
|
376
|
+
]);
|
377
|
+
if (!hasClientEvent || data === false) {
|
378
|
+
if (Object.keys(errorResponse[0].extensions).includes("SERVICE_CANCELED") || Object.keys(extensions).includes("isServiceCancelled")) {
|
379
|
+
(((_a = watingRequestsById.get(value.request.variables[value.index].queryID)) === null || _a === void 0 ? void 0 : _a.reject) || Promise.reject)(new ServiceCanceledException("Service canceled", value.message));
|
378
380
|
}
|
379
|
-
|
380
|
-
|
381
|
-
|
381
|
+
else {
|
382
|
+
(((_b = watingRequestsById.get(value.request.variables[value.index].queryID)) === null || _b === void 0 ? void 0 : _b.reject) || Promise.reject)(new ErrorException("Falha detectada", value.message));
|
383
|
+
}
|
384
|
+
}
|
385
|
+
}
|
386
|
+
}
|
382
387
|
//Resolve promises with data from query
|
383
|
-
|
384
|
-
Object.entries(data)
|
388
|
+
for (const data of dataResponse) {
|
389
|
+
const entries = Object.entries(data);
|
390
|
+
for (const [key, val] of entries) {
|
385
391
|
const waitingRequest = watingRequestsById.get(key);
|
386
392
|
await this.proccesGraphQLClientEvents(extensions, waitingRequest.request, waitingRequest.resolve, waitingRequest.reject);
|
387
393
|
((waitingRequest === null || waitingRequest === void 0 ? void 0 : waitingRequest.resolve) || Promise.resolve)(val);
|
388
|
-
}
|
389
|
-
}
|
394
|
+
}
|
395
|
+
}
|
390
396
|
}
|
391
397
|
buildGraphQlURL(quietMode) {
|
392
398
|
const urlParams = UrlUtils.getQueryParams(location.search);
|
package/dist/collection/lib/http/data-fetcher/fetchers/AttachFetcher/anexo-sistema-fetcher.js
CHANGED
@@ -6,21 +6,23 @@ const SERVICE = {
|
|
6
6
|
download: "AnexoSistemaSP.baixar",
|
7
7
|
};
|
8
8
|
export class AnexoSistemaFetcher {
|
9
|
-
constructor(entityName,
|
9
|
+
constructor(entityName, dataUnitName) {
|
10
10
|
var _a;
|
11
11
|
this.entityName = entityName;
|
12
|
-
this.registerKey = registerKey;
|
13
12
|
this.dataUnitName = dataUnitName;
|
14
13
|
this.validateFields = (fields) => {
|
15
14
|
if (!!fields.LINK && !!fields.NOMEARQUIVO)
|
16
15
|
throw new Error(SaveErrorsEnum.LINK_AND_FILE_AT_THE_SAME_TIME);
|
17
16
|
if (!fields.LINK && !fields.NOMEARQUIVO)
|
18
17
|
throw new Error(SaveErrorsEnum.ANY_LINK_OR_FILE_FILLED);
|
19
|
-
if (!this.
|
18
|
+
if (!this._registerKey)
|
20
19
|
throw new Error('Register key can not be null');
|
21
20
|
};
|
22
21
|
this.resourceID = (window["resourceID"] || ((_a = window["workspace"]) === null || _a === void 0 ? void 0 : _a.resourceID));
|
23
22
|
}
|
23
|
+
set registerKey(registerKey) {
|
24
|
+
this._registerKey = registerKey;
|
25
|
+
}
|
24
26
|
async save(change) {
|
25
27
|
var _a, _b;
|
26
28
|
let { updatingFields: fields } = change;
|
@@ -39,7 +41,7 @@ export class AnexoSistemaFetcher {
|
|
39
41
|
nameAttach: fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.name,
|
40
42
|
link: fields.LINK,
|
41
43
|
nameEntity: this.entityName,
|
42
|
-
pkEntity: this.
|
44
|
+
pkEntity: this._registerKey,
|
43
45
|
typeAcess: fields.TIPOACESSO,
|
44
46
|
typeApres: fields.TIPOAPRES,
|
45
47
|
}
|
@@ -79,7 +81,7 @@ export class AnexoSistemaFetcher {
|
|
79
81
|
nameAttach: fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.name,
|
80
82
|
link: fields.LINK,
|
81
83
|
nameEntity: this.entityName,
|
82
|
-
pkEntity: this.
|
84
|
+
pkEntity: this._registerKey,
|
83
85
|
typeAcess: fields.TIPOACESSO,
|
84
86
|
typeApres: fields.TIPOAPRES,
|
85
87
|
}
|