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

Fix room/teacher removing mechanism

parent 06429f5a
No related branches found
No related tags found
1 merge request!329Introduce substitution to do list
Pipeline #187776 failed
......@@ -241,18 +241,12 @@ export default {
return this.roomsWithStatus.find((r) => r.id === room.id)?.status;
},
removeTeacher(teacher) {
const index = this.teachers.indexOf(teacher.id);
if (index >= 0) {
this.teachers.splice(index, 1);
this.save();
}
this.teachers = this.substitutionTeacherIDs.filter((t) => t !== teacher.id);
this.save(true);
},
removeRoom(room) {
const index = this.rooms.indexOf(room.id);
if (index >= 0) {
this.rooms.splice(index, 1);
this.save();
}
this.rooms = this.substitutionRoomIDs.filter((r) => r !== room.id);
this.save(true);
},
teachersInput(teachers) {
this.teachers = teachers;
......@@ -266,8 +260,9 @@ export default {
this.cancelled = cancelled;
this.save();
},
save() {
save(allowEmpty = false) {
if (
allowEmpty ||
this.teachers.length ||
this.rooms.length ||
this.comment !== null ||
......@@ -276,8 +271,8 @@ export default {
this.createOrPatch([
{
id: this.substitution.id,
...(this.teachers.length && { teachers: this.teachers }),
...(this.rooms.length && { rooms: this.rooms }),
...((allowEmpty || this.teachers.length) && { teachers: this.teachers }),
...((allowEmpty || this.rooms.length) && { rooms: this.rooms }),
...(this.comment !== null && { comment: this.comment }),
...(this.cancelled !== null && { cancelled: this.cancelled }),
},
......
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