From c3d4e37861e820f384af23342f92ff662952ef14 Mon Sep 17 00:00:00 2001
From: Michael Bauer <michael-bauer@posteo.de>
Date: Fri, 31 May 2024 14:01:25 +0200
Subject: [PATCH] Integrate StatisticsForPersonPage

---
 .../statistics/StatisticsForPersonCard.vue         | 14 ++++++++++++++
 .../statistics/StatisticsForPersonPage.vue         | 13 +++++++++++--
 aleksis/apps/alsijil/frontend/index.js             | 13 +++++++++++++
 3 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsForPersonCard.vue b/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsForPersonCard.vue
index 912f7f875..b34401b9e 100644
--- a/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsForPersonCard.vue
+++ b/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsForPersonCard.vue
@@ -10,6 +10,7 @@
         :icon="true"
         icon-text="mdi-open-in-new"
         i18n-key=""
+        @click="switchToOwnPage"
       />
     </v-card-title>
     <v-card-title v-else>
@@ -84,5 +85,18 @@ export default {
       },
     },
   },
+  methods: {
+    switchToOwnPage() {
+      this.$router.push({
+        name: "alsijil.coursebook_statistics",
+        params: {
+          personId: this.person.id,
+          schoolTermId: this.statistics.schoolTerm,
+        },
+        // TODO: Add where we came from as get parameter if
+        //       meeting decided that own page.
+      });
+    },
+  },
 };
 </script>
diff --git a/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsForPersonPage.vue b/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsForPersonPage.vue
index 8625ae4ed..dee6974a3 100644
--- a/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsForPersonPage.vue
+++ b/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsForPersonPage.vue
@@ -4,8 +4,8 @@
   <!-- documentations statistics list -->
   <statistics-for-person-card
     :compact="false"
-    :personId="TODO"
-    :schoolTermId="TODO"
+    :person="{ id: personId }"
+    :school-term="{ id: schoolTermId }"
   />
 </template>
 
@@ -18,6 +18,15 @@ export default {
     StatisticsForPersonCard,
   },
   props: {
+    // personId & schoolTermId are supplied via the url
+    personId: {
+      type: [Number, String],
+      required: true,
+    },
+    schoolTermId: {
+      type: [Number, String],
+      required: true,
+    },
   },
 };
 </script>
diff --git a/aleksis/apps/alsijil/frontend/index.js b/aleksis/apps/alsijil/frontend/index.js
index 20318ea59..fac7721f6 100644
--- a/aleksis/apps/alsijil/frontend/index.js
+++ b/aleksis/apps/alsijil/frontend/index.js
@@ -104,5 +104,18 @@ export default {
         permission: "alsijil.view_documentations_menu_rule",
       },
     },
+    {
+      path: "statistics/:personId/:schoolTermId/",
+      component: () => import("./components/coursebook/statistics/StatisticsForPersonPage.vue"),
+      name: "alsijil.coursebook_statistics",
+      props: true,
+      meta: {
+        inMenu: false,
+        titleKey: "alsijil.coursebook.statistics.person_compact.title",
+        toolbarTitle: "alsijil.coursebook.statistics.person_compact.title",
+        // TODO: Add permission & change it here.
+        permission: "alsijil.view_documentations_menu_rule",
+      },
+    },
   ],
 };
-- 
GitLab