From 6173292704059107b5b76c64b7ffe12670a2b148 Mon Sep 17 00:00:00 2001
From: Julian Leucker <leuckerj@gmail.com>
Date: Wed, 6 Nov 2024 12:45:43 +0100
Subject: [PATCH] Fix statistics translations

---
 .../statistics/StatisticsForPersonCard.vue    |  2 +-
 .../statistics/StatisticsForPersonPage.vue    | 23 ++++++++++++++++++-
 .../coursebook/statistics/statistics.graphql  |  7 ++++++
 .../apps/alsijil/frontend/messages/de.json    |  5 ++--
 .../apps/alsijil/frontend/messages/en.json    |  5 ++--
 5 files changed, 36 insertions(+), 6 deletions(-)

diff --git a/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsForPersonCard.vue b/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsForPersonCard.vue
index 130b4c9b1..b857a1ba5 100644
--- a/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsForPersonCard.vue
+++ b/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsForPersonCard.vue
@@ -21,7 +21,7 @@
       />
     </v-card-title>
     <v-card-title v-else>
-      {{ $t("alsijil.coursebook.statistics.person_page.title") }}
+      {{ $t("alsijil.coursebook.statistics.title_plural") }}
     </v-card-title>
 
     <v-card-text>
diff --git a/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsForPersonPage.vue b/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsForPersonPage.vue
index b372e3917..af1858baa 100644
--- a/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsForPersonPage.vue
+++ b/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsForPersonPage.vue
@@ -10,7 +10,7 @@
         <school-term-field v-model="schoolTerm" :enable-create="false" />
         <!-- documentations for person list -->
         <c-r-u-d-iterator
-          i18n-key="TODO"
+          i18n-key="alsijil.coursebook.statistics"
           :gql-query="gqlQuery"
           :gql-additional-query-args="gqlQueryArgs"
           :enable-create="false"
@@ -133,6 +133,7 @@ import StatisticsForPersonCard from "./StatisticsForPersonCard.vue";
 import {
   participationsOfPerson,
   personalNotesForPerson,
+  personName,
 } from "./statistics.graphql";
 import { DateTime } from "luxon";
 import ExtraMarkChip from "../../extra_marks/ExtraMarkChip.vue";
@@ -165,6 +166,26 @@ export default {
       required: true,
     },
   },
+  apollo: {
+    personName: {
+      query: personName,
+      variables() {
+        return {
+          person: this.personId,
+        };
+      },
+      result({ data }) {
+        this.$setToolBarTitle(
+          this.$t(
+            "alsijil.coursebook.statistics.person_page.title",
+            {
+              fullName: data.personName.fullName || "???",
+            },
+          )
+        );
+      },
+    },
+  },
   data() {
     return {
       mode: MODE.PARTICIPATIONS,
diff --git a/aleksis/apps/alsijil/frontend/components/coursebook/statistics/statistics.graphql b/aleksis/apps/alsijil/frontend/components/coursebook/statistics/statistics.graphql
index 38d8817b8..68e0a08ca 100644
--- a/aleksis/apps/alsijil/frontend/components/coursebook/statistics/statistics.graphql
+++ b/aleksis/apps/alsijil/frontend/components/coursebook/statistics/statistics.graphql
@@ -110,3 +110,10 @@ query statisticsByGroup($group: ID!, $term: ID) {
     #    }
   }
 }
+
+query personName($person: ID!) {
+  personName: personById(id: $person) {
+    id
+    fullName
+  }
+}
diff --git a/aleksis/apps/alsijil/frontend/messages/de.json b/aleksis/apps/alsijil/frontend/messages/de.json
index b3072a421..64d53a19e 100644
--- a/aleksis/apps/alsijil/frontend/messages/de.json
+++ b/aleksis/apps/alsijil/frontend/messages/de.json
@@ -96,8 +96,9 @@
           "title": "Kursbuch · Statistiken"
         },
         "person_page": {
-          "title": "Statistiken"
-        }
+          "title": "Kursbuch · Statistiken · {fullName}"
+        },
+        "title_plural": "Statistiken"
       }
     },
     "excuse_types": {
diff --git a/aleksis/apps/alsijil/frontend/messages/en.json b/aleksis/apps/alsijil/frontend/messages/en.json
index 4cb74d6bc..e1af3ea7c 100644
--- a/aleksis/apps/alsijil/frontend/messages/en.json
+++ b/aleksis/apps/alsijil/frontend/messages/en.json
@@ -154,9 +154,10 @@
           "title": "Coursebook · Statistics"
         },
         "person_page": {
-          "title": "Statistics"
+          "title": "Coursebook · Statistics · {fullName}"
         },
-        "person_view_details": "Details"
+        "person_view_details": "Details",
+        "title_plural": "Statistics"
       },
       "personal_notes": "Personal Notes"
     }
-- 
GitLab