@sankhyalabs/sankhyablocks 8.11.1 → 8.12.0-rc.1
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/{SnkFormConfigManager-906ee5f7.js → SnkFormConfigManager-467907f6.js} +21 -4
- package/dist/cjs/{SnkMessageBuilder-fbc33123.js → SnkMessageBuilder-7293d0ad.js} +9 -1
- package/dist/cjs/{taskbar-processor-bce3f499.js → field-search-ca27041a.js} +7 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-application.cjs.entry.js +1 -1
- package/dist/cjs/snk-attach.cjs.entry.js +1 -1
- package/dist/cjs/snk-crud.cjs.entry.js +24 -0
- package/dist/cjs/snk-data-exporter.cjs.entry.js +2 -2
- package/dist/cjs/{snk-data-unit-04d76538.js → snk-data-unit-1bc69073.js} +1 -1
- package/dist/cjs/snk-data-unit.cjs.entry.js +2 -2
- package/dist/cjs/snk-detail-view.cjs.entry.js +4 -4
- package/dist/cjs/snk-form-view.cjs.entry.js +14 -0
- package/dist/cjs/snk-form.cjs.entry.js +1 -1
- package/dist/cjs/snk-grid.cjs.entry.js +52 -6
- package/dist/cjs/{snk-guides-viewer-5b82abc4.js → snk-guides-viewer-f94f2113.js} +78 -13
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +3 -3
- package/dist/cjs/snk-simple-crud.cjs.entry.js +133 -6
- package/dist/collection/components/snk-attach/snk-attach.js +1 -1
- package/dist/collection/components/snk-crud/snk-crud.js +25 -1
- package/dist/collection/components/snk-crud/subcomponents/snk-form-view.js +45 -0
- package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +98 -11
- package/dist/collection/components/snk-form/SnkFormConfigManager.js +22 -5
- package/dist/collection/components/snk-grid/snk-grid.js +69 -4
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +136 -6
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +1 -0
- package/dist/collection/components/snk-taskbar/subcomponents/field-search.js +4 -0
- package/dist/collection/lib/message/SnkMessageBuilder.js +2 -0
- package/dist/collection/lib/message/resources/snk-crud.msg.js +1 -0
- package/dist/collection/lib/message/resources/snk-grid.msg.js +3 -1
- package/dist/collection/lib/message/resources/snk-simple-crud.msg.js +4 -0
- package/dist/components/SnkFormConfigManager.js +22 -5
- package/dist/components/SnkMessageBuilder.js +9 -1
- package/dist/components/{SnkMultiSelectionListDataSource.js → field-search.js} +6 -1
- package/dist/components/snk-attach2.js +1 -1
- package/dist/components/snk-crud.js +25 -1
- package/dist/components/snk-detail-view2.js +80 -12
- package/dist/components/snk-form-view2.js +15 -0
- package/dist/components/snk-grid2.js +52 -5
- package/dist/components/snk-simple-crud2.js +135 -6
- package/dist/esm/{SnkFormConfigManager-8aedc650.js → SnkFormConfigManager-587e9030.js} +22 -5
- package/dist/esm/{SnkMessageBuilder-f60c5443.js → SnkMessageBuilder-ca843d1b.js} +9 -1
- package/dist/esm/{taskbar-processor-94402e6e.js → field-search-c6938ee4.js} +7 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-application.entry.js +1 -1
- package/dist/esm/snk-attach.entry.js +1 -1
- package/dist/esm/snk-crud.entry.js +25 -1
- package/dist/esm/snk-data-exporter.entry.js +2 -2
- package/dist/esm/{snk-data-unit-ad5cf70c.js → snk-data-unit-6208ebf0.js} +1 -1
- package/dist/esm/snk-data-unit.entry.js +2 -2
- package/dist/esm/snk-detail-view.entry.js +4 -4
- package/dist/esm/snk-form-view.entry.js +14 -0
- package/dist/esm/snk-form.entry.js +1 -1
- package/dist/esm/snk-grid.entry.js +51 -5
- package/dist/esm/{snk-guides-viewer-f68589c4.js → snk-guides-viewer-86171cf4.js} +77 -12
- package/dist/esm/snk-guides-viewer.entry.js +3 -3
- package/dist/esm/snk-simple-crud.entry.js +133 -6
- package/dist/sankhyablocks/p-03dcc5ff.entry.js +1 -0
- package/dist/sankhyablocks/p-2028633c.js +1 -0
- package/dist/sankhyablocks/{p-c8b1ebf1.entry.js → p-257feef3.entry.js} +2 -2
- package/dist/sankhyablocks/{p-a2bd1825.entry.js → p-2e963486.entry.js} +1 -1
- package/dist/sankhyablocks/{p-cd2a285d.js → p-32f0935f.js} +1 -1
- package/dist/sankhyablocks/{p-dc7412bf.entry.js → p-35fe6e61.entry.js} +1 -1
- package/dist/sankhyablocks/p-3ecd72a4.js +1 -0
- package/dist/sankhyablocks/p-4775a293.entry.js +1 -0
- package/dist/sankhyablocks/{p-787edf13.entry.js → p-50734e76.entry.js} +1 -1
- package/dist/sankhyablocks/p-50e18dee.entry.js +1 -0
- package/dist/sankhyablocks/p-672380c5.js +1 -0
- package/dist/sankhyablocks/{p-5de077f3.entry.js → p-729f5f5b.entry.js} +1 -1
- package/dist/sankhyablocks/p-d2666ae0.entry.js +1 -0
- package/dist/sankhyablocks/p-de56f563.entry.js +1 -0
- package/dist/sankhyablocks/p-f5059aa8.entry.js +1 -0
- package/dist/sankhyablocks/p-ff6064e7.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-crud/snk-crud.d.ts +3 -0
- package/dist/types/components/snk-crud/subcomponents/snk-form-view.d.ts +10 -1
- package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +25 -1
- package/dist/types/components/snk-form/SnkFormConfigManager.d.ts +6 -1
- package/dist/types/components/snk-grid/snk-grid.d.ts +7 -0
- package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +23 -2
- package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +2 -3
- package/dist/types/components/snk-taskbar/subcomponents/field-search.d.ts +2 -0
- package/dist/types/components.d.ts +20 -0
- package/dist/types/lib/message/resources/snk-simple-crud.msg.d.ts +2 -0
- package/package.json +1 -1
- package/dist/sankhyablocks/p-152f0949.entry.js +0 -1
- package/dist/sankhyablocks/p-16eaa54b.entry.js +0 -1
- package/dist/sankhyablocks/p-74545be0.js +0 -1
- package/dist/sankhyablocks/p-86b9846a.entry.js +0 -1
- package/dist/sankhyablocks/p-9be1dfd5.entry.js +0 -1
- package/dist/sankhyablocks/p-aa3b0d19.js +0 -1
- package/dist/sankhyablocks/p-bceed094.js +0 -1
- package/dist/sankhyablocks/p-c2beb95c.js +0 -1
- package/dist/sankhyablocks/p-c555075c.entry.js +0 -1
- package/dist/sankhyablocks/p-cea081b7.entry.js +0 -1
@@ -7,6 +7,7 @@ import { TaskbarElement } from '../../snk-taskbar/elements/taskbar-elements';
|
|
7
7
|
import { VIEW_MODE } from '../../../lib/utils/constants';
|
8
8
|
import { PresentationMode } from '../../../lib';
|
9
9
|
import { SelectionMode } from '@sankhyalabs/core/dist/dataunit/DataUnit';
|
10
|
+
import { buildFieldSearch } from '../../snk-taskbar/subcomponents/field-search';
|
10
11
|
const FORM_NAME_PREFIX = "__FORM:";
|
11
12
|
export class SnkGuidesViewer {
|
12
13
|
constructor() {
|
@@ -25,10 +26,12 @@ export class SnkGuidesViewer {
|
|
25
26
|
this.presentationMode = undefined;
|
26
27
|
this.resourceID = undefined;
|
27
28
|
this.detailTaskbarCustomContainerId = undefined;
|
29
|
+
this._hasToCreateFieldSearch = true;
|
28
30
|
this._breadcrumbItems = [];
|
29
31
|
this._guides = undefined;
|
30
32
|
this._formEditorConfigManager = undefined;
|
31
33
|
this._formEditorDataUnit = undefined;
|
34
|
+
this._fieldToGetFocus = undefined;
|
32
35
|
}
|
33
36
|
observeDataUnit() {
|
34
37
|
this.loadGuides(true);
|
@@ -53,6 +56,23 @@ export class SnkGuidesViewer {
|
|
53
56
|
this._formEditorConfigManager = masterConfig ? this._configManager : this._currentDetail.formConfigManager;
|
54
57
|
this._formEditorDataUnit = masterConfig ? this.dataUnit : this._currentDetail.dataUnit;
|
55
58
|
}
|
59
|
+
/**
|
60
|
+
* Abre o localizador de campos
|
61
|
+
*/
|
62
|
+
async findField() {
|
63
|
+
if (!this._moreOptions) {
|
64
|
+
return;
|
65
|
+
}
|
66
|
+
if (!(await this._moreOptions.isOpened())) {
|
67
|
+
this._moreOptions.showActions();
|
68
|
+
return;
|
69
|
+
}
|
70
|
+
if (this._fieldSearch) {
|
71
|
+
const realElement = this._fieldSearch["$elm$"];
|
72
|
+
realElement.value = null;
|
73
|
+
requestAnimationFrame(() => realElement.setFocus());
|
74
|
+
}
|
75
|
+
}
|
56
76
|
exitViewer() {
|
57
77
|
if (this.dataUnit.isDirty()) {
|
58
78
|
this.dataUnit.cancelEdition({ after: () => this.exit.emit() });
|
@@ -176,25 +196,26 @@ export class SnkGuidesViewer {
|
|
176
196
|
static updateContentCard(formName, cardConfig, propertyChanged, configManager) {
|
177
197
|
return configManager.saveCardState(formName, cardConfig, propertyChanged);
|
178
198
|
}
|
179
|
-
static buildFixedForms(
|
180
|
-
|
199
|
+
static buildFixedForms(params) {
|
200
|
+
var _a;
|
201
|
+
const cardsState = (_a = params.formConfig) === null || _a === void 0 ? void 0 : _a.cardsState;
|
181
202
|
if (cardsState == undefined) {
|
182
203
|
return;
|
183
204
|
}
|
184
205
|
return (h(Fragment, null, Array.from(cardsState.entries())
|
185
|
-
.filter(([formName, cardConfig]) => (cardConfig === null || cardConfig === void 0 ? void 0 : cardConfig.fixed) && formName != selectedForm)
|
206
|
+
.filter(([formName, cardConfig]) => (cardConfig === null || cardConfig === void 0 ? void 0 : cardConfig.fixed) && formName != params.selectedForm)
|
186
207
|
.sort(([, cardConfigA], [, cardConfigB]) => {
|
187
208
|
const indexA = (cardConfigA === null || cardConfigA === void 0 ? void 0 : cardConfigA.fixSequence) || 0;
|
188
209
|
const indexB = (cardConfigB === null || cardConfigB === void 0 ? void 0 : cardConfigB.fixSequence) || 0;
|
189
210
|
return indexA - indexB;
|
190
211
|
})
|
191
212
|
.map(([formName, cardConfig]) => {
|
192
|
-
var _a;
|
193
|
-
const sheet = formMetadata.getSheet(formName);
|
213
|
+
var _a, _b;
|
214
|
+
const sheet = params.formMetadata.getSheet(formName);
|
194
215
|
if (sheet == undefined) {
|
195
216
|
return;
|
196
217
|
}
|
197
|
-
return h("snk-form-view", { levelPath: levelPath, label: sheet.label, name: formName, fields: sheet.fields, formMetadata: formMetadata, dataUnit: dataUnit, recordsValidator: recordsValidator, contracted: (cardConfig === null || cardConfig === void 0 ? void 0 : cardConfig.presentation) === "CONTRACTED", fixed: cardConfig === null || cardConfig === void 0 ? void 0 : cardConfig.fixed, summaryFields: (_a = formConfig === null ||
|
218
|
+
return h("snk-form-view", { levelPath: params.levelPath, label: sheet.label, name: formName, fields: sheet.fields, formMetadata: params.formMetadata, dataUnit: params.dataUnit, recordsValidator: params.recordsValidator, contracted: (cardConfig === null || cardConfig === void 0 ? void 0 : cardConfig.presentation) === "CONTRACTED", fixed: cardConfig === null || cardConfig === void 0 ? void 0 : cardConfig.fixed, summaryFields: (_b = (_a = params.formConfig) === null || _a === void 0 ? void 0 : _a.summary) === null || _b === void 0 ? void 0 : _b.get(formName), fieldToFocus: params.fieldToFocus, key: formName, onSnkRequestClearFieldToFocus: _ => { var _a; return (_a = params.onRequestClearFieldToFocus) === null || _a === void 0 ? void 0 : _a.call(params); } });
|
198
219
|
})));
|
199
220
|
}
|
200
221
|
wrapDetail(levels, content) {
|
@@ -243,7 +264,7 @@ export class SnkGuidesViewer {
|
|
243
264
|
const sheet = this._masterFormMetadata.getSheet(cardId);
|
244
265
|
if (sheet) {
|
245
266
|
const cardConfig = (_c = (_b = this.masterFormConfig) === null || _b === void 0 ? void 0 : _b.cardsState) === null || _c === void 0 ? void 0 : _c.get(cardId);
|
246
|
-
content = h("snk-form-view", { ref: ref => this._mainForm = ref, fixed: cardConfig === null || cardConfig === void 0 ? void 0 : cardConfig.fixed, summaryFields: (_e = (_d = this.masterFormConfig) === null || _d === void 0 ? void 0 : _d.summary) === null || _e === void 0 ? void 0 : _e.get(cardId), name: cardId, label: sheet.label, fields: sheet.fields, dataUnit: this.dataUnit, formMetadata: this._masterFormMetadata, recordsValidator: this.recordsValidator, key: guideId }, this.presentationMode == PresentationMode.SECONDARY && this.buildTaskBar());
|
267
|
+
content = h("snk-form-view", { ref: ref => this._mainForm = ref, fixed: cardConfig === null || cardConfig === void 0 ? void 0 : cardConfig.fixed, summaryFields: (_e = (_d = this.masterFormConfig) === null || _d === void 0 ? void 0 : _d.summary) === null || _e === void 0 ? void 0 : _e.get(cardId), name: cardId, label: sheet.label, fields: sheet.fields, dataUnit: this.dataUnit, formMetadata: this._masterFormMetadata, recordsValidator: this.recordsValidator, fieldToFocus: this._fieldToGetFocus, key: guideId, onSnkRequestClearFieldToFocus: _ => this.clearFieldToFocusHandler() }, this.presentationMode == PresentationMode.SECONDARY && this.buildTaskBar());
|
247
268
|
}
|
248
269
|
}
|
249
270
|
return content;
|
@@ -262,6 +283,13 @@ export class SnkGuidesViewer {
|
|
262
283
|
});
|
263
284
|
this.resetGuideBadge(currentItem);
|
264
285
|
}
|
286
|
+
changeGuideHandler(guideName) {
|
287
|
+
var _a;
|
288
|
+
(_a = this._guideNavigator) === null || _a === void 0 ? void 0 : _a.selectGuide(guideName);
|
289
|
+
}
|
290
|
+
clearFieldToFocusHandler() {
|
291
|
+
this._fieldToGetFocus = undefined;
|
292
|
+
}
|
265
293
|
resetGuideBadge(selectedGuide) {
|
266
294
|
var _a;
|
267
295
|
this._guides = [...(_a = this._guides) === null || _a === void 0 ? void 0 : _a.map(guide => {
|
@@ -327,11 +355,41 @@ export class SnkGuidesViewer {
|
|
327
355
|
}
|
328
356
|
this._guideHasChanged = false;
|
329
357
|
}
|
358
|
+
getFieldsSearch(actionButton, item) {
|
359
|
+
if (this._fieldSearch == undefined || this._hasToCreateFieldSearch) {
|
360
|
+
this._hasToCreateFieldSearch = false;
|
361
|
+
this._moreOptions = actionButton;
|
362
|
+
actionButton.addEventListener("ezPopoverOpen", () => this.findField());
|
363
|
+
actionButton.addEventListener("ezDisconnectedActionButtons", () => this._hasToCreateFieldSearch = true);
|
364
|
+
this._fieldSearch = buildFieldSearch(item, ({ argument }) => this.fieldsOptionLoader(argument), (option) => this.onSelectField(option, actionButton));
|
365
|
+
}
|
366
|
+
return this._fieldSearch;
|
367
|
+
}
|
368
|
+
fieldsOptionLoader(argument) {
|
369
|
+
return Promise.resolve(this._configManager.getFieldsList(this.dataUnit, argument)
|
370
|
+
.map(field => ({ value: field.name, label: field.label })));
|
371
|
+
}
|
372
|
+
onSelectField(option, actionButton) {
|
373
|
+
if (option == undefined) {
|
374
|
+
return;
|
375
|
+
}
|
376
|
+
this._fieldToGetFocus = option.value;
|
377
|
+
const fieldGuideName = this.getGuideName(option.value);
|
378
|
+
if (fieldGuideName !== this.selectedGuide.id) {
|
379
|
+
this.changeGuideHandler(fieldGuideName);
|
380
|
+
}
|
381
|
+
actionButton.hideActions();
|
382
|
+
}
|
330
383
|
getActionsList() {
|
384
|
+
const hardList = [{
|
385
|
+
value: "",
|
386
|
+
label: this.getMessage("snkCrud.findColumn"),
|
387
|
+
itemBuilder: (actionButton, item) => this.getFieldsSearch(actionButton, item)
|
388
|
+
}];
|
331
389
|
if (this.taskbarManager != undefined && this.taskbarManager.getMoreOptions != undefined) {
|
332
|
-
return this.taskbarManager.getMoreOptions(this.getTaskBarId(), this.configName, this.dataState, this.actionsList);
|
390
|
+
return hardList.concat(this.taskbarManager.getMoreOptions(this.getTaskBarId(), this.configName, this.dataState, this.actionsList));
|
333
391
|
}
|
334
|
-
return this.actionsList;
|
392
|
+
return hardList.concat(this.actionsList);
|
335
393
|
}
|
336
394
|
buildTaskBar() {
|
337
395
|
var _a;
|
@@ -398,7 +456,15 @@ export class SnkGuidesViewer {
|
|
398
456
|
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 ?
|
399
457
|
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) })
|
400
458
|
:
|
401
|
-
h("div", null), h("div", { class: "snk-guides-viewer__detail-container" }, SnkGuidesViewer.buildFixedForms(
|
459
|
+
h("div", null), h("div", { class: "snk-guides-viewer__detail-container" }, SnkGuidesViewer.buildFixedForms({
|
460
|
+
formConfig: this.masterFormConfig,
|
461
|
+
formMetadata: this._masterFormMetadata,
|
462
|
+
selectedForm: (_b = this.selectedGuide) === null || _b === void 0 ? void 0 : _b.id,
|
463
|
+
dataUnit: this.dataUnit,
|
464
|
+
recordsValidator: this.recordsValidator,
|
465
|
+
fieldToFocus: this._fieldToGetFocus,
|
466
|
+
onRequestClearFieldToFocus: this.clearFieldToFocusHandler.bind(this)
|
467
|
+
}), this.getContent())), h("snk-configurator", { ref: (ref) => this._snkConfigurator = ref, viewMode: this.getConfigViewMode(), onConfigSelected: (evt) => this.changeConfigViewMode(evt.detail), messagesBuilder: this.messagesBuilder, onOpenConfig: (evt) => this.openConfig(evt.detail), resourceID: this.resourceID })));
|
402
468
|
}
|
403
469
|
static get is() { return "snk-guides-viewer"; }
|
404
470
|
static get encapsulation() { return "scoped"; }
|
@@ -689,10 +755,12 @@ export class SnkGuidesViewer {
|
|
689
755
|
}
|
690
756
|
static get states() {
|
691
757
|
return {
|
758
|
+
"_hasToCreateFieldSearch": {},
|
692
759
|
"_breadcrumbItems": {},
|
693
760
|
"_guides": {},
|
694
761
|
"_formEditorConfigManager": {},
|
695
|
-
"_formEditorDataUnit": {}
|
762
|
+
"_formEditorDataUnit": {},
|
763
|
+
"_fieldToGetFocus": {}
|
696
764
|
};
|
697
765
|
}
|
698
766
|
static get events() {
|
@@ -776,6 +844,25 @@ export class SnkGuidesViewer {
|
|
776
844
|
"text": "detail - Define se a configura\u00E7\u00E3o que est\u00E1 sendo carregada \u00E9\nreferente a um form detail."
|
777
845
|
}]
|
778
846
|
}
|
847
|
+
},
|
848
|
+
"findField": {
|
849
|
+
"complexType": {
|
850
|
+
"signature": "() => Promise<void>",
|
851
|
+
"parameters": [],
|
852
|
+
"references": {
|
853
|
+
"Promise": {
|
854
|
+
"location": "global"
|
855
|
+
},
|
856
|
+
"HTMLEzSearchElement": {
|
857
|
+
"location": "global"
|
858
|
+
}
|
859
|
+
},
|
860
|
+
"return": "Promise<void>"
|
861
|
+
},
|
862
|
+
"docs": {
|
863
|
+
"text": "Abre o localizador de campos",
|
864
|
+
"tags": []
|
865
|
+
}
|
779
866
|
}
|
780
867
|
};
|
781
868
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { ConfigStorage } from "../../lib/configs/ConfigStorage";
|
2
|
-
import { ObjectUtils } from "@sankhyalabs/core";
|
2
|
+
import { ObjectUtils, StringUtils } from "@sankhyalabs/core";
|
3
3
|
import { FormConfigFetcher } from "../../lib/http/data-fetcher/fetchers/form-config-fetcher";
|
4
4
|
export class SnkFormConfigManager {
|
5
5
|
constructor(configName, resourceID, onConfigChange) {
|
@@ -62,19 +62,36 @@ export class SnkFormConfigManager {
|
|
62
62
|
}
|
63
63
|
return updatingCardConfig;
|
64
64
|
}
|
65
|
-
getFieldsList(dataUnit) {
|
65
|
+
getFieldsList(dataUnit, descriptionFilter) {
|
66
66
|
var _a;
|
67
67
|
const fields = (_a = this._config) === null || _a === void 0 ? void 0 : _a.fields;
|
68
68
|
if (fields != undefined && fields.length > 0) {
|
69
|
-
return
|
69
|
+
return fields.map(({ label, name, readOnly }) => {
|
70
|
+
if (label == undefined) {
|
71
|
+
return dataUnit.getField(name);
|
72
|
+
}
|
73
|
+
return { name, label, readOnly };
|
74
|
+
})
|
75
|
+
.filter(field => this.isFieldVisible(field, descriptionFilter));
|
70
76
|
}
|
71
77
|
if (dataUnit != undefined) {
|
72
78
|
return dataUnit.metadata.fields
|
73
|
-
.filter(field => field
|
74
|
-
.map(({ name }) => { return { name }; });
|
79
|
+
.filter(field => this.isFieldVisible(field, descriptionFilter))
|
80
|
+
.map(({ label, name, readOnly }) => { return { label, name, readOnly }; });
|
75
81
|
}
|
76
82
|
return [];
|
77
83
|
}
|
84
|
+
isFieldVisible(field, descriptionFilter) {
|
85
|
+
if (field.visible === false) {
|
86
|
+
return false;
|
87
|
+
}
|
88
|
+
if (descriptionFilter == undefined) {
|
89
|
+
return true;
|
90
|
+
}
|
91
|
+
const normalizedText = StringUtils.replaceAccentuatedCharsLower((field.label || field.name).toLocaleLowerCase());
|
92
|
+
const normalizedFilter = StringUtils.replaceAccentuatedCharsLower(descriptionFilter.toLocaleLowerCase());
|
93
|
+
return normalizedText.includes(normalizedFilter);
|
94
|
+
}
|
78
95
|
getInsertionConfig(dataUnit) {
|
79
96
|
const fields = this.getFieldsList(dataUnit).filter(field => {
|
80
97
|
if (dataUnit) {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { h, Fragment } from '@stencil/core';
|
2
2
|
import { ApplicationContext, DataType, ElementIDUtils } from '@sankhyalabs/core';
|
3
|
-
import { UserInterface } from '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
3
|
+
import { SortMode, UserInterface } from '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
4
4
|
import { TaskbarElement } from '../snk-taskbar/elements/taskbar-elements';
|
5
5
|
import { ConfigStorage } from '../../lib/configs/ConfigStorage';
|
6
6
|
import { PresentationMode } from '../../lib/@types';
|
@@ -8,7 +8,7 @@ import TaskbarProcessor from '../snk-taskbar/processor/taskbar-processor';
|
|
8
8
|
import store from "../../lib/store";
|
9
9
|
import SnkMultiSelectionListDataSource from './filtercolumn/SnkMultiSelectionListDataSource';
|
10
10
|
import { SelectionMode } from '@sankhyalabs/core/dist/dataunit/DataUnit';
|
11
|
-
import {
|
11
|
+
import { buildFieldSearch } from '../snk-taskbar/subcomponents/field-search';
|
12
12
|
export class SnkGrid {
|
13
13
|
constructor() {
|
14
14
|
this._topTaskbarProcessor = new TaskbarProcessor({
|
@@ -77,6 +77,22 @@ export class SnkGrid {
|
|
77
77
|
var _a;
|
78
78
|
(_a = this._snkFilterBar) === null || _a === void 0 ? void 0 : _a.reload();
|
79
79
|
}
|
80
|
+
/**
|
81
|
+
* Abre o localizador de colunas
|
82
|
+
*/
|
83
|
+
async findColumn() {
|
84
|
+
if (!this._moreOptions) {
|
85
|
+
return;
|
86
|
+
}
|
87
|
+
if (!(await this._moreOptions.isOpened())) {
|
88
|
+
this._moreOptions.showActions();
|
89
|
+
}
|
90
|
+
if (this._columnSearch) {
|
91
|
+
const realElement = this._columnSearch["$elm$"];
|
92
|
+
realElement.value = null;
|
93
|
+
requestAnimationFrame(() => realElement.setFocus());
|
94
|
+
}
|
95
|
+
}
|
80
96
|
/**
|
81
97
|
* Retorna o elemento da filter-bar da grade.
|
82
98
|
*/
|
@@ -321,12 +337,42 @@ export class SnkGrid {
|
|
321
337
|
getPrimaryButton() {
|
322
338
|
return this.presentationMode === PresentationMode.PRIMARY ? "INSERT" : "";
|
323
339
|
}
|
340
|
+
getColumnSearch(actionButton, item) {
|
341
|
+
if (this._columnSearch != undefined) {
|
342
|
+
return this._columnSearch;
|
343
|
+
}
|
344
|
+
actionButton.addEventListener("ezPopoverOpen", () => {
|
345
|
+
if (this._columnSearch) {
|
346
|
+
const realElement = this._columnSearch["$elm$"];
|
347
|
+
realElement.value = null;
|
348
|
+
}
|
349
|
+
});
|
350
|
+
this._moreOptions = actionButton;
|
351
|
+
this._columnSearch = buildFieldSearch(item, ({ argument }) => new Promise(accept => {
|
352
|
+
this._grid.filterColumns(argument).then((columns) => {
|
353
|
+
accept(columns
|
354
|
+
.filter(column => !column.hidden)
|
355
|
+
.map(column => ({ label: column.label, value: column.name })));
|
356
|
+
});
|
357
|
+
}), (option) => {
|
358
|
+
if (option != undefined) {
|
359
|
+
this._grid.locateColumn(option.value);
|
360
|
+
actionButton.hideActions();
|
361
|
+
}
|
362
|
+
});
|
363
|
+
return this._columnSearch;
|
364
|
+
}
|
324
365
|
getActionsList() {
|
366
|
+
const hardList = [{
|
367
|
+
value: "",
|
368
|
+
label: this.messagesBuilder.getMessage("snkGrid.findColumn", {}),
|
369
|
+
itemBuilder: (actionButton, item) => this.getColumnSearch(actionButton, item)
|
370
|
+
}];
|
325
371
|
if (this.taskbarManager != undefined && this.taskbarManager.getMoreOptions != undefined) {
|
326
372
|
const taskbarID = this.getTopTaskBarId();
|
327
|
-
return this.taskbarManager.getMoreOptions(taskbarID, this.configName, this._dataState, this.actionsList);
|
373
|
+
return hardList.concat(this.taskbarManager.getMoreOptions(taskbarID, this.configName, this._dataState, this.actionsList));
|
328
374
|
}
|
329
|
-
return this.actionsList;
|
375
|
+
return hardList.concat(this.actionsList);
|
330
376
|
}
|
331
377
|
handleFilterConfigUpdated(filterConfig) {
|
332
378
|
if (!filterConfig.length) {
|
@@ -805,6 +851,25 @@ export class SnkGrid {
|
|
805
851
|
"tags": []
|
806
852
|
}
|
807
853
|
},
|
854
|
+
"findColumn": {
|
855
|
+
"complexType": {
|
856
|
+
"signature": "() => Promise<void>",
|
857
|
+
"parameters": [],
|
858
|
+
"references": {
|
859
|
+
"Promise": {
|
860
|
+
"location": "global"
|
861
|
+
},
|
862
|
+
"HTMLEzSearchElement": {
|
863
|
+
"location": "global"
|
864
|
+
}
|
865
|
+
},
|
866
|
+
"return": "Promise<void>"
|
867
|
+
},
|
868
|
+
"docs": {
|
869
|
+
"text": "Abre o localizador de colunas",
|
870
|
+
"tags": []
|
871
|
+
}
|
872
|
+
},
|
808
873
|
"getFilterBar": {
|
809
874
|
"complexType": {
|
810
875
|
"signature": "() => Promise<HTMLSnkFilterBarElement>",
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { ApplicationContext, DataType, ObjectUtils, UserInterface, } from '@sankhyalabs/core';
|
1
|
+
import { ApplicationContext, DataType, FloatingManager, ObjectUtils, UserInterface, JSUtils } from '@sankhyalabs/core';
|
2
2
|
import { h } from '@stencil/core';
|
3
3
|
import { SIMPLE_CRUD_MODE, VIEW_MODE } from '../../lib/utils/constants';
|
4
4
|
import { TaskbarElement } from '../snk-taskbar/elements/taskbar-elements';
|
@@ -6,11 +6,13 @@ import { PresentationMode } from '../../lib';
|
|
6
6
|
import TaskbarProcessor from '../snk-taskbar/processor/taskbar-processor';
|
7
7
|
import InMemoryLoader from '../../lib/dataUnit/InMemoryLoader';
|
8
8
|
import SnkMultiSelectionListDataSource from '../snk-grid/filtercolumn/SnkMultiSelectionListDataSource';
|
9
|
+
import { buildFieldSearch } from '../snk-taskbar/subcomponents/field-search';
|
9
10
|
export class SnkSimpleCrud {
|
10
11
|
constructor() {
|
11
|
-
this.REGULAR_DEFAULT_BTNS = ["INSERT", "REFRESH", "PREVIOUS", "NEXT", "DIVIDER"];
|
12
|
-
this.REGULAR_SELECTED_BTNS = ["INSERT", "REFRESH", "PREVIOUS", "NEXT", "DIVIDER", "CLONE", "REMOVE", "DIVIDER"];
|
12
|
+
this.REGULAR_DEFAULT_BTNS = ["INSERT", "REFRESH", "PREVIOUS", "NEXT", "DIVIDER", "MORE_OPTIONS"];
|
13
|
+
this.REGULAR_SELECTED_BTNS = ["INSERT", "REFRESH", "PREVIOUS", "NEXT", "DIVIDER", "CLONE", "REMOVE", "DIVIDER", "MORE_OPTIONS"];
|
13
14
|
this._multiSelectionListDataSource = new SnkMultiSelectionListDataSource();
|
15
|
+
this._keyDownHandler = (event) => this.keyDownListener(event);
|
14
16
|
this._taskbarProcessor = new TaskbarProcessor({
|
15
17
|
"snkSimpleCrudTaskbar.form_regular": this.resolveInMemoryBtns(this.REGULAR_DEFAULT_BTNS).concat(TaskbarElement.GRID_MODE),
|
16
18
|
"snkSimpleCrudTaskbar.grid_regular": this.resolveInMemoryBtns(this.REGULAR_DEFAULT_BTNS).concat(TaskbarElement.FORM_MODE),
|
@@ -20,11 +22,13 @@ export class SnkSimpleCrud {
|
|
20
22
|
});
|
21
23
|
this._currentViewMode = VIEW_MODE.GRID;
|
22
24
|
this._config = undefined;
|
25
|
+
this._fieldToGetFocus = undefined;
|
23
26
|
this.dataState = undefined;
|
24
27
|
this.dataUnit = undefined;
|
25
28
|
this.mode = SIMPLE_CRUD_MODE.SERVER;
|
26
29
|
this.gridConfig = undefined;
|
27
30
|
this.formConfig = undefined;
|
31
|
+
this._formFields = [];
|
28
32
|
this.multipleSelection = undefined;
|
29
33
|
this.useCancelConfirm = true;
|
30
34
|
this.taskbarManager = undefined;
|
@@ -172,11 +176,135 @@ export class SnkSimpleCrud {
|
|
172
176
|
this.dataUnit.clearSelection();
|
173
177
|
}
|
174
178
|
}
|
179
|
+
getColumnSearch(actionButton, item) {
|
180
|
+
if (this._columnSearch != undefined) {
|
181
|
+
return this._columnSearch;
|
182
|
+
}
|
183
|
+
actionButton.addEventListener("ezPopoverOpen", () => {
|
184
|
+
if (this._columnSearch) {
|
185
|
+
const realElement = this._columnSearch["$elm$"];
|
186
|
+
realElement.value = null;
|
187
|
+
}
|
188
|
+
});
|
189
|
+
this._moreOptions = actionButton;
|
190
|
+
this._columnSearch = buildFieldSearch(item, ({ argument }) => new Promise(accept => {
|
191
|
+
this._grid.filterColumns(argument).then((columns) => {
|
192
|
+
accept(columns
|
193
|
+
.filter(column => !column.hidden)
|
194
|
+
.map(column => ({ label: column.label, value: column.name })));
|
195
|
+
});
|
196
|
+
}), (option) => {
|
197
|
+
if (option != undefined) {
|
198
|
+
this._grid.locateColumn(option.value);
|
199
|
+
actionButton.hideActions();
|
200
|
+
}
|
201
|
+
});
|
202
|
+
return this._columnSearch;
|
203
|
+
}
|
204
|
+
onSelectField(option, actionButton) {
|
205
|
+
if (option == undefined) {
|
206
|
+
return;
|
207
|
+
}
|
208
|
+
this._fieldToGetFocus = option.value;
|
209
|
+
actionButton.hideActions();
|
210
|
+
}
|
211
|
+
getFieldSearch(actionButton, item) {
|
212
|
+
if (this._fieldSearch != undefined) {
|
213
|
+
return this._fieldSearch;
|
214
|
+
}
|
215
|
+
this._moreOptions = actionButton;
|
216
|
+
actionButton.addEventListener("ezPopoverOpen", () => this.findField());
|
217
|
+
this._fieldSearch = buildFieldSearch(item, ({ argument }) => this.fieldsOptionLoader(argument), (option) => this.onSelectField(option, actionButton));
|
218
|
+
return this._fieldSearch;
|
219
|
+
}
|
220
|
+
getFormFields() {
|
221
|
+
var _a, _b;
|
222
|
+
return (_b = (_a = this.formConfig) === null || _a === void 0 ? void 0 : _a.fields) !== null && _b !== void 0 ? _b : this._formFields;
|
223
|
+
}
|
224
|
+
handleFormSetFields(fields) {
|
225
|
+
this._formFields = fields !== null && fields !== void 0 ? fields : [];
|
226
|
+
}
|
227
|
+
fieldsOptionLoader(argument) {
|
228
|
+
const searchTerm = argument === null || argument === void 0 ? void 0 : argument.toLowerCase();
|
229
|
+
const allFields = this.getFormFields().map(field => { var _a; return (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getField(field.name); });
|
230
|
+
const filteredFields = allFields.filter(field => {
|
231
|
+
var _a, _b;
|
232
|
+
return ((_a = field.name) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(searchTerm)) ||
|
233
|
+
((_b = field.label) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes(searchTerm));
|
234
|
+
});
|
235
|
+
const options = filteredFields.map(field => ({ value: field.name, label: field.label }));
|
236
|
+
return Promise.resolve(options);
|
237
|
+
}
|
238
|
+
getActionsList() {
|
239
|
+
var _a, _b;
|
240
|
+
return [{
|
241
|
+
value: "",
|
242
|
+
label: (_b = (_a = this.messagesBuilder) === null || _a === void 0 ? void 0 : _a.getMessage("snkSimpleCrud.findColumn", undefined)) !== null && _b !== void 0 ? _b : "Buscar",
|
243
|
+
itemBuilder: (actionButton, item) => (this._currentViewMode === VIEW_MODE.GRID)
|
244
|
+
? this.getColumnSearch(actionButton, item)
|
245
|
+
: this.getFieldSearch(actionButton, item)
|
246
|
+
}];
|
247
|
+
}
|
248
|
+
keyDownListener(event) {
|
249
|
+
if (!event.ctrlKey || event.key == undefined || event.key.toUpperCase() !== "F") {
|
250
|
+
return;
|
251
|
+
}
|
252
|
+
if (this._element == undefined) {
|
253
|
+
return;
|
254
|
+
}
|
255
|
+
if (JSUtils.isHiddenElement(this._element)) {
|
256
|
+
return;
|
257
|
+
}
|
258
|
+
FloatingManager.closeAll();
|
259
|
+
if (this._currentViewMode === VIEW_MODE.GRID) {
|
260
|
+
this.findColumn();
|
261
|
+
}
|
262
|
+
else {
|
263
|
+
this.findField();
|
264
|
+
}
|
265
|
+
event.preventDefault();
|
266
|
+
}
|
267
|
+
async findField() {
|
268
|
+
if (!this._moreOptions) {
|
269
|
+
return;
|
270
|
+
}
|
271
|
+
if (!(await this._moreOptions.isOpened())) {
|
272
|
+
this._moreOptions.showActions();
|
273
|
+
return;
|
274
|
+
}
|
275
|
+
if (this._fieldSearch) {
|
276
|
+
const realElement = this._fieldSearch["$elm$"];
|
277
|
+
realElement.value = null;
|
278
|
+
requestAnimationFrame(() => realElement.setFocus());
|
279
|
+
}
|
280
|
+
}
|
281
|
+
async findColumn() {
|
282
|
+
if (!this._moreOptions) {
|
283
|
+
return;
|
284
|
+
}
|
285
|
+
if (!(await this._moreOptions.isOpened())) {
|
286
|
+
this._moreOptions.showActions();
|
287
|
+
}
|
288
|
+
if (this._columnSearch) {
|
289
|
+
const realElement = this._columnSearch["$elm$"];
|
290
|
+
realElement.value = null;
|
291
|
+
requestAnimationFrame(() => realElement.setFocus());
|
292
|
+
}
|
293
|
+
}
|
294
|
+
clearFieldToFocusHandler() {
|
295
|
+
this._fieldToGetFocus = undefined;
|
296
|
+
}
|
297
|
+
connectedCallback() {
|
298
|
+
window.addEventListener("keydown", this._keyDownHandler, { capture: true });
|
299
|
+
}
|
300
|
+
disconnectedCallback() {
|
301
|
+
window.removeEventListener("keydown", this._keyDownHandler);
|
302
|
+
}
|
175
303
|
render() {
|
176
304
|
var _a;
|
177
|
-
return (h("snk-data-unit", { class: "simple-crud__container", dataUnit: this.dataUnit, useCancelConfirm: this.useCancelConfirm, onDataStateChange: evt => this.onDataStateChange(evt), onCancelEdition: this.handleCancelEdit.bind(this), onInsertionMode: () => this.goToView(VIEW_MODE.FORM), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail), ignoreSaveMessage: this._currentViewMode === VIEW_MODE.GRID, onMessagesBuilderUpdated: evt => this.messagesBuilder = evt.detail }, h("header", null, h("slot", { name: "snkSimpleCrudHeader" })), h("section", { class: "ez-box ez-box--shadow simple-crud__container-section" }, h("snk-taskbar", { class: "ez-box ez-box--shadow ez-padding--medium ez-margin-bottom--large", dataUnit: this.dataUnit, primaryButton: ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? "SAVE" : "INSERT", "data-element-id": "grid_left", messagesBuilder: this.messagesBuilder, buttons: this._taskbarProcessor.buttons, disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, slot: "leftButtons", presentationMode: PresentationMode.SECONDARY }, h("slot", { name: "TASKBAR_CUSTOM_ELEMENTS" })), h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, h("stack-item", null, h("ez-grid", { dataUnit: this.dataUnit, config: this.gridConfig, "no-header": true, multipleSelection: this.multipleSelection, onEzDoubleClick: () => this.goToView(VIEW_MODE.FORM), columnfilterDataSource: this.dataUnit.name.includes(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME)
|
305
|
+
return (h("snk-data-unit", { class: "simple-crud__container", dataUnit: this.dataUnit, useCancelConfirm: this.useCancelConfirm, onDataStateChange: evt => this.onDataStateChange(evt), onCancelEdition: this.handleCancelEdit.bind(this), onInsertionMode: () => this.goToView(VIEW_MODE.FORM), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail), ignoreSaveMessage: this._currentViewMode === VIEW_MODE.GRID, onMessagesBuilderUpdated: evt => this.messagesBuilder = evt.detail }, h("header", null, h("slot", { name: "snkSimpleCrudHeader" })), h("section", { class: "ez-box ez-box--shadow simple-crud__container-section" }, h("snk-taskbar", { class: "ez-box ez-box--shadow ez-padding--medium ez-margin-bottom--large", dataUnit: this.dataUnit, primaryButton: ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? "SAVE" : "INSERT", "data-element-id": "grid_left", messagesBuilder: this.messagesBuilder, buttons: this._taskbarProcessor.buttons, actionsList: this.getActionsList(), disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, 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", { ref: ref => this._grid = ref, dataUnit: this.dataUnit, config: this.gridConfig, "no-header": true, multipleSelection: this.multipleSelection, onEzDoubleClick: () => this.goToView(VIEW_MODE.FORM), columnfilterDataSource: this.dataUnit.name.includes(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME)
|
178
306
|
? undefined
|
179
|
-
: this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab }, h("div", { slot: "footer" }, h("slot", { name: "snkSimpleCrudFooter" })))), h("stack-item", null, h("ez-form", { dataUnit: this.dataUnit, config: this.formConfig }))))));
|
307
|
+
: this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab }, h("div", { slot: "footer" }, h("slot", { name: "snkSimpleCrudFooter" })))), h("stack-item", null, h("ez-form", { dataUnit: this.dataUnit, config: this.formConfig, fieldToFocus: this._fieldToGetFocus, onEzFormSetFields: (evt) => this.handleFormSetFields(evt.detail), onEzFormRequestClearFieldToFocus: this.clearFieldToFocusHandler.bind(this) }))))));
|
180
308
|
}
|
181
309
|
static get is() { return "snk-simple-crud"; }
|
182
310
|
static get encapsulation() { return "scoped"; }
|
@@ -393,7 +521,9 @@ export class SnkSimpleCrud {
|
|
393
521
|
static get states() {
|
394
522
|
return {
|
395
523
|
"_currentViewMode": {},
|
396
|
-
"_config": {}
|
524
|
+
"_config": {},
|
525
|
+
"_fieldToGetFocus": {},
|
526
|
+
"_formFields": {}
|
397
527
|
};
|
398
528
|
}
|
399
529
|
static get events() {
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import { h } from '@stencil/core';
|
2
|
+
export const buildFieldSearch = (action, optionLoader, onSelectField) => {
|
3
|
+
return h("ez-search", { class: "ez-actions-button--bottom-padding", canShowError: "false", showSelectedValue: "false", showOptionValue: "false", suppressEmptyOption: "true", label: action.label, value: action.value, optionLoader: optionLoader, onEzChange: (evt) => onSelectField(evt.detail), ignoreLimitCharsToSearch: true });
|
4
|
+
};
|
@@ -4,6 +4,7 @@ import snkTaskbarMessages from "./resources/snk-taskbar.msg.js";
|
|
4
4
|
import crudUtilsMessages from "./resources/crud-utils.msg.js";
|
5
5
|
import snkExporterMessages from "./resources/snk-exporter.msg.js";
|
6
6
|
import snkCrudMessages from "./resources/snk-crud.msg.js";
|
7
|
+
import snkSimpleCrudMessages from "./resources/snk-simple-crud.msg.js";
|
7
8
|
import fileViewerMessages from "./resources/file-viewer.msg.js";
|
8
9
|
import snkApplicationMessages from "./resources/snk-application.msg.js";
|
9
10
|
import { snkFormConfigMessages, snkConfigOptionsMessages, snkFieldConfigMessages, snkTabConfigMessages } from "./resources/snk-form.msg.js";
|
@@ -37,6 +38,7 @@ export class SnkMessageBuilder {
|
|
37
38
|
snkExporter: snkExporterMessages,
|
38
39
|
snkDataExporter: snkDataExporterMessages,
|
39
40
|
snkCrud: snkCrudMessages,
|
41
|
+
snkSimpleCrud: snkSimpleCrudMessages,
|
40
42
|
fileViewer: fileViewerMessages,
|
41
43
|
snkFilterParamConfig: snkFilterParamConfigMessages,
|
42
44
|
snkFilterFieldSearch: snkFilterFieldSearchMessages,
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { C as ConfigStorage } from './ConfigStorage.js';
|
2
|
-
import { ObjectUtils } from '@sankhyalabs/core';
|
2
|
+
import { ObjectUtils, StringUtils } from '@sankhyalabs/core';
|
3
3
|
import { F as FormConfigFetcher } from './form-config-fetcher.js';
|
4
4
|
|
5
5
|
class SnkFormConfigManager {
|
@@ -63,19 +63,36 @@ class SnkFormConfigManager {
|
|
63
63
|
}
|
64
64
|
return updatingCardConfig;
|
65
65
|
}
|
66
|
-
getFieldsList(dataUnit) {
|
66
|
+
getFieldsList(dataUnit, descriptionFilter) {
|
67
67
|
var _a;
|
68
68
|
const fields = (_a = this._config) === null || _a === void 0 ? void 0 : _a.fields;
|
69
69
|
if (fields != undefined && fields.length > 0) {
|
70
|
-
return
|
70
|
+
return fields.map(({ label, name, readOnly }) => {
|
71
|
+
if (label == undefined) {
|
72
|
+
return dataUnit.getField(name);
|
73
|
+
}
|
74
|
+
return { name, label, readOnly };
|
75
|
+
})
|
76
|
+
.filter(field => this.isFieldVisible(field, descriptionFilter));
|
71
77
|
}
|
72
78
|
if (dataUnit != undefined) {
|
73
79
|
return dataUnit.metadata.fields
|
74
|
-
.filter(field => field
|
75
|
-
.map(({ name }) => { return { name }; });
|
80
|
+
.filter(field => this.isFieldVisible(field, descriptionFilter))
|
81
|
+
.map(({ label, name, readOnly }) => { return { label, name, readOnly }; });
|
76
82
|
}
|
77
83
|
return [];
|
78
84
|
}
|
85
|
+
isFieldVisible(field, descriptionFilter) {
|
86
|
+
if (field.visible === false) {
|
87
|
+
return false;
|
88
|
+
}
|
89
|
+
if (descriptionFilter == undefined) {
|
90
|
+
return true;
|
91
|
+
}
|
92
|
+
const normalizedText = StringUtils.replaceAccentuatedCharsLower((field.label || field.name).toLocaleLowerCase());
|
93
|
+
const normalizedFilter = StringUtils.replaceAccentuatedCharsLower(descriptionFilter.toLocaleLowerCase());
|
94
|
+
return normalizedText.includes(normalizedFilter);
|
95
|
+
}
|
79
96
|
getInsertionConfig(dataUnit) {
|
80
97
|
const fields = this.getFieldsList(dataUnit).filter(field => {
|
81
98
|
if (dataUnit) {
|