@sankhyalabs/sankhyablocks 0.0.0-feat-dev-KB-29514.3 → 0.0.0-feat-dev-KB-68095.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{IExporterProvider-a85bb749.js → IExporterProvider-5e0a1ec8.js} +16 -25
- package/dist/cjs/{SnkFormConfigManager-8011ba78.js → SnkFormConfigManager-a4af1627.js} +65 -13
- package/dist/cjs/snk-detail-view.cjs.entry.js +3 -3
- package/dist/cjs/snk-form-config.cjs.entry.js +3 -3
- package/dist/cjs/snk-form.cjs.entry.js +4 -3
- package/dist/cjs/snk-grid.cjs.entry.js +1 -1
- package/dist/cjs/{snk-guides-viewer-4e652782.js → snk-guides-viewer-2d705fa1.js} +6 -3
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +3 -3
- package/dist/cjs/snk-simple-crud.cjs.entry.js +3 -3
- 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 +5 -2
- package/dist/collection/components/snk-form/snk-form.js +2 -2
- package/dist/collection/components/snk-form-config/SnkFormConfigManager.js +65 -13
- package/dist/collection/components/snk-form-config/snk-form-config.js +3 -3
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +1 -1
- package/dist/collection/lib/utils/CrudUtils.js +16 -25
- package/dist/components/IExporterProvider.js +16 -25
- package/dist/components/SnkFormConfigManager.js +65 -13
- package/dist/components/snk-detail-view2.js +6 -3
- package/dist/components/snk-form-config2.js +3 -3
- package/dist/components/snk-form.js +2 -2
- package/dist/components/snk-simple-crud2.js +1 -1
- package/dist/esm/{IExporterProvider-8ee41d91.js → IExporterProvider-a57aa108.js} +16 -25
- package/dist/esm/{SnkFormConfigManager-bf58e152.js → SnkFormConfigManager-175c8bca.js} +65 -13
- package/dist/esm/snk-detail-view.entry.js +3 -3
- package/dist/esm/snk-form-config.entry.js +3 -3
- package/dist/esm/snk-form.entry.js +4 -3
- package/dist/esm/snk-grid.entry.js +1 -1
- package/dist/esm/{snk-guides-viewer-d4ba12e6.js → snk-guides-viewer-8d3a56a0.js} +6 -3
- package/dist/esm/snk-guides-viewer.entry.js +3 -3
- package/dist/esm/snk-simple-crud.entry.js +3 -3
- package/dist/sankhyablocks/{p-bfdb5671.entry.js → p-21377b29.entry.js} +1 -1
- package/dist/sankhyablocks/{p-46b9762d.entry.js → p-7dd27e81.entry.js} +1 -1
- package/dist/sankhyablocks/p-8974e0fb.entry.js +1 -0
- package/dist/sankhyablocks/p-8b920710.js +1 -0
- package/dist/sankhyablocks/p-95d58d82.entry.js +1 -0
- package/dist/sankhyablocks/p-9c7ef5d1.entry.js +1 -0
- package/dist/sankhyablocks/p-c6468562.js +1 -0
- package/dist/sankhyablocks/p-d52eadff.entry.js +1 -0
- package/dist/sankhyablocks/{p-73cce46c.js → p-fa72057c.js} +1 -1
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +1 -0
- package/dist/types/components/snk-form-config/SnkFormConfigManager.d.ts +6 -2
- package/dist/types/lib/utils/CrudUtils.d.ts +0 -1
- package/package.json +1 -1
- package/dist/sankhyablocks/p-6815ed9f.entry.js +0 -1
- package/dist/sankhyablocks/p-6a33bce0.entry.js +0 -1
- package/dist/sankhyablocks/p-ce73709e.entry.js +0 -1
- package/dist/sankhyablocks/p-d56d1ae9.js +0 -1
- package/dist/sankhyablocks/p-e768b51e.entry.js +0 -1
- package/dist/sankhyablocks/p-ff747e5e.js +0 -1
|
@@ -29,28 +29,6 @@ class CrudUtils {
|
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
static parseCrudResults(entities, onlyFirst) {
|
|
33
|
-
if (!Array.isArray(entities)) {
|
|
34
|
-
entities = [entities];
|
|
35
|
-
}
|
|
36
|
-
const crudFindResults = [];
|
|
37
|
-
for (const entity of entities) {
|
|
38
|
-
let crudFindResult = {
|
|
39
|
-
fields: new Map()
|
|
40
|
-
};
|
|
41
|
-
for (let key in entity) {
|
|
42
|
-
let fieldValue = entity[key];
|
|
43
|
-
if (fieldValue.hasOwnProperty('$')) {
|
|
44
|
-
crudFindResult.fields.set(key, fieldValue.$);
|
|
45
|
-
}
|
|
46
|
-
if (onlyFirst) {
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
crudFindResults.push(crudFindResult);
|
|
51
|
-
}
|
|
52
|
-
return crudFindResults.length > 1 ? crudFindResults : crudFindResults[0];
|
|
53
|
-
}
|
|
54
32
|
static find(entityName, fields, criteria, onlyFirst = true, criteriaExpression, orderBy) {
|
|
55
33
|
const SERVICE_CRUD_FIND = "mge@crud.find";
|
|
56
34
|
let parsedFields = [];
|
|
@@ -98,11 +76,24 @@ class CrudUtils {
|
|
|
98
76
|
DataFetcher.DataFetcher.get().callServiceBroker(SERVICE_CRUD_FIND, JSON.stringify(request)).then((result) => {
|
|
99
77
|
var _a;
|
|
100
78
|
let entities = (_a = result.entidades) === null || _a === void 0 ? void 0 : _a.entidade;
|
|
101
|
-
if (
|
|
79
|
+
if (entities != undefined) {
|
|
80
|
+
let crudFindResult = {
|
|
81
|
+
fields: new Map()
|
|
82
|
+
};
|
|
83
|
+
for (let key in entities) {
|
|
84
|
+
let fieldValue = entities[key];
|
|
85
|
+
if (fieldValue.hasOwnProperty('$')) {
|
|
86
|
+
crudFindResult.fields.set(key, fieldValue.$);
|
|
87
|
+
}
|
|
88
|
+
if (onlyFirst) {
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
resolve(crudFindResult);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
102
95
|
resolve(null);
|
|
103
96
|
}
|
|
104
|
-
const crudFindResults = this.parseCrudResults(entities, onlyFirst);
|
|
105
|
-
resolve(crudFindResults);
|
|
106
97
|
});
|
|
107
98
|
});
|
|
108
99
|
}
|
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
const ConfigStorage = require('./ConfigStorage-7e9cfe06.js');
|
|
4
4
|
const core = require('@sankhyalabs/core');
|
|
5
5
|
const formConfigFetcher = require('./form-config-fetcher-5c6995ec.js');
|
|
6
|
+
const constants = require('./constants-35ddd366.js');
|
|
6
7
|
|
|
7
8
|
class SnkFormConfigManager {
|
|
8
|
-
constructor(configName, resourceID, onConfigChange) {
|
|
9
|
+
constructor(configName, resourceID, onConfigChange, dataUnit) {
|
|
9
10
|
this._resourceID = resourceID;
|
|
10
11
|
this._configName = configName;
|
|
11
12
|
this._onConfigChange = onConfigChange;
|
|
13
|
+
this._dataUnit = dataUnit;
|
|
12
14
|
}
|
|
13
15
|
addFormLegacyConfig(legacyConfigName) {
|
|
14
16
|
if (this._configName) {
|
|
@@ -19,6 +21,7 @@ class SnkFormConfigManager {
|
|
|
19
21
|
return new Promise(resolve => {
|
|
20
22
|
ConfigStorage.ConfigStorage.loadFormConfig(this._configName, this._resourceID)
|
|
21
23
|
.then((config) => {
|
|
24
|
+
config = this.buildFormMetadataUITabs(config);
|
|
22
25
|
this.setConfig(config);
|
|
23
26
|
resolve(config);
|
|
24
27
|
})
|
|
@@ -70,25 +73,36 @@ class SnkFormConfigManager {
|
|
|
70
73
|
}
|
|
71
74
|
return updatingCardConfig;
|
|
72
75
|
}
|
|
73
|
-
|
|
76
|
+
hasConfig(config) {
|
|
77
|
+
var _a;
|
|
78
|
+
const currentConfig = config !== null && config !== void 0 ? config : this._config;
|
|
79
|
+
if (currentConfig && ((_a = currentConfig.fields) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
getFieldsList(descriptionFilter) {
|
|
74
85
|
var _a;
|
|
75
86
|
const fields = (_a = this._config) === null || _a === void 0 ? void 0 : _a.fields;
|
|
76
|
-
|
|
77
|
-
|
|
87
|
+
const hasConfig = this.hasConfig();
|
|
88
|
+
if (hasConfig) {
|
|
89
|
+
return fields.map(({ label, name, readOnly, visible, required, tab }) => {
|
|
90
|
+
var _a;
|
|
78
91
|
if (label == undefined) {
|
|
79
|
-
const currentField =
|
|
80
|
-
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 });
|
|
92
|
+
const currentField = (_a = this._dataUnit) === null || _a === void 0 ? void 0 : _a.getField(name);
|
|
93
|
+
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 });
|
|
81
94
|
}
|
|
82
|
-
return { name, label, readOnly, visible, required };
|
|
95
|
+
return { name, label, readOnly, visible, required, tab };
|
|
83
96
|
})
|
|
84
97
|
.filter(field => this.isFieldVisible(field, descriptionFilter));
|
|
85
98
|
}
|
|
86
|
-
if (
|
|
87
|
-
return
|
|
88
|
-
.filter(field => this.isFieldVisible(field, descriptionFilter))
|
|
89
|
-
.map(({ label, name, readOnly }) => { return { label, name, readOnly }; });
|
|
99
|
+
if (!this._dataUnit) {
|
|
100
|
+
return [];
|
|
90
101
|
}
|
|
91
|
-
|
|
102
|
+
const filteredFields = this._dataUnit.metadata.fields
|
|
103
|
+
.filter(field => this.isFieldVisible(field, descriptionFilter))
|
|
104
|
+
.map(({ label, name, readOnly, visible, required, properties }) => ({ label, name, readOnly, visible, required, tab: properties === null || properties === void 0 ? void 0 : properties.UITabName }));
|
|
105
|
+
return filteredFields;
|
|
92
106
|
}
|
|
93
107
|
isFieldVisible(field, descriptionFilter) {
|
|
94
108
|
if (field.visible === false) {
|
|
@@ -102,7 +116,7 @@ class SnkFormConfigManager {
|
|
|
102
116
|
return normalizedText.includes(normalizedFilter);
|
|
103
117
|
}
|
|
104
118
|
getFormConfig(dataUnit, ignoreReadOnlyFormFields) {
|
|
105
|
-
let fields = this.getFieldsList(
|
|
119
|
+
let fields = this.getFieldsList();
|
|
106
120
|
if (ignoreReadOnlyFormFields) {
|
|
107
121
|
fields = fields.filter(field => {
|
|
108
122
|
if (dataUnit) {
|
|
@@ -155,6 +169,44 @@ class SnkFormConfigManager {
|
|
|
155
169
|
async fetchDefaultConfig() {
|
|
156
170
|
return this.getFormConfigFetcher().fetchDefaultConfig(this._configName, this._resourceID);
|
|
157
171
|
}
|
|
172
|
+
parseObjectList(object) {
|
|
173
|
+
if (!object) {
|
|
174
|
+
return [];
|
|
175
|
+
}
|
|
176
|
+
return Array.isArray(object) ? object : [object];
|
|
177
|
+
}
|
|
178
|
+
buildFormMetadataUITabs(config) {
|
|
179
|
+
var _a;
|
|
180
|
+
const hasConfig = this.hasConfig(config);
|
|
181
|
+
if (!this._dataUnit || hasConfig) {
|
|
182
|
+
return config;
|
|
183
|
+
}
|
|
184
|
+
config = this.getFormConfig(this._dataUnit, false);
|
|
185
|
+
config.tabs = this.parseObjectList(config.tabs);
|
|
186
|
+
config.emptyConfig = false;
|
|
187
|
+
config.defaultConfiguration = true;
|
|
188
|
+
const fields = this._dataUnit.metadata.fields;
|
|
189
|
+
for (const currentField of fields) {
|
|
190
|
+
const field = config.fields.find(field => field.name === currentField.name);
|
|
191
|
+
const uiTabName = (_a = currentField.properties) === null || _a === void 0 ? void 0 : _a.UITabName;
|
|
192
|
+
if (!uiTabName || uiTabName === constants.TAB_NAMES.main) {
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
const haveTab = config.tabs.some((tab) => tab.label === uiTabName);
|
|
196
|
+
if (!haveTab) {
|
|
197
|
+
config.tabs.push({
|
|
198
|
+
label: uiTabName,
|
|
199
|
+
name: uiTabName,
|
|
200
|
+
order: 0,
|
|
201
|
+
visible: true,
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
if (field) {
|
|
205
|
+
field.tab = uiTabName;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return config;
|
|
209
|
+
}
|
|
158
210
|
}
|
|
159
211
|
|
|
160
212
|
exports.SnkFormConfigManager = SnkFormConfigManager;
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const index = require('./index-f9e81701.js');
|
|
6
6
|
const core = require('@sankhyalabs/core');
|
|
7
|
-
const SnkFormConfigManager = require('./SnkFormConfigManager-
|
|
7
|
+
const SnkFormConfigManager = require('./SnkFormConfigManager-a4af1627.js');
|
|
8
8
|
const form = require('@sankhyalabs/ezui/dist/collection/utils/form');
|
|
9
9
|
require('./DataFetcher-cadeef8e.js');
|
|
10
10
|
require('./pesquisa-fetcher-ca89181c.js');
|
|
@@ -17,7 +17,7 @@ require('./filter-item-type.enum-a7ffdaa6.js');
|
|
|
17
17
|
require('./form-config-fetcher-5c6995ec.js');
|
|
18
18
|
const taskbarElements = require('./taskbar-elements-9ad1f9c0.js');
|
|
19
19
|
const constants = require('./constants-35ddd366.js');
|
|
20
|
-
const snkGuidesViewer = require('./snk-guides-viewer-
|
|
20
|
+
const snkGuidesViewer = require('./snk-guides-viewer-2d705fa1.js');
|
|
21
21
|
const SnkMessageBuilder = require('./SnkMessageBuilder-cceebbae.js');
|
|
22
22
|
require('./ConfigStorage-7e9cfe06.js');
|
|
23
23
|
require('./PrintUtils-bcaeb82f.js');
|
|
@@ -291,7 +291,7 @@ const SnkDetailView = class {
|
|
|
291
291
|
}
|
|
292
292
|
componentWillLoad() {
|
|
293
293
|
this._configName = `dynaform.${this.entityName}`;
|
|
294
|
-
this.formConfigManager = new SnkFormConfigManager.SnkFormConfigManager(this._configName, this.resourceID, () => this.loadMetadata());
|
|
294
|
+
this.formConfigManager = new SnkFormConfigManager.SnkFormConfigManager(this._configName, this.resourceID, () => this.loadMetadata(), this.dataUnit);
|
|
295
295
|
this.formConfigManager.loadConfig();
|
|
296
296
|
if (this.messagesBuilder == undefined) {
|
|
297
297
|
this.messagesBuilder = new SnkMessageBuilder.SnkMessageBuilder(this.entityName);
|
|
@@ -540,9 +540,6 @@ const SnkFormConfig = class {
|
|
|
540
540
|
case formConfigFetcher.UserConfigType.DEFAULT:
|
|
541
541
|
config = await this.configManager.fetchDefaultConfig();
|
|
542
542
|
break;
|
|
543
|
-
case formConfigFetcher.UserConfigType.DEFAULT:
|
|
544
|
-
config = await this.configManager.fetchDefaultConfig();
|
|
545
|
-
break;
|
|
546
543
|
}
|
|
547
544
|
if (config != undefined) {
|
|
548
545
|
this._formConfig = config;
|
|
@@ -744,6 +741,9 @@ const SnkFormConfig = class {
|
|
|
744
741
|
if (layoutFormConfig == undefined) {
|
|
745
742
|
layoutFormConfig = [];
|
|
746
743
|
}
|
|
744
|
+
if (this._formConfig.defaultConfiguration) {
|
|
745
|
+
return layoutFormConfig;
|
|
746
|
+
}
|
|
747
747
|
return this._formConfig.tabs.map((tab) => {
|
|
748
748
|
return layoutFormConfig.find(config => { var _a, _b; return ((_a = tab.label) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === ((_b = config.tab) === null || _b === void 0 ? void 0 : _b.toLowerCase()); })
|
|
749
749
|
|| { tab: tab.label, groups: [], visible: tab.visible };
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const index = require('./index-f9e81701.js');
|
|
6
6
|
const core = require('@sankhyalabs/core');
|
|
7
|
-
const SnkFormConfigManager = require('./SnkFormConfigManager-
|
|
7
|
+
const SnkFormConfigManager = require('./SnkFormConfigManager-a4af1627.js');
|
|
8
8
|
const ResourceIDUtils = require('./ResourceIDUtils-5ff86aa7.js');
|
|
9
9
|
require('./ConfigStorage-7e9cfe06.js');
|
|
10
10
|
require('./form-config-fetcher-5c6995ec.js');
|
|
@@ -12,6 +12,7 @@ require('./DataFetcher-cadeef8e.js');
|
|
|
12
12
|
require('./PrintUtils-bcaeb82f.js');
|
|
13
13
|
require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
|
|
14
14
|
require('./filter-item-type.enum-a7ffdaa6.js');
|
|
15
|
+
require('./constants-35ddd366.js');
|
|
15
16
|
|
|
16
17
|
const snkFormCss = ".sc-snk-form-h{--snk-form__header--min-height:94px;display:block}.snk-form__form--hidden.sc-snk-form{display:none}";
|
|
17
18
|
|
|
@@ -104,7 +105,7 @@ const SnkForm = class {
|
|
|
104
105
|
if (this.resourceID == undefined) {
|
|
105
106
|
this.resourceID = await ResourceIDUtils.ResourceIDUtils.getResourceID();
|
|
106
107
|
}
|
|
107
|
-
this._configManager = new SnkFormConfigManager.SnkFormConfigManager(this.configName, this.resourceID);
|
|
108
|
+
this._configManager = new SnkFormConfigManager.SnkFormConfigManager(this.configName, this.resourceID, undefined, this._dataUnit);
|
|
108
109
|
this.addFormLegacyConfig();
|
|
109
110
|
await this._configManager.loadConfig();
|
|
110
111
|
}
|
|
@@ -133,7 +134,7 @@ const SnkForm = class {
|
|
|
133
134
|
if (!this._dataUnit || !this._dataState) {
|
|
134
135
|
return undefined;
|
|
135
136
|
}
|
|
136
|
-
return (index.h("section", null, index.h("div", { class: "ez-row" }, index.h("div", { class: "ez-col ez-col--sd-12" }, index.h("ez-form", { ref: (ref) => this._form = ref, key: "ezForm" + this._snkDataUnit.entityName, "data-element-id": "embedded", dataUnit: this._dataUnit, config: this._configManager.getConfig(this.
|
|
137
|
+
return (index.h("section", null, index.h("div", { class: "ez-row" }, index.h("div", { class: "ez-col ez-col--sd-12" }, index.h("ez-form", { ref: (ref) => this._form = ref, key: "ezForm" + this._snkDataUnit.entityName, "data-element-id": "embedded", dataUnit: this._dataUnit, config: this._configManager.getConfig(this._dataUnit), recordsValidator: this.recordsValidator, class: this._showFormConfig ? 'snk-form__form--hidden' : '' }), this._showFormConfig &&
|
|
137
138
|
index.h("snk-form-config", { messagesBuilder: this.messagesBuilder, dataUnit: this._dataUnit, configManager: this._configManager, onConfigClose: () => this.closeConfig() })))));
|
|
138
139
|
}
|
|
139
140
|
get _element() { return index.getElement(this); }
|
|
@@ -9,7 +9,7 @@ const ConfigStorage = require('./ConfigStorage-7e9cfe06.js');
|
|
|
9
9
|
const index$1 = require('./index-1dfc7a6e.js');
|
|
10
10
|
const fieldSearch = require('./field-search-f56aa7d6.js');
|
|
11
11
|
const index$2 = require('./index-102ba62d.js');
|
|
12
|
-
const IExporterProvider = require('./IExporterProvider-
|
|
12
|
+
const IExporterProvider = require('./IExporterProvider-5e0a1ec8.js');
|
|
13
13
|
const DataUnit = require('@sankhyalabs/core/dist/dataunit/DataUnit');
|
|
14
14
|
require('./DataFetcher-cadeef8e.js');
|
|
15
15
|
require('./pesquisa-fetcher-ca89181c.js');
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const index = require('./index-f9e81701.js');
|
|
4
4
|
const core = require('@sankhyalabs/core');
|
|
5
|
-
const SnkFormConfigManager = require('./SnkFormConfigManager-
|
|
5
|
+
const SnkFormConfigManager = require('./SnkFormConfigManager-a4af1627.js');
|
|
6
6
|
const form = require('@sankhyalabs/ezui/dist/collection/utils/form');
|
|
7
7
|
const fieldSearch = require('./field-search-f56aa7d6.js');
|
|
8
8
|
const taskbarElements = require('./taskbar-elements-9ad1f9c0.js');
|
|
@@ -377,11 +377,14 @@ const SnkGuidesViewer = class {
|
|
|
377
377
|
this._configManager.addFormLegacyConfig(this.formLegacyConfigName);
|
|
378
378
|
}
|
|
379
379
|
}
|
|
380
|
+
setMasterFormConfig(config) {
|
|
381
|
+
this.masterFormConfig = config;
|
|
382
|
+
}
|
|
380
383
|
componentWillLoad() {
|
|
381
384
|
if (this.resourceID == undefined) {
|
|
382
385
|
throw new Error("Erro interno: resourceID não informado");
|
|
383
386
|
}
|
|
384
|
-
this._configManager = new SnkFormConfigManager.SnkFormConfigManager(this.configName, this.resourceID,
|
|
387
|
+
this._configManager = new SnkFormConfigManager.SnkFormConfigManager(this.configName, this.resourceID, this.setMasterFormConfig.bind(this), this.dataUnit);
|
|
385
388
|
this.addFormLegacyConfigName();
|
|
386
389
|
this._configManager.loadConfig();
|
|
387
390
|
}
|
|
@@ -409,7 +412,7 @@ const SnkGuidesViewer = class {
|
|
|
409
412
|
return this._fieldSearch;
|
|
410
413
|
}
|
|
411
414
|
fieldsOptionLoader(argument) {
|
|
412
|
-
return Promise.resolve(this._configManager.getFieldsList(
|
|
415
|
+
return Promise.resolve(this._configManager.getFieldsList(argument)
|
|
413
416
|
.map(field => ({ value: field.name, label: field.label })));
|
|
414
417
|
}
|
|
415
418
|
onSelectField(option, actionButton) {
|
|
@@ -2,22 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const snkGuidesViewer = require('./snk-guides-viewer-
|
|
5
|
+
const snkGuidesViewer = require('./snk-guides-viewer-2d705fa1.js');
|
|
6
6
|
require('./index-f9e81701.js');
|
|
7
7
|
require('@sankhyalabs/core');
|
|
8
|
-
require('./SnkFormConfigManager-
|
|
8
|
+
require('./SnkFormConfigManager-a4af1627.js');
|
|
9
9
|
require('./ConfigStorage-7e9cfe06.js');
|
|
10
10
|
require('./form-config-fetcher-5c6995ec.js');
|
|
11
11
|
require('./DataFetcher-cadeef8e.js');
|
|
12
12
|
require('./PrintUtils-bcaeb82f.js');
|
|
13
13
|
require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
|
|
14
14
|
require('./filter-item-type.enum-a7ffdaa6.js');
|
|
15
|
+
require('./constants-35ddd366.js');
|
|
15
16
|
require('@sankhyalabs/ezui/dist/collection/utils/form');
|
|
16
17
|
require('./field-search-f56aa7d6.js');
|
|
17
18
|
require('./taskbar-elements-9ad1f9c0.js');
|
|
18
19
|
require('./index-1dfc7a6e.js');
|
|
19
20
|
require('./index-102ba62d.js');
|
|
20
|
-
require('./constants-35ddd366.js');
|
|
21
21
|
require('./pesquisa-fetcher-ca89181c.js');
|
|
22
22
|
require('./ISave-e91b70a7.js');
|
|
23
23
|
require('@sankhyalabs/ezui/dist/collection/utils/constants');
|
|
@@ -9,7 +9,7 @@ const constants = require('./constants-35ddd366.js');
|
|
|
9
9
|
const taskbarElements = require('./taskbar-elements-9ad1f9c0.js');
|
|
10
10
|
require('./DataFetcher-cadeef8e.js');
|
|
11
11
|
require('./pesquisa-fetcher-ca89181c.js');
|
|
12
|
-
const IExporterProvider = require('./IExporterProvider-
|
|
12
|
+
const IExporterProvider = require('./IExporterProvider-5e0a1ec8.js');
|
|
13
13
|
const index = require('./index-1dfc7a6e.js');
|
|
14
14
|
require('./ISave-e91b70a7.js');
|
|
15
15
|
require('@sankhyalabs/ezui/dist/collection/utils/constants');
|
|
@@ -19,7 +19,7 @@ require('./filter-item-type.enum-a7ffdaa6.js');
|
|
|
19
19
|
const formConfigFetcher = require('./form-config-fetcher-5c6995ec.js');
|
|
20
20
|
const fieldSearch = require('./field-search-f56aa7d6.js');
|
|
21
21
|
const ConfigStorage = require('./ConfigStorage-7e9cfe06.js');
|
|
22
|
-
const SnkFormConfigManager = require('./SnkFormConfigManager-
|
|
22
|
+
const SnkFormConfigManager = require('./SnkFormConfigManager-a4af1627.js');
|
|
23
23
|
const RecordIDUtils = require('./RecordIDUtils-3735135c.js');
|
|
24
24
|
const index$2 = require('./index-102ba62d.js');
|
|
25
25
|
require('./PrintUtils-bcaeb82f.js');
|
|
@@ -359,7 +359,7 @@ const SnkSimpleCrud = class {
|
|
|
359
359
|
return;
|
|
360
360
|
}
|
|
361
361
|
if (this._formConfigManager == undefined) {
|
|
362
|
-
this._formConfigManager = new SnkFormConfigManager.SnkFormConfigManager(this.configName, this.resolveResourceID());
|
|
362
|
+
this._formConfigManager = new SnkFormConfigManager.SnkFormConfigManager(this.configName, this.resolveResourceID(), undefined, this.dataUnit);
|
|
363
363
|
this._formConfigManager.setConfig(this.formConfig);
|
|
364
364
|
}
|
|
365
365
|
if (this.formConfigIsLoaded() && !forceLoad) {
|
package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js
CHANGED
|
@@ -222,7 +222,7 @@ export class SnkDetailView {
|
|
|
222
222
|
}
|
|
223
223
|
componentWillLoad() {
|
|
224
224
|
this._configName = `dynaform.${this.entityName}`;
|
|
225
|
-
this.formConfigManager = new SnkFormConfigManager(this._configName, this.resourceID, () => this.loadMetadata());
|
|
225
|
+
this.formConfigManager = new SnkFormConfigManager(this._configName, this.resourceID, () => this.loadMetadata(), this.dataUnit);
|
|
226
226
|
this.formConfigManager.loadConfig();
|
|
227
227
|
if (this.messagesBuilder == undefined) {
|
|
228
228
|
this.messagesBuilder = new SnkMessageBuilder(this.entityName);
|
|
@@ -361,11 +361,14 @@ export class SnkGuidesViewer {
|
|
|
361
361
|
this._configManager.addFormLegacyConfig(this.formLegacyConfigName);
|
|
362
362
|
}
|
|
363
363
|
}
|
|
364
|
+
setMasterFormConfig(config) {
|
|
365
|
+
this.masterFormConfig = config;
|
|
366
|
+
}
|
|
364
367
|
componentWillLoad() {
|
|
365
368
|
if (this.resourceID == undefined) {
|
|
366
369
|
throw new Error("Erro interno: resourceID não informado");
|
|
367
370
|
}
|
|
368
|
-
this._configManager = new SnkFormConfigManager(this.configName, this.resourceID,
|
|
371
|
+
this._configManager = new SnkFormConfigManager(this.configName, this.resourceID, this.setMasterFormConfig.bind(this), this.dataUnit);
|
|
369
372
|
this.addFormLegacyConfigName();
|
|
370
373
|
this._configManager.loadConfig();
|
|
371
374
|
}
|
|
@@ -393,7 +396,7 @@ export class SnkGuidesViewer {
|
|
|
393
396
|
return this._fieldSearch;
|
|
394
397
|
}
|
|
395
398
|
fieldsOptionLoader(argument) {
|
|
396
|
-
return Promise.resolve(this._configManager.getFieldsList(
|
|
399
|
+
return Promise.resolve(this._configManager.getFieldsList(argument)
|
|
397
400
|
.map(field => ({ value: field.name, label: field.label })));
|
|
398
401
|
}
|
|
399
402
|
onSelectField(option, actionButton) {
|
|
@@ -87,7 +87,7 @@ export class SnkForm {
|
|
|
87
87
|
if (this.resourceID == undefined) {
|
|
88
88
|
this.resourceID = await ResourceIDUtils.getResourceID();
|
|
89
89
|
}
|
|
90
|
-
this._configManager = new SnkFormConfigManager(this.configName, this.resourceID);
|
|
90
|
+
this._configManager = new SnkFormConfigManager(this.configName, this.resourceID, undefined, this._dataUnit);
|
|
91
91
|
this.addFormLegacyConfig();
|
|
92
92
|
await this._configManager.loadConfig();
|
|
93
93
|
}
|
|
@@ -117,7 +117,7 @@ export class SnkForm {
|
|
|
117
117
|
if (!this._dataUnit || !this._dataState) {
|
|
118
118
|
return undefined;
|
|
119
119
|
}
|
|
120
|
-
return (h("section", null, h("div", { class: "ez-row" }, h("div", { class: "ez-col ez-col--sd-12" }, h("ez-form", { ref: (ref) => this._form = ref, key: "ezForm" + this._snkDataUnit.entityName, "data-element-id": "embedded", dataUnit: this._dataUnit, config: this._configManager.getConfig(this.
|
|
120
|
+
return (h("section", null, h("div", { class: "ez-row" }, h("div", { class: "ez-col ez-col--sd-12" }, h("ez-form", { ref: (ref) => this._form = ref, key: "ezForm" + this._snkDataUnit.entityName, "data-element-id": "embedded", dataUnit: this._dataUnit, config: this._configManager.getConfig(this._dataUnit), recordsValidator: this.recordsValidator, class: this._showFormConfig ? 'snk-form__form--hidden' : '' }), this._showFormConfig &&
|
|
121
121
|
h("snk-form-config", { messagesBuilder: this.messagesBuilder, dataUnit: this._dataUnit, configManager: this._configManager, onConfigClose: () => this.closeConfig() })))));
|
|
122
122
|
}
|
|
123
123
|
static get is() { return "snk-form"; }
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { ConfigStorage } from '../../lib/configs/ConfigStorage';
|
|
2
2
|
import { ObjectUtils, StringUtils } from "@sankhyalabs/core";
|
|
3
3
|
import { FormConfigFetcher } from "../../lib/http/data-fetcher/fetchers/form-config-fetcher";
|
|
4
|
+
import { TAB_NAMES } from "../../lib/utils/constants";
|
|
4
5
|
export class SnkFormConfigManager {
|
|
5
|
-
constructor(configName, resourceID, onConfigChange) {
|
|
6
|
+
constructor(configName, resourceID, onConfigChange, dataUnit) {
|
|
6
7
|
this._resourceID = resourceID;
|
|
7
8
|
this._configName = configName;
|
|
8
9
|
this._onConfigChange = onConfigChange;
|
|
10
|
+
this._dataUnit = dataUnit;
|
|
9
11
|
}
|
|
10
12
|
addFormLegacyConfig(legacyConfigName) {
|
|
11
13
|
if (this._configName) {
|
|
@@ -16,6 +18,7 @@ export class SnkFormConfigManager {
|
|
|
16
18
|
return new Promise(resolve => {
|
|
17
19
|
ConfigStorage.loadFormConfig(this._configName, this._resourceID)
|
|
18
20
|
.then((config) => {
|
|
21
|
+
config = this.buildFormMetadataUITabs(config);
|
|
19
22
|
this.setConfig(config);
|
|
20
23
|
resolve(config);
|
|
21
24
|
})
|
|
@@ -67,25 +70,36 @@ export class SnkFormConfigManager {
|
|
|
67
70
|
}
|
|
68
71
|
return updatingCardConfig;
|
|
69
72
|
}
|
|
70
|
-
|
|
73
|
+
hasConfig(config) {
|
|
74
|
+
var _a;
|
|
75
|
+
const currentConfig = config !== null && config !== void 0 ? config : this._config;
|
|
76
|
+
if (currentConfig && ((_a = currentConfig.fields) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
getFieldsList(descriptionFilter) {
|
|
71
82
|
var _a;
|
|
72
83
|
const fields = (_a = this._config) === null || _a === void 0 ? void 0 : _a.fields;
|
|
73
|
-
|
|
74
|
-
|
|
84
|
+
const hasConfig = this.hasConfig();
|
|
85
|
+
if (hasConfig) {
|
|
86
|
+
return fields.map(({ label, name, readOnly, visible, required, tab }) => {
|
|
87
|
+
var _a;
|
|
75
88
|
if (label == undefined) {
|
|
76
|
-
const currentField =
|
|
77
|
-
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 });
|
|
89
|
+
const currentField = (_a = this._dataUnit) === null || _a === void 0 ? void 0 : _a.getField(name);
|
|
90
|
+
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 });
|
|
78
91
|
}
|
|
79
|
-
return { name, label, readOnly, visible, required };
|
|
92
|
+
return { name, label, readOnly, visible, required, tab };
|
|
80
93
|
})
|
|
81
94
|
.filter(field => this.isFieldVisible(field, descriptionFilter));
|
|
82
95
|
}
|
|
83
|
-
if (
|
|
84
|
-
return
|
|
85
|
-
.filter(field => this.isFieldVisible(field, descriptionFilter))
|
|
86
|
-
.map(({ label, name, readOnly }) => { return { label, name, readOnly }; });
|
|
96
|
+
if (!this._dataUnit) {
|
|
97
|
+
return [];
|
|
87
98
|
}
|
|
88
|
-
|
|
99
|
+
const filteredFields = this._dataUnit.metadata.fields
|
|
100
|
+
.filter(field => this.isFieldVisible(field, descriptionFilter))
|
|
101
|
+
.map(({ label, name, readOnly, visible, required, properties }) => ({ label, name, readOnly, visible, required, tab: properties === null || properties === void 0 ? void 0 : properties.UITabName }));
|
|
102
|
+
return filteredFields;
|
|
89
103
|
}
|
|
90
104
|
isFieldVisible(field, descriptionFilter) {
|
|
91
105
|
if (field.visible === false) {
|
|
@@ -99,7 +113,7 @@ export class SnkFormConfigManager {
|
|
|
99
113
|
return normalizedText.includes(normalizedFilter);
|
|
100
114
|
}
|
|
101
115
|
getFormConfig(dataUnit, ignoreReadOnlyFormFields) {
|
|
102
|
-
let fields = this.getFieldsList(
|
|
116
|
+
let fields = this.getFieldsList();
|
|
103
117
|
if (ignoreReadOnlyFormFields) {
|
|
104
118
|
fields = fields.filter(field => {
|
|
105
119
|
if (dataUnit) {
|
|
@@ -152,4 +166,42 @@ export class SnkFormConfigManager {
|
|
|
152
166
|
async fetchDefaultConfig() {
|
|
153
167
|
return this.getFormConfigFetcher().fetchDefaultConfig(this._configName, this._resourceID);
|
|
154
168
|
}
|
|
169
|
+
parseObjectList(object) {
|
|
170
|
+
if (!object) {
|
|
171
|
+
return [];
|
|
172
|
+
}
|
|
173
|
+
return Array.isArray(object) ? object : [object];
|
|
174
|
+
}
|
|
175
|
+
buildFormMetadataUITabs(config) {
|
|
176
|
+
var _a;
|
|
177
|
+
const hasConfig = this.hasConfig(config);
|
|
178
|
+
if (!this._dataUnit || hasConfig) {
|
|
179
|
+
return config;
|
|
180
|
+
}
|
|
181
|
+
config = this.getFormConfig(this._dataUnit, false);
|
|
182
|
+
config.tabs = this.parseObjectList(config.tabs);
|
|
183
|
+
config.emptyConfig = false;
|
|
184
|
+
config.defaultConfiguration = true;
|
|
185
|
+
const fields = this._dataUnit.metadata.fields;
|
|
186
|
+
for (const currentField of fields) {
|
|
187
|
+
const field = config.fields.find(field => field.name === currentField.name);
|
|
188
|
+
const uiTabName = (_a = currentField.properties) === null || _a === void 0 ? void 0 : _a.UITabName;
|
|
189
|
+
if (!uiTabName || uiTabName === TAB_NAMES.main) {
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
const haveTab = config.tabs.some((tab) => tab.label === uiTabName);
|
|
193
|
+
if (!haveTab) {
|
|
194
|
+
config.tabs.push({
|
|
195
|
+
label: uiTabName,
|
|
196
|
+
name: uiTabName,
|
|
197
|
+
order: 0,
|
|
198
|
+
visible: true,
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
if (field) {
|
|
202
|
+
field.tab = uiTabName;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return config;
|
|
206
|
+
}
|
|
155
207
|
}
|
|
@@ -530,9 +530,6 @@ export class SnkFormConfig {
|
|
|
530
530
|
case UserConfigType.DEFAULT:
|
|
531
531
|
config = await this.configManager.fetchDefaultConfig();
|
|
532
532
|
break;
|
|
533
|
-
case UserConfigType.DEFAULT:
|
|
534
|
-
config = await this.configManager.fetchDefaultConfig();
|
|
535
|
-
break;
|
|
536
533
|
}
|
|
537
534
|
if (config != undefined) {
|
|
538
535
|
this._formConfig = config;
|
|
@@ -734,6 +731,9 @@ export class SnkFormConfig {
|
|
|
734
731
|
if (layoutFormConfig == undefined) {
|
|
735
732
|
layoutFormConfig = [];
|
|
736
733
|
}
|
|
734
|
+
if (this._formConfig.defaultConfiguration) {
|
|
735
|
+
return layoutFormConfig;
|
|
736
|
+
}
|
|
737
737
|
return this._formConfig.tabs.map((tab) => {
|
|
738
738
|
return layoutFormConfig.find(config => { var _a, _b; return ((_a = tab.label) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === ((_b = config.tab) === null || _b === void 0 ? void 0 : _b.toLowerCase()); })
|
|
739
739
|
|| { tab: tab.label, groups: [], visible: tab.visible };
|
|
@@ -279,7 +279,7 @@ export class SnkSimpleCrud {
|
|
|
279
279
|
return;
|
|
280
280
|
}
|
|
281
281
|
if (this._formConfigManager == undefined) {
|
|
282
|
-
this._formConfigManager = new SnkFormConfigManager(this.configName, this.resolveResourceID());
|
|
282
|
+
this._formConfigManager = new SnkFormConfigManager(this.configName, this.resolveResourceID(), undefined, this.dataUnit);
|
|
283
283
|
this._formConfigManager.setConfig(this.formConfig);
|
|
284
284
|
}
|
|
285
285
|
if (this.formConfigIsLoaded() && !forceLoad) {
|
|
@@ -13,28 +13,6 @@ export class CrudUtils {
|
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
static parseCrudResults(entities, onlyFirst) {
|
|
17
|
-
if (!Array.isArray(entities)) {
|
|
18
|
-
entities = [entities];
|
|
19
|
-
}
|
|
20
|
-
const crudFindResults = [];
|
|
21
|
-
for (const entity of entities) {
|
|
22
|
-
let crudFindResult = {
|
|
23
|
-
fields: new Map()
|
|
24
|
-
};
|
|
25
|
-
for (let key in entity) {
|
|
26
|
-
let fieldValue = entity[key];
|
|
27
|
-
if (fieldValue.hasOwnProperty('$')) {
|
|
28
|
-
crudFindResult.fields.set(key, fieldValue.$);
|
|
29
|
-
}
|
|
30
|
-
if (onlyFirst) {
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
crudFindResults.push(crudFindResult);
|
|
35
|
-
}
|
|
36
|
-
return crudFindResults.length > 1 ? crudFindResults : crudFindResults[0];
|
|
37
|
-
}
|
|
38
16
|
static find(entityName, fields, criteria, onlyFirst = true, criteriaExpression, orderBy) {
|
|
39
17
|
const SERVICE_CRUD_FIND = "mge@crud.find";
|
|
40
18
|
let parsedFields = [];
|
|
@@ -83,11 +61,24 @@ export class CrudUtils {
|
|
|
83
61
|
DataFetcher.get().callServiceBroker(SERVICE_CRUD_FIND, JSON.stringify(request)).then((result) => {
|
|
84
62
|
var _a;
|
|
85
63
|
let entities = (_a = result.entidades) === null || _a === void 0 ? void 0 : _a.entidade;
|
|
86
|
-
if (
|
|
64
|
+
if (entities != undefined) {
|
|
65
|
+
let crudFindResult = {
|
|
66
|
+
fields: new Map()
|
|
67
|
+
};
|
|
68
|
+
for (let key in entities) {
|
|
69
|
+
let fieldValue = entities[key];
|
|
70
|
+
if (fieldValue.hasOwnProperty('$')) {
|
|
71
|
+
crudFindResult.fields.set(key, fieldValue.$);
|
|
72
|
+
}
|
|
73
|
+
if (onlyFirst) {
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
resolve(crudFindResult);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
87
80
|
resolve(null);
|
|
88
81
|
}
|
|
89
|
-
const crudFindResults = this.parseCrudResults(entities, onlyFirst);
|
|
90
|
-
resolve(crudFindResults);
|
|
91
82
|
});
|
|
92
83
|
});
|
|
93
84
|
}
|