Mercurial > gemma
changeset 2503:51dbcbf11c5f critical-bottlenecks
client: addendum for e13daf439068
Of course, as you'd expect, this only solves the problem if you don't care about
significant changes in the tables sorting behavior. To point out the difference
this commit shows the other way to solve the problem without changing the tables
behavior.
author | Markus Kottlaender <markus@intevation.de> |
---|---|
date | Mon, 04 Mar 2019 16:28:49 +0100 |
parents | e13daf439068 |
children | 89c439721db2 |
files | client/src/components/usermanagement/Usermanagement.vue |
diffstat | 1 files changed, 14 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/components/usermanagement/Usermanagement.vue Mon Mar 04 16:20:57 2019 +0100 +++ b/client/src/components/usermanagement/Usermanagement.vue Mon Mar 04 16:28:49 2019 +0100 @@ -171,13 +171,20 @@ ...mapState("application", ["showSidebar"]), sortedUsers() { const start = (this.currentPage - 1) * this.pageSize; - return this.users.slice(start, start + this.pageSize).sort((a, b) => { - if (a[this.sortColumn].toLowerCase() < b[this.sortColumn].toLowerCase()) - return this.sortDirection === "ASC" ? -1 : 1; - if (a[this.sortColumn].toLowerCase() > b[this.sortColumn].toLowerCase()) - return this.sortDirection === "ASC" ? 1 : -1; - return 0; - }); + return this.users + .filter(u => u) // to clone the array and leave the original store value intact + .sort((a, b) => { + if ( + a[this.sortColumn].toLowerCase() < b[this.sortColumn].toLowerCase() + ) + return this.sortDirection === "ASC" ? -1 : 1; + if ( + a[this.sortColumn].toLowerCase() > b[this.sortColumn].toLowerCase() + ) + return this.sortDirection === "ASC" ? 1 : -1; + return 0; + }) + .slice(start, start + this.pageSize); }, pages() { return Math.ceil(this.users.length / this.pageSize);