@universis/ngx-tables 0.8.2 → 0.8.3

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.
@@ -2006,8 +2006,9 @@
2006
2006
  if (_this.dataTable) {
2007
2007
  var info = _this.dataTable.page.info();
2008
2008
  _this.page.emit(info);
2009
- if (drawIndex_1 > 1)
2009
+ if (drawIndex_1 > 1) {
2010
2010
  return;
2011
+ }
2011
2012
  try {
2012
2013
  drawIndex_1++;
2013
2014
  setTimeout(function () { _this.dataTable.columns.adjust(); }, 1);
@@ -2586,7 +2587,7 @@
2586
2587
  var index = columnOrder.indexOf(i);
2587
2588
  var visible = _this.dataTable.column(index).visible();
2588
2589
  // set title for select column
2589
- if (i == 0 && _this.selectable) {
2590
+ if (i === 0 && _this.selectable) {
2590
2591
  title = '<' + _this._translateService.instant('Tables.SelectColumn') + '>';
2591
2592
  }
2592
2593
  // get column title
@@ -2620,9 +2621,18 @@
2620
2621
  });
2621
2622
  this._columnSelector.selectColumns(columns).then(function (event) {
2622
2623
  if (event.result === 'ok') {
2624
+ var sorted = event.columns
2625
+ .map(function (col) {
2626
+ return {
2627
+ key: col.key,
2628
+ index: col.index
2629
+ };
2630
+ })
2631
+ .sort(function (a, b) { return a.index - b.index; });
2623
2632
  // get column order e.g. [3, 1, 2, 0, 4]
2624
- var indexes = event.columns.map(function (item) {
2625
- return item.index;
2633
+ var indexes = sorted
2634
+ .map(function (item) {
2635
+ return event.columns.findIndex(function (next) { return item.key === next.key; });
2626
2636
  });
2627
2637
  // reset column visibilty
2628
2638
  for (var index = 0; index < event.columns.length; index++) {
@@ -2737,12 +2747,10 @@
2737
2747
  cleanupIndexes.push(index);
2738
2748
  return false;
2739
2749
  }
2740
- // find item by title
2741
- var findItem = _this.config.columns.find(function (column) {
2742
- return column.title && column.title.length && _this._translateService.instant(column.title) === headerItem;
2743
- });
2744
2750
  // exclude hidden columns
2745
- if (findItem && findItem.hidden === true) {
2751
+ // note: use the datatable visible() function
2752
+ // instead of the hidden config property, to satisfy the column selector
2753
+ if (!_this.dataTable.column(index).visible()) {
2746
2754
  cleanupIndexes.push(index);
2747
2755
  return false;
2748
2756
  }
@@ -5645,7 +5653,10 @@
5645
5653
  this.table.stateSave = true;
5646
5654
  this.table.stateLoadCallback = function (settings, callback) {
5647
5655
  _this.store.pipe(store.select(selectTable, { id: _this.tableState }), operators.first()).subscribe(function (state) {
5648
- return callback(state && state.table);
5656
+ callback(state && state.table);
5657
+ if (state && state.table && state.table.ColReorder) {
5658
+ _this.table.dataTable.colReorder.order(state.table.ColReorder, true);
5659
+ }
5649
5660
  });
5650
5661
  };
5651
5662
  var firstDraw = true;