From 07e0af8704b1977efbf4cc178fa81c13715a9a10 Mon Sep 17 00:00:00 2001 From: tofulm Date: Mon, 25 Jan 2021 20:39:15 +0100 Subject: [PATCH] correction de la recup du localstorage, avec la nouvelle orgainisation du filtrage --- js/gamutable.es6.js | 31 ++++++++++++++++--------------- js/gamutable.js | 38 ++++++++++++++++++++++---------------- 2 files changed, 38 insertions(+), 31 deletions(-) diff --git a/js/gamutable.es6.js b/js/gamutable.es6.js index 2c2b044..3f91578 100644 --- a/js/gamutable.es6.js +++ b/js/gamutable.es6.js @@ -303,7 +303,7 @@ let monTableau = { header: this.header, crayons: this.crayons, classes: this.classes, - filtreCol: this.filtreCol, + filtreCol: this.filtreColType, }, ], ...this.table, @@ -360,21 +360,22 @@ let monTableau = { if (config.classes !== undefined) { this.classes = config.classes; } - // if (config.filtreCol !== undefined) { - // this.filtreCol = config.filtreCol; - // this.filtreCol.forEach((col) => { - // let Tval = ['']; - // this.table.forEach((t) => { - // let valCol = t.html[col]; - // if (Tval.indexOf(valCol) === -1) { - // Tval.push(valCol); - // } - // }); - // this.filtreColVal[col] = Tval; - // this.filtreColSelected[col] = []; - // }); - // } this.table = data; + if (config.filtreCol !== undefined) { + this.filtreColType = config.filtreCol; + Object.keys(this.filtreColType).forEach((col) => { + let Tval = ['']; + this.table.forEach((t) => { + let valCol = t.html[col]; + if (Tval.indexOf(valCol) === -1) { + Tval.push(valCol); + } + }); + this.filtreCol.push(col); + this.filtreColVal[col] = Tval; + this.filtreColSelected[col] = []; + }); + } if (data.length && data[0].search) { this.champ_search = 'search'; } diff --git a/js/gamutable.js b/js/gamutable.js index d648bc0..0ed3725 100644 --- a/js/gamutable.js +++ b/js/gamutable.js @@ -345,7 +345,7 @@ var monTableau = { header: this.header, crayons: this.crayons, classes: this.classes, - filtreCol: this.filtreCol + filtreCol: this.filtreColType }].concat(_toConsumableArray(this.table)); localStorage.setItem(this.nameLocalStorage, JSON.stringify($table)); }, @@ -411,24 +411,30 @@ var monTableau = { if (config.classes !== undefined) { this.classes = config.classes; - } // if (config.filtreCol !== undefined) { - // this.filtreCol = config.filtreCol; - // this.filtreCol.forEach((col) => { - // let Tval = ['']; - // this.table.forEach((t) => { - // let valCol = t.html[col]; - // if (Tval.indexOf(valCol) === -1) { - // Tval.push(valCol); - // } - // }); - // this.filtreColVal[col] = Tval; - // this.filtreColSelected[col] = []; - // }); - // } - + } this.table = data; + if (config.filtreCol !== undefined) { + this.filtreColType = config.filtreCol; + Object.keys(this.filtreColType).forEach(function (col) { + var Tval = ['']; + + _this4.table.forEach(function (t) { + var valCol = t.html[col]; + + if (Tval.indexOf(valCol) === -1) { + Tval.push(valCol); + } + }); + + _this4.filtreCol.push(col); + + _this4.filtreColVal[col] = Tval; + _this4.filtreColSelected[col] = []; + }); + } + if (data.length && data[0].search) { this.champ_search = 'search'; }