Skip to content
Snippets Groups Projects
Commit df75ee31 authored by Julian's avatar Julian
Browse files

Add possibility to create new personal notes

parent d0b9f28e
No related branches found
No related tags found
No related merge requests found
...@@ -34,6 +34,18 @@ export default { ...@@ -34,6 +34,18 @@ export default {
this.editedExcused = personalNote.excused || false; this.editedExcused = personalNote.excused || false;
this.editedExcuseType = personalNote.excuse_type || null; this.editedExcuseType = personalNote.excuse_type || null;
this.editedExtraMarks = personalNote.extra_marks || []; this.editedExtraMarks = personalNote.extra_marks || [];
this.newPersonalNote = !!(personalNote && Object.keys(personalNote).length === 0 && Object.getPrototypeOf(personalNote) === Object.prototype);
},
createPersonalNote() {
this.editedPersonID = ID_NO_PERSON;
this.editedTardiness = 0;
this.editedAbsent = false;
this.editedExcused = false;
this.editedExcuseType = null;
this.editedExtraMarks = [];
this.newPersonalNote = true;
this.dialog = true;
}, },
personalNoteByStudentID(studentID) { personalNoteByStudentID(studentID) {
if (this.editedPersonID === ID_NO_PERSON) { if (this.editedPersonID === ID_NO_PERSON) {
...@@ -46,16 +58,30 @@ export default { ...@@ -46,16 +58,30 @@ export default {
return return
} }
// Loop through all personal notes and update the ones that match the editedPersonID if (this.newPersonalNote) {
this.personalNotes.forEach(item => { this.personalNotes.push({
if (item.student.id === this.editedPersonID) { student: {
item.tardiness = this.editedTardiness; id: this.editedPersonID,
item.absent = this.editedAbsent; full_name: this.studentNameByID(this.editedPersonID)
item.excused = this.editedExcused; },
item.excuse_type = this.editedExcuseType; tardiness: this.editedTardiness,
item.extra_marks = this.editedExtraMarks; absent: this.editedAbsent,
} excused: this.editedExcused,
}); excuse_type: this.editedExcuseType,
extra_marks: this.editedExtraMarks
});
} else {
// Loop through all personal notes and update the ones that match the editedPersonID
this.personalNotes.forEach(item => {
if (item.student.id === this.editedPersonID) {
item.tardiness = this.editedTardiness;
item.absent = this.editedAbsent;
item.excused = this.editedExcused;
item.excuse_type = this.editedExcuseType;
item.extra_marks = this.editedExtraMarks;
}
});
}
}, },
cancelDialog() { cancelDialog() {
this.dialog = false; this.dialog = false;
...@@ -89,6 +115,13 @@ export default { ...@@ -89,6 +115,13 @@ export default {
personalNoteString += ")"; personalNoteString += ")";
} }
return personalNoteString; return personalNoteString;
},
studentNameByID(studentID) {
try {
return this.persons.filter(item => item.id === studentID)[0].full_name;
} catch (TypeError) {
return "";
}
} }
}, },
props: ["personalNotes", "groups", "excuseTypes", "extraMarks"], props: ["personalNotes", "groups", "excuseTypes", "extraMarks"],
...@@ -104,6 +137,7 @@ export default { ...@@ -104,6 +137,7 @@ export default {
editedExcused: false, editedExcused: false,
editedExcuseType: null, editedExcuseType: null,
editedExtraMarks: [], editedExtraMarks: [],
newPersonalNote: false,
} }
}, },
computed: { computed: {
...@@ -143,6 +177,7 @@ export default { ...@@ -143,6 +177,7 @@ export default {
outlined outlined
v-bind="attrs" v-bind="attrs"
v-on="on" v-on="on"
@click="createPersonalNote"
> >
<v-icon> <v-icon>
mdi-plus mdi-plus
......
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