diff --git a/dist/tablefilter/tablefilter.js b/dist/tablefilter/tablefilter.js index 9df388ac..469a5cd3 100644 --- a/dist/tablefilter/tablefilter.js +++ b/dist/tablefilter/tablefilter.js @@ -7943,11 +7943,7 @@ return /******/ (function(modules) { // webpackBootstrap } }); - console.log(hiddenCols); - this.emitter.emit('set-hidden-columns', tf, hiddenCols); - hiddenCols.forEach(function (colIdx) { - console.log('hide', colIdx); _this6.emitter.emit('hide-column', tf, colIdx); }); }; diff --git a/dist/tablefilter/tf-1.js b/dist/tablefilter/tf-1.js index 40f1cb73..13335d51 100644 --- a/dist/tablefilter/tf-1.js +++ b/dist/tablefilter/tf-1.js @@ -1129,10 +1129,11 @@ webpackJsonp([1],{ this.emitter.on(['hide-column'], function (tf, colIndex) { return _this.hideCol(colIndex); }); - this.emitter.on(['set-hidden-columns'], function (tf, hiddenCols) { - return _this.setHiddenCols(hiddenCols); - }); this.emitter.emit('columns-visibility-initialized', tf, this); + + // Hide columns at start at very end of initialization + // TODO: re-evaluate this as conceptually wrong + this.hideAtStart(); }; /** @@ -1294,16 +1295,16 @@ webpackJsonp([1],{ this.btnEl.parentNode.insertBefore(container, this.btnEl); this.contEl = container; - if (this.atStart) { - var a = this.atStart; - for (var k = 0; k < a.length; k++) { - // let itm = Dom.id('col_' + a[k] + '_' + tf.id); - // if (itm) { - // itm.click(); - // } - this.hideCol(a[k]); - } - } + // if (this.atStart) { + // let a = this.atStart; + // for (let k = 0; k < a.length; k++) { + // // let itm = Dom.id('col_' + a[k] + '_' + tf.id); + // // if (itm) { + // // itm.click(); + // // } + // this.hideCol(a[k]); + // } + // } }; /** @@ -1412,7 +1413,6 @@ webpackJsonp([1],{ ColsVisibility.prototype.hideCol = function hideCol(colIndex) { - console.log(colIndex); if (colIndex === undefined || this.isColHidden(colIndex)) { return; } @@ -1422,7 +1422,6 @@ webpackJsonp([1],{ itm.click(); } } else { - console.log(colIndex, this.isColHidden(colIndex)); this.setHidden(colIndex, true); } }; @@ -1455,7 +1454,7 @@ webpackJsonp([1],{ }; /** - * Returns the indexes of the columns currently hidden + * Return the indexes of the columns currently hidden * @return {Array} column indexes */ @@ -1464,10 +1463,19 @@ webpackJsonp([1],{ return this.hiddenCols; }; - ColsVisibility.prototype.setHiddenCols = function setHiddenCols() { - var hiddenCols = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0]; + /** + * Hide columns at start + */ - this.hiddenCols = hiddenCols; + + ColsVisibility.prototype.hideAtStart = function hideAtStart() { + if (!this.atStart) { + return; + } + var a = this.atStart; + for (var k = 0; k < a.length; k++) { + this.hideCol(a[k]); + } }; /** @@ -1495,9 +1503,6 @@ webpackJsonp([1],{ this.emitter.off(['hide-column'], function (tf, colIndex) { return _this4.hideCol(colIndex); }); - this.emitter.off(['set-hidden-columns'], function (tf, hiddenCols) { - return _this4.setHiddenCols(hiddenCols); - }); this.initialized = false; }; diff --git a/src/extensions/colsVisibility/colsVisibility.js b/src/extensions/colsVisibility/colsVisibility.js index 72973221..350b5016 100644 --- a/src/extensions/colsVisibility/colsVisibility.js +++ b/src/extensions/colsVisibility/colsVisibility.js @@ -181,9 +181,11 @@ export default class ColsVisibility { this.emitter.on(['hide-column'], (tf, colIndex) => this.hideCol(colIndex)); - this.emitter.on(['set-hidden-columns'], - (tf, hiddenCols) => this.setHiddenCols(hiddenCols)); this.emitter.emit('columns-visibility-initialized', tf, this); + + // Hide columns at start at very end of initialization + // TODO: re-evaluate this as conceptually wrong + this.hideAtStart(); } /** @@ -328,16 +330,16 @@ export default class ColsVisibility { this.btnEl.parentNode.insertBefore(container, this.btnEl); this.contEl = container; - if (this.atStart) { - let a = this.atStart; - for (let k = 0; k < a.length; k++) { - // let itm = Dom.id('col_' + a[k] + '_' + tf.id); - // if (itm) { - // itm.click(); - // } - this.hideCol(a[k]); - } - } + // if (this.atStart) { + // let a = this.atStart; + // for (let k = 0; k < a.length; k++) { + // // let itm = Dom.id('col_' + a[k] + '_' + tf.id); + // // if (itm) { + // // itm.click(); + // // } + // this.hideCol(a[k]); + // } + // } } /** @@ -443,7 +445,7 @@ export default class ColsVisibility { * Hide specified column * @param {Number} colIndex Column index */ - hideCol(colIndex) {console.log(colIndex); + hideCol(colIndex) { if (colIndex === undefined || this.isColHidden(colIndex)) { return; } @@ -453,7 +455,6 @@ export default class ColsVisibility { itm.click(); } } else { - console.log(colIndex, this.isColHidden(colIndex)); this.setHidden(colIndex, true); } } @@ -482,15 +483,24 @@ export default class ColsVisibility { } /** - * Returns the indexes of the columns currently hidden + * Return the indexes of the columns currently hidden * @return {Array} column indexes */ getHiddenCols() { return this.hiddenCols; } - setHiddenCols(hiddenCols=[]){ - this.hiddenCols = hiddenCols; + /** + * Hide columns at start + */ + hideAtStart() { + if (!this.atStart) { + return; + } + let a = this.atStart; + for (let k = 0; k < a.length; k++) { + this.hideCol(a[k]); + } } /** @@ -513,8 +523,6 @@ export default class ColsVisibility { this.emitter.off(['hide-column'], (tf, colIndex) => this.hideCol(colIndex)); - this.emitter.off(['set-hidden-columns'], - (tf, hiddenCols) => this.setHiddenCols(hiddenCols)); this.initialized = false; } diff --git a/src/modules/state.js b/src/modules/state.js index ceccf999..14f64022 100644 --- a/src/modules/state.js +++ b/src/modules/state.js @@ -323,11 +323,7 @@ export class State extends Feature { } }); - console.log(hiddenCols); - this.emitter.emit('set-hidden-columns', tf, hiddenCols); - hiddenCols.forEach((colIdx) => { - console.log('hide', colIdx); this.emitter.emit('hide-column', tf, colIdx); }); }