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 0000000000000000000000000000000000000000..4ce43a1225e1e3c66f1ea60f3f651a8144351dad --- /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 85df65a95f5aa38414a57ea6fe988305efdeccfc..9414ec16f7efdb4069a076d1f462a08da5d7cece 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 } }