From 0afdb47fa202326d13555991d6708da77ec01b89 Mon Sep 17 00:00:00 2001 From: Michael Bauer <michael-bauer@posteo.de> Date: Tue, 4 Jun 2024 22:19:13 +0200 Subject: [PATCH] WIP Implement StatisticsForGroupTab --- .../statistics/StatisticsForGroupTab.vue | 74 +++++++++++++++++++ .../coursebook/statistics/statistics.graphql | 3 +- 2 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsForGroupTab.vue diff --git a/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsForGroupTab.vue b/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsForGroupTab.vue new file mode 100644 index 000000000..4ce43a122 --- /dev/null +++ b/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsForGroupTab.vue @@ -0,0 +1,74 @@ +<template> + <c-r-u-d-table + > + i18n-key="TODO" + :headers="headers" + :gql-query="gqlQuery" + :gql-additional-query-args="gqlQueryArgs" + :enable-create="false" + :enable-edit="false" + :elevated="false" + @items="items = $event" + > + <template #header="{ }"> + <thead> + <tr> + <!-- https://stackoverflow.com/questions/55702916/is-it-possible-to-create-a-multi-line-header-in-a-vuetify-datatable --> + </c-r-u-d-table> +</template> + +<script> +import groupOverviewTabMixin from "aleksis.core/mixins/groupOverviewTabMixin.js"; +import CRUDTable from "aleksis.core/components/generic/CRUDTable.vue"; + +import { documentationsByGroup } from "./statistics.graphql"; + +export default { + name: "StatisticsForGroupTab", + mixins: [groupOverviewTabMixin], + components: { + CRUDTable, + }, + data() { + return { + gqlQuery: documentationsByGroup, + items: [], + }; + }, + computed: { + headers() { + // TODO: i18n + { + text: "name", + value: "fullName", + }, + ...[new Set(this.items.flatMap((person) => { + return person.absenceReasons.map((absence) => absence.absenceReason.shortName) + }))].map((name) => { + return { + text: name, + }; + }), + ...[new Set(this.items.flatMap((person) => { + return person.extraMarks.map((extraMark) => extraMark.extraMark.shortName) + }))].map((name) => { + return { + text: name, + }; + }), + { + text: "", + }, + }, + gqlQueryArgs() { + const term = this.schoolTerm + ? { term: this.schoolTerm.id } + : {}; + return { + group: this.group.id, + ...term, + }; + }, + }, +}; +</script> diff --git a/aleksis/apps/alsijil/frontend/components/coursebook/statistics/statistics.graphql b/aleksis/apps/alsijil/frontend/components/coursebook/statistics/statistics.graphql index 85df65a95..9414ec16f 100644 --- a/aleksis/apps/alsijil/frontend/components/coursebook/statistics/statistics.graphql +++ b/aleksis/apps/alsijil/frontend/components/coursebook/statistics/statistics.graphql @@ -93,8 +93,7 @@ query statisticsByGroup ( ) { persons { id - firstName - lastName + fullName ...statistics } } -- GitLab