Skip to content
Snippets Groups Projects
LessonNotes.vue 1.4 KiB
Newer Older
<script setup>
import AbsenceReasonChip from "aleksis.apps.kolego/components/AbsenceReasonChip.vue";
</script>

permcu's avatar
permcu committed
<template>
Hangzhi Yu's avatar
Hangzhi Yu committed
    class="d-flex align-center justify-space-between justify-md-end flex-wrap gap"
  >
    <v-chip dense color="success" outlined v-if="total > 0">
Hangzhi Yu's avatar
Hangzhi Yu committed
      {{ $t("alsijil.coursebook.present_number", { present, total }) }}
    <absence-reason-chip
      v-for="participation in absences"
      :absence-reason="participation.absenceReason"
      dense
    >
Hangzhi Yu's avatar
Hangzhi Yu committed
      <template #prepend> {{ participation.person.fullName }}: </template>
    </absence-reason-chip>

    <manage-students-trigger v-bind="documentationPartProps" />
permcu's avatar
permcu committed
</template>

<script>
import documentationPartMixin from "./documentationPartMixin";
import ManageStudentsTrigger from "../absences/ManageStudentsTrigger.vue";
permcu's avatar
permcu committed
export default {
  name: "LessonNotes",
  components: { ManageStudentsTrigger },
  mixins: [documentationPartMixin],
  computed: {
    total() {
      return this.documentation.participations.length;
    },
    present() {
Hangzhi Yu's avatar
Hangzhi Yu committed
      return this.documentation.participations.filter(
        (p) => p.absenceReason === null,
      ).length;
    },
    absences() {
      // Get all course attendants who have an absence reason
Hangzhi Yu's avatar
Hangzhi Yu committed
      return this.documentation.participations.filter(
        (p) => p.absenceReason !== null,
      );
permcu's avatar
permcu committed
};
</script>

<style scoped>
.gap {
Julian's avatar
Julian committed
  gap: 0.25em;