tuain-ng-forms-lib 14.5.10 → 14.5.26
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/esm2020/lib/classes/forms/action.mjs +18 -1
- package/esm2020/lib/classes/forms/field.mjs +1 -1
- package/esm2020/lib/classes/forms/piece-propagate.mjs +3 -2
- package/esm2020/lib/classes/forms/piece.mjs +27 -5
- package/esm2020/lib/classes/forms/table/action.mjs +1 -20
- package/esm2020/lib/classes/forms/table/table.mjs +63 -16
- package/esm2020/lib/components/elements/field.component.mjs +14 -1
- package/esm2020/lib/components/elements/tables/table-record-action.component.mjs +15 -9
- package/esm2020/lib/services/file-manager.service.mjs +2 -1
- package/fesm2015/tuain-ng-forms-lib.mjs +144 -55
- package/fesm2015/tuain-ng-forms-lib.mjs.map +1 -1
- package/fesm2020/tuain-ng-forms-lib.mjs +135 -47
- package/fesm2020/tuain-ng-forms-lib.mjs.map +1 -1
- package/lib/classes/forms/action.d.ts +2 -0
- package/lib/classes/forms/piece.d.ts +6 -2
- package/lib/classes/forms/table/action.d.ts +0 -3
- package/lib/components/elements/tables/table-record-action.component.d.ts +3 -1
- package/lib/services/file-manager.service.d.ts +1 -0
- package/package.json +1 -1
|
@@ -125,23 +125,36 @@ class FieldComponent extends ElementComponent {
|
|
|
125
125
|
this.field = null;
|
|
126
126
|
}
|
|
127
127
|
ngOnInit() {
|
|
128
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
128
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
129
129
|
if (!this.field) {
|
|
130
130
|
return;
|
|
131
131
|
}
|
|
132
132
|
this.formConfig = (_a = this.field) === null || _a === void 0 ? void 0 : _a._formConfig;
|
|
133
133
|
const mapping = Object.entries((_b = this.formConfig) === null || _b === void 0 ? void 0 : _b.fieldPropagateAttributes);
|
|
134
|
+
const customAttributesMapping = (_d = (_c = this.formConfig) === null || _c === void 0 ? void 0 : _c.propagationCustomAttributes.fields) !== null && _d !== void 0 ? _d : [];
|
|
134
135
|
for (let index = 0; index < mapping.length; index++) {
|
|
135
|
-
const fieldAttr = (
|
|
136
|
-
const componentAttr = (
|
|
136
|
+
const fieldAttr = (_e = mapping[index]) === null || _e === void 0 ? void 0 : _e[0];
|
|
137
|
+
const componentAttr = (_h = (_g = (_f = mapping[index]) === null || _f === void 0 ? void 0 : _f[1]) === null || _g === void 0 ? void 0 : _g.toString()) !== null && _h !== void 0 ? _h : '';
|
|
137
138
|
if (componentAttr) {
|
|
138
|
-
const value = (
|
|
139
|
+
const value = (_j = this.field) === null || _j === void 0 ? void 0 : _j[fieldAttr];
|
|
139
140
|
this.defaultProcessAttributeChange(componentAttr, value);
|
|
140
141
|
this.customProcessAttributeChange(componentAttr, value);
|
|
141
142
|
}
|
|
142
143
|
}
|
|
144
|
+
// Atributos personalizados
|
|
145
|
+
for (let index = 0; index < customAttributesMapping.length; index++) {
|
|
146
|
+
const customAttribute = customAttributesMapping[index];
|
|
147
|
+
if (customAttribute) {
|
|
148
|
+
const value = (_k = this.field) === null || _k === void 0 ? void 0 : _k.getCustomAttribute(customAttribute);
|
|
149
|
+
const fullName = `customAttributes.${customAttribute}`;
|
|
150
|
+
if (value) {
|
|
151
|
+
this.defaultProcessAttributeChange(fullName, value);
|
|
152
|
+
this.customProcessAttributeChange(fullName, value);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
143
156
|
// Subscripción a cambios en atributos
|
|
144
|
-
(
|
|
157
|
+
(_l = this.field) === null || _l === void 0 ? void 0 : _l.attributeChange.subscribe(event => {
|
|
145
158
|
const { name: componentAttr, value } = event;
|
|
146
159
|
this.defaultProcessAttributeChange(componentAttr, value);
|
|
147
160
|
this.customProcessAttributeChange(componentAttr, value);
|
|
@@ -308,10 +321,11 @@ const INLINE_ACTION$1 = 'INLINE';
|
|
|
308
321
|
class LibTableRecordActionComponent extends PieceComponent {
|
|
309
322
|
constructor() {
|
|
310
323
|
super(...arguments);
|
|
324
|
+
this.isVisible = true;
|
|
311
325
|
this.actionSelected = new EventEmitter();
|
|
312
326
|
}
|
|
313
327
|
ngOnInit() {
|
|
314
|
-
var _a, _b, _c
|
|
328
|
+
var _a, _b, _c;
|
|
315
329
|
this.formConfig = (_a = this.action) === null || _a === void 0 ? void 0 : _a._formConfig;
|
|
316
330
|
const mapping = (_b = this.formConfig) === null || _b === void 0 ? void 0 : _b.actionPropagateAttributes;
|
|
317
331
|
for (let index = 0; index < mapping.length; index++) {
|
|
@@ -320,21 +334,26 @@ class LibTableRecordActionComponent extends PieceComponent {
|
|
|
320
334
|
this.defaultProcessAttributeChange(attrName, attributeValue);
|
|
321
335
|
this.customProcessAttributeChange(attrName, attributeValue);
|
|
322
336
|
}
|
|
323
|
-
// Subscripción a cambios en atributos
|
|
324
|
-
(_d = this.action) === null || _d === void 0 ? void 0 : _d.attributeChange.subscribe(event => {
|
|
325
|
-
const { name: attrName, value } = event;
|
|
326
|
-
this.defaultProcessAttributeChange(attrName, value);
|
|
327
|
-
this.customProcessAttributeChange(attrName, value);
|
|
328
|
-
});
|
|
329
337
|
this.start();
|
|
330
338
|
}
|
|
331
339
|
start() {
|
|
332
|
-
|
|
333
|
-
|
|
340
|
+
if (this.action && this.action.restrictedOnField && this.recordData) {
|
|
341
|
+
const relatedField = this.recordData[this.action.restrictedOnField];
|
|
342
|
+
if (relatedField) {
|
|
343
|
+
const fieldValue = relatedField;
|
|
344
|
+
const restrictionOper = this.action.restrictedOnOperator;
|
|
345
|
+
const restrictionValue = this.action.restrictedOnValue;
|
|
346
|
+
if ((restrictionOper === '==' && fieldValue !== restrictionValue)
|
|
347
|
+
|| (restrictionOper === '!=' && fieldValue === restrictionValue)) {
|
|
348
|
+
this.isVisible = false;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
334
352
|
}
|
|
335
353
|
onActivate() {
|
|
354
|
+
var _a, _b;
|
|
336
355
|
const tableEvent = {
|
|
337
|
-
actionCode: this.action.actionCode,
|
|
356
|
+
actionCode: (_b = (_a = this.action) === null || _a === void 0 ? void 0 : _a.actionCode) !== null && _b !== void 0 ? _b : '',
|
|
338
357
|
recordId: this.recordId,
|
|
339
358
|
recordData: this.recordData,
|
|
340
359
|
};
|
|
@@ -509,8 +528,8 @@ class FormPiece {
|
|
|
509
528
|
this._formState = '';
|
|
510
529
|
this._absoluteVisible = true;
|
|
511
530
|
this._absoluteDisabled = false;
|
|
512
|
-
this.visibleStates =
|
|
513
|
-
this.enabledStates =
|
|
531
|
+
this.visibleStates = [];
|
|
532
|
+
this.enabledStates = [];
|
|
514
533
|
this._form = null;
|
|
515
534
|
this._visible = true;
|
|
516
535
|
this._disabled = false;
|
|
@@ -543,13 +562,35 @@ class FormPiece {
|
|
|
543
562
|
const visibleStates = (!Array.isArray(newStates) && typeof newStates === 'string')
|
|
544
563
|
? newStates.split(',').map(state => state.trim()).filter(state => state.length > 0)
|
|
545
564
|
: newStates;
|
|
546
|
-
this.visibleStates = (Array.isArray(visibleStates)) ? visibleStates : [];
|
|
565
|
+
this.visibleStates = (Array.isArray(visibleStates)) ? [...(new Set(visibleStates))] : [];
|
|
566
|
+
}
|
|
567
|
+
addVisibleState(state) {
|
|
568
|
+
if (!this.visibleStates.includes(state)) {
|
|
569
|
+
this.visibleStates.push(state);
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
removeVisibleState(state) {
|
|
573
|
+
const existStateIdx = this.visibleStates.findIndex(st => st === state);
|
|
574
|
+
if (existStateIdx >= 0) {
|
|
575
|
+
this.visibleStates.splice(existStateIdx, 1);
|
|
576
|
+
}
|
|
547
577
|
}
|
|
548
578
|
setEnabledStates(newStates) {
|
|
549
579
|
const enabledStates = (!Array.isArray(newStates) && typeof newStates === 'string')
|
|
550
580
|
? newStates.split(',').map(state => state.trim()).filter(state => state.length > 0)
|
|
551
581
|
: newStates;
|
|
552
|
-
this.enabledStates = (Array.isArray(enabledStates)) ? enabledStates : [];
|
|
582
|
+
this.enabledStates = (Array.isArray(enabledStates)) ? [...(new Set(enabledStates))] : [];
|
|
583
|
+
}
|
|
584
|
+
addEnabledState(state) {
|
|
585
|
+
if (!this.enabledStates.includes(state)) {
|
|
586
|
+
this.enabledStates.push(state);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
removeEnabledState(state) {
|
|
590
|
+
const existStateIdx = this.enabledStates.findIndex(st => st === state);
|
|
591
|
+
if (existStateIdx >= 0) {
|
|
592
|
+
this.enabledStates.splice(existStateIdx, 1);
|
|
593
|
+
}
|
|
553
594
|
}
|
|
554
595
|
viewOnState(state) { return (this.visibleStates && state) ? this.visibleStates.includes(state) : false; }
|
|
555
596
|
enabledOnState(state) { return (this.enabledStates && state) ? this.enabledStates.includes(state) : false; }
|
|
@@ -619,7 +660,8 @@ class FormPiecePropagate extends FormPiece {
|
|
|
619
660
|
var _a;
|
|
620
661
|
super.setCustomAttribute(name, value);
|
|
621
662
|
if ((_a = this.propagationCustomAttributes) === null || _a === void 0 ? void 0 : _a.includes(name)) {
|
|
622
|
-
|
|
663
|
+
const fullName = `customAttributes.${name}`;
|
|
664
|
+
this.propagateAttribute(fullName, value);
|
|
623
665
|
}
|
|
624
666
|
}
|
|
625
667
|
setVisibility(visible, forced = null) {
|
|
@@ -680,6 +722,24 @@ class FormAction extends FormElement {
|
|
|
680
722
|
}
|
|
681
723
|
this.customValidation = () => true;
|
|
682
724
|
}
|
|
725
|
+
connectWithParentForm(form, formChangeSubject) {
|
|
726
|
+
var _a;
|
|
727
|
+
super.connectWithParentForm(form, formChangeSubject);
|
|
728
|
+
if (this.restrictedOnField) {
|
|
729
|
+
const relatedField = (_a = this._form.fields) === null || _a === void 0 ? void 0 : _a[this.restrictedOnField];
|
|
730
|
+
if (relatedField) {
|
|
731
|
+
relatedField.editionFinish.subscribe(event => this.updateRestrictedVisibility());
|
|
732
|
+
relatedField.editionPartial.subscribe(event => this.updateRestrictedVisibility());
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
updateRestrictedVisibility() {
|
|
737
|
+
const lastVisible = this._visible;
|
|
738
|
+
const newVisible = this._absoluteVisible && this.viewOnState(this._formState);
|
|
739
|
+
if (lastVisible !== newVisible) {
|
|
740
|
+
this.setVisibility(newVisible);
|
|
741
|
+
}
|
|
742
|
+
}
|
|
683
743
|
viewOnState(state) {
|
|
684
744
|
var _a;
|
|
685
745
|
const actionVisible = (this.visibleStates && state) ? this.visibleStates.includes(state) : false;
|
|
@@ -1243,26 +1303,6 @@ class TableAction extends FormPiece {
|
|
|
1243
1303
|
this.restrictedOnOperator = actionDefinition.operatorRestricted || null;
|
|
1244
1304
|
}
|
|
1245
1305
|
}
|
|
1246
|
-
viewOnState(state) {
|
|
1247
|
-
var _a;
|
|
1248
|
-
const actionVisible = (this.visibleStates && state) ? this.visibleStates.includes(state) : false;
|
|
1249
|
-
if (actionVisible && this._form && this.restrictedOnField) {
|
|
1250
|
-
// Aqui se debe cambiar el campo por la columna del registro!!!!!
|
|
1251
|
-
// const relatedField = this._form.fields?.[this.restrictedOnField];
|
|
1252
|
-
const relatedField = (_a = this.recordData) === null || _a === void 0 ? void 0 : _a[this.restrictedOnField];
|
|
1253
|
-
if (relatedField) {
|
|
1254
|
-
const fieldValue = relatedField.value;
|
|
1255
|
-
if ((this.restrictedOnOperator === '==' && fieldValue !== this.restrictedOnValue)
|
|
1256
|
-
|| (this.restrictedOnOperator === '!=' && fieldValue === this.restrictedOnValue)) {
|
|
1257
|
-
return false;
|
|
1258
|
-
}
|
|
1259
|
-
}
|
|
1260
|
-
}
|
|
1261
|
-
return actionVisible;
|
|
1262
|
-
}
|
|
1263
|
-
setRecodData(recordData) {
|
|
1264
|
-
this.recordData = recordData;
|
|
1265
|
-
}
|
|
1266
1306
|
}
|
|
1267
1307
|
|
|
1268
1308
|
class TableRecordData {
|
|
@@ -1629,23 +1669,71 @@ class RecordTable extends FormElement {
|
|
|
1629
1669
|
}
|
|
1630
1670
|
updateFromServer(tableReceived) {
|
|
1631
1671
|
this.requestedPage = 1;
|
|
1632
|
-
|
|
1633
|
-
this.
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1672
|
+
const { visible = true, totalPages = 1, recordsNumber, currentPage = 1, recordsPerPage, totalRecordsNumber, sortingColumn, sortingDirection, tableRecords, actions, fields, } = tableReceived;
|
|
1673
|
+
this.visible = visible;
|
|
1674
|
+
if (actions) {
|
|
1675
|
+
Object.keys(actions).forEach(actionCode => {
|
|
1676
|
+
var _a, _b, _c, _d;
|
|
1677
|
+
const tblAction = this.getAction(actionCode);
|
|
1678
|
+
const actionReceived = actions[actionCode];
|
|
1679
|
+
if (actionReceived.visible === true || actionReceived.visible === false) {
|
|
1680
|
+
(actionReceived.visible === true) && tblAction.show();
|
|
1681
|
+
(actionReceived.visible === false) && tblAction.hide();
|
|
1682
|
+
}
|
|
1683
|
+
if (actionReceived.enabled === true || actionReceived.enabled === false) {
|
|
1684
|
+
(actionReceived.enabled === true) && tblAction.enable();
|
|
1685
|
+
(actionReceived.enabled === false) && tblAction.disable();
|
|
1686
|
+
}
|
|
1687
|
+
if (actionReceived.showOnStates) {
|
|
1688
|
+
(_a = actionReceived.showOnStates) === null || _a === void 0 ? void 0 : _a.forEach(newState => {
|
|
1689
|
+
tblAction.addVisibleState(newState);
|
|
1690
|
+
});
|
|
1691
|
+
}
|
|
1692
|
+
if (actionReceived.hideOnStates) {
|
|
1693
|
+
(_b = actionReceived.hideOnStates) === null || _b === void 0 ? void 0 : _b.forEach(newState => {
|
|
1694
|
+
tblAction.removeVisibleState(newState);
|
|
1695
|
+
});
|
|
1696
|
+
}
|
|
1697
|
+
if (actionReceived.enableOnStates) {
|
|
1698
|
+
(_c = actionReceived.enableOnStates) === null || _c === void 0 ? void 0 : _c.forEach(newState => {
|
|
1699
|
+
tblAction.addEnabledState(newState);
|
|
1700
|
+
});
|
|
1701
|
+
}
|
|
1702
|
+
if (actionReceived.disableOnStates) {
|
|
1703
|
+
(_d = actionReceived.disableOnStates) === null || _d === void 0 ? void 0 : _d.forEach(newState => {
|
|
1704
|
+
tblAction.removeEnabledState(newState);
|
|
1705
|
+
});
|
|
1706
|
+
}
|
|
1707
|
+
});
|
|
1645
1708
|
}
|
|
1646
|
-
|
|
1647
|
-
|
|
1709
|
+
if (fields) {
|
|
1710
|
+
Object.keys(fields).forEach(fieldCode => {
|
|
1711
|
+
const tblField = this.columnDefinition(fieldCode);
|
|
1712
|
+
const fieldReceived = fields[fieldCode];
|
|
1713
|
+
if (fieldReceived.visible === true || fieldReceived.visible === false) {
|
|
1714
|
+
(fieldReceived.visible === true) && tblField.show();
|
|
1715
|
+
(fieldReceived.visible === false) && tblField.hide();
|
|
1716
|
+
}
|
|
1717
|
+
});
|
|
1718
|
+
}
|
|
1719
|
+
if (tableRecords) {
|
|
1720
|
+
this.totalPages = totalPages;
|
|
1721
|
+
this.recordsNumber = recordsNumber;
|
|
1722
|
+
this.setAttr(attrs.currentPage, +currentPage);
|
|
1723
|
+
this.setAttr(attrs.recordsPerPage, +recordsPerPage);
|
|
1724
|
+
this.setAttr(attrs.totalRecordsNumber, (this.clientPaging) ? tableRecords.length : +totalRecordsNumber);
|
|
1725
|
+
this.setAttr(attrs.sorting, {
|
|
1726
|
+
columnName: sortingColumn || '',
|
|
1727
|
+
direction: sortingDirection || ''
|
|
1728
|
+
});
|
|
1729
|
+
if (!this._appendPages) {
|
|
1730
|
+
this.replaceRecords(tableRecords);
|
|
1731
|
+
}
|
|
1732
|
+
else {
|
|
1733
|
+
this.appendRecords(tableRecords);
|
|
1734
|
+
}
|
|
1648
1735
|
}
|
|
1736
|
+
this.waiting = false;
|
|
1649
1737
|
this.updateVisibleRecords();
|
|
1650
1738
|
}
|
|
1651
1739
|
getTableRecord(recordId) {
|
|
@@ -2553,6 +2641,7 @@ class LibFileManagementService {
|
|
|
2553
2641
|
openFile(fileBase64Data, fileName, fileType) { }
|
|
2554
2642
|
saveFileFromURL(fileUrl, fullFileName = null) { }
|
|
2555
2643
|
saveFile(fileBase64Data, fileName, fileType) { }
|
|
2644
|
+
printPdfFile(pdfBufferData) { }
|
|
2556
2645
|
}
|
|
2557
2646
|
|
|
2558
2647
|
const PAYLOAD_VERSION = 'TUAINEXCHANGE_1.0';
|