tuain-ng-forms-lib 12.0.57 → 12.0.61

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.
@@ -669,10 +669,15 @@
669
669
  fieldValue: [{ type: core.Input }]
670
670
  };
671
671
 
672
- var changeViewAttributes = ['visibleRecords', 'currentPage', 'recordsPerPage', 'sorting'];
672
+ var changeViewAttributes = ['visibleRecords', 'currentPage', 'recordsPerPage'];
673
673
  var LibTableComponent = /** @class */ (function () {
674
674
  function LibTableComponent() {
675
675
  this.globalFilterString = '';
676
+ this.currentPage = 1;
677
+ this.globalSearch = false;
678
+ this.selectedRecords = [];
679
+ this.totalRecordsNumber = 0;
680
+ this.allSelected = false;
676
681
  this.loaded = false;
677
682
  this.selectable = false;
678
683
  this.hasActions = false;
@@ -709,36 +714,19 @@
709
714
  LibTableComponent.prototype.tableGlobalAction = function (actionCode) { this.table.notifyGlobalAction(actionCode); };
710
715
  LibTableComponent.prototype.tableSelectionAction = function (actionCode) { this.table.notifySelectionAction(actionCode); };
711
716
  LibTableComponent.prototype.tableActionSelected = function (actionEvent) { this.table.notifyInlineAction(actionEvent); };
712
- LibTableComponent.prototype.changePage = function (requestedPage) { !this.clientPaging && this.table.notifyGetDataAction(requestedPage); };
713
717
  LibTableComponent.prototype.tableSelectionToggle = function (recordId) { this.table.notifyRecordSelection(recordId); };
714
718
  LibTableComponent.prototype.toggleSelectAll = function () { return (this.allSelected) ? this.table.unSelectAll() : this.table.selectAll(); };
715
719
  LibTableComponent.prototype.globalFilterCompleted = function () { this.changePage(1); };
720
+ LibTableComponent.prototype.changePage = function (requestedPage) { this.table.changePage(requestedPage); };
721
+ LibTableComponent.prototype.tableColumnSort = function (columnName) { this.table.sort(columnName); };
722
+ LibTableComponent.prototype.globalFilterChanged = function () { var _a, _b; this.table.setGlobalFilterString((_b = (_a = this.globalFilterString) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : ''); };
716
723
  LibTableComponent.prototype.syncAttribute = function (name, value) {
717
- this.hasOwnProperty(name) && (this[name] = value);
718
- if (changeViewAttributes.includes(name)) {
719
- this.updateTableView();
720
- }
721
- };
722
- LibTableComponent.prototype.globalFilterChanged = function () {
723
- var _a, _b;
724
- this.table.setGlobalFilterString((_b = (_a = this.globalFilterString) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : '');
725
- if (this.clientPaging) {
726
- this.table.setAttr('currentPage', 1);
727
- this.table.updateVisibleRecords();
724
+ try {
725
+ this[name] = value;
728
726
  }
729
- };
730
- LibTableComponent.prototype.tableColumnSort = function (columnName) {
731
- this.table.setRequiredOrder(columnName);
732
- return this.clientPaging ? this.table.localSortData() : this.table.notifyGetDataAction();
733
- };
734
- LibTableComponent.prototype.updateTableView = function () {
735
- var currentPageRecords = this.visibleRecords;
736
- if (this.clientPaging) {
737
- currentPageRecords = currentPageRecords.map(function (record, i) { return (Object.assign({ id: i + 1 }, record)); })
738
- .slice((this.currentPage - 1) * this.recordsPerPage, (this.currentPage - 1) * this.recordsPerPage + this.recordsPerPage);
739
- this.totalRecordsNumber = this.visibleRecords.length;
727
+ catch (e) {
728
+ console.log('Error asignando valor a un atributo del objeto');
740
729
  }
741
- this.currentPageRecords = currentPageRecords;
742
730
  };
743
731
  return LibTableComponent;
744
732
  }());
@@ -1536,12 +1524,12 @@
1536
1524
  _this.tableTitle = tableReceived.tableTitle;
1537
1525
  _this._appendPages = (_a = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.append) !== null && _a !== void 0 ? _a : false;
1538
1526
  _this.selectable = (_b = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.selectable) !== null && _b !== void 0 ? _b : false;
1527
+ _this.selectionBackend = (_c = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.selectionBackend) !== null && _c !== void 0 ? _c : false;
1528
+ _this.sortable = (_d = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.sortable) !== null && _d !== void 0 ? _d : false;
1539
1529
  _this.setAttr('allSelected', false);
1540
1530
  _this.setAttr('tableCode', tableReceived.tableCode);
1541
- _this.setAttr('clientPaging', (_c = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.clientPaging) !== null && _c !== void 0 ? _c : true);
1542
- _this.setAttr('globalSearch', (_d = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.simpleFilter) !== null && _d !== void 0 ? _d : false);
1543
- _this.setAttr('selectionBackend', (_e = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.selectionBackend) !== null && _e !== void 0 ? _e : false);
1544
- _this.setAttr('sortable', (_f = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.sortable) !== null && _f !== void 0 ? _f : false);
1531
+ _this.setAttr('clientPaging', (_e = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.clientPaging) !== null && _e !== void 0 ? _e : true);
1532
+ _this.setAttr('globalSearch', (_f = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.simpleFilter) !== null && _f !== void 0 ? _f : false);
1545
1533
  _this.setAttr('sorting', { columnName: '', direction: '' });
1546
1534
  _this.setAttr('recordsPerPage', formConfig.defaultRecordsPerPage);
1547
1535
  if (tableReceived.fields) {
@@ -1708,10 +1696,10 @@
1708
1696
  return null;
1709
1697
  };
1710
1698
  RecordTable.prototype.clean = function () {
1711
- this.visibleRecords = [];
1712
1699
  this.tableRecords = [];
1713
1700
  this.unSelectAll();
1714
1701
  this.tableRecordObj = {};
1702
+ this.updateVisibleRecords();
1715
1703
  };
1716
1704
  RecordTable.prototype.selectAll = function () {
1717
1705
  this.setAttr('allSelected', true);
@@ -1755,14 +1743,27 @@
1755
1743
  };
1756
1744
  RecordTable.prototype.appendRecords = function (records) { this.setTableRecords(records, true); };
1757
1745
  RecordTable.prototype.replaceRecords = function (records) { this.setTableRecords(records, false); };
1746
+ RecordTable.prototype.changePage = function (requestedPage) {
1747
+ if (this.clientPaging) {
1748
+ this.setAttr('currentPage', requestedPage);
1749
+ this.updateVisibleRecords();
1750
+ }
1751
+ else {
1752
+ this.notifyGetDataAction(requestedPage);
1753
+ }
1754
+ };
1758
1755
  RecordTable.prototype.updateVisibleRecords = function () {
1759
- var _a;
1760
- if (!this.clientPaging || !this.tableRecords || ((_a = this.tableRecords) === null || _a === void 0 ? void 0 : _a.length) === 0) {
1761
- this.setAttr('visibleRecords', this.tableRecords);
1756
+ // updateView const changeViewAttributes = ['currentPage', 'recordsPerPage', 'sorting'];
1757
+ var visibleRecords;
1758
+ if (this.clientPaging) {
1759
+ var filteredRecords = this.getFilteredRecords();
1760
+ this.setAttr('totalRecordsNumber', filteredRecords.length);
1761
+ visibleRecords = filteredRecords.slice((this.currentPage - 1) * this.recordsPerPage, (this.currentPage - 1) * this.recordsPerPage + this.recordsPerPage);
1762
1762
  }
1763
1763
  else {
1764
- this.setAttr('visibleRecords', this.getFilteredRecords());
1764
+ visibleRecords = this.tableRecords;
1765
1765
  }
1766
+ this.setAttr('visibleRecords', visibleRecords);
1766
1767
  };
1767
1768
  RecordTable.prototype.updateFromServer = function (tableReceived) {
1768
1769
  var _a;
@@ -1773,7 +1774,7 @@
1773
1774
  this.recordsNumber = tableReceived.recordsNumber;
1774
1775
  this.setAttr('currentPage', (_a = +(tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.currentPage)) !== null && _a !== void 0 ? _a : 1);
1775
1776
  this.setAttr('recordsPerPage', +tableReceived.recordsPerPage);
1776
- this.setAttr('totalRecordsNumber', +tableReceived.totalRecordsNumber);
1777
+ this.setAttr('totalRecordsNumber', (this.clientPaging) ? tableReceived.tableRecords.length : +tableReceived.totalRecordsNumber);
1777
1778
  this.setAttr('sorting', {
1778
1779
  columnName: tableReceived.sortingColumn || '',
1779
1780
  direction: tableReceived.sortingDirection || ''
@@ -1808,6 +1809,9 @@
1808
1809
  RecordTable.prototype.setGlobalFilterString = function (text) {
1809
1810
  var _a;
1810
1811
  this.globalFilterStrings = (_a = text.split(' ').filter(function (t) { return t && t.trim().length > 0; }).map(function (t) { return t.trim(); })) !== null && _a !== void 0 ? _a : [];
1812
+ if (this.clientPaging) {
1813
+ this.changePage(1);
1814
+ }
1811
1815
  };
1812
1816
  RecordTable.prototype.addFilterDefinition = function (filterDefinition) {
1813
1817
  var tableColumn = this.columnDefinition(filterDefinition.fieldCode);
@@ -1863,6 +1867,15 @@
1863
1867
  configurable: true
1864
1868
  });
1865
1869
  // Ordenamiento de registros local
1870
+ RecordTable.prototype.sort = function (columnName) {
1871
+ this.setRequiredOrder(columnName);
1872
+ if (this.clientPaging) {
1873
+ this.localSortData();
1874
+ }
1875
+ else {
1876
+ this.notifyGetDataAction();
1877
+ }
1878
+ };
1866
1879
  RecordTable.prototype.setRequiredOrder = function (columnField) {
1867
1880
  if (columnField !== this.sorting.columnName) {
1868
1881
  this.setAttr('sorting', {