1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-06-06 07:52:29 +02:00

Continued columns visibility persistence

This commit is contained in:
Max Guglielmi 2016-04-20 10:41:20 +02:00
parent ae6c2eee6b
commit f3760a0dcd
4 changed files with 54 additions and 49 deletions

View file

@ -7943,11 +7943,7 @@ return /******/ (function(modules) { // webpackBootstrap
} }
}); });
console.log(hiddenCols);
this.emitter.emit('set-hidden-columns', tf, hiddenCols);
hiddenCols.forEach(function (colIdx) { hiddenCols.forEach(function (colIdx) {
console.log('hide', colIdx);
_this6.emitter.emit('hide-column', tf, colIdx); _this6.emitter.emit('hide-column', tf, colIdx);
}); });
}; };

View file

@ -1129,10 +1129,11 @@ webpackJsonp([1],{
this.emitter.on(['hide-column'], function (tf, colIndex) { this.emitter.on(['hide-column'], function (tf, colIndex) {
return _this.hideCol(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); 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.btnEl.parentNode.insertBefore(container, this.btnEl);
this.contEl = container; this.contEl = container;
if (this.atStart) { // if (this.atStart) {
var a = this.atStart; // let a = this.atStart;
for (var k = 0; k < a.length; k++) { // for (let k = 0; k < a.length; k++) {
// let itm = Dom.id('col_' + a[k] + '_' + tf.id); // // let itm = Dom.id('col_' + a[k] + '_' + tf.id);
// if (itm) { // // if (itm) {
// itm.click(); // // itm.click();
// } // // }
this.hideCol(a[k]); // this.hideCol(a[k]);
} // }
} // }
}; };
/** /**
@ -1412,7 +1413,6 @@ webpackJsonp([1],{
ColsVisibility.prototype.hideCol = function hideCol(colIndex) { ColsVisibility.prototype.hideCol = function hideCol(colIndex) {
console.log(colIndex);
if (colIndex === undefined || this.isColHidden(colIndex)) { if (colIndex === undefined || this.isColHidden(colIndex)) {
return; return;
} }
@ -1422,7 +1422,6 @@ webpackJsonp([1],{
itm.click(); itm.click();
} }
} else { } else {
console.log(colIndex, this.isColHidden(colIndex));
this.setHidden(colIndex, true); 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 * @return {Array} column indexes
*/ */
@ -1464,10 +1463,19 @@ webpackJsonp([1],{
return this.hiddenCols; 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) { this.emitter.off(['hide-column'], function (tf, colIndex) {
return _this4.hideCol(colIndex); return _this4.hideCol(colIndex);
}); });
this.emitter.off(['set-hidden-columns'], function (tf, hiddenCols) {
return _this4.setHiddenCols(hiddenCols);
});
this.initialized = false; this.initialized = false;
}; };

View file

@ -181,9 +181,11 @@ export default class ColsVisibility {
this.emitter.on(['hide-column'], this.emitter.on(['hide-column'],
(tf, colIndex) => this.hideCol(colIndex)); (tf, colIndex) => this.hideCol(colIndex));
this.emitter.on(['set-hidden-columns'],
(tf, hiddenCols) => this.setHiddenCols(hiddenCols));
this.emitter.emit('columns-visibility-initialized', tf, this); 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.btnEl.parentNode.insertBefore(container, this.btnEl);
this.contEl = container; this.contEl = container;
if (this.atStart) { // if (this.atStart) {
let a = this.atStart; // let a = this.atStart;
for (let k = 0; k < a.length; k++) { // for (let k = 0; k < a.length; k++) {
// let itm = Dom.id('col_' + a[k] + '_' + tf.id); // // let itm = Dom.id('col_' + a[k] + '_' + tf.id);
// if (itm) { // // if (itm) {
// itm.click(); // // itm.click();
// } // // }
this.hideCol(a[k]); // this.hideCol(a[k]);
} // }
} // }
} }
/** /**
@ -443,7 +445,7 @@ export default class ColsVisibility {
* Hide specified column * Hide specified column
* @param {Number} colIndex Column index * @param {Number} colIndex Column index
*/ */
hideCol(colIndex) {console.log(colIndex); hideCol(colIndex) {
if (colIndex === undefined || this.isColHidden(colIndex)) { if (colIndex === undefined || this.isColHidden(colIndex)) {
return; return;
} }
@ -453,7 +455,6 @@ export default class ColsVisibility {
itm.click(); itm.click();
} }
} else { } else {
console.log(colIndex, this.isColHidden(colIndex));
this.setHidden(colIndex, true); 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 * @return {Array} column indexes
*/ */
getHiddenCols() { getHiddenCols() {
return this.hiddenCols; 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'], this.emitter.off(['hide-column'],
(tf, colIndex) => this.hideCol(colIndex)); (tf, colIndex) => this.hideCol(colIndex));
this.emitter.off(['set-hidden-columns'],
(tf, hiddenCols) => this.setHiddenCols(hiddenCols));
this.initialized = false; this.initialized = false;
} }

View file

@ -323,11 +323,7 @@ export class State extends Feature {
} }
}); });
console.log(hiddenCols);
this.emitter.emit('set-hidden-columns', tf, hiddenCols);
hiddenCols.forEach((colIdx) => { hiddenCols.forEach((colIdx) => {
console.log('hide', colIdx);
this.emitter.emit('hide-column', tf, colIdx); this.emitter.emit('hide-column', tf, colIdx);
}); });
} }