diff --git a/aleksis/apps/chronos/frontend/components/substitutions/SubstitutionCard.vue b/aleksis/apps/chronos/frontend/components/substitutions/SubstitutionCard.vue index 55736c9790837c674d9decba0dcacb2ae288c781..8284ac6548d95bec437b46a58d9a1eba73d27a9f 100644 --- a/aleksis/apps/chronos/frontend/components/substitutions/SubstitutionCard.vue +++ b/aleksis/apps/chronos/frontend/components/substitutions/SubstitutionCard.vue @@ -331,10 +331,13 @@ export default { substitutionRoomIDs() { return this.substitution.rooms.map((room) => room.id); }, + // Group teachers by their substitution status (regular, new, removed) teachersWithStatus() { + // IDs of teachers of amended lesson const oldIds = this.substitution.amends.teachers.map( (teacher) => teacher.id, ); + // IDs of teachers of new substitution lesson const newIds = this.substitution.teachers.map((teacher) => teacher.id); const allTeachers = new Set( this.substitution.amends.teachers.concat(this.substitution.teachers), @@ -342,11 +345,13 @@ export default { let teachersWithStatus = Array.from(allTeachers).map((teacher) => { let status = "regular"; if (newIds.includes(teacher.id) && !oldIds.includes(teacher.id)) { + // Mark teacher as being new if they are only linked to the substitution lesson status = "new"; } else if ( !newIds.includes(teacher.id) && oldIds.includes(teacher.id) ) { + // Mark teacher as being rremoved if they are only linked to the amended lesson status = "removed"; } return { ...teacher, status: status };