Skip to content
Snippets Groups Projects
Commit 83832f8b authored by Hangzhi Yu's avatar Hangzhi Yu
Browse files

Add some explaining comments

parent 046f9821
No related branches found
No related tags found
1 merge request!329Introduce substitution to do list
Pipeline #193187 failed
......@@ -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 };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment