From 0c644d54e1919122797c54e73beced21a3532f70 Mon Sep 17 00:00:00 2001 From: Julian Leucker <leuckerj@gmail.com> Date: Thu, 12 Sep 2024 14:09:51 +0200 Subject: [PATCH] Kind of display a working table in StatisticsForGroupTab.vue --- .../statistics/StatisticsForGroupTab.vue | 75 +++++++++++-------- .../coursebook/statistics/statistics.graphql | 16 ++-- 2 files changed, 53 insertions(+), 38 deletions(-) diff --git a/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsForGroupTab.vue b/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsForGroupTab.vue index 4ce43a122..c9dbcbc1e 100644 --- a/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsForGroupTab.vue +++ b/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsForGroupTab.vue @@ -1,6 +1,5 @@ <template> - <c-r-u-d-table - > + <c-r-u-d-list i18n-key="TODO" :headers="headers" :gql-query="gqlQuery" @@ -8,57 +7,69 @@ :enable-create="false" :enable-edit="false" :elevated="false" + :show-select="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 #header.person="header"> + Hello world + {{ header }} + </template> + + <template #person="{ item }"> + <v-avatar class="my-1 me-2"> + <avatar-content :id="item.person.id" /> + </v-avatar> + {{ item.person.fullName }} + </template> + </c-r-u-d-list> </template> <script> import groupOverviewTabMixin from "aleksis.core/mixins/groupOverviewTabMixin.js"; -import CRUDTable from "aleksis.core/components/generic/CRUDTable.vue"; +import CRUDList from "aleksis.core/components/generic/CRUDList.vue"; +import AvatarContent from "aleksis.core/components/person/AvatarContent.vue"; -import { documentationsByGroup } from "./statistics.graphql"; +import { statisticsByGroup } from "./statistics.graphql"; export default { name: "StatisticsForGroupTab", mixins: [groupOverviewTabMixin], components: { - CRUDTable, + AvatarContent, + CRUDList, }, data() { return { - gqlQuery: documentationsByGroup, + gqlQuery: statisticsByGroup, 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: "", - }, + return [ + { + text: this.$t("person.name"), + value: "person", + }, + ...(this.items.length > 0 ? [new Set(this.items.flatMap((person) => { + return person.absenceReasons.map((absence) => absence.absenceReason.shortName) + }))].map((name) => { + return { + text: name, + }; + }) : []), + ...(this.items.length > 0 ? [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 diff --git a/aleksis/apps/alsijil/frontend/components/coursebook/statistics/statistics.graphql b/aleksis/apps/alsijil/frontend/components/coursebook/statistics/statistics.graphql index 1da470c12..476209b10 100644 --- a/aleksis/apps/alsijil/frontend/components/coursebook/statistics/statistics.graphql +++ b/aleksis/apps/alsijil/frontend/components/coursebook/statistics/statistics.graphql @@ -1,4 +1,8 @@ fragment statistics on StatisticsByPersonType { + person { + id + fullName + } participationCount absenceCount absenceReasons { @@ -71,11 +75,11 @@ query documentationsByPerson($person: ID!, $term: ID) { } query statisticsByGroup($group: ID!, $term: ID) { - statistics: statisticsByGroup(group: $group, term: $term) { - persons { - id - fullName - ...statistics - } + items: statisticsByGroup(group: $group, term: $term) { +# persons { +# id +# fullName + ...statistics +# } } } -- GitLab