From f25e699bab0677120e244c6c0c386750d5ce2bde Mon Sep 17 00:00:00 2001
From: Michael Bauer <michael-bauer@posteo.de>
Date: Fri, 11 Oct 2024 14:15:56 +0200
Subject: [PATCH] Implement groups-field

---
 .../frontend/components/Substitutions.vue     | 25 ++++++++++---------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/aleksis/apps/chronos/frontend/components/Substitutions.vue b/aleksis/apps/chronos/frontend/components/Substitutions.vue
index 45396aa6..3a668efa 100644
--- a/aleksis/apps/chronos/frontend/components/Substitutions.vue
+++ b/aleksis/apps/chronos/frontend/components/Substitutions.vue
@@ -11,7 +11,18 @@ import CRUDList from "aleksis.core/components/generic/CRUDList.vue";
     :show-select="false"
     :enable-create="false"
     :enable-edit="false"
-  />
+  >
+    <template #groups="{ item: { oldGroups, newGroups } }">
+      <span v-if="newGroups.length > 0">
+        <strike v-for="g in oldGroups"> {{ g.shortName }} </strike>
+        <span> &nbsp;→&nbsp </span>
+        <b v-for="g in newGroups"> {{ g.shortName }} </b>
+      </span>
+      <span
+        v-else
+        v-for="g in oldGroups"
+      > {{ g.shortName }} </span>
+    </template>
   </c-r-u-d-list>
 </template>
 
@@ -65,17 +76,7 @@ export default {
     prepareList(data) {
       this.affectedTeachers = data.affectedTeachers;
       this.affectedGroups = data.affectedGroups;
-
-      return data.substitutions.map((sub) => {
-        return {
-          groups: sub.oldGroups[0].shortName,
-          time: sub.startTime,
-          teachers: sub.oldTeachers[0].shortName,
-          subject: sub.oldSubject,
-          room: sub.oldRooms[0].shortName,
-          notes: sub.comment,
-        };
-      });
+      return data.substitutions;
     },
   },
 };
-- 
GitLab