tuain-ng-forms-lib 12.0.60 → 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,17 +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
- this.currentPageRecords = [];
676
675
  this.globalFilterString = '';
676
+ this.currentPage = 1;
677
677
  this.globalSearch = false;
678
678
  this.selectedRecords = [];
679
- this.selectionBackend = false;
680
- this.allSelected = false;
681
- this.currentPage = 1;
682
679
  this.totalRecordsNumber = 0;
680
+ this.allSelected = false;
683
681
  this.loaded = false;
684
682
  this.selectable = false;
685
683
  this.hasActions = false;
@@ -719,47 +717,16 @@
719
717
  LibTableComponent.prototype.tableSelectionToggle = function (recordId) { this.table.notifyRecordSelection(recordId); };
720
718
  LibTableComponent.prototype.toggleSelectAll = function () { return (this.allSelected) ? this.table.unSelectAll() : this.table.selectAll(); };
721
719
  LibTableComponent.prototype.globalFilterCompleted = function () { this.changePage(1); };
722
- LibTableComponent.prototype.changePage = function (requestedPage) {
723
- if (this.clientPaging) {
724
- this.currentPage = requestedPage;
725
- this.updateTableView();
726
- }
727
- else {
728
- this.table.notifyGetDataAction(requestedPage);
729
- }
730
- };
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 : ''); };
731
723
  LibTableComponent.prototype.syncAttribute = function (name, value) {
732
724
  try {
733
- // this.hasOwnProperty(name)
734
725
  this[name] = value;
735
726
  }
736
727
  catch (e) {
737
728
  console.log('Error asignando valor a un atributo del objeto');
738
729
  }
739
- if (changeViewAttributes.includes(name)) {
740
- this.updateTableView();
741
- }
742
- };
743
- LibTableComponent.prototype.globalFilterChanged = function () {
744
- var _a, _b;
745
- this.table.setGlobalFilterString((_b = (_a = this.globalFilterString) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : '');
746
- if (this.clientPaging) {
747
- this.table.setAttr('currentPage', 1);
748
- this.table.updateVisibleRecords();
749
- }
750
- };
751
- LibTableComponent.prototype.tableColumnSort = function (columnName) {
752
- this.table.setRequiredOrder(columnName);
753
- return this.clientPaging ? this.table.localSortData() : this.table.notifyGetDataAction();
754
- };
755
- LibTableComponent.prototype.updateTableView = function () {
756
- var currentPageRecords = this.visibleRecords;
757
- if (this.clientPaging) {
758
- currentPageRecords = currentPageRecords.map(function (record, i) { return (Object.assign({ id: i + 1 }, record)); })
759
- .slice((this.currentPage - 1) * this.recordsPerPage, (this.currentPage - 1) * this.recordsPerPage + this.recordsPerPage);
760
- this.totalRecordsNumber = this.visibleRecords.length;
761
- }
762
- this.currentPageRecords = currentPageRecords;
763
730
  };
764
731
  return LibTableComponent;
765
732
  }());
@@ -1557,12 +1524,12 @@
1557
1524
  _this.tableTitle = tableReceived.tableTitle;
1558
1525
  _this._appendPages = (_a = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.append) !== null && _a !== void 0 ? _a : false;
1559
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;
1560
1529
  _this.setAttr('allSelected', false);
1561
1530
  _this.setAttr('tableCode', tableReceived.tableCode);
1562
- _this.setAttr('clientPaging', (_c = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.clientPaging) !== null && _c !== void 0 ? _c : true);
1563
- _this.setAttr('globalSearch', (_d = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.simpleFilter) !== null && _d !== void 0 ? _d : false);
1564
- _this.setAttr('selectionBackend', (_e = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.selectionBackend) !== null && _e !== void 0 ? _e : false);
1565
- _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);
1566
1533
  _this.setAttr('sorting', { columnName: '', direction: '' });
1567
1534
  _this.setAttr('recordsPerPage', formConfig.defaultRecordsPerPage);
1568
1535
  if (tableReceived.fields) {
@@ -1729,10 +1696,10 @@
1729
1696
  return null;
1730
1697
  };
1731
1698
  RecordTable.prototype.clean = function () {
1732
- this.visibleRecords = [];
1733
1699
  this.tableRecords = [];
1734
1700
  this.unSelectAll();
1735
1701
  this.tableRecordObj = {};
1702
+ this.updateVisibleRecords();
1736
1703
  };
1737
1704
  RecordTable.prototype.selectAll = function () {
1738
1705
  this.setAttr('allSelected', true);
@@ -1776,14 +1743,27 @@
1776
1743
  };
1777
1744
  RecordTable.prototype.appendRecords = function (records) { this.setTableRecords(records, true); };
1778
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
+ };
1779
1755
  RecordTable.prototype.updateVisibleRecords = function () {
1780
- var _a;
1781
- if (!this.clientPaging || !this.tableRecords || ((_a = this.tableRecords) === null || _a === void 0 ? void 0 : _a.length) === 0) {
1782
- 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);
1783
1762
  }
1784
1763
  else {
1785
- this.setAttr('visibleRecords', this.getFilteredRecords());
1764
+ visibleRecords = this.tableRecords;
1786
1765
  }
1766
+ this.setAttr('visibleRecords', visibleRecords);
1787
1767
  };
1788
1768
  RecordTable.prototype.updateFromServer = function (tableReceived) {
1789
1769
  var _a;
@@ -1829,6 +1809,9 @@
1829
1809
  RecordTable.prototype.setGlobalFilterString = function (text) {
1830
1810
  var _a;
1831
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
+ }
1832
1815
  };
1833
1816
  RecordTable.prototype.addFilterDefinition = function (filterDefinition) {
1834
1817
  var tableColumn = this.columnDefinition(filterDefinition.fieldCode);
@@ -1884,6 +1867,15 @@
1884
1867
  configurable: true
1885
1868
  });
1886
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
+ };
1887
1879
  RecordTable.prototype.setRequiredOrder = function (columnField) {
1888
1880
  if (columnField !== this.sorting.columnName) {
1889
1881
  this.setAttr('sorting', {