@sankhyalabs/sankhyablocks 8.15.0-dev.66 → 8.15.0-dev.68
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/loader.cjs.js +1 -1
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-attach.cjs.entry.js +15 -20
- package/dist/cjs/snk-crud.cjs.entry.js +50 -0
- package/dist/cjs/snk-detail-view.cjs.entry.js +41 -2
- package/dist/cjs/snk-form-view.cjs.entry.js +31 -0
- package/dist/cjs/snk-form.cjs.entry.js +26 -1
- package/dist/cjs/snk-grid.cjs.entry.js +46 -0
- package/dist/cjs/{snk-guides-viewer-545dd904.js → snk-guides-viewer-66dd6949.js} +19 -3
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +1 -1
- package/dist/cjs/snk-simple-crud.cjs.entry.js +49 -1
- package/dist/collection/components/snk-attach/snk-attach.js +21 -29
- package/dist/collection/components/snk-crud/interfaces/PropsCustomEditor.js +1 -0
- package/dist/collection/components/snk-crud/interfaces/PropsCustomRender.js +1 -0
- package/dist/collection/components/snk-crud/snk-crud.js +102 -0
- package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +135 -0
- package/dist/collection/components/snk-crud/subcomponents/snk-form-view.js +82 -0
- package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +73 -3
- package/dist/collection/components/snk-form/snk-form.js +52 -1
- package/dist/collection/components/snk-grid/snk-grid.js +104 -0
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +101 -1
- package/dist/components/snk-attach2.js +15 -20
- package/dist/components/snk-crud.js +52 -0
- package/dist/components/snk-detail-view2.js +68 -5
- package/dist/components/snk-form-view2.js +33 -0
- package/dist/components/snk-form.js +27 -1
- package/dist/components/snk-grid2.js +48 -0
- package/dist/components/snk-simple-crud2.js +51 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-attach.entry.js +15 -20
- package/dist/esm/snk-crud.entry.js +50 -0
- package/dist/esm/snk-detail-view.entry.js +41 -2
- package/dist/esm/snk-form-view.entry.js +31 -0
- package/dist/esm/snk-form.entry.js +26 -1
- package/dist/esm/snk-grid.entry.js +46 -0
- package/dist/esm/{snk-guides-viewer-081bcf90.js → snk-guides-viewer-11cf8dc7.js} +19 -3
- package/dist/esm/snk-guides-viewer.entry.js +1 -1
- package/dist/esm/snk-simple-crud.entry.js +49 -1
- package/dist/sankhyablocks/p-188e1432.entry.js +1 -0
- package/dist/sankhyablocks/p-1db45d26.entry.js +1 -0
- package/dist/sankhyablocks/p-2c9ea7b6.entry.js +1 -0
- package/dist/sankhyablocks/p-50e72d6c.js +1 -0
- package/dist/sankhyablocks/p-5201ab24.entry.js +1 -0
- package/dist/sankhyablocks/{p-34935c5a.entry.js → p-8171e586.entry.js} +1 -1
- package/dist/sankhyablocks/p-a6c4b656.entry.js +1 -0
- package/dist/sankhyablocks/p-aa9c4099.entry.js +1 -0
- package/dist/sankhyablocks/{p-af3e1265.entry.js → p-b68918fc.entry.js} +1 -1
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-attach/snk-attach.d.ts +9 -9
- package/dist/types/components/snk-crud/interfaces/PropsCustomEditor.d.ts +4 -0
- package/dist/types/components/snk-crud/interfaces/PropsCustomRender.d.ts +4 -0
- package/dist/types/components/snk-crud/snk-crud.d.ts +14 -0
- package/dist/types/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.d.ts +23 -0
- package/dist/types/components/snk-crud/subcomponents/snk-form-view.d.ts +15 -2
- package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +13 -0
- package/dist/types/components/snk-form/snk-form.d.ts +8 -0
- package/dist/types/components/snk-grid/snk-grid.d.ts +19 -0
- package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +13 -2
- package/dist/types/components.d.ts +76 -0
- package/package.json +1 -1
- package/dist/sankhyablocks/p-1122030d.js +0 -1
- package/dist/sankhyablocks/p-24880828.entry.js +0 -1
- package/dist/sankhyablocks/p-33f695d6.entry.js +0 -1
- package/dist/sankhyablocks/p-39f8ebb3.entry.js +0 -1
- package/dist/sankhyablocks/p-e4e044cf.entry.js +0 -1
- package/dist/sankhyablocks/p-ecc666ef.entry.js +0 -1
- package/dist/sankhyablocks/p-ee1d9c09.entry.js +0 -1
@@ -3,6 +3,7 @@ import { Host, h } from "@stencil/core";
|
|
3
3
|
import { DataBinder } from "@sankhyalabs/ezui/dist/collection/utils/form";
|
4
4
|
export class SnkFormView {
|
5
5
|
constructor() {
|
6
|
+
this._customEditors = new Map();
|
6
7
|
this._fieldProps = new Map();
|
7
8
|
this.levelPath = undefined;
|
8
9
|
this.label = undefined;
|
@@ -17,6 +18,7 @@ export class SnkFormView {
|
|
17
18
|
this.canFix = true;
|
18
19
|
this.recordsValidator = undefined;
|
19
20
|
this.fieldToFocus = undefined;
|
21
|
+
this.customEditors = undefined;
|
20
22
|
this.fieldsProps = undefined;
|
21
23
|
}
|
22
24
|
async showUp() {
|
@@ -24,6 +26,23 @@ export class SnkFormView {
|
|
24
26
|
this._formView.showUp();
|
25
27
|
}
|
26
28
|
}
|
29
|
+
/**
|
30
|
+
* Registra um editor customizado para campos da grade e formulário
|
31
|
+
*/
|
32
|
+
async addCustomEditor(fieldName, customEditor, detailContext) {
|
33
|
+
if (this._formView) {
|
34
|
+
this._formView.addCustomEditor(fieldName, customEditor, detailContext);
|
35
|
+
return;
|
36
|
+
}
|
37
|
+
const newCustomEditors = new Map(this._customEditors);
|
38
|
+
newCustomEditors.set(fieldName, { customEditor, detailContext });
|
39
|
+
this._customEditors = newCustomEditors;
|
40
|
+
}
|
41
|
+
observePropsCustomEditor(newValue) {
|
42
|
+
for (const fieldName in newValue) {
|
43
|
+
this.addCustomEditor(fieldName, newValue[fieldName]);
|
44
|
+
}
|
45
|
+
}
|
27
46
|
/**
|
28
47
|
* Altera/adiciona uma propriedade nos metadados do campo.
|
29
48
|
*/
|
@@ -99,9 +118,11 @@ export class SnkFormView {
|
|
99
118
|
}
|
100
119
|
}
|
101
120
|
componentDidLoad() {
|
121
|
+
this.observePropsCustomEditor(this.customEditors);
|
102
122
|
this.observeFieldsProps(this.fieldsProps);
|
103
123
|
}
|
104
124
|
componentDidRender() {
|
125
|
+
this.setCustomEditors();
|
105
126
|
this.setFieldProps();
|
106
127
|
if (this.fieldToFocus == undefined) {
|
107
128
|
return;
|
@@ -114,6 +135,15 @@ export class SnkFormView {
|
|
114
135
|
this.snkRequestClearFieldToFocus.emit();
|
115
136
|
});
|
116
137
|
}
|
138
|
+
setCustomEditors() {
|
139
|
+
if (!this._formView) {
|
140
|
+
return;
|
141
|
+
}
|
142
|
+
for (const [fieldName, customEditorProps] of this._customEditors) {
|
143
|
+
this._formView.addCustomEditor(fieldName, customEditorProps.customEditor, customEditorProps.detailContext);
|
144
|
+
this._customEditors.delete(fieldName);
|
145
|
+
}
|
146
|
+
}
|
117
147
|
setFieldProps() {
|
118
148
|
if (!this._formView) {
|
119
149
|
return;
|
@@ -395,6 +425,26 @@ export class SnkFormView {
|
|
395
425
|
"attribute": "field-to-focus",
|
396
426
|
"reflect": false
|
397
427
|
},
|
428
|
+
"customEditors": {
|
429
|
+
"type": "unknown",
|
430
|
+
"mutable": false,
|
431
|
+
"complexType": {
|
432
|
+
"original": "PropsCustomEditor",
|
433
|
+
"resolved": "PropsCustomEditor",
|
434
|
+
"references": {
|
435
|
+
"PropsCustomEditor": {
|
436
|
+
"location": "import",
|
437
|
+
"path": "../interfaces/PropsCustomEditor"
|
438
|
+
}
|
439
|
+
}
|
440
|
+
},
|
441
|
+
"required": false,
|
442
|
+
"optional": false,
|
443
|
+
"docs": {
|
444
|
+
"tags": [],
|
445
|
+
"text": "Registra um editor customizado para campos da grade e formul\u00E1rio."
|
446
|
+
}
|
447
|
+
},
|
398
448
|
"fieldsProps": {
|
399
449
|
"type": "unknown",
|
400
450
|
"mutable": false,
|
@@ -490,6 +540,35 @@ export class SnkFormView {
|
|
490
540
|
"tags": []
|
491
541
|
}
|
492
542
|
},
|
543
|
+
"addCustomEditor": {
|
544
|
+
"complexType": {
|
545
|
+
"signature": "(fieldName: string, customEditor: ICustomEditor, detailContext?: string) => Promise<void>",
|
546
|
+
"parameters": [{
|
547
|
+
"tags": [],
|
548
|
+
"text": ""
|
549
|
+
}, {
|
550
|
+
"tags": [],
|
551
|
+
"text": ""
|
552
|
+
}, {
|
553
|
+
"tags": [],
|
554
|
+
"text": ""
|
555
|
+
}],
|
556
|
+
"references": {
|
557
|
+
"Promise": {
|
558
|
+
"location": "global"
|
559
|
+
},
|
560
|
+
"ICustomEditor": {
|
561
|
+
"location": "import",
|
562
|
+
"path": "@sankhyalabs/ezui/dist/types/utils/customEditor/interfaces/ICustomEditor"
|
563
|
+
}
|
564
|
+
},
|
565
|
+
"return": "Promise<void>"
|
566
|
+
},
|
567
|
+
"docs": {
|
568
|
+
"text": "Registra um editor customizado para campos da grade e formul\u00E1rio",
|
569
|
+
"tags": []
|
570
|
+
}
|
571
|
+
},
|
493
572
|
"setFieldProp": {
|
494
573
|
"complexType": {
|
495
574
|
"signature": "(fieldName: string, propName: string, value: any) => Promise<void>",
|
@@ -519,6 +598,9 @@ export class SnkFormView {
|
|
519
598
|
}
|
520
599
|
static get watchers() {
|
521
600
|
return [{
|
601
|
+
"propName": "customEditors",
|
602
|
+
"methodName": "observePropsCustomEditor"
|
603
|
+
}, {
|
522
604
|
"propName": "fieldsProps",
|
523
605
|
"methodName": "observeFieldsProps"
|
524
606
|
}];
|
@@ -33,6 +33,8 @@ export class SnkGuidesViewer {
|
|
33
33
|
this._formEditorConfigManager = undefined;
|
34
34
|
this._formEditorDataUnit = undefined;
|
35
35
|
this._fieldToGetFocus = undefined;
|
36
|
+
this._customEditors = undefined;
|
37
|
+
this._customRenders = undefined;
|
36
38
|
this._fieldsProps = {};
|
37
39
|
}
|
38
40
|
observeDataUnit() {
|
@@ -64,6 +66,19 @@ export class SnkGuidesViewer {
|
|
64
66
|
async findField() {
|
65
67
|
await openFieldSearch(this._moreOptions, this._fieldSearch);
|
66
68
|
}
|
69
|
+
/**
|
70
|
+
* Registra um editor customizado para campos da grade e formulário
|
71
|
+
*/
|
72
|
+
async addCustomEditor(fieldName, customEditor) {
|
73
|
+
this._customEditors = Object.assign(Object.assign({}, this._customEditors), { [fieldName]: customEditor });
|
74
|
+
}
|
75
|
+
/**
|
76
|
+
* Registra um render customizado para colunas da grid.
|
77
|
+
*/
|
78
|
+
async addGridCustomRender(fieldName, customRender) {
|
79
|
+
this._customRenders = Object.assign(Object.assign({}, this._customRenders), { [fieldName]: customRender });
|
80
|
+
}
|
81
|
+
;
|
67
82
|
/**
|
68
83
|
* Altera/adiciona uma propriedade nos metadados do campo.
|
69
84
|
*/
|
@@ -215,7 +230,7 @@ export class SnkGuidesViewer {
|
|
215
230
|
if (sheet == undefined) {
|
216
231
|
return;
|
217
232
|
}
|
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); }, fieldsProps: params.fieldsProps });
|
233
|
+
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); }, customEditors: params.propsCustomEditor, fieldsProps: params.fieldsProps });
|
219
234
|
})));
|
220
235
|
}
|
221
236
|
wrapDetail(levels, content) {
|
@@ -257,14 +272,14 @@ export class SnkGuidesViewer {
|
|
257
272
|
else {
|
258
273
|
detailBranch = this.selectedGuide;
|
259
274
|
}
|
260
|
-
content = this.wrapDetail(levels, h("snk-detail-view", { ref: (ref) => this._currentDetail = ref, dataUnitName: this.getDataUnitName(levels, childEntityName), onSnkDetailGuidesChange: (evt) => this.updateGuide(evt.detail), entityName: childEntityName, selectedForm: formName, branchGuide: detailBranch, guideItemPath: this._breadcrumbItems, key: `detail${detailId}`, canEdit: this.canEdit, onSnkSwitchGuide: evt => this._guideNavigator.selectGuide(evt.detail), resourceID: this.resourceID, taskbarCustomContainerId: this.detailTaskbarCustomContainerId }));
|
275
|
+
content = this.wrapDetail(levels, h("snk-detail-view", { ref: (ref) => this._currentDetail = ref, dataUnitName: this.getDataUnitName(levels, childEntityName), onSnkDetailGuidesChange: (evt) => this.updateGuide(evt.detail), entityName: childEntityName, selectedForm: formName, branchGuide: detailBranch, guideItemPath: this._breadcrumbItems, key: `detail${detailId}`, canEdit: this.canEdit, onSnkSwitchGuide: evt => this._guideNavigator.selectGuide(evt.detail), resourceID: this.resourceID, taskbarCustomContainerId: this.detailTaskbarCustomContainerId, customEditors: this._customEditors, customRenders: this._customRenders }));
|
261
276
|
}
|
262
277
|
else {
|
263
278
|
const cardId = this.selectedGuide.id;
|
264
279
|
const sheet = this._masterFormMetadata.getSheet(cardId);
|
265
280
|
if (sheet) {
|
266
281
|
const cardConfig = (_c = (_b = this.masterFormConfig) === null || _b === void 0 ? void 0 : _b.cardsState) === null || _c === void 0 ? void 0 : _c.get(cardId);
|
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(), fieldsProps: this._fieldsProps }, this.presentationMode == PresentationMode.SECONDARY && this.buildTaskBar());
|
282
|
+
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(), customEditors: this._customEditors, fieldsProps: this._fieldsProps }, this.presentationMode == PresentationMode.SECONDARY && this.buildTaskBar());
|
268
283
|
}
|
269
284
|
}
|
270
285
|
return content;
|
@@ -471,6 +486,7 @@ export class SnkGuidesViewer {
|
|
471
486
|
recordsValidator: this.recordsValidator,
|
472
487
|
fieldToFocus: this._fieldToGetFocus,
|
473
488
|
onRequestClearFieldToFocus: this.clearFieldToFocusHandler.bind(this),
|
489
|
+
propsCustomEditor: this._customEditors,
|
474
490
|
fieldsProps: this._fieldsProps
|
475
491
|
}), 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 })));
|
476
492
|
}
|
@@ -786,6 +802,8 @@ export class SnkGuidesViewer {
|
|
786
802
|
"_formEditorConfigManager": {},
|
787
803
|
"_formEditorDataUnit": {},
|
788
804
|
"_fieldToGetFocus": {},
|
805
|
+
"_customEditors": {},
|
806
|
+
"_customRenders": {},
|
789
807
|
"_fieldsProps": {}
|
790
808
|
};
|
791
809
|
}
|
@@ -887,6 +905,58 @@ export class SnkGuidesViewer {
|
|
887
905
|
"tags": []
|
888
906
|
}
|
889
907
|
},
|
908
|
+
"addCustomEditor": {
|
909
|
+
"complexType": {
|
910
|
+
"signature": "(fieldName: string, customEditor: ICustomEditor) => Promise<void>",
|
911
|
+
"parameters": [{
|
912
|
+
"tags": [],
|
913
|
+
"text": ""
|
914
|
+
}, {
|
915
|
+
"tags": [],
|
916
|
+
"text": ""
|
917
|
+
}],
|
918
|
+
"references": {
|
919
|
+
"Promise": {
|
920
|
+
"location": "global"
|
921
|
+
},
|
922
|
+
"ICustomEditor": {
|
923
|
+
"location": "import",
|
924
|
+
"path": "@sankhyalabs/ezui/dist/types/utils"
|
925
|
+
}
|
926
|
+
},
|
927
|
+
"return": "Promise<void>"
|
928
|
+
},
|
929
|
+
"docs": {
|
930
|
+
"text": "Registra um editor customizado para campos da grade e formul\u00E1rio",
|
931
|
+
"tags": []
|
932
|
+
}
|
933
|
+
},
|
934
|
+
"addGridCustomRender": {
|
935
|
+
"complexType": {
|
936
|
+
"signature": "(fieldName: string, customRender: ICustomRender) => Promise<void>",
|
937
|
+
"parameters": [{
|
938
|
+
"tags": [],
|
939
|
+
"text": ""
|
940
|
+
}, {
|
941
|
+
"tags": [],
|
942
|
+
"text": ""
|
943
|
+
}],
|
944
|
+
"references": {
|
945
|
+
"Promise": {
|
946
|
+
"location": "global"
|
947
|
+
},
|
948
|
+
"ICustomRender": {
|
949
|
+
"location": "import",
|
950
|
+
"path": "@sankhyalabs/ezui/dist/types/utils"
|
951
|
+
}
|
952
|
+
},
|
953
|
+
"return": "Promise<void>"
|
954
|
+
},
|
955
|
+
"docs": {
|
956
|
+
"text": "Registra um render customizado para colunas da grid.",
|
957
|
+
"tags": []
|
958
|
+
}
|
959
|
+
},
|
890
960
|
"setFieldProp": {
|
891
961
|
"complexType": {
|
892
962
|
"signature": "(fieldName: string, propName: string, value: any) => Promise<void>",
|
@@ -4,6 +4,7 @@ import { SnkFormConfigManager } from '../snk-form-config/SnkFormConfigManager';
|
|
4
4
|
import ResourceIDUtils from '../../lib/resourceid/ResourceIDUtils';
|
5
5
|
export class SnkForm {
|
6
6
|
constructor() {
|
7
|
+
this._customEditors = new Map();
|
7
8
|
this._dataUnit = undefined;
|
8
9
|
this._dataState = undefined;
|
9
10
|
this._showFormConfig = false;
|
@@ -26,6 +27,18 @@ export class SnkForm {
|
|
26
27
|
async hideConfig() {
|
27
28
|
this._showFormConfig = false;
|
28
29
|
}
|
30
|
+
/**
|
31
|
+
* Registra um editor customizado para campos da grade e formulário.
|
32
|
+
*/
|
33
|
+
async addCustomEditor(fieldName, customEditor) {
|
34
|
+
if (this._form) {
|
35
|
+
this._form.addCustomEditor(fieldName, customEditor);
|
36
|
+
return;
|
37
|
+
}
|
38
|
+
const newCustomEditors = new Map(this._customEditors);
|
39
|
+
newCustomEditors.set(fieldName, customEditor);
|
40
|
+
this._customEditors = newCustomEditors;
|
41
|
+
}
|
29
42
|
/**
|
30
43
|
* Altera/adiciona uma propriedade nos metadados do campo.
|
31
44
|
*/
|
@@ -39,6 +52,18 @@ export class SnkForm {
|
|
39
52
|
const dataInfo = { dataUnit: this._dataUnit };
|
40
53
|
ElementIDUtils.addIDInfo(this._element, null, dataInfo);
|
41
54
|
}
|
55
|
+
setCustomEditors() {
|
56
|
+
if (!this._form) {
|
57
|
+
return;
|
58
|
+
}
|
59
|
+
for (const [fieldName, customEditor] of this._customEditors) {
|
60
|
+
this._form.addCustomEditor(fieldName, customEditor);
|
61
|
+
this._customEditors.delete(fieldName);
|
62
|
+
}
|
63
|
+
}
|
64
|
+
async componentDidRender() {
|
65
|
+
this.setCustomEditors();
|
66
|
+
}
|
42
67
|
async componentWillLoad() {
|
43
68
|
let parent = this._element.parentElement;
|
44
69
|
while (parent) {
|
@@ -92,7 +117,7 @@ export class SnkForm {
|
|
92
117
|
if (!this._dataUnit || !this._dataState) {
|
93
118
|
return undefined;
|
94
119
|
}
|
95
|
-
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._dataState.insertionMode, this._dataUnit), recordsValidator: this.recordsValidator, class: this._showFormConfig ? 'snk-form__form--hidden' : '' }), this._showFormConfig &&
|
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._dataState.insertionMode, this._dataUnit), recordsValidator: this.recordsValidator, class: this._showFormConfig ? 'snk-form__form--hidden' : '' }), this._showFormConfig &&
|
96
121
|
h("snk-form-config", { messagesBuilder: this.messagesBuilder, dataUnit: this._dataUnit, configManager: this._configManager, onConfigClose: () => this.closeConfig() })))));
|
97
122
|
}
|
98
123
|
static get is() { return "snk-form"; }
|
@@ -299,6 +324,32 @@ export class SnkForm {
|
|
299
324
|
"tags": []
|
300
325
|
}
|
301
326
|
},
|
327
|
+
"addCustomEditor": {
|
328
|
+
"complexType": {
|
329
|
+
"signature": "(fieldName: string, customEditor: ICustomEditor) => Promise<void>",
|
330
|
+
"parameters": [{
|
331
|
+
"tags": [],
|
332
|
+
"text": ""
|
333
|
+
}, {
|
334
|
+
"tags": [],
|
335
|
+
"text": ""
|
336
|
+
}],
|
337
|
+
"references": {
|
338
|
+
"Promise": {
|
339
|
+
"location": "global"
|
340
|
+
},
|
341
|
+
"ICustomEditor": {
|
342
|
+
"location": "import",
|
343
|
+
"path": "@sankhyalabs/ezui/dist/types/utils"
|
344
|
+
}
|
345
|
+
},
|
346
|
+
"return": "Promise<void>"
|
347
|
+
},
|
348
|
+
"docs": {
|
349
|
+
"text": "Registra um editor customizado para campos da grade e formul\u00E1rio.",
|
350
|
+
"tags": []
|
351
|
+
}
|
352
|
+
},
|
302
353
|
"setFieldProp": {
|
303
354
|
"complexType": {
|
304
355
|
"signature": "(fieldName: string, propName: string, value: any) => Promise<void>",
|
@@ -13,6 +13,8 @@ import RmPrecisionCustomValueFormatter from '../../lib/DefaultCustomFormatters/R
|
|
13
13
|
import ServerSideExporterProvider from '../snk-data-exporter/providers/ServerSideExporterProvider';
|
14
14
|
export class SnkGrid {
|
15
15
|
constructor() {
|
16
|
+
this._customEditors = new Map();
|
17
|
+
this._customRenders = new Map();
|
16
18
|
this._topTaskbarProcessor = new TaskbarProcessor({
|
17
19
|
"snkGridTopTaskbar.regular": ["FORM_MODE", "CONFIGURATOR", "INSERT"],
|
18
20
|
"snkGridTopTaskbar.regular.secondary": ["FORM_MODE", "CONFIGURATOR", "INSERT"],
|
@@ -111,6 +113,30 @@ export class SnkGrid {
|
|
111
113
|
async findColumn() {
|
112
114
|
await openFieldSearch(this._moreOptions, this._columnSearch);
|
113
115
|
}
|
116
|
+
/**
|
117
|
+
* Registra um editor customizado para campos da grade e formulário
|
118
|
+
*/
|
119
|
+
async addCustomEditor(fieldName, customEditor, detailContext) {
|
120
|
+
if (this._grid) {
|
121
|
+
this._grid.addCustomEditor(fieldName, customEditor, detailContext);
|
122
|
+
return;
|
123
|
+
}
|
124
|
+
const newCustomEditors = new Map(this._customEditors);
|
125
|
+
newCustomEditors.set(fieldName, { customEditor, detailContext });
|
126
|
+
this._customEditors = newCustomEditors;
|
127
|
+
}
|
128
|
+
/**
|
129
|
+
* Registra um render customizado para colunas da grid.
|
130
|
+
*/
|
131
|
+
async addGridCustomRender(fieldName, customRender, detailContext) {
|
132
|
+
if (this._grid) {
|
133
|
+
this._grid.addGridCustomRender(fieldName, customRender, detailContext);
|
134
|
+
return;
|
135
|
+
}
|
136
|
+
const newCustomRenders = new Map(this._customRenders);
|
137
|
+
newCustomRenders.set(fieldName, { customRender, detailContext });
|
138
|
+
this._customRenders = newCustomRenders;
|
139
|
+
}
|
114
140
|
/**
|
115
141
|
* Registra um formatador de valores para uma coluna da grid.
|
116
142
|
*/
|
@@ -209,6 +235,24 @@ export class SnkGrid {
|
|
209
235
|
this.columnFilterDataSource.setDataUnit(this._dataUnit);
|
210
236
|
}
|
211
237
|
}
|
238
|
+
setCustomRenders() {
|
239
|
+
if (!this._grid) {
|
240
|
+
return;
|
241
|
+
}
|
242
|
+
for (const [fieldName, customRenderProps] of this._customRenders) {
|
243
|
+
this._grid.addGridCustomRender(fieldName, customRenderProps.customRender, customRenderProps.detailContext);
|
244
|
+
this._customRenders.delete(fieldName);
|
245
|
+
}
|
246
|
+
}
|
247
|
+
setCustomEditors() {
|
248
|
+
if (!this._grid) {
|
249
|
+
return;
|
250
|
+
}
|
251
|
+
for (const [fieldName, customEditorProps] of this._customEditors) {
|
252
|
+
this._grid.addCustomEditor(fieldName, customEditorProps.customEditor, customEditorProps.detailContext);
|
253
|
+
this._customEditors.delete(fieldName);
|
254
|
+
}
|
255
|
+
}
|
212
256
|
componentWillLoad() {
|
213
257
|
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
214
258
|
//TODO: substituir pelo metodo nativo closest
|
@@ -246,6 +290,8 @@ export class SnkGrid {
|
|
246
290
|
componentDidRender() {
|
247
291
|
this._rmPrecisionCustomValueFormatter.setGrid(this._grid);
|
248
292
|
this.loadGridCustomFormatters(this._dataUnit.metadata.fields);
|
293
|
+
this.setCustomRenders();
|
294
|
+
this.setCustomEditors();
|
249
295
|
}
|
250
296
|
async handleDataStateChange(evt) {
|
251
297
|
this._dataState = evt.detail;
|
@@ -944,6 +990,64 @@ export class SnkGrid {
|
|
944
990
|
"tags": []
|
945
991
|
}
|
946
992
|
},
|
993
|
+
"addCustomEditor": {
|
994
|
+
"complexType": {
|
995
|
+
"signature": "(fieldName: string, customEditor: ICustomEditor, detailContext?: string) => Promise<void>",
|
996
|
+
"parameters": [{
|
997
|
+
"tags": [],
|
998
|
+
"text": ""
|
999
|
+
}, {
|
1000
|
+
"tags": [],
|
1001
|
+
"text": ""
|
1002
|
+
}, {
|
1003
|
+
"tags": [],
|
1004
|
+
"text": ""
|
1005
|
+
}],
|
1006
|
+
"references": {
|
1007
|
+
"Promise": {
|
1008
|
+
"location": "global"
|
1009
|
+
},
|
1010
|
+
"ICustomEditor": {
|
1011
|
+
"location": "import",
|
1012
|
+
"path": "@sankhyalabs/ezui/dist/types/utils"
|
1013
|
+
}
|
1014
|
+
},
|
1015
|
+
"return": "Promise<void>"
|
1016
|
+
},
|
1017
|
+
"docs": {
|
1018
|
+
"text": "Registra um editor customizado para campos da grade e formul\u00E1rio",
|
1019
|
+
"tags": []
|
1020
|
+
}
|
1021
|
+
},
|
1022
|
+
"addGridCustomRender": {
|
1023
|
+
"complexType": {
|
1024
|
+
"signature": "(fieldName: string, customRender: ICustomRender, detailContext?: string) => Promise<void>",
|
1025
|
+
"parameters": [{
|
1026
|
+
"tags": [],
|
1027
|
+
"text": ""
|
1028
|
+
}, {
|
1029
|
+
"tags": [],
|
1030
|
+
"text": ""
|
1031
|
+
}, {
|
1032
|
+
"tags": [],
|
1033
|
+
"text": ""
|
1034
|
+
}],
|
1035
|
+
"references": {
|
1036
|
+
"Promise": {
|
1037
|
+
"location": "global"
|
1038
|
+
},
|
1039
|
+
"ICustomRender": {
|
1040
|
+
"location": "import",
|
1041
|
+
"path": "@sankhyalabs/ezui/dist/types/utils"
|
1042
|
+
}
|
1043
|
+
},
|
1044
|
+
"return": "Promise<void>"
|
1045
|
+
},
|
1046
|
+
"docs": {
|
1047
|
+
"text": "Registra um render customizado para colunas da grid.",
|
1048
|
+
"tags": []
|
1049
|
+
}
|
1050
|
+
},
|
947
1051
|
"addCustomValueFormatter": {
|
948
1052
|
"complexType": {
|
949
1053
|
"signature": "(columnName: string, customFormatter: ICustomFormatter) => Promise<void>",
|
@@ -19,6 +19,8 @@ export class SnkSimpleCrud {
|
|
19
19
|
this._multiSelectionListDataSource = new SnkMultiSelectionListDataSource();
|
20
20
|
this._keyDownHandler = (event) => this.keyDownListener(event);
|
21
21
|
this._formConfigFetcher = new FormConfigFetcher();
|
22
|
+
this._customEditors = new Map();
|
23
|
+
this._customRenders = new Map();
|
22
24
|
this._taskbarProcessor = new TaskbarProcessor({
|
23
25
|
"snkSimpleCrudTaskbar.form_regular": this.getButtons(false, [TaskbarElement.GRID_MODE]),
|
24
26
|
"snkSimpleCrudTaskbar.grid_regular": this.getButtons(false, [TaskbarElement.DATA_EXPORTER, TaskbarElement.FORM_MODE]),
|
@@ -55,6 +57,31 @@ export class SnkSimpleCrud {
|
|
55
57
|
this.ignoreReadOnlyFormFields = false;
|
56
58
|
this.autoLoad = undefined;
|
57
59
|
}
|
60
|
+
/**
|
61
|
+
* Registra um editor customizado para campos da grade e formulário.
|
62
|
+
*/
|
63
|
+
async addCustomEditor(fieldName, customEditor) {
|
64
|
+
if (this._grid && this._form) {
|
65
|
+
this._grid.addCustomEditor(fieldName, customEditor);
|
66
|
+
this._form.addCustomEditor(fieldName, customEditor);
|
67
|
+
return;
|
68
|
+
}
|
69
|
+
const newCustomEditors = new Map(this._customEditors);
|
70
|
+
newCustomEditors.set(fieldName, customEditor);
|
71
|
+
this._customEditors = newCustomEditors;
|
72
|
+
}
|
73
|
+
/**
|
74
|
+
* Registra um render customizado para colunas da grid.
|
75
|
+
*/
|
76
|
+
async addGridCustomRender(fieldName, customRender) {
|
77
|
+
if (this._grid) {
|
78
|
+
this._grid.addGridCustomRender(fieldName, customRender);
|
79
|
+
return;
|
80
|
+
}
|
81
|
+
const newCustomRenders = new Map(this._customRenders);
|
82
|
+
newCustomRenders.set(fieldName, customRender);
|
83
|
+
this._customRenders = newCustomRenders;
|
84
|
+
}
|
58
85
|
handleResourceIDChanged(newValue, oldValue) {
|
59
86
|
if (StringUtils.isEmpty(newValue)) {
|
60
87
|
return;
|
@@ -283,6 +310,8 @@ export class SnkSimpleCrud {
|
|
283
310
|
this._rmPrecisionCustomValueFormatter.setGrid(this._grid);
|
284
311
|
this.addGridCustomValueFormattters();
|
285
312
|
this.setFieldsProps();
|
313
|
+
this.setCustomRenders();
|
314
|
+
this.setCustomEditors();
|
286
315
|
}
|
287
316
|
componentWillLoad() {
|
288
317
|
this.processMetadata();
|
@@ -293,6 +322,25 @@ export class SnkSimpleCrud {
|
|
293
322
|
componentDidLoad() {
|
294
323
|
CSSVarsUtils.applyVarsGrid(this._element, this._grid);
|
295
324
|
}
|
325
|
+
setCustomRenders() {
|
326
|
+
if (!this._grid) {
|
327
|
+
return;
|
328
|
+
}
|
329
|
+
for (const [fieldName, customRender] of this._customRenders) {
|
330
|
+
this._grid.addGridCustomRender(fieldName, customRender);
|
331
|
+
this._customRenders.delete(fieldName);
|
332
|
+
}
|
333
|
+
}
|
334
|
+
setCustomEditors() {
|
335
|
+
if (!this._grid || !this._form) {
|
336
|
+
return;
|
337
|
+
}
|
338
|
+
for (const [fieldName, customEditor] of this._customEditors) {
|
339
|
+
this._grid.addCustomEditor(fieldName, customEditor);
|
340
|
+
this._form.addCustomEditor(fieldName, customEditor);
|
341
|
+
this._customEditors.delete(fieldName);
|
342
|
+
}
|
343
|
+
}
|
296
344
|
configDatasource() {
|
297
345
|
this._multiSelectionListDataSource.setApplication(this.application);
|
298
346
|
this._multiSelectionListDataSource.setDataUnit(this.dataUnit);
|
@@ -643,7 +691,7 @@ export class SnkSimpleCrud {
|
|
643
691
|
}
|
644
692
|
return (h("snk-data-unit", { ref: ref => this._snkDataUnit = ref, class: "simple-crud__container", dataUnit: this.dataUnit, useCancelConfirm: this.useCancelConfirm, onDataStateChange: evt => this.onDataStateChange(evt), onCancelEdition: this.handleCancelEdit.bind(this), pageSize: this.getPageSize(), onInsertionMode: () => this.goToView(VIEW_MODE.FORM), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail), ignoreSaveMessage: this._currentViewMode === VIEW_MODE.GRID, onMessagesBuilderUpdated: evt => this.messagesBuilder = evt.detail, onDataUnitFieldsHidded: this.updateFormConfig.bind(this) }, h("header", null, h("slot", { name: "snkSimpleCrudHeader" })), h("section", { class: "ez-box ez-box--shadow simple-crud__container-section" }, h("snk-taskbar", { class: "ez-box ez-box--shadow ez-padding--medium", dataUnit: this.dataUnit, primaryButton: ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? "SAVE" : "INSERT", "data-element-id": "grid_left", messagesBuilder: this.messagesBuilder, buttons: this._taskbarProcessor.buttons, actionsList: this.getActionsList(), disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, "data-exporter-store-key": this.getDataExporterStoreKey(), slot: "leftButtons", presentationMode: PresentationMode.SECONDARY }, h("slot", { name: "TASKBAR_CUSTOM_ELEMENTS" })), h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, h("stack-item", null, h("ez-grid", { class: "ez-margin-bottom--large", ref: ref => this._grid = ref, dataUnit: this.dataUnit, config: this.gridConfig, "no-header": true, multipleSelection: this.multipleSelection, onEzDoubleClick: () => this.goToView(VIEW_MODE.FORM), onConfigChange: evt => this.gridConfigChangeHandler(evt), columnfilterDataSource: this.dataUnit.name && this.dataUnit.name.includes(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME)
|
645
693
|
? undefined
|
646
|
-
: this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab }, h("div", { slot: "footer" }, h("slot", { name: "snkSimpleCrudFooter" })))), h("stack-item", null, h("ez-form", { ref: ref => this._form = ref, class: `ez-margin-top--large ${this.handleShowFormConfig() ? "simple-crud__form--hidden" : ""}`, dataUnit: this.dataUnit, config: this.getFormConfig(), fieldToFocus: this._fieldToGetFocus, onEzFormSetFields: (evt) => this.handleFormSetFields(evt.detail), onEzFormRequestClearFieldToFocus: this.clearFieldToFocusHandler.bind(this) }), this.handleShowFormConfig() && h("snk-form-config", { messagesBuilder: this.messagesBuilder, dataUnit: this.dataUnit, configManager: this._formConfigManager, onConfigClose: () => this.closeFormConfig() })), this.messagesBuilder && h("snk-configurator", { ref: (ref) => this._snkConfigurator = ref, viewMode: this._currentViewMode, messagesBuilder: this.messagesBuilder, onConfigSelected: (evt) => this.goToView(evt.detail), onOpenConfig: (evt) => this.openConfig(evt.detail), showActionButtons: this.showConfiguratorButtons, onSave: evt => this.handleConfiguratorEvent(evt, 'SAVE'), onCancel: evt => this.handleConfiguratorEvent(evt, 'CANCEL'), resourceID: this.resolveResourceID(), customContainerId: this._customContainerId })), h("div", { id: `${this._customContainerId}` }, h("slot", { name: "SnkConfigContainerSlot" }))), h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._showPopUpGridConfig, onEzCloseModal: () => this.closeGridConfig() }, h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this.gridConfig, "data-element-id": this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this.resolveResourceID() }))));
|
694
|
+
: this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab }, h("div", { slot: "footer" }, h("slot", { name: "snkSimpleCrudFooter" })))), h("stack-item", null, h("ez-form", { ref: (ref) => this._form = ref, class: `ez-margin-top--large ${this.handleShowFormConfig() ? "simple-crud__form--hidden" : ""}`, dataUnit: this.dataUnit, config: this.getFormConfig(), fieldToFocus: this._fieldToGetFocus, onEzFormSetFields: (evt) => this.handleFormSetFields(evt.detail), onEzFormRequestClearFieldToFocus: this.clearFieldToFocusHandler.bind(this) }), this.handleShowFormConfig() && h("snk-form-config", { messagesBuilder: this.messagesBuilder, dataUnit: this.dataUnit, configManager: this._formConfigManager, onConfigClose: () => this.closeFormConfig() })), this.messagesBuilder && h("snk-configurator", { ref: (ref) => this._snkConfigurator = ref, viewMode: this._currentViewMode, messagesBuilder: this.messagesBuilder, onConfigSelected: (evt) => this.goToView(evt.detail), onOpenConfig: (evt) => this.openConfig(evt.detail), showActionButtons: this.showConfiguratorButtons, onSave: evt => this.handleConfiguratorEvent(evt, 'SAVE'), onCancel: evt => this.handleConfiguratorEvent(evt, 'CANCEL'), resourceID: this.resolveResourceID(), customContainerId: this._customContainerId })), h("div", { id: `${this._customContainerId}` }, h("slot", { name: "SnkConfigContainerSlot" }))), h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._showPopUpGridConfig, onEzCloseModal: () => this.closeGridConfig() }, h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this.gridConfig, "data-element-id": this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this.resolveResourceID() }))));
|
647
695
|
}
|
648
696
|
static get is() { return "snk-simple-crud"; }
|
649
697
|
static get encapsulation() { return "scoped"; }
|
@@ -1159,6 +1207,58 @@ export class SnkSimpleCrud {
|
|
1159
1207
|
}
|
1160
1208
|
static get methods() {
|
1161
1209
|
return {
|
1210
|
+
"addCustomEditor": {
|
1211
|
+
"complexType": {
|
1212
|
+
"signature": "(fieldName: string, customEditor: ICustomEditor) => Promise<void>",
|
1213
|
+
"parameters": [{
|
1214
|
+
"tags": [],
|
1215
|
+
"text": ""
|
1216
|
+
}, {
|
1217
|
+
"tags": [],
|
1218
|
+
"text": ""
|
1219
|
+
}],
|
1220
|
+
"references": {
|
1221
|
+
"Promise": {
|
1222
|
+
"location": "global"
|
1223
|
+
},
|
1224
|
+
"ICustomEditor": {
|
1225
|
+
"location": "import",
|
1226
|
+
"path": "@sankhyalabs/ezui/dist/types/utils"
|
1227
|
+
}
|
1228
|
+
},
|
1229
|
+
"return": "Promise<void>"
|
1230
|
+
},
|
1231
|
+
"docs": {
|
1232
|
+
"text": "Registra um editor customizado para campos da grade e formul\u00E1rio.",
|
1233
|
+
"tags": []
|
1234
|
+
}
|
1235
|
+
},
|
1236
|
+
"addGridCustomRender": {
|
1237
|
+
"complexType": {
|
1238
|
+
"signature": "(fieldName: string, customRender: ICustomRender) => Promise<void>",
|
1239
|
+
"parameters": [{
|
1240
|
+
"tags": [],
|
1241
|
+
"text": ""
|
1242
|
+
}, {
|
1243
|
+
"tags": [],
|
1244
|
+
"text": ""
|
1245
|
+
}],
|
1246
|
+
"references": {
|
1247
|
+
"Promise": {
|
1248
|
+
"location": "global"
|
1249
|
+
},
|
1250
|
+
"ICustomRender": {
|
1251
|
+
"location": "import",
|
1252
|
+
"path": "@sankhyalabs/ezui/dist/types/utils"
|
1253
|
+
}
|
1254
|
+
},
|
1255
|
+
"return": "Promise<void>"
|
1256
|
+
},
|
1257
|
+
"docs": {
|
1258
|
+
"text": "Registra um render customizado para colunas da grid.",
|
1259
|
+
"tags": []
|
1260
|
+
}
|
1261
|
+
},
|
1162
1262
|
"addCustomValueFormatter": {
|
1163
1263
|
"complexType": {
|
1164
1264
|
"signature": "(columnName: string, customFormatter: ICustomFormatter) => Promise<void>",
|