tuain-ng-forms-lib 12.0.5 → 12.0.6
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/bundles/tuain-ng-forms-lib.umd.js +112 -63
- package/bundles/tuain-ng-forms-lib.umd.js.map +1 -1
- package/esm2015/lib/classes/forms/field.js +15 -15
- package/esm2015/lib/classes/forms/table/table.js +46 -31
- package/esm2015/lib/components/elements/tables/table.component.js +39 -19
- package/esm2015/lib/components/forms/basic-form.js +3 -2
- package/fesm2015/tuain-ng-forms-lib.js +99 -63
- package/fesm2015/tuain-ng-forms-lib.js.map +1 -1
- package/lib/classes/forms/table/table.d.ts +3 -0
- package/lib/components/elements/tables/table.component.d.ts +18 -6
- package/package.json +1 -1
- package/tuain-ng-forms-lib.metadata.json +1 -1
|
@@ -935,13 +935,13 @@
|
|
|
935
935
|
_this._recordSelectionTrigger = new rxjs.Subject();
|
|
936
936
|
_this._selectionActionTrigger = new rxjs.Subject();
|
|
937
937
|
_this._getDataTrigger = new rxjs.Subject();
|
|
938
|
+
_this._attributeChange = new rxjs.Subject();
|
|
938
939
|
_this.tableRecordObj = {};
|
|
939
940
|
_this._tableColumnObj = {};
|
|
940
941
|
_this._actionsObj = {};
|
|
941
942
|
_this.allSelected = false;
|
|
942
943
|
_this.elementType = elementTypes.table;
|
|
943
944
|
_this.waiting = false;
|
|
944
|
-
_this.complexFilter = false;
|
|
945
945
|
_this.currentPage = 1;
|
|
946
946
|
_this.totalPages = 1;
|
|
947
947
|
_this.requestedPage = 1;
|
|
@@ -949,26 +949,29 @@
|
|
|
949
949
|
_this._tableColumnObj = {};
|
|
950
950
|
_this._actions = [];
|
|
951
951
|
_this._actionsObj = {};
|
|
952
|
-
_this.filterConfig = [];
|
|
953
|
-
_this.filterObject = new Filter();
|
|
954
952
|
_this.tableRecords = [];
|
|
955
|
-
_this.
|
|
953
|
+
_this.setAttr('allSelected', false);
|
|
954
|
+
_this.setAttr('filterObject', new Filter());
|
|
955
|
+
_this.setAttr('filterConfig', []);
|
|
956
|
+
_this.setAttr('tableCode', tableReceived.tableCode);
|
|
956
957
|
_this.tableTitle = tableReceived.tableTitle;
|
|
957
|
-
_this.clientPaging
|
|
958
|
-
_this.simpleFilter
|
|
958
|
+
_this.setAttr('clientPaging', (_a = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.clientPaging) !== null && _a !== void 0 ? _a : true);
|
|
959
|
+
_this.setAttr('simpleFilter', (_b = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.simpleFilter) !== null && _b !== void 0 ? _b : false);
|
|
960
|
+
_this.setAttr('complexFilter', false);
|
|
959
961
|
_this._appendPages = (_c = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.append) !== null && _c !== void 0 ? _c : false;
|
|
960
962
|
_this.selectable = (_d = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.selectable) !== null && _d !== void 0 ? _d : false;
|
|
961
|
-
_this.selectionBackend
|
|
963
|
+
_this.setAttr('selectionBackend', (_e = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.selectionBackend) !== null && _e !== void 0 ? _e : false);
|
|
962
964
|
_this.customAttributes = (_f = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.customAttributes) !== null && _f !== void 0 ? _f : {};
|
|
963
|
-
_this.sortable
|
|
964
|
-
_this.sorting
|
|
965
|
-
_this.recordsPerPage
|
|
965
|
+
_this.setAttr('sortable', (_g = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.sortable) !== null && _g !== void 0 ? _g : false);
|
|
966
|
+
_this.setAttr('sorting', { columnName: '', direction: '' });
|
|
967
|
+
_this.setAttr('recordsPerPage', formConfig.defaultRecordsPerPage);
|
|
966
968
|
if (tableReceived.fields) {
|
|
969
|
+
var columns = [];
|
|
967
970
|
try {
|
|
968
971
|
for (var _l = __values(tableReceived.fields), _m = _l.next(); !_m.done; _m = _l.next()) {
|
|
969
972
|
var columnReceived = _m.value;
|
|
970
973
|
var columnDefinition = new RecordTableColumn(columnReceived, _this._formConfig);
|
|
971
|
-
|
|
974
|
+
columns.push(columnDefinition);
|
|
972
975
|
_this._tableColumnObj[columnDefinition.fieldCode] = columnDefinition;
|
|
973
976
|
}
|
|
974
977
|
}
|
|
@@ -979,6 +982,7 @@
|
|
|
979
982
|
}
|
|
980
983
|
finally { if (e_1) throw e_1.error; }
|
|
981
984
|
}
|
|
985
|
+
_this.setAttr('columns', columns);
|
|
982
986
|
}
|
|
983
987
|
if (tableReceived.actions) {
|
|
984
988
|
var tableActions = tableReceived.actions.map(function (objDef) {
|
|
@@ -1011,12 +1015,13 @@
|
|
|
1011
1015
|
}
|
|
1012
1016
|
}
|
|
1013
1017
|
if (tableReceived.filters && tableReceived.filters.length > 0) {
|
|
1014
|
-
_this.complexFilter
|
|
1018
|
+
_this.setAttr('complexFilter', true);
|
|
1019
|
+
var filterConfig = _this.filterConfig;
|
|
1015
1020
|
try {
|
|
1016
1021
|
for (var _o = __values(tableReceived.filters), _p = _o.next(); !_p.done; _p = _o.next()) {
|
|
1017
1022
|
var filterReceived = _p.value;
|
|
1018
1023
|
var filterItem = new FieldSearch(filterReceived);
|
|
1019
|
-
|
|
1024
|
+
filterConfig.push(filterItem);
|
|
1020
1025
|
}
|
|
1021
1026
|
}
|
|
1022
1027
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
@@ -1026,6 +1031,7 @@
|
|
|
1026
1031
|
}
|
|
1027
1032
|
finally { if (e_3) throw e_3.error; }
|
|
1028
1033
|
}
|
|
1034
|
+
_this.setAttr('filterConfig', filterConfig);
|
|
1029
1035
|
}
|
|
1030
1036
|
if (_this.selectable) {
|
|
1031
1037
|
_this.selectionField = _this.columns
|
|
@@ -1058,6 +1064,11 @@
|
|
|
1058
1064
|
enumerable: false,
|
|
1059
1065
|
configurable: true
|
|
1060
1066
|
});
|
|
1067
|
+
Object.defineProperty(RecordTable.prototype, "attributeChange", {
|
|
1068
|
+
get: function () { return this._attributeChange; },
|
|
1069
|
+
enumerable: false,
|
|
1070
|
+
configurable: true
|
|
1071
|
+
});
|
|
1061
1072
|
Object.defineProperty(RecordTable.prototype, "hasActions", {
|
|
1062
1073
|
get: function () { return (this._actions.length > 0); },
|
|
1063
1074
|
enumerable: false,
|
|
@@ -1087,6 +1098,12 @@
|
|
|
1087
1098
|
enumerable: false,
|
|
1088
1099
|
configurable: true
|
|
1089
1100
|
});
|
|
1101
|
+
RecordTable.prototype.setAttr = function (name, value) {
|
|
1102
|
+
this[name] = value;
|
|
1103
|
+
if (this._formConfig.monitoredTableAttributes.includes(name)) {
|
|
1104
|
+
this._attributeChange.next({ name: name, value: value });
|
|
1105
|
+
}
|
|
1106
|
+
};
|
|
1090
1107
|
RecordTable.prototype.appendRecords = function (records) { this.setTableRecords(records, true); };
|
|
1091
1108
|
RecordTable.prototype.replaceRecords = function (records) { this.setTableRecords(records, false); };
|
|
1092
1109
|
RecordTable.prototype.columnDefinition = function (fieldCode) { return this._tableColumnObj[fieldCode]; };
|
|
@@ -1154,11 +1171,11 @@
|
|
|
1154
1171
|
this.tableRecordObj = {};
|
|
1155
1172
|
};
|
|
1156
1173
|
RecordTable.prototype.selectAll = function () {
|
|
1157
|
-
this.allSelected
|
|
1174
|
+
this.setAttr('allSelected', true);
|
|
1158
1175
|
this.tableRecords.forEach(function (record) { return record.select(); });
|
|
1159
1176
|
};
|
|
1160
1177
|
RecordTable.prototype.unSelectAll = function () {
|
|
1161
|
-
this.allSelected
|
|
1178
|
+
this.setAttr('allSelected', false);
|
|
1162
1179
|
this.tableRecords.forEach(function (record) { return record.unselect(); });
|
|
1163
1180
|
};
|
|
1164
1181
|
RecordTable.prototype.setTableRecords = function (tableRecords, append) {
|
|
@@ -1192,21 +1209,24 @@
|
|
|
1192
1209
|
RecordTable.prototype.updateVisibleRecords = function () {
|
|
1193
1210
|
var _this = this;
|
|
1194
1211
|
if (!this.clientPaging || !this.tableRecords || this.tableRecords.length === 0) {
|
|
1195
|
-
this.visibleRecords
|
|
1212
|
+
this.setAttr('visibleRecords', this.tableRecords);
|
|
1196
1213
|
}
|
|
1197
|
-
|
|
1214
|
+
var recordsVisible = (this.filterObject.filterModeSimple)
|
|
1198
1215
|
? this.tableRecords.filter(function (record) { return record.hasPattern(_this.filterObject.simpleFilterWords); })
|
|
1199
1216
|
: this.tableRecords.filter(function (record) { return record.hasCondition(_this.filterObject.advancedFilter); });
|
|
1217
|
+
this.setAttr('visibleRecords', recordsVisible);
|
|
1200
1218
|
};
|
|
1201
1219
|
RecordTable.prototype.updateFromServer = function (tableReceived) {
|
|
1202
1220
|
this.visible = (tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.visible) || true;
|
|
1203
|
-
this.currentPage
|
|
1221
|
+
this.setAttr('currentPage', parseInt(tableReceived.currentPage, 10) || 1);
|
|
1204
1222
|
this.totalPages = tableReceived.totalPages || 1;
|
|
1205
|
-
this.recordsPerPage
|
|
1223
|
+
this.setAttr('recordsPerPage', tableReceived.recordsPerPage);
|
|
1206
1224
|
this.recordsNumber = tableReceived.recordsNumber;
|
|
1207
|
-
this.totalRecordsNumber
|
|
1208
|
-
this.sorting
|
|
1209
|
-
|
|
1225
|
+
this.setAttr('totalRecordsNumber', tableReceived.totalRecordsNumber);
|
|
1226
|
+
this.setAttr('sorting', {
|
|
1227
|
+
columnName: tableReceived.sortingColumn || '',
|
|
1228
|
+
direction: tableReceived.sortingDirection || ''
|
|
1229
|
+
});
|
|
1210
1230
|
this.requestedPage = 1;
|
|
1211
1231
|
this.waiting = false;
|
|
1212
1232
|
this.clean();
|
|
@@ -1301,16 +1321,15 @@
|
|
|
1301
1321
|
// Ordenamiento
|
|
1302
1322
|
RecordTable.prototype.setRequiredOrder = function (columnField) {
|
|
1303
1323
|
if (columnField !== this.sorting.columnName) {
|
|
1304
|
-
this.sorting
|
|
1305
|
-
|
|
1324
|
+
this.setAttr('sorting', {
|
|
1325
|
+
columnName: columnField,
|
|
1326
|
+
direction: TABLE_SORT_ASCENDING
|
|
1327
|
+
});
|
|
1306
1328
|
}
|
|
1307
1329
|
else {
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
else {
|
|
1312
|
-
this.sorting.direction = TABLE_SORT_ASCENDING;
|
|
1313
|
-
}
|
|
1330
|
+
var tableSort = this.sorting;
|
|
1331
|
+
tableSort.direction = (tableSort.direction === TABLE_SORT_ASCENDING) ? TABLE_SORT_DESCENDING : TABLE_SORT_ASCENDING;
|
|
1332
|
+
this.setAttr('sorting', tableSort);
|
|
1314
1333
|
}
|
|
1315
1334
|
};
|
|
1316
1335
|
RecordTable.prototype.localSortData = function () {
|
|
@@ -1494,15 +1513,30 @@
|
|
|
1494
1513
|
this.hasActions = false;
|
|
1495
1514
|
}
|
|
1496
1515
|
LibTableComponent.prototype.ngOnInit = function () {
|
|
1497
|
-
var
|
|
1498
|
-
|
|
1499
|
-
this.
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1516
|
+
var _this = this;
|
|
1517
|
+
var _a, _b;
|
|
1518
|
+
if (this.tableObject) {
|
|
1519
|
+
this.formConfig = (_a = this.tableObject) === null || _a === void 0 ? void 0 : _a._formConfig;
|
|
1520
|
+
this.tableFieldStyles = this.formConfig.tableFieldStyles;
|
|
1521
|
+
this.selectable = this.tableObject.selectable;
|
|
1522
|
+
this.hasActions = this.tableObject.hasActions;
|
|
1523
|
+
this.tableObject.widget = this;
|
|
1524
|
+
this.inlineActions = this.tableObject.getActions(this.formConfig.tableActions.inline);
|
|
1525
|
+
this.globalActions = this.tableObject.getActions(this.formConfig.tableActions.global);
|
|
1526
|
+
this.selectionActions = this.tableObject.getActions(this.formConfig.tableActions.selection);
|
|
1527
|
+
// Inicialización de campos mapeados del objeto
|
|
1528
|
+
var mapping = Object.entries(this.formConfig.componentTableAttrMap);
|
|
1529
|
+
for (var index = 0; index < mapping.length; index++) {
|
|
1530
|
+
var _c = __read(mapping[index], 2), tableAttr = _c[0], compAttr = _c[1];
|
|
1531
|
+
this[compAttr.toString()] = (_b = this.tableObject) === null || _b === void 0 ? void 0 : _b[tableAttr.toString()];
|
|
1532
|
+
}
|
|
1533
|
+
// Subscripción a cambios en atributos
|
|
1534
|
+
this.tableObject.attributeChange.subscribe(function (event) {
|
|
1535
|
+
var tableAttr = event.name, value = event.value;
|
|
1536
|
+
var compAttr = _this.formConfig.componentTableAttrMap[tableAttr];
|
|
1537
|
+
_this.hasOwnProperty(compAttr) && (_this[compAttr] = value);
|
|
1538
|
+
});
|
|
1539
|
+
}
|
|
1506
1540
|
this.start();
|
|
1507
1541
|
};
|
|
1508
1542
|
LibTableComponent.prototype.start = function () { };
|
|
@@ -1517,23 +1551,23 @@
|
|
|
1517
1551
|
};
|
|
1518
1552
|
LibTableComponent.prototype.tableColumnSort = function (columnFieldCode) {
|
|
1519
1553
|
this.tableObject.setRequiredOrder(columnFieldCode);
|
|
1520
|
-
if (this.
|
|
1554
|
+
if (this.clientPaging) {
|
|
1521
1555
|
return this.tableObject.localSortData();
|
|
1522
1556
|
}
|
|
1523
1557
|
this.tableObject.notifyGetDataAction();
|
|
1524
1558
|
};
|
|
1525
1559
|
LibTableComponent.prototype.changePage = function (requestedPage) {
|
|
1526
|
-
if (!this.
|
|
1560
|
+
if (!this.clientPaging) {
|
|
1527
1561
|
this.tableObject.notifyGetDataAction(requestedPage);
|
|
1528
1562
|
}
|
|
1529
1563
|
};
|
|
1530
1564
|
Object.defineProperty(LibTableComponent.prototype, "records", {
|
|
1531
1565
|
get: function () {
|
|
1532
|
-
var currentPageRecords = this.
|
|
1533
|
-
if (this.
|
|
1534
|
-
this.
|
|
1566
|
+
var currentPageRecords = this.visibleRecords;
|
|
1567
|
+
if (this.clientPaging && currentPageRecords && currentPageRecords.length > 0) {
|
|
1568
|
+
this.totalRecordsNumber = currentPageRecords.length;
|
|
1535
1569
|
return currentPageRecords.map(function (record, i) { return (Object.assign({ id: i + 1 }, record)); })
|
|
1536
|
-
.slice((this.
|
|
1570
|
+
.slice((this.currentPage - 1) * this.recordsPerPage, (this.currentPage - 1) * this.recordsPerPage + this.recordsPerPage);
|
|
1537
1571
|
}
|
|
1538
1572
|
return currentPageRecords;
|
|
1539
1573
|
},
|
|
@@ -1545,8 +1579,8 @@
|
|
|
1545
1579
|
var triggerDataUpdate = false;
|
|
1546
1580
|
if (eventType === TABLE_FILTER_TYPES.simpleFilterChange || eventType === TABLE_FILTER_TYPES.simpleFilterFinish) {
|
|
1547
1581
|
this.tableObject.simpleFilterText = tableFilterEvent.simpleFilterString.trim();
|
|
1548
|
-
if (this.
|
|
1549
|
-
this.tableObject.currentPage
|
|
1582
|
+
if (this.clientPaging) {
|
|
1583
|
+
this.tableObject.setAttr('currentPage', 1);
|
|
1550
1584
|
this.tableObject.updateVisibleRecords();
|
|
1551
1585
|
}
|
|
1552
1586
|
else if (eventType === TABLE_FILTER_TYPES.simpleFilterFinish) {
|
|
@@ -1571,13 +1605,27 @@
|
|
|
1571
1605
|
this.tableObject.notifyRecordSelection(recordId);
|
|
1572
1606
|
};
|
|
1573
1607
|
LibTableComponent.prototype.toggleSelectAll = function () {
|
|
1574
|
-
if (this.
|
|
1608
|
+
if (this.allSelected) {
|
|
1575
1609
|
this.tableObject.unSelectAll();
|
|
1576
1610
|
}
|
|
1577
1611
|
else {
|
|
1578
1612
|
this.tableObject.selectAll();
|
|
1579
1613
|
}
|
|
1580
1614
|
};
|
|
1615
|
+
Object.defineProperty(LibTableComponent.prototype, "availableFilters", {
|
|
1616
|
+
get: function () {
|
|
1617
|
+
return this.tableObject.availableFilters;
|
|
1618
|
+
},
|
|
1619
|
+
enumerable: false,
|
|
1620
|
+
configurable: true
|
|
1621
|
+
});
|
|
1622
|
+
Object.defineProperty(LibTableComponent.prototype, "selectedRecords", {
|
|
1623
|
+
get: function () {
|
|
1624
|
+
return this.tableObject.selectedRecords;
|
|
1625
|
+
},
|
|
1626
|
+
enumerable: false,
|
|
1627
|
+
configurable: true
|
|
1628
|
+
});
|
|
1581
1629
|
return LibTableComponent;
|
|
1582
1630
|
}());
|
|
1583
1631
|
LibTableComponent.decorators = [
|
|
@@ -2125,20 +2173,20 @@
|
|
|
2125
2173
|
for (var index = 0; index < fieldKeys.length; index++) {
|
|
2126
2174
|
var attrName = fieldKeys[index];
|
|
2127
2175
|
var attrValue = fld[attrName];
|
|
2128
|
-
(attrName === this._formConfig.
|
|
2129
|
-
(attrName === this._formConfig.
|
|
2130
|
-
(attrName === this._formConfig.
|
|
2131
|
-
(attrName === this._formConfig.
|
|
2132
|
-
(attrName === this._formConfig.
|
|
2133
|
-
(attrName === this._formConfig.
|
|
2134
|
-
(attrName === this._formConfig.
|
|
2135
|
-
(attrName === this._formConfig.
|
|
2136
|
-
(attrName === this._formConfig.
|
|
2137
|
-
(attrName === this._formConfig.
|
|
2138
|
-
(attrName === this._formConfig.
|
|
2139
|
-
(attrName === this._formConfig.
|
|
2140
|
-
(attrName === this._formConfig.
|
|
2141
|
-
(attrName === this._formConfig.
|
|
2176
|
+
(attrName === this._formConfig.apiFieldAttrs.visible) && this.setVisibility(attrValue);
|
|
2177
|
+
(attrName === this._formConfig.apiFieldAttrs.labelVisible) && this.setVisibleLabel(fld.visibleLabel);
|
|
2178
|
+
(attrName === this._formConfig.apiFieldAttrs.required) && this.setAttr(fldAttr.required, (_a = fld.required) !== null && _a !== void 0 ? _a : false);
|
|
2179
|
+
(attrName === this._formConfig.apiFieldAttrs.errorCode) && this.setAttr(fldAttr.errorCode, fld.errorCode);
|
|
2180
|
+
(attrName === this._formConfig.apiFieldAttrs.errorMessage) && this.setAttr(fldAttr.errorMessage, fld.errorMessage);
|
|
2181
|
+
(attrName === this._formConfig.apiFieldAttrs.tooltip) && this.setAttr(fldAttr.tooltipText, fld.tooltip);
|
|
2182
|
+
(attrName === this._formConfig.apiFieldAttrs.info) && this.setAttr(fldAttr.info, fld.info);
|
|
2183
|
+
(attrName === this._formConfig.apiFieldAttrs.editable) && this.setEditable(fld.editable);
|
|
2184
|
+
(attrName === this._formConfig.apiFieldAttrs.title) && this.setLabel(fld.fieldTitle.toString());
|
|
2185
|
+
(attrName === this._formConfig.apiFieldAttrs.value) && (this.setValue(fld.fieldValue) && this.setChanged(false));
|
|
2186
|
+
(attrName === this._formConfig.apiFieldAttrs.options) && this.setFieldOptions(fld.fieldOptions);
|
|
2187
|
+
(attrName === this._formConfig.apiFieldAttrs.captureType) && this.setAttr(fldAttr.captureType, fld.captureType || 'INPUT');
|
|
2188
|
+
(attrName === this._formConfig.apiFieldAttrs.type) && this.setFieldType(fld.fieldTypeCode);
|
|
2189
|
+
(attrName === this._formConfig.apiFieldAttrs.maxLength) && this.setAttr(fldAttr.maxLength, fld.maxLength);
|
|
2142
2190
|
}
|
|
2143
2191
|
};
|
|
2144
2192
|
FieldDescriptor.prototype.setFieldType = function (inputFieldType) {
|
|
@@ -3443,7 +3491,8 @@
|
|
|
3443
3491
|
this.controlToken = (_a = params === null || params === void 0 ? void 0 : params[TOKEN]) !== null && _a !== void 0 ? _a : null;
|
|
3444
3492
|
var _j = this.formManagerService.getFormInfo(this.controlToken), token = _j.token, subject = _j.subject, state = _j.state, fields = _j.fields, extra = _j.extra, originToken = _j.originToken;
|
|
3445
3493
|
if (!this.controlToken || this.controlToken !== token) {
|
|
3446
|
-
console.log("No se obtuvo un token v\u00E1lido para abrir el formulario " + this.controlToken + "->" + token);
|
|
3494
|
+
console.log("No se obtuvo un token v\u00E1lido para abrir el formulario " + this.name + ":" + this.controlToken + "->" + token);
|
|
3495
|
+
return;
|
|
3447
3496
|
}
|
|
3448
3497
|
this.formSubject = (_c = (_b = params === null || params === void 0 ? void 0 : params[SUBJECT]) !== null && _b !== void 0 ? _b : subject) !== null && _c !== void 0 ? _c : null;
|
|
3449
3498
|
this.inputDataFields = fields;
|