From 51c8058404af0c750bd4fb23a5ccad8b86476058 Mon Sep 17 00:00:00 2001
From: Hangzhi Yu <hangzhi@protonmail.com>
Date: Wed, 15 May 2024 02:03:38 +0200
Subject: [PATCH] Tidy up information component

---
 .../substitutions/SubstitutionCard.vue        |  4 +-
 ...mation.vue => SubstitutionInformation.vue} | 44 +++++++------------
 2 files changed, 19 insertions(+), 29 deletions(-)
 rename aleksis/apps/chronos/frontend/components/substitutions/{LessonInformation.vue => SubstitutionInformation.vue} (57%)

diff --git a/aleksis/apps/chronos/frontend/components/substitutions/SubstitutionCard.vue b/aleksis/apps/chronos/frontend/components/substitutions/SubstitutionCard.vue
index 5194dd19..f25ca04a 100644
--- a/aleksis/apps/chronos/frontend/components/substitutions/SubstitutionCard.vue
+++ b/aleksis/apps/chronos/frontend/components/substitutions/SubstitutionCard.vue
@@ -1,6 +1,6 @@
 <script setup>
 import DeleteButton from "aleksis.core/components/generic/buttons/DeleteButton.vue";
-import LessonInformation from "./LessonInformation.vue";
+import SubstitutionInformation from "./SubstitutionInformation.vue";
 import LessonRelatedObjectChip from "../LessonRelatedObjectChip.vue";
 
 import { gqlPersons } from "../amendLesson.graphql";
@@ -18,7 +18,7 @@ import createOrPatchMixin from "aleksis.core/mixins/createOrPatchMixin.js";
         vertical: $vuetify.breakpoint.mobile,
       }"
     >
-      <lesson-information :lesson="substitution" />
+      <substitution-information :substitution="substitution" />
 
       <v-spacer />
 
diff --git a/aleksis/apps/chronos/frontend/components/substitutions/LessonInformation.vue b/aleksis/apps/chronos/frontend/components/substitutions/SubstitutionInformation.vue
similarity index 57%
rename from aleksis/apps/chronos/frontend/components/substitutions/LessonInformation.vue
rename to aleksis/apps/chronos/frontend/components/substitutions/SubstitutionInformation.vue
index 62f2857c..00b44118 100644
--- a/aleksis/apps/chronos/frontend/components/substitutions/LessonInformation.vue
+++ b/aleksis/apps/chronos/frontend/components/substitutions/SubstitutionInformation.vue
@@ -8,7 +8,7 @@ import { DateTime } from "luxon";
 <template>
   <div class="full-width grid">
     <div class="d-flex">
-      <v-tooltip bottom v-if="lesson.cancelled">
+      <v-tooltip bottom v-if="substitution.cancelled">
         <template #activator="{ on, attrs }">
           <v-icon color="error" class="mr-md-4" v-on="on" v-bind="attrs"
             >mdi-cancel</v-icon
@@ -17,11 +17,11 @@ import { DateTime } from "luxon";
         <span>{{ $t("chronos.event.amend.cancelled") }}</span>
       </v-tooltip>
       <div class="text-right d-flex flex-column fit-content">
-        <time :datetime="lesson.datetimeStart" class="text-no-wrap">
-          {{ $d(toDateTime(lesson.datetimeStart), "shortTime") }}
+        <time :datetime="substitution.datetimeStart" class="text-no-wrap">
+          {{ $d(toDateTime(substitution.datetimeStart), "shortTime") }}
         </time>
-        <time :datetime="lesson.datetimeEnd" class="text-no-wrap">
-          {{ $d(toDateTime(lesson.datetimeEnd), "shortTime") }}
+        <time :datetime="substitution.datetimeEnd" class="text-no-wrap">
+          {{ $d(toDateTime(substitution.datetimeEnd), "shortTime") }}
         </time>
       </div>
     </div>
@@ -30,25 +30,15 @@ import { DateTime } from "luxon";
     </span>
     <div class="d-flex align-center flex-wrap gap justify-center">
       <subject-chip v-if="subject" :subject="subject" />
-      <!--<subject-chip-->
-      <!--  v-if="-->
-      <!--    documentation?.lessonEvent?.amends?.subject &&-->
-      <!--    documentation.lessonEvent.amends.subject.id !==-->
-      <!--      documentation.subject.id-->
-      <!--  "-->
-      <!--  :subject="documentation.lessonEvent.amends.subject"-->
-      <!--  class="text-decoration-line-through"-->
-      <!--  disabled-->
-      <!--/>-->
     </div>
   </div>
 </template>
 
 <script>
 export default {
-  name: "LessonInformation",
+  name: "SubstitutionInformation",
   props: {
-    lesson: {
+    substitution: {
       type: Object,
       required: true,
     },
@@ -60,19 +50,19 @@ export default {
   },
   computed: {
     subject() {
-      return this.lesson.subject
-        ? this.lesson.subject
-        : this.lesson.course?.subject
-          ? this.lesson.course.subject
-          : this.lesson.amends?.subject
-            ? this.lesson.amends.subject
+      return this.substitution.subject
+        ? this.substitution.subject
+        : this.substitution.course?.subject
+          ? this.substitution.course.subject
+          : this.substitution.amends?.subject
+            ? this.substitution.amends.subject
             : undefined;
     },
     course() {
-      return this.lesson.course
-        ? this.lesson.course
-        : this.lesson.amends?.course
-          ? this.lesson.amends.course
+      return this.substitution.course
+        ? this.substitution.course
+        : this.substitution.amends?.course
+          ? this.substitution.amends.course
           : undefined;
     },
   },
-- 
GitLab