Optimisation, si pas de caractere, on ne passe pas dans le filtre

This commit is contained in:
Christophe 2020-05-06 23:46:54 +02:00
parent ef82382f33
commit 99a6444c39
2 changed files with 11 additions and 12 deletions

View file

@ -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
)
);
},
},

View file

@ -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;
}));
}
},