CurrentModuleExecutionsRow.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <tr
  3. class="row"
  4. :class="[highlight ? 'italic bg-gray-300 dark:bg-gray-900' : '']"
  5. >
  6. <td
  7. class="cursor-pointer"
  8. @click="clickedRow"
  9. >
  10. {{ cls.executionTime }}
  11. </td>
  12. <td
  13. class="cursor-pointer"
  14. @click="clickedRow"
  15. >
  16. {{ cls.class }}
  17. </td>
  18. <td
  19. class="cursor-pointer"
  20. @click="clickedRow"
  21. >
  22. {{ cls.teachers.join(", ") }}
  23. </td>
  24. <td
  25. class="cursor-pointer"
  26. @click="clickedRow"
  27. >
  28. <span class="mr-2">{{ cls.rooms.join(", ") }}</span>
  29. <TeachingTypeIcon :teaching-type="cls.teaching_type" />
  30. </td>
  31. <td>
  32. <button
  33. :title="addRemoveClassTitle(cls.module, classChosen)"
  34. class="action-button"
  35. :disabled="cls.module?.hasCompleted || cls.module?.maxAttemptsReached"
  36. @click="toggleClassState"
  37. >
  38. <font-awesome-icon
  39. v-if="addable"
  40. icon="fa-solid fa-plus"
  41. />
  42. <font-awesome-icon
  43. v-else
  44. icon="fa-solid fa-minus"
  45. />
  46. </button>
  47. <a
  48. title="Klassen PDF in einem neuem Tab öffnen"
  49. target="_blank"
  50. :href="classesPDFLink(cls)"
  51. >
  52. <button
  53. class="action-button"
  54. title="Klassen PDF in einem neuem Tab öffnen"
  55. >
  56. <!-- I just gave up styling the link... -->
  57. <font-awesome-icon icon="fa-solid fa-file-pdf" />
  58. </button>
  59. </a>
  60. </td>
  61. </tr>
  62. </template>
  63. <script lang="ts">
  64. import { PropType } from "vue";
  65. import { addRemoveClassTitle, classesPDFLink } from "../../helpers";
  66. import { usePlanningStore } from "../../stores/planning";
  67. import { useStateStore } from "../../stores/state";
  68. import TeachingTypeIcon from "../general/TeachingTypeIcon.vue";
  69. import { TaughtClass } from "../../api/types/semesters/versions/class";
  70. export default {
  71. name: "CurrentModuleExecutionsRow",
  72. components: { TeachingTypeIcon },
  73. props: {
  74. cls: {
  75. required: true,
  76. type: Object as PropType<TaughtClass>,
  77. },
  78. highlight: {
  79. required: false,
  80. type: Boolean,
  81. default: false,
  82. },
  83. },
  84. setup() {
  85. const planningStore = usePlanningStore();
  86. const stateStore = useStateStore();
  87. return {
  88. planningStore,
  89. stateStore,
  90. classesPDFLink,
  91. addRemoveClassTitle,
  92. };
  93. },
  94. computed: {
  95. classChosen(): boolean {
  96. return this.planningStore.isModuleChosen(this.cls);
  97. },
  98. addable(): boolean {
  99. return !this.classChosen || (this.cls.module?.hasCompleted ?? false);
  100. },
  101. },
  102. methods: {
  103. toggleClassState() {
  104. if (this.classChosen) this.planningStore.remove(this.cls);
  105. else this.planningStore.add(this.cls);
  106. },
  107. clickedRow() {
  108. this.stateStore.inspectingClass = this.cls;
  109. this.stateStore.inspectingModule = null;
  110. },
  111. },
  112. };
  113. </script>
  114. <style scoped>
  115. .row {
  116. @apply border-b
  117. dark:border-gray-500
  118. hover:bg-slate-200
  119. dark:hover:bg-gray-700
  120. transition-all
  121. duration-100;
  122. }
  123. .module-table td {
  124. @apply border-x border-gray-300 dark:border-gray-500 h-11;
  125. }
  126. .action-button {
  127. @apply rounded-lg
  128. aspect-square
  129. inline-block
  130. w-6
  131. text-xs
  132. md:w-8
  133. md:text-base
  134. hover:bg-gray-300
  135. active:bg-gray-300
  136. dark:hover:bg-gray-500
  137. dark:active:bg-gray-600
  138. mx-0.5
  139. transition-all
  140. duration-200
  141. disabled:hover:bg-inherit
  142. disabled:text-gray-300
  143. disabled:dark:text-gray-500
  144. cursor-pointer;
  145. }
  146. </style>