Skip to content

Commit

Permalink
sort isTeacher and isAdmin with true first
Browse files Browse the repository at this point in the history
  • Loading branch information
reyniersbram committed Apr 19, 2024
1 parent 633338e commit 51dcbd2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions frontend/src/views/AdminView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ const { data: users, isLoading: isUsersLoading } = useUsersQuery();
const { mutateAsync: toggleAdmin } = useToggleAdminMutation();
const { mutateAsync: toggleTeacher } = useToggleTeacherMutation();
/**
* Sorts boolean values in descending order.
*/
function sortBool(a: boolean, b: boolean): number {
return a === b ? 0 : a ? -1 : 1;
}
const search = ref("");
const sortBy = ref([{ key: "given_name", order: "asc" }]);
Expand Down Expand Up @@ -95,13 +102,15 @@ const headers = ref([
sortable: true,
filterable: false,
filter: () => true, // disable filter
sort: sortBool,
},
{
title: computed(() => t("admin.userTable.isAdmin")),
key: "is_admin",
sortable: true,
filterable: false,
filter: () => true, // disable filter
sort: sortBool,
},
]);
</script>
Expand Down

0 comments on commit 51dcbd2

Please sign in to comment.