@sankhyalabs/sankhyablocks 8.16.0-rc.10 → 8.16.0-rc.12
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/{ConfigStorage-e49214c6.js → ConfigStorage-ecc0ed20.js} +2 -2
- package/dist/cjs/{IExporterProvider-8c030a7e.js → ContinuousInsertUtils-807730a8.js} +38 -5
- package/dist/cjs/{DataFetcher-77729a93.js → DataFetcher-cadeef8e.js} +21 -20
- package/dist/cjs/{SnkFormConfigManager-beebf47a.js → SnkFormConfigManager-f1c92f79.js} +72 -16
- package/dist/cjs/{SnkMessageBuilder-cceebbae.js → SnkMessageBuilder-bae64d0d.js} +5 -1
- package/dist/cjs/{auth-fetcher-29bb791c.js → auth-fetcher-d68841bc.js} +1 -1
- package/dist/cjs/{dataunit-fetcher-d4873076.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-feb08214.js → form-config-fetcher-ed497282.js} +5 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{pesquisa-fetcher-a1d0353f.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 +5 -5
- package/dist/cjs/snk-application.cjs.entry.js +7 -7
- package/dist/cjs/snk-attach.cjs.entry.js +37 -28
- package/dist/cjs/snk-crud.cjs.entry.js +12 -6
- package/dist/cjs/snk-data-exporter.cjs.entry.js +6 -6
- package/dist/cjs/{snk-data-unit-c7dcfa19.js → snk-data-unit-47202e42.js} +4 -3
- package/dist/cjs/snk-data-unit.cjs.entry.js +4 -4
- package/dist/cjs/snk-detail-view.cjs.entry.js +10 -10
- package/dist/cjs/snk-filter-bar.cjs.entry.js +22 -18
- 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 +15 -4
- package/dist/cjs/snk-form.cjs.entry.js +7 -6
- package/dist/cjs/snk-grid.cjs.entry.js +58 -18
- package/dist/cjs/{snk-guides-viewer-69ec61af.js → snk-guides-viewer-68777d37.js} +23 -11
- 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 +51 -18
- package/dist/collection/components/snk-attach/snk-attach.js +24 -15
- 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 +59 -1
- package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +1 -1
- package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +50 -5
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +2 -1
- 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 +44 -14
- 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 +13 -2
- package/dist/collection/components/snk-grid/snk-grid.css +2 -0
- package/dist/collection/components/snk-grid/snk-grid.js +67 -7
- 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 +61 -9
- 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/dataUnit/InMemoryLoader.js +2 -4
- package/dist/collection/lib/dataUnit/dataUnitInMemoryUtils.js +34 -9
- package/dist/collection/lib/http/data-fetcher/DataFetcher.js +21 -20
- 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-grid.msg.js +5 -1
- package/dist/collection/lib/utils/ContinuousInsertUtils.js +31 -0
- package/dist/components/{IExporterProvider.js → ContinuousInsertUtils.js} +38 -3
- package/dist/components/DataFetcher.js +21 -20
- package/dist/components/SnkFormConfigManager.js +70 -14
- package/dist/components/SnkMessageBuilder.js +5 -1
- package/dist/components/dataunit-fetcher.js +45 -15
- package/dist/components/form-config-fetcher.js +4 -1
- package/dist/components/snk-attach2.js +33 -24
- package/dist/components/snk-crud.js +9 -1
- package/dist/components/snk-data-unit2.js +3 -2
- package/dist/components/snk-detail-view2.js +21 -7
- package/dist/components/snk-filter-bar2.js +20 -15
- 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 +13 -2
- package/dist/components/snk-form.js +2 -2
- package/dist/components/snk-grid2.js +50 -8
- 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 +42 -7
- package/dist/esm/{ConfigStorage-e476378d.js → ConfigStorage-7b36d041.js} +2 -2
- package/dist/esm/{IExporterProvider-f86019db.js → ContinuousInsertUtils-1a82a768.js} +38 -6
- package/dist/esm/{DataFetcher-773a3e4b.js → DataFetcher-a9c598f2.js} +21 -20
- package/dist/esm/{SnkFormConfigManager-298cd647.js → SnkFormConfigManager-139f09fa.js} +72 -16
- package/dist/esm/{SnkMessageBuilder-ae87b754.js → SnkMessageBuilder-6fff4a4c.js} +5 -1
- package/dist/esm/{auth-fetcher-a411f73c.js → auth-fetcher-749d880f.js} +1 -1
- package/dist/esm/{dataunit-fetcher-3d2ec959.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-e0382e5a.js → form-config-fetcher-adbe5d34.js} +5 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{pesquisa-fetcher-a87445a0.js → pesquisa-fetcher-8edaa8cd.js} +1 -1
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-actions-button_4.entry.js +5 -5
- package/dist/esm/snk-application.entry.js +7 -7
- package/dist/esm/snk-attach.entry.js +37 -28
- package/dist/esm/snk-crud.entry.js +12 -6
- package/dist/esm/snk-data-exporter.entry.js +6 -6
- package/dist/esm/{snk-data-unit-3276e55e.js → snk-data-unit-de45e0e1.js} +4 -3
- package/dist/esm/snk-data-unit.entry.js +4 -4
- package/dist/esm/snk-detail-view.entry.js +10 -10
- package/dist/esm/snk-filter-bar.entry.js +22 -18
- 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 +15 -4
- package/dist/esm/snk-form.entry.js +7 -6
- package/dist/esm/snk-grid.entry.js +53 -13
- package/dist/esm/{snk-guides-viewer-43f21b03.js → snk-guides-viewer-b5dd30e6.js} +23 -11
- 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 +47 -14
- package/dist/sankhyablocks/p-0035ad6e.entry.js +1 -0
- package/dist/sankhyablocks/{p-181975f1.js → p-06421fdb.js} +2 -2
- package/dist/sankhyablocks/p-0911e61a.entry.js +1 -0
- package/dist/sankhyablocks/p-17425c72.js +1 -0
- package/dist/sankhyablocks/{p-25f1fc39.js → p-1bf06cd3.js} +2 -2
- package/dist/sankhyablocks/{p-9dfda04a.entry.js → p-212213d9.entry.js} +1 -1
- package/dist/sankhyablocks/p-23736d75.js +1 -0
- package/dist/sankhyablocks/p-3ae9d08a.js +1 -0
- package/dist/sankhyablocks/p-3e3cc017.js +1 -0
- package/dist/sankhyablocks/{p-72fc257b.entry.js → p-434817f0.entry.js} +1 -1
- package/dist/sankhyablocks/{p-3287a6cc.js → p-4d9549cf.js} +1 -1
- package/dist/sankhyablocks/p-50779ad3.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-92ed1d24.entry.js → p-62e048c6.entry.js} +1 -1
- package/dist/sankhyablocks/{p-fd8a58ff.entry.js → p-694e1c4a.entry.js} +1 -1
- package/dist/sankhyablocks/p-73185e58.entry.js +1 -0
- package/dist/sankhyablocks/p-7ac7932c.js +60 -0
- package/dist/sankhyablocks/p-7eef0898.entry.js +1 -0
- package/dist/sankhyablocks/{p-41f8bfa3.entry.js → p-8c235d4c.entry.js} +1 -1
- package/dist/sankhyablocks/{p-162b9a59.entry.js → p-a42e7a1e.entry.js} +2 -2
- package/dist/sankhyablocks/p-afbb070d.js +1 -0
- package/dist/sankhyablocks/p-b9679243.entry.js +1 -0
- package/dist/sankhyablocks/{p-6d55957a.js → p-bccfc262.js} +1 -1
- package/dist/sankhyablocks/p-c2e468c9.entry.js +1 -0
- package/dist/sankhyablocks/{p-0cd3c0a9.js → p-ca5ec380.js} +1 -1
- package/dist/sankhyablocks/{p-1a21b61a.entry.js → p-da34270e.entry.js} +1 -1
- package/dist/sankhyablocks/p-e16e87fc.entry.js +1 -0
- package/dist/sankhyablocks/{p-1e596b15.entry.js → p-eb9f0407.entry.js} +1 -1
- package/dist/sankhyablocks/{p-594bc21d.js → p-f3434fc4.js} +1 -1
- package/dist/sankhyablocks/{p-bd008859.entry.js → p-fb34e0cf.entry.js} +1 -1
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-attach/snk-attach.d.ts +1 -0
- package/dist/types/components/snk-crud/snk-crud.d.ts +9 -0
- package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +11 -0
- package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +4 -0
- package/dist/types/components/snk-form-config/SnkFormConfigManager.d.ts +7 -2
- package/dist/types/components/snk-grid/snk-grid.d.ts +12 -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.d.ts +57 -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/package.json +1 -1
- package/dist/sankhyablocks/p-091ce761.js +0 -60
- package/dist/sankhyablocks/p-1f35c795.js +0 -1
- package/dist/sankhyablocks/p-2e9c764c.entry.js +0 -1
- package/dist/sankhyablocks/p-42f7b05d.entry.js +0 -1
- package/dist/sankhyablocks/p-4e1b47a4.js +0 -1
- package/dist/sankhyablocks/p-53412c1d.entry.js +0 -1
- package/dist/sankhyablocks/p-5b26cc7c.entry.js +0 -1
- package/dist/sankhyablocks/p-5f016aed.js +0 -1
- package/dist/sankhyablocks/p-7b8f7242.entry.js +0 -1
- package/dist/sankhyablocks/p-7c4aabe2.js +0 -1
- package/dist/sankhyablocks/p-88aa931b.entry.js +0 -1
- package/dist/sankhyablocks/p-939e15d3.entry.js +0 -1
- package/dist/sankhyablocks/p-aa5b3b2c.entry.js +0 -1
- package/dist/sankhyablocks/p-aa6d510d.entry.js +0 -1
- package/dist/sankhyablocks/p-b11aa1e0.entry.js +0 -1
- package/dist/sankhyablocks/p-c2495304.js +0 -1
@@ -1,12 +1,14 @@
|
|
1
1
|
import { C as ConfigStorage } from './ConfigStorage.js';
|
2
2
|
import { ObjectUtils, StringUtils } from '@sankhyalabs/core';
|
3
3
|
import { F as FormConfigFetcher } from './form-config-fetcher.js';
|
4
|
+
import { c as TAB_NAMES } from './constants.js';
|
4
5
|
|
5
6
|
class SnkFormConfigManager {
|
6
|
-
constructor(configName, resourceID, onConfigChange) {
|
7
|
+
constructor(configName, resourceID, onConfigChange, dataUnit) {
|
7
8
|
this._resourceID = resourceID;
|
8
9
|
this._configName = configName;
|
9
10
|
this._onConfigChange = onConfigChange;
|
11
|
+
this._dataUnit = dataUnit;
|
10
12
|
}
|
11
13
|
addFormLegacyConfig(legacyConfigName) {
|
12
14
|
if (this._configName) {
|
@@ -17,6 +19,7 @@ class SnkFormConfigManager {
|
|
17
19
|
return new Promise(resolve => {
|
18
20
|
ConfigStorage.loadFormConfig(this._configName, this._resourceID)
|
19
21
|
.then((config) => {
|
22
|
+
config = this.buildFormMetadataUITabs(config);
|
20
23
|
this.setConfig(config);
|
21
24
|
resolve(config);
|
22
25
|
})
|
@@ -25,6 +28,10 @@ class SnkFormConfigManager {
|
|
25
28
|
});
|
26
29
|
});
|
27
30
|
}
|
31
|
+
getEmptyConfig() {
|
32
|
+
const config = this.buildFormMetadataUITabs({ fields: [], emptyConfig: true }, true);
|
33
|
+
return config;
|
34
|
+
}
|
28
35
|
saveConfig(config) {
|
29
36
|
const configToSave = ObjectUtils.copy(config);
|
30
37
|
return new Promise(accept => {
|
@@ -68,25 +75,36 @@ class SnkFormConfigManager {
|
|
68
75
|
}
|
69
76
|
return updatingCardConfig;
|
70
77
|
}
|
71
|
-
|
78
|
+
hasConfig(config) {
|
79
|
+
var _a;
|
80
|
+
const currentConfig = config !== null && config !== void 0 ? config : this._config;
|
81
|
+
if (currentConfig && ((_a = currentConfig.fields) === null || _a === void 0 ? void 0 : _a.length)) {
|
82
|
+
return true;
|
83
|
+
}
|
84
|
+
return false;
|
85
|
+
}
|
86
|
+
getFieldsList(descriptionFilter, forceEmptyConfig = false) {
|
72
87
|
var _a;
|
73
88
|
const fields = (_a = this._config) === null || _a === void 0 ? void 0 : _a.fields;
|
74
|
-
|
75
|
-
|
89
|
+
const hasConfig = this.hasConfig();
|
90
|
+
if (hasConfig && !forceEmptyConfig) {
|
91
|
+
return fields.map(({ label, name, readOnly, visible, required, tab }) => {
|
92
|
+
var _a;
|
76
93
|
if (label == undefined) {
|
77
|
-
const currentField =
|
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 });
|
94
|
+
const currentField = (_a = this._dataUnit) === null || _a === void 0 ? void 0 : _a.getField(name);
|
95
|
+
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, tab: tab });
|
79
96
|
}
|
80
|
-
return { name, label, readOnly, visible, required };
|
97
|
+
return { name, label, readOnly, visible, required, tab };
|
81
98
|
})
|
82
99
|
.filter(field => this.isFieldVisible(field, descriptionFilter));
|
83
100
|
}
|
84
|
-
if (
|
85
|
-
return
|
86
|
-
.filter(field => this.isFieldVisible(field, descriptionFilter))
|
87
|
-
.map(({ label, name, readOnly }) => { return { label, name, readOnly }; });
|
101
|
+
if (!this._dataUnit) {
|
102
|
+
return [];
|
88
103
|
}
|
89
|
-
|
104
|
+
const filteredFields = this._dataUnit.metadata.fields
|
105
|
+
.filter(field => this.isFieldVisible(field, descriptionFilter))
|
106
|
+
.map(({ label, name, readOnly, visible, required, properties }) => ({ label, name, readOnly, visible, required, tab: properties === null || properties === void 0 ? void 0 : properties.UITabName }));
|
107
|
+
return filteredFields;
|
90
108
|
}
|
91
109
|
isFieldVisible(field, descriptionFilter) {
|
92
110
|
if (field.visible === false) {
|
@@ -99,8 +117,8 @@ class SnkFormConfigManager {
|
|
99
117
|
const normalizedFilter = StringUtils.replaceAccentuatedCharsLower(descriptionFilter.toLocaleLowerCase());
|
100
118
|
return normalizedText.includes(normalizedFilter);
|
101
119
|
}
|
102
|
-
getFormConfig(dataUnit, ignoreReadOnlyFormFields) {
|
103
|
-
let fields = this.getFieldsList(
|
120
|
+
getFormConfig(dataUnit, ignoreReadOnlyFormFields, forceEmptyConfig = false) {
|
121
|
+
let fields = this.getFieldsList(undefined, forceEmptyConfig);
|
104
122
|
if (ignoreReadOnlyFormFields) {
|
105
123
|
fields = fields.filter(field => {
|
106
124
|
if (dataUnit) {
|
@@ -153,6 +171,44 @@ class SnkFormConfigManager {
|
|
153
171
|
async fetchDefaultConfig() {
|
154
172
|
return this.getFormConfigFetcher().fetchDefaultConfig(this._configName, this._resourceID);
|
155
173
|
}
|
174
|
+
parseObjectList(object) {
|
175
|
+
if (!object) {
|
176
|
+
return [];
|
177
|
+
}
|
178
|
+
return Array.isArray(object) ? object : [object];
|
179
|
+
}
|
180
|
+
buildFormMetadataUITabs(config, forceEmptyConfig = false) {
|
181
|
+
var _a;
|
182
|
+
const hasConfig = this.hasConfig(config);
|
183
|
+
if (!forceEmptyConfig && (!this._dataUnit || hasConfig)) {
|
184
|
+
return config;
|
185
|
+
}
|
186
|
+
config = this.getFormConfig(this._dataUnit, false, true);
|
187
|
+
config.tabs = this.parseObjectList(config.tabs);
|
188
|
+
config.emptyConfig = false;
|
189
|
+
config.defaultConfiguration = true;
|
190
|
+
const fields = this._dataUnit.metadata.fields;
|
191
|
+
for (const currentField of fields) {
|
192
|
+
const field = config.fields.find(field => field.name === currentField.name);
|
193
|
+
const uiTabName = (_a = currentField.properties) === null || _a === void 0 ? void 0 : _a.UITabName;
|
194
|
+
if (!uiTabName || uiTabName === TAB_NAMES.main) {
|
195
|
+
continue;
|
196
|
+
}
|
197
|
+
const haveTab = config.tabs.some((tab) => tab.label === uiTabName);
|
198
|
+
if (!haveTab) {
|
199
|
+
config.tabs.push({
|
200
|
+
label: uiTabName,
|
201
|
+
name: uiTabName,
|
202
|
+
order: 0,
|
203
|
+
visible: true,
|
204
|
+
});
|
205
|
+
}
|
206
|
+
if (field) {
|
207
|
+
field.tab = uiTabName;
|
208
|
+
}
|
209
|
+
}
|
210
|
+
return config;
|
211
|
+
}
|
156
212
|
}
|
157
213
|
|
158
214
|
export { SnkFormConfigManager as S };
|
@@ -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",
|
@@ -235,6 +235,21 @@ function applyFilter(records, dataUnit, filters) {
|
|
235
235
|
}
|
236
236
|
return records.filter(filterFunction);
|
237
237
|
}
|
238
|
+
function buildLoadDataResponse(recordsIn, dataUnit, request) {
|
239
|
+
let records = recordsIn ? [...recordsIn] : [];
|
240
|
+
records = applyFilter(records, dataUnit, request.filters);
|
241
|
+
records = applySorting(records, dataUnit, request.sort);
|
242
|
+
const { offset, limit } = request;
|
243
|
+
const paginationInfoBuilderParams = {
|
244
|
+
recordsLength: records.length,
|
245
|
+
offset,
|
246
|
+
recordsPerPage: limit,
|
247
|
+
};
|
248
|
+
return Promise.resolve({
|
249
|
+
records: getPagesByRecords(records, offset, limit),
|
250
|
+
paginationInfo: buildPaginationInfo(paginationInfoBuilderParams),
|
251
|
+
});
|
252
|
+
}
|
238
253
|
function applySorting(records, dataUnit, sorting) {
|
239
254
|
if (sorting == undefined || sorting.length == 0) {
|
240
255
|
return records;
|
@@ -245,18 +260,28 @@ function applySorting(records, dataUnit, sorting) {
|
|
245
260
|
}
|
246
261
|
return records.sort(sortingFunction);
|
247
262
|
}
|
248
|
-
function
|
249
|
-
|
250
|
-
|
263
|
+
function hasValidLimitAndOffset(offset, limit) {
|
264
|
+
return offset >= 0 && limit >= 0;
|
265
|
+
}
|
266
|
+
function getPagesByRecords(records, offset = 0, limit = 0) {
|
267
|
+
if (!records || !records.length || !hasValidLimitAndOffset(offset, limit))
|
268
|
+
return [];
|
269
|
+
if (limit === 0 && offset === 0)
|
270
|
+
return records;
|
271
|
+
return records.slice(offset, offset + limit);
|
272
|
+
}
|
273
|
+
function buildPaginationInfo({ recordsLength = 0, offset = 0, recordsPerPage = 0 }) {
|
274
|
+
if (!recordsLength) {
|
275
|
+
return { currentPage: 0, firstRecord: 0, lastRecord: 0, total: 0, hasMore: false };
|
251
276
|
}
|
252
|
-
const
|
253
|
-
const lastRecord = Math.min(
|
277
|
+
const lastRecordIndex = offset + recordsPerPage;
|
278
|
+
const lastRecord = lastRecordIndex ? Math.min(lastRecordIndex, recordsLength) : recordsLength;
|
254
279
|
return {
|
255
|
-
currentPage:
|
256
|
-
firstRecord: offset,
|
280
|
+
currentPage: recordsPerPage === 0 ? 0 : Math.ceil(offset / recordsPerPage),
|
281
|
+
firstRecord: offset + 1,
|
257
282
|
lastRecord: lastRecord,
|
258
|
-
total:
|
259
|
-
hasMore:
|
283
|
+
total: recordsLength,
|
284
|
+
hasMore: lastRecord < recordsLength,
|
260
285
|
};
|
261
286
|
}
|
262
287
|
|
@@ -342,9 +367,7 @@ class InMemoryLoader {
|
|
342
367
|
return StringUtils.generateUUID();
|
343
368
|
}
|
344
369
|
inMemoryLoader(dataUnit, request, recordsIn) {
|
345
|
-
|
346
|
-
records = applySorting(records, dataUnit, request.sort);
|
347
|
-
return Promise.resolve({ records, paginationInfo: buildPaginationInfo(records, request.offset, request.limit) });
|
370
|
+
return buildLoadDataResponse(recordsIn, dataUnit, request);
|
348
371
|
}
|
349
372
|
metadaLoader() {
|
350
373
|
return Promise.resolve(this._metadata);
|
@@ -424,12 +447,19 @@ class DatasetStrategy {
|
|
424
447
|
const records = this.processRecords(dataUnit, fields, responseRecords);
|
425
448
|
const loadingInProgress = pagerId != undefined;
|
426
449
|
const count = loadingInfo.count + records.length;
|
450
|
+
const isInsertingNewRecord = dataUnit.hasNewRecord();
|
427
451
|
const needReload = !loadingInProgress && localSorting.length > 0;
|
452
|
+
/**
|
453
|
+
* Caso precise recarregar dados, porém está no meio de uma inserção, os dados não devem recarregados instantaneamente,
|
454
|
+
* Mas sim, sinalizar que o dataUnit está aguardando para der recarregado.
|
455
|
+
*/
|
456
|
+
if (needReload && isInsertingNewRecord) {
|
457
|
+
dataUnit.setWaitingToReload(true);
|
458
|
+
}
|
428
459
|
return Promise.resolve({
|
429
460
|
records,
|
430
461
|
loadingInfo: Object.assign(Object.assign({}, loadingInfo), { pagerId,
|
431
|
-
loadingInProgress, total: loadingInProgress ? undefined : count, count,
|
432
|
-
needReload })
|
462
|
+
loadingInProgress, total: loadingInProgress ? undefined : count, count, needReload: needReload && !isInsertingNewRecord })
|
433
463
|
});
|
434
464
|
}
|
435
465
|
catch (error) {
|
@@ -1052,4 +1082,4 @@ class DataUnitFetcher {
|
|
1052
1082
|
}
|
1053
1083
|
}
|
1054
1084
|
|
1055
|
-
export { DataUnitFetcher as D, InMemoryLoader as I, PreloadManager as P,
|
1085
|
+
export { DataUnitFetcher as D, InMemoryLoader as I, PreloadManager as P, DatasetStrategy as a, buildLoadDataResponse as b, getRecordValue as g };
|
@@ -217,7 +217,10 @@ class FormConfigFetcher extends ResourceFetcher {
|
|
217
217
|
query: this.queryConfig.get("fetchDefaultConfig"),
|
218
218
|
})
|
219
219
|
.then((result) => {
|
220
|
-
|
220
|
+
if (!(result === null || result === void 0 ? void 0 : result.resource)) {
|
221
|
+
resolve(null);
|
222
|
+
}
|
223
|
+
resolve(ObjectUtils.stringToObject(result === null || result === void 0 ? void 0 : result.resource));
|
221
224
|
})
|
222
225
|
.catch((error) => {
|
223
226
|
reject(error);
|
@@ -3,7 +3,7 @@ import { ApplicationContext, DataType, Action, UserInterface, StringUtils, DataU
|
|
3
3
|
import { D as DataFetcher } from './DataFetcher.js';
|
4
4
|
import './pesquisa-fetcher.js';
|
5
5
|
import { S as SaveErrorsEnum } from './ISave.js';
|
6
|
-
import { P as PreloadManager,
|
6
|
+
import { P as PreloadManager, b as buildLoadDataResponse, D as DataUnitFetcher, I as InMemoryLoader } from './dataunit-fetcher.js';
|
7
7
|
import './filter-item-type.enum.js';
|
8
8
|
import './form-config-fetcher.js';
|
9
9
|
import { V as VIEW_MODE } from './constants.js';
|
@@ -119,21 +119,23 @@ const SERVICE = {
|
|
119
119
|
download: "AnexoSistemaSP.baixar",
|
120
120
|
};
|
121
121
|
class AnexoSistemaFetcher {
|
122
|
-
constructor(entityName,
|
122
|
+
constructor(entityName, dataUnitName) {
|
123
123
|
var _a;
|
124
124
|
this.entityName = entityName;
|
125
|
-
this.registerKey = registerKey;
|
126
125
|
this.dataUnitName = dataUnitName;
|
127
126
|
this.validateFields = (fields) => {
|
128
127
|
if (!!fields.LINK && !!fields.NOMEARQUIVO)
|
129
128
|
throw new Error(SaveErrorsEnum.LINK_AND_FILE_AT_THE_SAME_TIME);
|
130
129
|
if (!fields.LINK && !fields.NOMEARQUIVO)
|
131
130
|
throw new Error(SaveErrorsEnum.ANY_LINK_OR_FILE_FILLED);
|
132
|
-
if (!this.
|
131
|
+
if (!this._registerKey)
|
133
132
|
throw new Error('Register key can not be null');
|
134
133
|
};
|
135
134
|
this.resourceID = (window["resourceID"] || ((_a = window["workspace"]) === null || _a === void 0 ? void 0 : _a.resourceID));
|
136
135
|
}
|
136
|
+
set registerKey(registerKey) {
|
137
|
+
this._registerKey = registerKey;
|
138
|
+
}
|
137
139
|
async save(change) {
|
138
140
|
var _a, _b;
|
139
141
|
let { updatingFields: fields } = change;
|
@@ -152,7 +154,7 @@ class AnexoSistemaFetcher {
|
|
152
154
|
nameAttach: fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.name,
|
153
155
|
link: fields.LINK,
|
154
156
|
nameEntity: this.entityName,
|
155
|
-
pkEntity: this.
|
157
|
+
pkEntity: this._registerKey,
|
156
158
|
typeAcess: fields.TIPOACESSO,
|
157
159
|
typeApres: fields.TIPOAPRES,
|
158
160
|
}
|
@@ -192,7 +194,7 @@ class AnexoSistemaFetcher {
|
|
192
194
|
nameAttach: fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.name,
|
193
195
|
link: fields.LINK,
|
194
196
|
nameEntity: this.entityName,
|
195
|
-
pkEntity: this.
|
197
|
+
pkEntity: this._registerKey,
|
196
198
|
typeAcess: fields.TIPOACESSO,
|
197
199
|
typeApres: fields.TIPOAPRES,
|
198
200
|
}
|
@@ -464,9 +466,7 @@ class AttachFetcherDataUnitFactory {
|
|
464
466
|
});
|
465
467
|
this._records = records;
|
466
468
|
}
|
467
|
-
|
468
|
-
records = applySorting(records, dataUnit, request.sort);
|
469
|
-
return Promise.resolve({ records, paginationInfo: buildPaginationInfo(records, request.offset, request.limit) });
|
469
|
+
return buildLoadDataResponse(this._records, dataUnit, request);
|
470
470
|
}
|
471
471
|
saveLoader(changes, fetcher) {
|
472
472
|
return new Promise((resolve) => {
|
@@ -663,11 +663,20 @@ const SnkAttach = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
663
663
|
this.loadAttachmentDataUnit();
|
664
664
|
}
|
665
665
|
if (oldRegisterKey !== newRegisterKey) {
|
666
|
+
if (this._currentFetcher instanceof AnexoSistemaFetcher) {
|
667
|
+
this._currentFetcher.registerKey = newRegisterKey;
|
668
|
+
}
|
666
669
|
await ((_a = this._currentDataUnit) === null || _a === void 0 ? void 0 : _a.loadData());
|
667
670
|
}
|
668
671
|
}
|
672
|
+
getAnexoSistemaFetcherInstance() {
|
673
|
+
var _a;
|
674
|
+
const anexoSistemaFetcher = new AnexoSistemaFetcher(this.entityName, (_a = this._currentDataUnit) === null || _a === void 0 ? void 0 : _a.name);
|
675
|
+
anexoSistemaFetcher.registerKey = this.registerKey;
|
676
|
+
return anexoSistemaFetcher;
|
677
|
+
}
|
669
678
|
async initAttach() {
|
670
|
-
var _a, _b, _c, _d, _e
|
679
|
+
var _a, _b, _c, _d, _e;
|
671
680
|
if (!this.fetcherType && !this.registerKey)
|
672
681
|
return;
|
673
682
|
if (!this.fetcherType) {
|
@@ -675,18 +684,18 @@ const SnkAttach = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
675
684
|
}
|
676
685
|
this.returnToGridMode();
|
677
686
|
if (this.fetcherType === "AnexoSistema") {
|
678
|
-
this._currentFetcher =
|
679
|
-
(
|
680
|
-
await ((
|
687
|
+
this._currentFetcher = this.getAnexoSistemaFetcherInstance();
|
688
|
+
(_a = this._currentDataUnitBuilder) === null || _a === void 0 ? void 0 : _a.initLoaders(this._currentDataUnit, this._currentFetcher, this.returnToGridMode.bind(this));
|
689
|
+
await ((_b = this._currentDataUnit) === null || _b === void 0 ? void 0 : _b.loadData());
|
681
690
|
return;
|
682
691
|
}
|
683
692
|
if (this.fetcherType === "Attach") {
|
684
|
-
const hasMoreOneItem = ((
|
693
|
+
const hasMoreOneItem = ((_c = this.registerKey) === null || _c === void 0 ? void 0 : _c.split("_").length) > 1;
|
685
694
|
if (hasMoreOneItem)
|
686
695
|
return;
|
687
696
|
}
|
688
|
-
await ((
|
689
|
-
await ((
|
697
|
+
await ((_d = this._currentDataUnit) === null || _d === void 0 ? void 0 : _d.loadMetadata());
|
698
|
+
await ((_e = this._currentDataUnit) === null || _e === void 0 ? void 0 : _e.loadData(undefined, undefined, true, this.registerKey));
|
690
699
|
}
|
691
700
|
/**
|
692
701
|
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
@@ -745,11 +754,11 @@ const SnkAttach = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
745
754
|
}
|
746
755
|
}
|
747
756
|
async loadAnexoSistema() {
|
748
|
-
var _a, _b
|
757
|
+
var _a, _b;
|
749
758
|
this._currentDataUnit = new DataUnitFetcher().getDataUnit(RESOURCE_ID, DATA_UNIT_NAME);
|
750
|
-
this._currentFetcher =
|
759
|
+
this._currentFetcher = this.getAnexoSistemaFetcherInstance();
|
751
760
|
if (!this._currentDataUnit.metadata) {
|
752
|
-
await ((
|
761
|
+
await ((_a = this._currentDataUnit) === null || _a === void 0 ? void 0 : _a.loadMetadata());
|
753
762
|
this.crudConfig = Object.assign({}, anexoSistemaCrudConfig);
|
754
763
|
}
|
755
764
|
this.initDataUnitLoaders();
|
@@ -759,7 +768,7 @@ const SnkAttach = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
759
768
|
this._currentDataUnit.addInterceptor({
|
760
769
|
interceptAction: (action) => this._currentDataUnitBuilder.getInterceptions(this._currentDataUnit, action, this._crudElement)
|
761
770
|
});
|
762
|
-
await ((
|
771
|
+
await ((_b = this._currentDataUnit) === null || _b === void 0 ? void 0 : _b.loadData());
|
763
772
|
this.disableEditFieldsNotInForm();
|
764
773
|
}
|
765
774
|
async loadAttach() {
|
@@ -785,16 +794,16 @@ const SnkAttach = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
785
794
|
}
|
786
795
|
}
|
787
796
|
initDataUnitLoaders() {
|
788
|
-
var _a, _b
|
797
|
+
var _a, _b;
|
789
798
|
if (this.fetcherType === "AnexoSistema") {
|
790
|
-
this._currentFetcher =
|
799
|
+
this._currentFetcher = this.getAnexoSistemaFetcherInstance();
|
791
800
|
this._currentDataUnitBuilder = new AnexoSistemaDataUnitFactory(this.entityName, this.getMessage.bind(this));
|
792
|
-
(
|
801
|
+
(_a = this._currentDataUnitBuilder) === null || _a === void 0 ? void 0 : _a.initLoaders(this._currentDataUnit, this._currentFetcher, this.returnToGridMode.bind(this));
|
793
802
|
}
|
794
803
|
if (this.fetcherType === "Attach") {
|
795
804
|
this._currentFetcher = new AttachFetcher();
|
796
805
|
this._currentDataUnitBuilder = new AttachFetcherDataUnitFactory(this.getMessage.bind(this));
|
797
|
-
(
|
806
|
+
(_b = this._currentDataUnitBuilder) === null || _b === void 0 ? void 0 : _b.initLoaders(this._currentDataUnit, this._currentFetcher, async () => {
|
798
807
|
this.returnToGridMode();
|
799
808
|
await this._currentDataUnit.loadData(undefined, undefined, true, this.registerKey);
|
800
809
|
});
|
@@ -51,6 +51,7 @@ const SnkCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
51
51
|
this.configuratorSave = createEvent(this, "configuratorSave", 7);
|
52
52
|
this.configuratorCancel = createEvent(this, "configuratorCancel", 7);
|
53
53
|
this.formItemsReady = createEvent(this, "formItemsReady", 7);
|
54
|
+
this.viewModeChanged = createEvent(this, "viewModeChanged", 7);
|
54
55
|
this._keyDownHandler = async (event) => this.keyDownListener(event);
|
55
56
|
this._viewHistory = [];
|
56
57
|
this._customEditors = new Map();
|
@@ -79,7 +80,9 @@ const SnkCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
79
80
|
this.disablePersonalizedFilter = undefined;
|
80
81
|
this.autoLoad = undefined;
|
81
82
|
this.autoFocus = true;
|
83
|
+
this.enableGridInsert = false;
|
82
84
|
this.domainMessagesBuilder = undefined;
|
85
|
+
this.setCustomFormTitle = undefined;
|
83
86
|
this.customContainerId = `SNK-CRUD-CUSTOM-CONTAINER-${StringUtils.generateUUID()}`;
|
84
87
|
}
|
85
88
|
/**
|
@@ -188,6 +191,7 @@ const SnkCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
188
191
|
else if (viewMode === VIEW_MODE.FORM) {
|
189
192
|
this._guidesViewer.setFocus();
|
190
193
|
}
|
194
|
+
this.viewModeChanged.emit(viewMode);
|
191
195
|
}
|
192
196
|
openConfig(viewMode) {
|
193
197
|
this._snkConfigurator.close();
|
@@ -203,6 +207,8 @@ const SnkCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
203
207
|
ElementIDUtils.addIDInfo(this._element, null, dataInfo);
|
204
208
|
}
|
205
209
|
insertionModeHandler() {
|
210
|
+
if (this.enableGridInsert)
|
211
|
+
return;
|
206
212
|
this.gridToForm();
|
207
213
|
}
|
208
214
|
cancelHandler() {
|
@@ -417,7 +423,7 @@ const SnkCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
417
423
|
return;
|
418
424
|
}
|
419
425
|
this._snkDataUnit.ignoreSaveMessage = this._currentViewMode === VIEW_MODE.GRID;
|
420
|
-
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" }))));
|
426
|
+
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, getCustomTitle: this.setCustomFormTitle }, 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
427
|
}
|
422
428
|
get _element() { return this; }
|
423
429
|
static get watchers() { return {
|
@@ -443,7 +449,9 @@ const SnkCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
443
449
|
"disablePersonalizedFilter": [4, "disable-personalized-filter"],
|
444
450
|
"autoLoad": [4, "auto-load"],
|
445
451
|
"autoFocus": [4, "auto-focus"],
|
452
|
+
"enableGridInsert": [4, "enable-grid-insert"],
|
446
453
|
"domainMessagesBuilder": [1, "domain-messages-builder"],
|
454
|
+
"setCustomFormTitle": [16],
|
447
455
|
"_dataUnit": [32],
|
448
456
|
"_dataState": [32],
|
449
457
|
"attachmentRegisterKey": [32],
|
@@ -2,7 +2,7 @@ import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/
|
|
2
2
|
import { Action, ObjectUtils, DataUnitAction, StringUtils, ApplicationContext } from '@sankhyalabs/core';
|
3
3
|
import { ApplicationUtils, DialogType } from '@sankhyalabs/ezui/dist/collection/utils';
|
4
4
|
import { O as OperationMap, S as SnkMessageBuilder } from './SnkMessageBuilder.js';
|
5
|
-
import { g as getRecordValue,
|
5
|
+
import { g as getRecordValue, a as DatasetStrategy } from './dataunit-fetcher.js';
|
6
6
|
import { convertType } from '@sankhyalabs/core/dist/dataunit/metadata/DataType';
|
7
7
|
import { g as getSelectedRecordsIDsInfo } from './GetSelectedRecordsIDsInfo.js';
|
8
8
|
|
@@ -566,7 +566,8 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
566
566
|
}
|
567
567
|
this.dataUnit.addInterceptor(this);
|
568
568
|
if ((_b = this.dataUnit.records) === null || _b === void 0 ? void 0 : _b.length) {
|
569
|
-
this.getMetadataByRow(this.dataUnit);
|
569
|
+
const { records } = this.getMetadataByRow(this.dataUnit);
|
570
|
+
this.dataUnit.records = records;
|
570
571
|
}
|
571
572
|
this.dataState = this.buildDataState();
|
572
573
|
let resolver;
|
@@ -12,7 +12,7 @@ import './filter-item-type.enum.js';
|
|
12
12
|
import './form-config-fetcher.js';
|
13
13
|
import { T as TaskbarElement, d as defineCustomElement$3 } from './snk-taskbar2.js';
|
14
14
|
import { V as VIEW_MODE } from './constants.js';
|
15
|
-
import { o as openFieldSearch, T as TaskbarProcessor, b as buildFieldSearch } from './
|
15
|
+
import { o as openFieldSearch, T as TaskbarProcessor, b as buildFieldSearch } from './ContinuousInsertUtils.js';
|
16
16
|
import { SelectionMode } from '@sankhyalabs/core/dist/dataunit/DataUnit';
|
17
17
|
import { d as defineCustomElement$u } from './snk-actions-button2.js';
|
18
18
|
import { d as defineCustomElement$t } from './snk-attach2.js';
|
@@ -70,6 +70,8 @@ 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;
|
74
|
+
this.getCustomTitle = undefined;
|
73
75
|
this._hasToCreateFieldSearch = true;
|
74
76
|
this._breadcrumbItems = [];
|
75
77
|
this._guides = undefined;
|
@@ -138,7 +140,7 @@ const SnkGuidesViewer = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
138
140
|
this._container.focus();
|
139
141
|
}
|
140
142
|
exitViewer() {
|
141
|
-
if (this.dataUnit.isDirty()) {
|
143
|
+
if (!this.enableGridInsert && this.dataUnit.isDirty()) {
|
142
144
|
this.dataUnit.cancelEdition({ after: () => this.exit.emit() });
|
143
145
|
}
|
144
146
|
else {
|
@@ -247,10 +249,13 @@ const SnkGuidesViewer = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
247
249
|
const invisibleButtons = this.getInvisibleButtons();
|
248
250
|
this._taskbarProcessor = new TaskbarProcessor({
|
249
251
|
"snkGuideViewer.regular": btnsRegularMode,
|
250
|
-
"snkGuideViewer.finish_edition": ["CANCEL", "SAVE"],
|
252
|
+
"snkGuideViewer.finish_edition": ["CANCEL", "SAVE", this.handleAddGridMode()],
|
251
253
|
});
|
252
254
|
this._taskbarProcessor.process(taskbarId, this.taskbarManager, this.dataState, disabledButtons, invisibleButtons);
|
253
255
|
}
|
256
|
+
handleAddGridMode() {
|
257
|
+
return this.enableGridInsert ? TaskbarElement.GRID_MODE : "";
|
258
|
+
}
|
254
259
|
getInvisibleButtons() {
|
255
260
|
const invisibleButtons = [];
|
256
261
|
if (this.dataState && this.dataState.selectionInfo.mode === SelectionMode.ALL_RECORDS)
|
@@ -403,11 +408,14 @@ const SnkGuidesViewer = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
403
408
|
this._configManager.addFormLegacyConfig(this.formLegacyConfigName);
|
404
409
|
}
|
405
410
|
}
|
411
|
+
setMasterFormConfig(config) {
|
412
|
+
this.masterFormConfig = config;
|
413
|
+
}
|
406
414
|
componentWillLoad() {
|
407
415
|
if (this.resourceID == undefined) {
|
408
416
|
throw new Error("Erro interno: resourceID não informado");
|
409
417
|
}
|
410
|
-
this._configManager = new SnkFormConfigManager(this.configName, this.resourceID,
|
418
|
+
this._configManager = new SnkFormConfigManager(this.configName, this.resourceID, this.setMasterFormConfig.bind(this), this.dataUnit);
|
411
419
|
this.addFormLegacyConfigName();
|
412
420
|
this._configManager.loadConfig();
|
413
421
|
}
|
@@ -435,7 +443,7 @@ const SnkGuidesViewer = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
435
443
|
return this._fieldSearch;
|
436
444
|
}
|
437
445
|
fieldsOptionLoader(argument) {
|
438
|
-
return Promise.resolve(this._configManager.getFieldsList(
|
446
|
+
return Promise.resolve(this._configManager.getFieldsList(argument)
|
439
447
|
.map(field => ({ value: field.name, label: field.label })));
|
440
448
|
}
|
441
449
|
onSelectField(option, actionButton) {
|
@@ -507,6 +515,10 @@ const SnkGuidesViewer = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
507
515
|
}
|
508
516
|
return "";
|
509
517
|
}
|
518
|
+
getTitle() {
|
519
|
+
var _a, _b;
|
520
|
+
return (_b = (_a = this.getCustomTitle) === null || _a === void 0 ? void 0 : _a.call(this)) !== null && _b !== void 0 ? _b : this.getMessage("snkCrud.title");
|
521
|
+
}
|
510
522
|
componentDidLoad() {
|
511
523
|
this.dataUnit.subscribe(this.dataUnitActionHandler.bind(this));
|
512
524
|
}
|
@@ -520,7 +532,7 @@ const SnkGuidesViewer = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
520
532
|
}
|
521
533
|
this.loadTaskbarProcessor();
|
522
534
|
const showGuides = this._guides && (this._guides.length > 1);
|
523
|
-
return (h("section", { class: "snk-guides-viewer", ref: ref => this._container = ref, tabindex: -1 }, h("div", { class: "ez-row snk-guides-viewer__header" }, h("div", { class: "snk-guides-viewer__header-breadcrumb ez-flex--align-items-center ez-flex-item--align-center ez-padding-left--large", key: "header" }, h("ez-button", { onClick: () => this.exitViewer(), title: this.getMessage("snkCrud.goBackTitle"), mode: "icon", iconName: "arrow_back", class: "ez-padding-right--medium", size: "small" }), h("div", { class: "ez-flex ez-flex--column ez-flex-item--auto" }, h("h1", { class: "ez-title ez-title--primary ez-title--xlarge" }, this.
|
535
|
+
return (h("section", { class: "snk-guides-viewer", ref: ref => this._container = ref, tabindex: -1 }, h("div", { class: "ez-row snk-guides-viewer__header" }, h("div", { class: "snk-guides-viewer__header-breadcrumb ez-flex--align-items-center ez-flex-item--align-center ez-padding-left--large", key: "header" }, h("ez-button", { onClick: () => this.exitViewer(), title: this.getMessage("snkCrud.goBackTitle"), mode: "icon", iconName: "arrow_back", class: "ez-padding-right--medium", size: "small" }), h("div", { class: "ez-flex ez-flex--column ez-flex-item--auto" }, h("h1", { class: "ez-title ez-title--primary ez-title--xlarge" }, this.getTitle()), ((_a = this._breadcrumbItems) === null || _a === void 0 ? void 0 : _a.length) > 1 &&
|
524
536
|
h("div", { class: "ez-margin-top--extra-small" }, h("ez-breadcrumb", Object.assign({ items: this._breadcrumbItems, onSelectedItem: (evt) => this.onBreadcrumbClickHandler(evt === null || evt === void 0 ? void 0 : evt.detail) }, { [ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${ElementIDUtils.getInternalIDInfo("breadcrumb")}` }))))), this.presentationMode != PresentationMode.SECONDARY && this.buildTaskBar()), h("div", { class: "snk-guides-viewer__container" }, showGuides ?
|
525
537
|
h("ez-guide-navigator", { ref: (ref) => this._guideNavigator = ref, class: "snk-guides-viewer__guide-navigator", items: this._guides, selectedId: this.selectedGuide ? this.selectedGuide.id : undefined, onEzSelectionChange: evt => this.updateSelectedGuideHandler(evt.detail) })
|
526
538
|
:
|
@@ -558,6 +570,8 @@ const SnkGuidesViewer = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
558
570
|
"resourceID": [1, "resource-i-d"],
|
559
571
|
"detailTaskbarCustomContainerId": [1, "detail-taskbar-custom-container-id"],
|
560
572
|
"formLegacyConfigName": [1, "form-legacy-config-name"],
|
573
|
+
"enableGridInsert": [4, "enable-grid-insert"],
|
574
|
+
"getCustomTitle": [16],
|
561
575
|
"_hasToCreateFieldSearch": [32],
|
562
576
|
"_breadcrumbItems": [32],
|
563
577
|
"_guides": [32],
|
@@ -1002,7 +1016,7 @@ const SnkDetailView = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
1002
1016
|
}
|
1003
1017
|
componentWillLoad() {
|
1004
1018
|
this._configName = `dynaform.${this.entityName}`;
|
1005
|
-
this.formConfigManager = new SnkFormConfigManager(this._configName, this.resourceID, () => this.loadMetadata());
|
1019
|
+
this.formConfigManager = new SnkFormConfigManager(this._configName, this.resourceID, () => this.loadMetadata(), this.dataUnit);
|
1006
1020
|
this.formConfigManager.loadConfig();
|
1007
1021
|
if (this.messagesBuilder == undefined) {
|
1008
1022
|
this.messagesBuilder = new SnkMessageBuilder(this.entityName);
|