From d2044975dbc9a80bf6fc3f22007f97c338c7bec4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Sun, 18 Apr 2021 11:20:46 +0200 Subject: [PATCH] [balance] sortable balance in adminpage --- src/plugins/balance/pages/Admin.vue | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/plugins/balance/pages/Admin.vue b/src/plugins/balance/pages/Admin.vue index a99bee2..1d7d96c 100644 --- a/src/plugins/balance/pages/Admin.vue +++ b/src/plugins/balance/pages/Admin.vue @@ -140,14 +140,27 @@ export default defineComponent({ name: 'limit', label: 'Limit', align: 'right', + field: 'userid', format: (_: undefined, row: { userid: string }) => getLimit(row.userid), }, { name: 'balance', label: 'Kontostand', align: 'right', + field: 'userid', format: (_: undefined, row: { debit: number; credit: number }) => getBalance(row.debit, row.credit), + sortable: true, + sort: ( + _: undefined, + __: undefined, + a: { debit: number; credit: number }, + b: { debit: number; credit: number } + ) => { + return ( + parseFloat(getBalance(a.debit, a.credit)) - parseFloat(getBalance(b.debit, b.credit)) + ); + }, }, ];