From 99a6444c3954903522522488c6aedf2f868ad8ff Mon Sep 17 00:00:00 2001 From: tofulm Date: Wed, 6 May 2020 23:46:54 +0200 Subject: [PATCH] Optimisation, si pas de caractere, on ne passe pas dans le filtre --- js/gamutable.es6.js | 13 ++++++------- js/gamutable.js | 10 +++++----- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/js/gamutable.es6.js b/js/gamutable.es6.js index 24204aa..5fcc38b 100644 --- a/js/gamutable.es6.js +++ b/js/gamutable.es6.js @@ -109,14 +109,13 @@ let monTableau = { }, computed: { tableau: function () { + if (!this.search) { + return this.pagination(this.table); + } return this.pagination( - this.table.filter((ligne) => { - if (this.search) { - return Object.values(ligne).toString().toLowerCase().indexOf(this.search) < 0 ? false : true; - } else { - return true; - } - }) + this.table.filter((ligne) => + Object.values(ligne).toString().toLowerCase().indexOf(this.search.toLowerCase()) < 0 ? false : true + ) ); }, }, diff --git a/js/gamutable.js b/js/gamutable.js index d2b5f84..8f48909 100644 --- a/js/gamutable.js +++ b/js/gamutable.js @@ -130,12 +130,12 @@ var monTableau = { tableau: function tableau() { var _this = this; + if (!this.search) { + return this.pagination(this.table); + } + return this.pagination(this.table.filter(function (ligne) { - if (_this.search) { - return Object.values(ligne).toString().toLowerCase().indexOf(_this.search) < 0 ? false : true; - } else { - return true; - } + return Object.values(ligne).toString().toLowerCase().indexOf(_this.search.toLowerCase()) < 0 ? false : true; })); } },