diff --git a/components/member/List.vue b/components/member/List.vue index dbc583836489f8809c212c46c49667d2598d333d..df23d52dd11f83b61b0c647189a33d3d2e364c0c 100644 --- a/components/member/List.vue +++ b/components/member/List.vue @@ -146,6 +146,11 @@ export default { if (this.adhesion) return member.limitDate if (this.certif) return member.received_certifications.limit return Math.min(member.limitDate, member.received_certifications.limit) + }, + sort(a, b, order) { + if (a < b) return -1 * order + if (a > b) return 1 * order + return 0 } }, computed: { @@ -156,30 +161,18 @@ export default { let modifier = this.currentSortDir === "desc" ? -1 : 1 if (this.currentSort == "uid") { - if (a["uid"].toLowerCase() < b["uid"].toLowerCase()) - return -1 * modifier - if (a["uid"].toLowerCase() > b["uid"].toLowerCase()) - return 1 * modifier + sort(a["uid"].toLowerCase(), b["uid"].toLowerCase(), modifier) } else if (this.currentSort == "pubkey") { - if (a["pubkey"].toLowerCase() < b["pubkey"].toLowerCase()) - return -1 * modifier - if (a["pubkey"].toLowerCase() > b["pubkey"].toLowerCase()) - return 1 * modifier + sort(a["pubkey"].toLowerCase(), b["pubkey"].toLowerCase(), modifier) } else if (this.currentSort == "date_sortie") { if (this.adhesion) { - if (a["limitDate"] < b["limitDate"]) return -1 * modifier - if (a["limitDate"] > b["limitDate"]) return 1 * modifier + sort(a["limitDate"], b["limitDate"], modifier) } else if (this.certif) { - if ( - a["received_certifications"]["limit"] < - b["received_certifications"]["limit"] + sort( + a["received_certifications"]["limit"], + b["received_certifications"]["limit"], + modifier ) - return -1 * modifier - if ( - a["received_certifications"]["limit"] > - b["received_certifications"]["limit"] - ) - return 1 * modifier } else { let minA = Math.min( a["limitDate"], @@ -189,11 +182,9 @@ export default { b["limitDate"], b["received_certifications"]["limit"] ) - if (minA < minB) return -1 * modifier - if (minA > minB) return 1 * modifier + sort(minA, minB, modifier) } } - return 0 }) .filter((row, index) => {