@sankhyalabs/sankhyablocks 0.0.0-bugfix-dev-KB-38445.0 → 0.0.0-bugfix-dev-KB-68936.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/{ConfigStorage-942ce74b.js → ConfigStorage-a343e418.js} +1 -0
- package/dist/cjs/{IExporterProvider-597949f9.js → IExporterProvider-d2a04ee7.js} +2 -2
- package/dist/cjs/{SnkFormConfigManager-1b13bacd.js → SnkFormConfigManager-166cbd1f.js} +6 -8
- package/dist/cjs/{SnkMessageBuilder-722b104e.js → SnkMessageBuilder-28ceaaed.js} +5 -1
- package/dist/cjs/{dataunit-fetcher-688d3f05.js → dataunit-fetcher-75f89355.js} +9 -2
- package/dist/cjs/{field-search-f56aa7d6.js → field-search-68e34bf4.js} +5 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-actions-button_4.cjs.entry.js +2 -2
- package/dist/cjs/snk-application.cjs.entry.js +3 -3
- package/dist/cjs/snk-attach.cjs.entry.js +1 -1
- package/dist/cjs/snk-crud.cjs.entry.js +5 -2
- package/dist/cjs/snk-data-exporter.cjs.entry.js +3 -3
- package/dist/cjs/{snk-data-unit-685272e7.js → snk-data-unit-bf418767.js} +2 -2
- package/dist/cjs/snk-data-unit.cjs.entry.js +3 -3
- package/dist/cjs/snk-detail-view.cjs.entry.js +7 -8
- package/dist/cjs/snk-filter-bar.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-modal-item.cjs.entry.js +1 -1
- package/dist/cjs/snk-form-config.cjs.entry.js +1 -1
- package/dist/cjs/snk-form.cjs.entry.js +2 -2
- package/dist/cjs/snk-grid.cjs.entry.js +35 -10
- package/dist/cjs/{snk-guides-viewer-67605336.js → snk-guides-viewer-14c27834.js} +10 -6
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +5 -5
- package/dist/cjs/snk-personalized-filter.cjs.entry.js +1 -1
- package/dist/cjs/snk-simple-crud.cjs.entry.js +28 -10
- package/dist/collection/components/snk-crud/snk-crud.js +22 -1
- package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +1 -2
- package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +25 -3
- package/dist/collection/components/snk-form-config/SnkFormConfigManager.js +5 -7
- package/dist/collection/components/snk-form-config/snk-form-config.js +1 -1
- package/dist/collection/components/snk-grid/snk-grid.css +0 -2
- package/dist/collection/components/snk-grid/snk-grid.js +58 -6
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +43 -8
- package/dist/collection/components/snk-taskbar/processor/taskbar-processor.js +5 -1
- package/dist/collection/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.js +1 -1
- package/dist/collection/lib/configs/ConfigStorage.js +1 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js +9 -2
- package/dist/collection/lib/message/resources/snk-grid.msg.js +5 -1
- package/dist/components/ConfigStorage.js +1 -0
- package/dist/components/IExporterProvider.js +6 -2
- package/dist/components/SnkFormConfigManager.js +5 -7
- package/dist/components/SnkMessageBuilder.js +5 -1
- package/dist/components/dataunit-fetcher.js +9 -2
- package/dist/components/snk-crud.js +5 -1
- package/dist/components/snk-detail-view2.js +9 -5
- package/dist/components/snk-form-config2.js +1 -1
- package/dist/components/snk-grid2.js +34 -8
- package/dist/components/snk-simple-crud2.js +24 -5
- package/dist/esm/{ConfigStorage-86187da3.js → ConfigStorage-3806514e.js} +1 -0
- package/dist/esm/{IExporterProvider-63a188b6.js → IExporterProvider-b2e244b3.js} +2 -2
- package/dist/esm/{SnkFormConfigManager-d4554df9.js → SnkFormConfigManager-31b24066.js} +6 -8
- package/dist/esm/{SnkMessageBuilder-89925609.js → SnkMessageBuilder-0485b99a.js} +5 -1
- package/dist/esm/{dataunit-fetcher-264191b2.js → dataunit-fetcher-6463ac8d.js} +9 -2
- package/dist/esm/{field-search-efbe307f.js → field-search-f8b1d91e.js} +5 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-actions-button_4.entry.js +2 -2
- package/dist/esm/snk-application.entry.js +3 -3
- package/dist/esm/snk-attach.entry.js +1 -1
- package/dist/esm/snk-crud.entry.js +5 -2
- package/dist/esm/snk-data-exporter.entry.js +3 -3
- package/dist/esm/{snk-data-unit-63f83504.js → snk-data-unit-20860cfc.js} +2 -2
- package/dist/esm/snk-data-unit.entry.js +3 -3
- package/dist/esm/snk-detail-view.entry.js +7 -8
- package/dist/esm/snk-filter-bar.entry.js +1 -1
- package/dist/esm/snk-filter-modal-item.entry.js +1 -1
- package/dist/esm/snk-form-config.entry.js +1 -1
- package/dist/esm/snk-form.entry.js +2 -2
- package/dist/esm/snk-grid.entry.js +35 -10
- package/dist/esm/{snk-guides-viewer-151f6091.js → snk-guides-viewer-b82ec79a.js} +10 -6
- package/dist/esm/snk-guides-viewer.entry.js +5 -5
- package/dist/esm/snk-personalized-filter.entry.js +1 -1
- package/dist/esm/snk-simple-crud.entry.js +28 -10
- package/dist/sankhyablocks/{p-3a212712.js → p-0e85d9ba.js} +1 -1
- package/dist/sankhyablocks/p-14c2056a.js +1 -0
- package/dist/sankhyablocks/p-23736d75.js +1 -0
- package/dist/sankhyablocks/{p-7505da04.entry.js → p-249adf8b.entry.js} +1 -1
- package/dist/sankhyablocks/p-2a408684.js +1 -0
- package/dist/sankhyablocks/{p-eae7a817.entry.js → p-2c68b3ae.entry.js} +1 -1
- package/dist/sankhyablocks/{p-c5268346.entry.js → p-2f978e29.entry.js} +1 -1
- package/dist/sankhyablocks/p-4111c6ce.entry.js +1 -0
- package/dist/sankhyablocks/p-4238fcd4.entry.js +1 -0
- package/dist/sankhyablocks/p-450c60e4.entry.js +1 -0
- package/dist/sankhyablocks/{p-a1d72395.entry.js → p-47db7e88.entry.js} +1 -1
- package/dist/sankhyablocks/{p-aff76a53.js → p-52920496.js} +1 -1
- package/dist/sankhyablocks/{p-8fc470e5.entry.js → p-62ba211a.entry.js} +1 -1
- package/dist/sankhyablocks/p-6614c578.js +1 -0
- package/dist/sankhyablocks/p-6fede3d4.entry.js +1 -0
- package/dist/sankhyablocks/p-701442ef.entry.js +1 -0
- package/dist/sankhyablocks/{p-82a0bfb0.entry.js → p-74fafa0d.entry.js} +2 -2
- package/dist/sankhyablocks/{p-fcac4dfc.js → p-950037cb.js} +1 -1
- package/dist/sankhyablocks/{p-941bf3ef.entry.js → p-95e44a9c.entry.js} +1 -1
- package/dist/sankhyablocks/{p-fe79f83a.js → p-b4d016a3.js} +1 -1
- package/dist/sankhyablocks/{p-bad55caa.entry.js → p-d0bec13f.entry.js} +1 -1
- package/dist/sankhyablocks/{p-47b60deb.entry.js → p-d6e26ea8.entry.js} +1 -1
- package/dist/sankhyablocks/{p-14b9f964.entry.js → p-ebc4011a.entry.js} +1 -1
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-crud/snk-crud.d.ts +4 -0
- package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +5 -0
- package/dist/types/components/snk-form-config/SnkFormConfigManager.d.ts +2 -2
- package/dist/types/components/snk-grid/snk-grid.d.ts +9 -0
- package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +7 -0
- package/dist/types/components/snk-taskbar/processor/taskbar-processor.d.ts +1 -0
- package/dist/types/components.d.ts +32 -0
- package/package.json +1 -1
- package/dist/sankhyablocks/p-14a08904.entry.js +0 -1
- package/dist/sankhyablocks/p-19c18d06.entry.js +0 -1
- package/dist/sankhyablocks/p-75f83d1d.entry.js +0 -1
- package/dist/sankhyablocks/p-7a337364.js +0 -1
- package/dist/sankhyablocks/p-829d4045.js +0 -1
- package/dist/sankhyablocks/p-b4b21558.entry.js +0 -1
- package/dist/sankhyablocks/p-c053256c.entry.js +0 -1
- package/dist/sankhyablocks/p-c2495304.js +0 -1
- package/dist/sankhyablocks/p-cefba299.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h, Fragment } from '@stencil/core';
|
|
1
|
+
import { h, Fragment, } from '@stencil/core';
|
|
2
2
|
import { Action as DUAction, ApplicationContext, ElementIDUtils, StringUtils } from '@sankhyalabs/core';
|
|
3
3
|
import { TaskbarElement } from '../snk-taskbar/elements/taskbar-elements';
|
|
4
4
|
import { ConfigStorage } from '../../lib/configs/ConfigStorage';
|
|
@@ -19,7 +19,7 @@ export class SnkGrid {
|
|
|
19
19
|
"snkGridTopTaskbar.regular": ["FORM_MODE", "CONFIGURATOR", "INSERT"],
|
|
20
20
|
"snkGridTopTaskbar.regular.secondary": ["FORM_MODE", "CONFIGURATOR", "INSERT"],
|
|
21
21
|
"snkGridTopTaskbar.regular.singleTaskbar": [],
|
|
22
|
-
"snkGridTopTaskbar.finish_edition": ["CANCEL", "SAVE"],
|
|
22
|
+
"snkGridTopTaskbar.finish_edition": ["CANCEL", "SAVE", this.handleAddFormMode()],
|
|
23
23
|
"snkGridTopTaskbar.finish_edition.secondary": [],
|
|
24
24
|
"snkGridTopTaskbar.finish_edition.singleTaskbar": [],
|
|
25
25
|
});
|
|
@@ -32,7 +32,7 @@ export class SnkGrid {
|
|
|
32
32
|
"snkGridHeaderTaskbar.singleTaskbar.selected": ["UPDATE", "CLONE", "REMOVE", "MORE_OPTIONS", "DIVIDER", "ATTACH", "FORM_MODE", "CONFIGURATOR", "REFRESH", "DATA_EXPORTER", "ACTIONS_BUTTON"],
|
|
33
33
|
"snkGridHeaderTaskbar.singleTaskbar.detail.unselected": ["INSERT", "FORM_MODE", "CONFIGURATOR", "REFRESH", "MORE_OPTIONS"],
|
|
34
34
|
"snkGridHeaderTaskbar.singleTaskbar.detail.selected": ["UPDATE", "ATTACH", "CLONE", "REMOVE", "MORE_OPTIONS", "DIVIDER", "FORM_MODE", "CONFIGURATOR", "REFRESH"],
|
|
35
|
-
"snkGridHeaderTaskbar.singleTaskbar.finish_edition": ["CANCEL", "SAVE"]
|
|
35
|
+
"snkGridHeaderTaskbar.singleTaskbar.finish_edition": ["CANCEL", "SAVE", this.handleAddFormMode()]
|
|
36
36
|
});
|
|
37
37
|
this.dataUnitInterceptor = {
|
|
38
38
|
interceptAction: async (action) => {
|
|
@@ -70,6 +70,7 @@ export class SnkGrid {
|
|
|
70
70
|
this.filterBarLegacyConfigName = undefined;
|
|
71
71
|
this.autoLoad = undefined;
|
|
72
72
|
this.autoFocus = true;
|
|
73
|
+
this.enableGridInsert = false;
|
|
73
74
|
}
|
|
74
75
|
/**
|
|
75
76
|
* Exibe a janela de configurações da grade.
|
|
@@ -156,6 +157,16 @@ export class SnkGrid {
|
|
|
156
157
|
async setFocus() {
|
|
157
158
|
this._grid.setFocus();
|
|
158
159
|
}
|
|
160
|
+
async handleClick(event) {
|
|
161
|
+
if (this.hasToBlockEvent(event)) {
|
|
162
|
+
event.preventDefault();
|
|
163
|
+
event.stopPropagation();
|
|
164
|
+
await this._dataUnit.cancelEdition();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
hasToBlockEvent(event) {
|
|
168
|
+
return this._snkFilterBar.contains(event.target) && this.enableGridInsert && this._dataUnit.hasNewRecord();
|
|
169
|
+
}
|
|
159
170
|
async handleGridLegacyConfigName(newLegacyConfig, oldLegacyConfig) {
|
|
160
171
|
if (!newLegacyConfig) {
|
|
161
172
|
return;
|
|
@@ -166,6 +177,9 @@ export class SnkGrid {
|
|
|
166
177
|
this.addGridLegacyConfigName();
|
|
167
178
|
this.loadConfig();
|
|
168
179
|
}
|
|
180
|
+
handleAddFormMode() {
|
|
181
|
+
return this.enableGridInsert ? TaskbarElement.FORM_MODE : "";
|
|
182
|
+
}
|
|
169
183
|
openGridConfig() {
|
|
170
184
|
this._grid.getColumnsState()
|
|
171
185
|
.then((gridColumns) => {
|
|
@@ -295,8 +309,9 @@ export class SnkGrid {
|
|
|
295
309
|
this.loadConfig();
|
|
296
310
|
}
|
|
297
311
|
componentDidRender() {
|
|
312
|
+
var _a, _b;
|
|
298
313
|
this._rmPrecisionCustomValueFormatter.setGrid(this._grid);
|
|
299
|
-
this.loadGridCustomFormatters(this._dataUnit.metadata.fields);
|
|
314
|
+
this.loadGridCustomFormatters((_b = (_a = this._dataUnit) === null || _a === void 0 ? void 0 : _a.metadata) === null || _b === void 0 ? void 0 : _b.fields);
|
|
300
315
|
this.setCustomRenders();
|
|
301
316
|
this.setCustomEditors();
|
|
302
317
|
}
|
|
@@ -394,6 +409,8 @@ export class SnkGrid {
|
|
|
394
409
|
eagerInitialize: true,
|
|
395
410
|
itemBuilder: (actionButton, item) => this.getColumnSearch(actionButton, item)
|
|
396
411
|
}];
|
|
412
|
+
if (this.isGridInsertActive())
|
|
413
|
+
return hardList;
|
|
397
414
|
if (this.taskbarManager != undefined && this.taskbarManager.getMoreOptions != undefined) {
|
|
398
415
|
const taskbarID = this.getTopTaskBarId();
|
|
399
416
|
return hardList.concat(this.taskbarManager.getMoreOptions(taskbarID, this.configName, this._dataState, this.actionsList));
|
|
@@ -411,12 +428,20 @@ export class SnkGrid {
|
|
|
411
428
|
}
|
|
412
429
|
this._showSnkFilterBar = true;
|
|
413
430
|
}
|
|
431
|
+
getGridHeaderButtons() {
|
|
432
|
+
if (this.isGridInsertActive())
|
|
433
|
+
return TaskbarElement.MORE_OPTIONS;
|
|
434
|
+
return this._headerTaskbarProcessor.buttons;
|
|
435
|
+
}
|
|
436
|
+
isGridInsertActive() {
|
|
437
|
+
return this.enableGridInsert && this._dataUnit.hasNewRecord();
|
|
438
|
+
}
|
|
414
439
|
render() {
|
|
415
440
|
if (!this._dataUnit) {
|
|
416
441
|
return undefined;
|
|
417
442
|
}
|
|
418
|
-
return (h("div", { class: "snk-grid__container ez-flex ez-flex--column ez-flex-item--auto" }, h("div", { class: "snk-grid__header ez-margin-bottom--medium" }, this._showSnkFilterBar &&
|
|
419
|
-
h(Fragment, null, h("snk-filter-bar", { ref: (ref) => this._snkFilterBar = ref, title: this.filterBarTitle, dataUnit: this._dataUnit, "data-element-id": "gridFilter", class: "snk-grid__filter-bar ez-align--top", configName: this.configName, messagesBuilder: this.messagesBuilder, resourceID: this.resourceID, onConfigUpdated: evt => this.handleFilterConfigUpdated(evt.detail), disablePersonalizedFilter: this.disablePersonalizedFilter, filterBarLegacyConfigName: this.filterBarLegacyConfigName, autoLoad: this.autoLoad }), h("hr", { class: "ez-divider-vertical ez-divider--dark ez-margin-left--medium snk-grid__header-divider" })), h("snk-taskbar", { class: "ez-padding-left--medium", "data-element-id": "grid_top", key: "topTaskbar", configName: this.configName, dataUnit: this._dataUnit, messagesBuilder: this.messagesBuilder, buttons: this._topTaskbarProcessor.buttons, disabledButtons: this._topTaskbarProcessor.disabledButtons, customButtons: this._topTaskbarProcessor.customButtons, primaryButton: this.getPrimaryButton(), resourceID: this.resourceID, customContainerId: this.taskbarCustomContainerId, customSlotId: this.topTaskbarCustomSlotId, overflowStrategy: 'none' }, h("slot", { name: this.topTaskbarCustomSlotId }))), h("ez-grid", { ref: ref => this._grid = ref, class: (this.presentationMode === PresentationMode.SECONDARY ? "snk-grid-container__without-shadow " : "") + "snk-grid__table", "data-element-id": "embedded", dataUnit: this._dataUnit, key: "grid-" + this._snkDataUnit.entityName, config: this._gridConfig, onConfigChange: (evt) => { this.gridConfigChangeHandler(evt); }, onEzDoubleClick: (evt) => this.gridDoubleClick.emit(evt.detail), statusResolver: this.statusResolver, multipleSelection: this.multipleSelection, columnfilterDataSource: this.columnFilterDataSource, selectionToastConfig: this.selectionToastConfig, useEnterLikeTab: this.useEnterLikeTab, recordsValidator: this.recordsValidator, canEdit: this.canEdit, autoFocus: this.autoFocus }, h("snk-taskbar", { id: 'teste', dataUnit: this._dataUnit, configName: this.configName, messagesBuilder: this.messagesBuilder, "data-element-id": "grid_left", buttons: this.
|
|
443
|
+
return (h("div", { class: "snk-grid__container ez-flex ez-flex--column ez-flex-item--auto ez-padding--large" }, h("div", { class: "snk-grid__header ez-margin-bottom--medium" }, this._showSnkFilterBar &&
|
|
444
|
+
h(Fragment, null, h("snk-filter-bar", { ref: (ref) => this._snkFilterBar = ref, title: this.filterBarTitle, dataUnit: this._dataUnit, "data-element-id": "gridFilter", class: "snk-grid__filter-bar ez-align--top", configName: this.configName, messagesBuilder: this.messagesBuilder, resourceID: this.resourceID, onConfigUpdated: evt => this.handleFilterConfigUpdated(evt.detail), disablePersonalizedFilter: this.disablePersonalizedFilter, filterBarLegacyConfigName: this.filterBarLegacyConfigName, autoLoad: this.autoLoad }), h("hr", { class: "ez-divider-vertical ez-divider--dark ez-margin-left--medium snk-grid__header-divider" })), h("snk-taskbar", { class: "ez-padding-left--medium", "data-element-id": "grid_top", key: "topTaskbar", configName: this.configName, dataUnit: this._dataUnit, messagesBuilder: this.messagesBuilder, buttons: this._topTaskbarProcessor.buttons, disabledButtons: this._topTaskbarProcessor.disabledButtons, customButtons: this._topTaskbarProcessor.customButtons, primaryButton: this.getPrimaryButton(), resourceID: this.resourceID, customContainerId: this.taskbarCustomContainerId, customSlotId: this.topTaskbarCustomSlotId, overflowStrategy: 'none' }, h("slot", { name: this.topTaskbarCustomSlotId }))), h("ez-grid", { ref: ref => this._grid = ref, class: (this.presentationMode === PresentationMode.SECONDARY ? "snk-grid-container__without-shadow " : "") + "snk-grid__table", "data-element-id": "embedded", dataUnit: this._dataUnit, key: "grid-" + this._snkDataUnit.entityName, config: this._gridConfig, onConfigChange: (evt) => { this.gridConfigChangeHandler(evt); }, onEzDoubleClick: (evt) => this.gridDoubleClick.emit(evt.detail), statusResolver: this.statusResolver, multipleSelection: this.multipleSelection, columnfilterDataSource: this.columnFilterDataSource, selectionToastConfig: this.selectionToastConfig, useEnterLikeTab: this.useEnterLikeTab, recordsValidator: this.recordsValidator, canEdit: this.canEdit, autoFocus: this.autoFocus, enableGridInsert: this.enableGridInsert }, h("snk-taskbar", { id: 'teste', dataUnit: this._dataUnit, configName: this.configName, messagesBuilder: this.messagesBuilder, "data-element-id": "grid_left", buttons: this.getGridHeaderButtons(), presentationMode: this.presentationMode, disabledButtons: this._headerTaskbarProcessor.disabledButtons, customButtons: this._headerTaskbarProcessor.customButtons, slot: "leftButtons", actionsList: this.getActionsList(), primaryButton: this.getPrimaryButton(), resourceID: this.resourceID, customContainerId: this.taskbarCustomContainerId, customSlotId: this.gridHeaderCustomSlotId }, h("slot", { name: this.gridHeaderCustomSlotId }))), h("div", { class: "ez-col ez-col--sd-12" }, h("slot", { name: "SnkGridFooter" })), h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._popUpGridConfig, onEzCloseModal: () => this.closeGridConfig() }, h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this._gridConfig, "data-element-id": this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this.resourceID }))));
|
|
420
445
|
}
|
|
421
446
|
static get is() { return "snk-grid"; }
|
|
422
447
|
static get encapsulation() { return "scoped"; }
|
|
@@ -862,6 +887,24 @@ export class SnkGrid {
|
|
|
862
887
|
"attribute": "auto-focus",
|
|
863
888
|
"reflect": false,
|
|
864
889
|
"defaultValue": "true"
|
|
890
|
+
},
|
|
891
|
+
"enableGridInsert": {
|
|
892
|
+
"type": "boolean",
|
|
893
|
+
"mutable": false,
|
|
894
|
+
"complexType": {
|
|
895
|
+
"original": "boolean",
|
|
896
|
+
"resolved": "boolean",
|
|
897
|
+
"references": {}
|
|
898
|
+
},
|
|
899
|
+
"required": false,
|
|
900
|
+
"optional": true,
|
|
901
|
+
"docs": {
|
|
902
|
+
"tags": [],
|
|
903
|
+
"text": "Ativa inser\u00E7\u00E3o de registros no modo grade."
|
|
904
|
+
},
|
|
905
|
+
"attribute": "enable-grid-insert",
|
|
906
|
+
"reflect": false,
|
|
907
|
+
"defaultValue": "false"
|
|
865
908
|
}
|
|
866
909
|
};
|
|
867
910
|
}
|
|
@@ -1143,4 +1186,13 @@ export class SnkGrid {
|
|
|
1143
1186
|
"methodName": "handleGridLegacyConfigName"
|
|
1144
1187
|
}];
|
|
1145
1188
|
}
|
|
1189
|
+
static get listeners() {
|
|
1190
|
+
return [{
|
|
1191
|
+
"name": "click",
|
|
1192
|
+
"method": "handleClick",
|
|
1193
|
+
"target": undefined,
|
|
1194
|
+
"capture": true,
|
|
1195
|
+
"passive": false
|
|
1196
|
+
}];
|
|
1197
|
+
}
|
|
1146
1198
|
}
|
|
@@ -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,7 @@ 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
17
|
export class SnkSimpleCrud {
|
|
18
18
|
constructor() {
|
|
19
19
|
this._multiSelectionListDataSource = new SnkMultiSelectionListDataSource();
|
|
@@ -26,7 +26,7 @@ export class SnkSimpleCrud {
|
|
|
26
26
|
"snkSimpleCrudTaskbar.grid_regular": this.getButtons(false, [TaskbarElement.DATA_EXPORTER, TaskbarElement.FORM_MODE]),
|
|
27
27
|
"snkSimpleCrudTaskbar.form_selected": this.getButtons(true, [TaskbarElement.GRID_MODE]),
|
|
28
28
|
"snkSimpleCrudTaskbar.grid_selected": this.getButtons(true, [TaskbarElement.DATA_EXPORTER, TaskbarElement.FORM_MODE]),
|
|
29
|
-
"snkSimpleCrudTaskbar.finish_edition":
|
|
29
|
+
"snkSimpleCrudTaskbar.finish_edition": this.getFinishEditionButtonsCallback.bind(this)
|
|
30
30
|
});
|
|
31
31
|
this._showPopUpGridConfig = false;
|
|
32
32
|
this._showFormConfig = false;
|
|
@@ -46,6 +46,7 @@ export class SnkSimpleCrud {
|
|
|
46
46
|
this.useCancelConfirm = true;
|
|
47
47
|
this.pageSize = 150;
|
|
48
48
|
this.resourceID = undefined;
|
|
49
|
+
this.enableGridInsert = false;
|
|
49
50
|
this.taskbarManager = undefined;
|
|
50
51
|
this.messagesBuilder = undefined;
|
|
51
52
|
this.useEnterLikeTab = false;
|
|
@@ -114,6 +115,13 @@ export class SnkSimpleCrud {
|
|
|
114
115
|
newCustomFieldProps.set(fieldName, Object.assign(Object.assign({}, currentProps), { [propName]: value }));
|
|
115
116
|
this._fieldsProps = newCustomFieldProps;
|
|
116
117
|
}
|
|
118
|
+
getFinishEditionButtonsCallback() {
|
|
119
|
+
const btns = ["CANCEL", "SAVE"];
|
|
120
|
+
if (this.enableGridInsert && this._currentViewMode !== VIEW_MODE.ATTACHMENT) {
|
|
121
|
+
btns.push(this._currentViewMode === VIEW_MODE.GRID ? TaskbarElement.FORM_MODE : TaskbarElement.GRID_MODE);
|
|
122
|
+
}
|
|
123
|
+
return btns;
|
|
124
|
+
}
|
|
117
125
|
getButtons(selected, extraButtons) {
|
|
118
126
|
return this.addConfigButton(this.resolveInMemoryBtns(selected ? REGULAR_SELECTED_BTNS : REGULAR_DEFAULT_BTNS)
|
|
119
127
|
.concat(extraButtons));
|
|
@@ -196,7 +204,6 @@ export class SnkSimpleCrud {
|
|
|
196
204
|
await this.setFieldProp(field, 'precision', rmPrecision);
|
|
197
205
|
await this.setFieldProp(field, 'prettyPrecision', rmPrecision);
|
|
198
206
|
}
|
|
199
|
-
;
|
|
200
207
|
this._rmPrecisionCustomValueFormatter.setDataState(this.dataState);
|
|
201
208
|
}
|
|
202
209
|
async handleUpdateGridLegacyConfig(newValue, oldValue) {
|
|
@@ -553,6 +560,9 @@ export class SnkSimpleCrud {
|
|
|
553
560
|
const options = filteredFields.map(field => ({ value: field.name, label: field.label }));
|
|
554
561
|
return Promise.resolve(options);
|
|
555
562
|
}
|
|
563
|
+
isGridInsertActive() {
|
|
564
|
+
return this.enableGridInsert && this.dataUnit.hasNewRecord();
|
|
565
|
+
}
|
|
556
566
|
getActionsList() {
|
|
557
567
|
var _a, _b;
|
|
558
568
|
const hardList = [{
|
|
@@ -564,6 +574,8 @@ export class SnkSimpleCrud {
|
|
|
564
574
|
? this.getColumnSearch(actionButton, item)
|
|
565
575
|
: this.getFieldSearch(actionButton, item)
|
|
566
576
|
}];
|
|
577
|
+
if (this.isGridInsertActive())
|
|
578
|
+
return hardList;
|
|
567
579
|
if (this.taskbarManager != undefined && this.taskbarManager.getMoreOptions != undefined) {
|
|
568
580
|
const taskbarID = this.getTopTaskBarId();
|
|
569
581
|
return hardList.concat(this.taskbarManager.getMoreOptions(taskbarID, this.configName, this.dataState, this.actionsList));
|
|
@@ -672,8 +684,8 @@ export class SnkSimpleCrud {
|
|
|
672
684
|
return StringUtils.isEmpty(this.resourceID) ? this._resourceID : this.resourceID;
|
|
673
685
|
}
|
|
674
686
|
getFormConfig() {
|
|
675
|
-
var _a
|
|
676
|
-
const configFromManager = (_a = this._formConfigManager) === null || _a === void 0 ? void 0 : _a.getConfig(
|
|
687
|
+
var _a;
|
|
688
|
+
const configFromManager = (_a = this._formConfigManager) === null || _a === void 0 ? void 0 : _a.getConfig(this.dataUnit, this.ignoreReadOnlyFormFields);
|
|
677
689
|
if (!this.configName && !configFromManager) {
|
|
678
690
|
return this.formConfig;
|
|
679
691
|
}
|
|
@@ -687,15 +699,20 @@ export class SnkSimpleCrud {
|
|
|
687
699
|
}
|
|
688
700
|
this._formConfigManager.setConfig(this.formConfig);
|
|
689
701
|
}
|
|
702
|
+
handleDataUnitOnInsertionMode() {
|
|
703
|
+
if (this.enableGridInsert)
|
|
704
|
+
return;
|
|
705
|
+
this.goToView(VIEW_MODE.FORM);
|
|
706
|
+
}
|
|
690
707
|
/* istanbul ignore next */
|
|
691
708
|
render() {
|
|
692
709
|
var _a;
|
|
693
710
|
if (this.dataUnit == undefined) {
|
|
694
711
|
return;
|
|
695
712
|
}
|
|
696
|
-
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:
|
|
713
|
+
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) }, h("header", null, h("slot", { name: "snkSimpleCrudHeader" })), h("section", { class: "ez-box ez-box--shadow simple-crud__container-section" }, h("snk-taskbar", { class: "ez-box ez-box--shadow ez-padding--medium", dataUnit: this.dataUnit, primaryButton: ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? "SAVE" : "INSERT", "data-element-id": "grid_left", messagesBuilder: this.messagesBuilder, buttons: this._taskbarProcessor.buttons, actionsList: this.getActionsList(), disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, "data-exporter-store-key": this.getDataExporterStoreKey(), slot: "leftButtons", presentationMode: PresentationMode.SECONDARY }, h("slot", { name: "TASKBAR_CUSTOM_ELEMENTS" })), 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)
|
|
697
714
|
? undefined
|
|
698
|
-
: 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() }))));
|
|
715
|
+
: this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab, autoFocus: this.autoFocus, enableGridInsert: this.enableGridInsert }, 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() }))));
|
|
699
716
|
}
|
|
700
717
|
static get is() { return "snk-simple-crud"; }
|
|
701
718
|
static get encapsulation() { return "scoped"; }
|
|
@@ -901,6 +918,24 @@ export class SnkSimpleCrud {
|
|
|
901
918
|
"attribute": "resource-i-d",
|
|
902
919
|
"reflect": false
|
|
903
920
|
},
|
|
921
|
+
"enableGridInsert": {
|
|
922
|
+
"type": "boolean",
|
|
923
|
+
"mutable": false,
|
|
924
|
+
"complexType": {
|
|
925
|
+
"original": "boolean",
|
|
926
|
+
"resolved": "boolean",
|
|
927
|
+
"references": {}
|
|
928
|
+
},
|
|
929
|
+
"required": false,
|
|
930
|
+
"optional": true,
|
|
931
|
+
"docs": {
|
|
932
|
+
"tags": [],
|
|
933
|
+
"text": "Ativa inser\u00E7\u00E3o de registros no modo grade."
|
|
934
|
+
},
|
|
935
|
+
"attribute": "enable-grid-insert",
|
|
936
|
+
"reflect": false,
|
|
937
|
+
"defaultValue": "false"
|
|
938
|
+
},
|
|
904
939
|
"taskbarManager": {
|
|
905
940
|
"type": "unknown",
|
|
906
941
|
"mutable": false,
|
|
@@ -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) {
|
|
@@ -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;
|
|
@@ -71,6 +71,7 @@ export class ConfigStorage {
|
|
|
71
71
|
if (config == undefined) {
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
|
+
name = this.handleLegacyConfigAsString(name, CONFIG_SOURCE.grid);
|
|
74
75
|
await this.deleteGridConfigCache(name, resourceID);
|
|
75
76
|
return this.gridConfigFetcher.saveConfig(config, name, resourceID);
|
|
76
77
|
}
|
package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js
CHANGED
|
@@ -44,12 +44,19 @@ export class DatasetStrategy {
|
|
|
44
44
|
const records = this.processRecords(dataUnit, fields, responseRecords);
|
|
45
45
|
const loadingInProgress = pagerId != undefined;
|
|
46
46
|
const count = loadingInfo.count + records.length;
|
|
47
|
+
const isInsertingNewRecord = dataUnit.hasNewRecord();
|
|
47
48
|
const needReload = !loadingInProgress && localSorting.length > 0;
|
|
49
|
+
/**
|
|
50
|
+
* Caso precise recarregar dados, porém está no meio de uma inserção, os dados não devem recarregados instantaneamente,
|
|
51
|
+
* Mas sim, sinalizar que o dataUnit está aguardando para der recarregado.
|
|
52
|
+
*/
|
|
53
|
+
if (needReload && isInsertingNewRecord) {
|
|
54
|
+
dataUnit.setWaitingToReload(true);
|
|
55
|
+
}
|
|
48
56
|
return Promise.resolve({
|
|
49
57
|
records,
|
|
50
58
|
loadingInfo: Object.assign(Object.assign({}, loadingInfo), { pagerId,
|
|
51
|
-
loadingInProgress, total: loadingInProgress ? undefined : count, count,
|
|
52
|
-
needReload })
|
|
59
|
+
loadingInProgress, total: loadingInProgress ? undefined : count, count, needReload: needReload && !isInsertingNewRecord })
|
|
53
60
|
});
|
|
54
61
|
}
|
|
55
62
|
catch (error) {
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export const snkGridMessages = {
|
|
2
|
-
findColumn: "Busca de colunas"
|
|
2
|
+
findColumn: "Busca de colunas",
|
|
3
|
+
cancelConfirmation: {
|
|
4
|
+
title: "Aviso",
|
|
5
|
+
message: "As alterações realizadas serão descartadas<br/><br/><b>Você realmente gostaria de cancelar?</b>",
|
|
6
|
+
}
|
|
3
7
|
};
|
|
4
8
|
export const snkGridConfigMessages = {
|
|
5
9
|
gridConfiguration: "Configuração da Grade",
|
|
@@ -423,6 +423,7 @@ class ConfigStorage {
|
|
|
423
423
|
if (config == undefined) {
|
|
424
424
|
return;
|
|
425
425
|
}
|
|
426
|
+
name = this.handleLegacyConfigAsString(name, CONFIG_SOURCE.grid);
|
|
426
427
|
await this.deleteGridConfigCache(name, resourceID);
|
|
427
428
|
return this.gridConfigFetcher.saveConfig(config, name, resourceID);
|
|
428
429
|
}
|
|
@@ -124,12 +124,16 @@ class TaskbarProcessor {
|
|
|
124
124
|
});
|
|
125
125
|
}
|
|
126
126
|
getButtonsArray(taskbarId, taskbarManager, dataState) {
|
|
127
|
-
const defaults = this.
|
|
127
|
+
const defaults = this.getButtonsFromKey(taskbarId);
|
|
128
128
|
if (taskbarManager) {
|
|
129
129
|
return taskbarManager.getButtons(taskbarId, dataState, [...defaults]);
|
|
130
130
|
}
|
|
131
131
|
return defaults;
|
|
132
132
|
}
|
|
133
|
+
getButtonsFromKey(taskbarId) {
|
|
134
|
+
const btnsValue = this._defaultButtons[taskbarId];
|
|
135
|
+
return typeof btnsValue === 'function' ? btnsValue() : btnsValue;
|
|
136
|
+
}
|
|
133
137
|
isEnabled(taskbarId, taskbarManager, buttonName, dataState, disabled) {
|
|
134
138
|
const originalValue = disabled.includes(buttonName) ? false : true;
|
|
135
139
|
if (taskbarManager && taskbarManager.isEnabled) {
|
|
@@ -217,7 +221,7 @@ class RmPrecisionCustomValueFormatter {
|
|
|
217
221
|
this.refreshSelectedRows();
|
|
218
222
|
}
|
|
219
223
|
setDataState(dataState) {
|
|
220
|
-
if (ObjectUtils.
|
|
224
|
+
if (this._dataState && ObjectUtils.equals(dataState === null || dataState === void 0 ? void 0 : dataState.metadataByRow, this._dataState.metadataByRow)) {
|
|
221
225
|
return;
|
|
222
226
|
}
|
|
223
227
|
this._dataState = dataState;
|
|
@@ -74,10 +74,8 @@ class SnkFormConfigManager {
|
|
|
74
74
|
if (fields != undefined && fields.length > 0) {
|
|
75
75
|
return fields.map(({ label, name, readOnly, visible, required }) => {
|
|
76
76
|
if (label == undefined) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
visible,
|
|
80
|
-
required });
|
|
77
|
+
const currentField = dataUnit.getField(name);
|
|
78
|
+
return Object.assign(Object.assign({}, currentField), { name: name !== null && name !== void 0 ? name : currentField.name, readOnly: readOnly !== null && readOnly !== void 0 ? readOnly : currentField.readOnly, visible: visible !== null && visible !== void 0 ? visible : currentField.visible, required: required !== null && required !== void 0 ? required : currentField.required });
|
|
81
79
|
}
|
|
82
80
|
return { name, label, readOnly, visible, required };
|
|
83
81
|
})
|
|
@@ -101,7 +99,7 @@ class SnkFormConfigManager {
|
|
|
101
99
|
const normalizedFilter = StringUtils.replaceAccentuatedCharsLower(descriptionFilter.toLocaleLowerCase());
|
|
102
100
|
return normalizedText.includes(normalizedFilter);
|
|
103
101
|
}
|
|
104
|
-
|
|
102
|
+
getFormConfig(dataUnit, ignoreReadOnlyFormFields) {
|
|
105
103
|
let fields = this.getFieldsList(dataUnit);
|
|
106
104
|
if (ignoreReadOnlyFormFields) {
|
|
107
105
|
fields = fields.filter(field => {
|
|
@@ -133,8 +131,8 @@ class SnkFormConfigManager {
|
|
|
133
131
|
this._onConfigChange(Object.assign({}, this._config));
|
|
134
132
|
}
|
|
135
133
|
}
|
|
136
|
-
getConfig(
|
|
137
|
-
return
|
|
134
|
+
getConfig(dataUnit, ignoreReadOnlyFormFields) {
|
|
135
|
+
return this.getFormConfig(dataUnit, ignoreReadOnlyFormFields !== null && ignoreReadOnlyFormFields !== void 0 ? ignoreReadOnlyFormFields : true);
|
|
138
136
|
}
|
|
139
137
|
getFormConfigFetcher() {
|
|
140
138
|
if (this._formConfigFetcher == undefined) {
|
|
@@ -245,7 +245,11 @@ const snkConfiguratorMessages = {
|
|
|
245
245
|
};
|
|
246
246
|
|
|
247
247
|
const snkGridMessages = {
|
|
248
|
-
findColumn: "Busca de colunas"
|
|
248
|
+
findColumn: "Busca de colunas",
|
|
249
|
+
cancelConfirmation: {
|
|
250
|
+
title: "Aviso",
|
|
251
|
+
message: "As alterações realizadas serão descartadas<br/><br/><b>Você realmente gostaria de cancelar?</b>",
|
|
252
|
+
}
|
|
249
253
|
};
|
|
250
254
|
const snkGridConfigMessages = {
|
|
251
255
|
gridConfiguration: "Configuração da Grade",
|
|
@@ -424,12 +424,19 @@ class DatasetStrategy {
|
|
|
424
424
|
const records = this.processRecords(dataUnit, fields, responseRecords);
|
|
425
425
|
const loadingInProgress = pagerId != undefined;
|
|
426
426
|
const count = loadingInfo.count + records.length;
|
|
427
|
+
const isInsertingNewRecord = dataUnit.hasNewRecord();
|
|
427
428
|
const needReload = !loadingInProgress && localSorting.length > 0;
|
|
429
|
+
/**
|
|
430
|
+
* Caso precise recarregar dados, porém está no meio de uma inserção, os dados não devem recarregados instantaneamente,
|
|
431
|
+
* Mas sim, sinalizar que o dataUnit está aguardando para der recarregado.
|
|
432
|
+
*/
|
|
433
|
+
if (needReload && isInsertingNewRecord) {
|
|
434
|
+
dataUnit.setWaitingToReload(true);
|
|
435
|
+
}
|
|
428
436
|
return Promise.resolve({
|
|
429
437
|
records,
|
|
430
438
|
loadingInfo: Object.assign(Object.assign({}, loadingInfo), { pagerId,
|
|
431
|
-
loadingInProgress, total: loadingInProgress ? undefined : count, count,
|
|
432
|
-
needReload })
|
|
439
|
+
loadingInProgress, total: loadingInProgress ? undefined : count, count, needReload: needReload && !isInsertingNewRecord })
|
|
433
440
|
});
|
|
434
441
|
}
|
|
435
442
|
catch (error) {
|
|
@@ -79,6 +79,7 @@ const SnkCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
79
79
|
this.disablePersonalizedFilter = undefined;
|
|
80
80
|
this.autoLoad = undefined;
|
|
81
81
|
this.autoFocus = true;
|
|
82
|
+
this.enableGridInsert = false;
|
|
82
83
|
this.customContainerId = `SNK-CRUD-CUSTOM-CONTAINER-${StringUtils.generateUUID()}`;
|
|
83
84
|
}
|
|
84
85
|
/**
|
|
@@ -202,6 +203,8 @@ const SnkCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
202
203
|
ElementIDUtils.addIDInfo(this._element, null, dataInfo);
|
|
203
204
|
}
|
|
204
205
|
insertionModeHandler() {
|
|
206
|
+
if (this.enableGridInsert)
|
|
207
|
+
return;
|
|
205
208
|
this.gridToForm();
|
|
206
209
|
}
|
|
207
210
|
cancelHandler() {
|
|
@@ -415,7 +418,7 @@ const SnkCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
415
418
|
return;
|
|
416
419
|
}
|
|
417
420
|
this._snkDataUnit.ignoreSaveMessage = this._currentViewMode === VIEW_MODE.GRID;
|
|
418
|
-
return (h(Host, null, h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "crud" }, h("stack-item", null, h("snk-grid", { ref: (ref) => this._snkGrid = ref, filterBarTitle: this.filterBarTitle, "data-element-id": "crud_grid", configName: this.configName, onGridDoubleClick: () => this.gridToForm(true), taskbarManager: this.taskbarManager, onActionClick: evt => this.executeAction(evt.detail), messagesBuilder: this.messagesBuilder, actionsList: this.actionsList, statusResolver: this.statusResolver, multipleSelection: this.multipleSelection, presentationMode: this.presentationMode, recordsValidator: this.recordsValidator, selectionToastConfig: this.selectionToastConfig, useEnterLikeTab: this.useEnterLikeTab, canEdit: this._canEdit, resourceID: this._resourceID, disablePersonalizedFilter: this.disablePersonalizedFilter, gridLegacyConfigName: this.gridLegacyConfigName, filterBarLegacyConfigName: this.filterBarLegacyConfigName, autoLoad: this.autoLoad, autoFocus: this.autoFocus }, h("slot", { name: "GRID_TASKBAR_CUSTOM_ELEMENTS" }), h("slot", { name: "GRID_HEADER_CUSTOM_ELEMENTS" }), h("slot", { name: "SnkGridHeader" }), h("slot", { name: "SnkGridFooter" }), h("slot", { name: "SnkGridTaskBar" }))), h("stack-item", null, h("snk-guides-viewer", { ref: ref => this._guidesViewer = ref, entityPath: this._snkDataUnit.entityName, messagesBuilder: this.messagesBuilder, onExit: () => this.setViewMode(VIEW_MODE.GRID), dataState: this._dataState, dataUnit: this._dataUnit, actionsList: this.actionsList, taskbarManager: this.taskbarManager, configName: this.configName, onActionClick: evt => this.executeAction(evt.detail), presentationMode: this.presentationMode, "data-element-id": "crud_form", canEdit: this._canEdit, recordsValidator: this.recordsValidator, resourceID: this._resourceID, detailTaskbarCustomContainerId: this.customContainerId, formLegacyConfigName: this.formLegacyConfigName }, 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" }))));
|
|
421
|
+
return (h(Host, null, h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "crud" }, h("stack-item", null, h("snk-grid", { ref: (ref) => this._snkGrid = ref, filterBarTitle: this.filterBarTitle, "data-element-id": "crud_grid", configName: this.configName, onGridDoubleClick: () => this.gridToForm(true), taskbarManager: this.taskbarManager, onActionClick: evt => this.executeAction(evt.detail), messagesBuilder: this.messagesBuilder, actionsList: this.actionsList, statusResolver: this.statusResolver, multipleSelection: this.multipleSelection, presentationMode: this.presentationMode, recordsValidator: this.recordsValidator, selectionToastConfig: this.selectionToastConfig, useEnterLikeTab: this.useEnterLikeTab, canEdit: this._canEdit, resourceID: this._resourceID, disablePersonalizedFilter: this.disablePersonalizedFilter, gridLegacyConfigName: this.gridLegacyConfigName, filterBarLegacyConfigName: this.filterBarLegacyConfigName, autoLoad: this.autoLoad, autoFocus: this.autoFocus, enableGridInsert: this.enableGridInsert }, h("slot", { name: "GRID_TASKBAR_CUSTOM_ELEMENTS" }), h("slot", { name: "GRID_HEADER_CUSTOM_ELEMENTS" }), h("slot", { name: "SnkGridHeader" }), h("slot", { name: "SnkGridFooter" }), h("slot", { name: "SnkGridTaskBar" }))), h("stack-item", null, h("snk-guides-viewer", { ref: ref => this._guidesViewer = ref, entityPath: this._snkDataUnit.entityName, messagesBuilder: this.messagesBuilder, onExit: () => this.setViewMode(VIEW_MODE.GRID), dataState: this._dataState, dataUnit: this._dataUnit, actionsList: this.actionsList, taskbarManager: this.taskbarManager, configName: this.configName, onActionClick: evt => this.executeAction(evt.detail), presentationMode: this.presentationMode, "data-element-id": "crud_form", canEdit: this._canEdit, recordsValidator: this.recordsValidator, resourceID: this._resourceID, detailTaskbarCustomContainerId: this.customContainerId, formLegacyConfigName: this.formLegacyConfigName, enableGridInsert: this.enableGridInsert }, 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" }))));
|
|
419
422
|
}
|
|
420
423
|
get _element() { return this; }
|
|
421
424
|
static get watchers() { return {
|
|
@@ -441,6 +444,7 @@ const SnkCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
441
444
|
"disablePersonalizedFilter": [4, "disable-personalized-filter"],
|
|
442
445
|
"autoLoad": [4, "auto-load"],
|
|
443
446
|
"autoFocus": [4, "auto-focus"],
|
|
447
|
+
"enableGridInsert": [4, "enable-grid-insert"],
|
|
444
448
|
"_dataUnit": [32],
|
|
445
449
|
"_dataState": [32],
|
|
446
450
|
"attachmentRegisterKey": [32],
|
|
@@ -70,6 +70,7 @@ const SnkGuidesViewer = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
|
70
70
|
this.resourceID = undefined;
|
|
71
71
|
this.detailTaskbarCustomContainerId = undefined;
|
|
72
72
|
this.formLegacyConfigName = undefined;
|
|
73
|
+
this.enableGridInsert = false;
|
|
73
74
|
this._hasToCreateFieldSearch = true;
|
|
74
75
|
this._breadcrumbItems = [];
|
|
75
76
|
this._guides = undefined;
|
|
@@ -138,7 +139,7 @@ const SnkGuidesViewer = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
|
138
139
|
this._container.focus();
|
|
139
140
|
}
|
|
140
141
|
exitViewer() {
|
|
141
|
-
if (this.dataUnit.isDirty()) {
|
|
142
|
+
if (!this.enableGridInsert && this.dataUnit.isDirty()) {
|
|
142
143
|
this.dataUnit.cancelEdition({ after: () => this.exit.emit() });
|
|
143
144
|
}
|
|
144
145
|
else {
|
|
@@ -156,7 +157,7 @@ const SnkGuidesViewer = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
|
156
157
|
}
|
|
157
158
|
onContentCardChanged(evt) {
|
|
158
159
|
SnkGuidesViewer.updateContentCard(evt.detail.formName, evt.detail.cardConfig, evt.detail.propertyChanged, this._configManager)
|
|
159
|
-
.then(() => this.masterFormConfig = this._configManager.getConfig(this.
|
|
160
|
+
.then(() => this.masterFormConfig = this._configManager.getConfig(this.dataUnit));
|
|
160
161
|
}
|
|
161
162
|
/**
|
|
162
163
|
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
|
@@ -247,10 +248,13 @@ const SnkGuidesViewer = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
|
247
248
|
const invisibleButtons = this.getInvisibleButtons();
|
|
248
249
|
this._taskbarProcessor = new TaskbarProcessor({
|
|
249
250
|
"snkGuideViewer.regular": btnsRegularMode,
|
|
250
|
-
"snkGuideViewer.finish_edition": ["CANCEL", "SAVE"],
|
|
251
|
+
"snkGuideViewer.finish_edition": ["CANCEL", "SAVE", this.handleAddGridMode()],
|
|
251
252
|
});
|
|
252
253
|
this._taskbarProcessor.process(taskbarId, this.taskbarManager, this.dataState, disabledButtons, invisibleButtons);
|
|
253
254
|
}
|
|
255
|
+
handleAddGridMode() {
|
|
256
|
+
return this.enableGridInsert ? TaskbarElement.GRID_MODE : "";
|
|
257
|
+
}
|
|
254
258
|
getInvisibleButtons() {
|
|
255
259
|
const invisibleButtons = [];
|
|
256
260
|
if (this.dataState && this.dataState.selectionInfo.mode === SelectionMode.ALL_RECORDS)
|
|
@@ -558,6 +562,7 @@ const SnkGuidesViewer = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
|
558
562
|
"resourceID": [1, "resource-i-d"],
|
|
559
563
|
"detailTaskbarCustomContainerId": [1, "detail-taskbar-custom-container-id"],
|
|
560
564
|
"formLegacyConfigName": [1, "form-legacy-config-name"],
|
|
565
|
+
"enableGridInsert": [4, "enable-grid-insert"],
|
|
561
566
|
"_hasToCreateFieldSearch": [32],
|
|
562
567
|
"_breadcrumbItems": [32],
|
|
563
568
|
"_guides": [32],
|
|
@@ -938,14 +943,13 @@ const SnkDetailView = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
938
943
|
return guideId.replace(SnkDetailView.REGEX_FORM_ID, "");
|
|
939
944
|
}
|
|
940
945
|
loadMetadata() {
|
|
941
|
-
var _a;
|
|
942
946
|
if (!this.dataUnit) {
|
|
943
947
|
return;
|
|
944
948
|
}
|
|
945
949
|
if (!this.formConfigManager.isLoaded) {
|
|
946
950
|
return;
|
|
947
951
|
}
|
|
948
|
-
const formConfig = this.formConfigManager.getConfig(
|
|
952
|
+
const formConfig = this.formConfigManager.getConfig(this.dataUnit);
|
|
949
953
|
//this._cardsState = formConfig?.cardsState;
|
|
950
954
|
this._formMetadata = buildFormMetadata(formConfig == undefined || formConfig.fields.length === 0 ? undefined : formConfig, this.dataUnit, true);
|
|
951
955
|
}
|
|
@@ -76,7 +76,7 @@ const SnkFormConfig = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
getConfig() {
|
|
79
|
-
let config = this.configManager.getConfig(
|
|
79
|
+
let config = this.configManager.getConfig(this.dataUnit);
|
|
80
80
|
if (config.fields && config.fields.length === 0) {
|
|
81
81
|
config = undefined;
|
|
82
82
|
}
|