UNCLASSIFIED

Commit d8056a03 authored by Keith Becker's avatar Keith Becker
Browse files

refactor

parent 2cf2e5b7
...@@ -58,6 +58,17 @@ export default { ...@@ -58,6 +58,17 @@ export default {
courseId: Number, courseId: Number,
}, },
methods: { methods: {
async fetchDebounced() {
this.course = await CourseService.getCourse(this.courseId);
const result = await CourseService.getCourseRegistrationsById(
this.course.id
);
this.course.registrations = result.registrations;
console.log(
"updated add students to course dialog registrations is now " +
this.course.registrations.length
);
},
availableSeatsInCourse, availableSeatsInCourse,
canAddStudentsToCourse, canAddStudentsToCourse,
async addSelectedUsersToSelectedCourses() { async addSelectedUsersToSelectedCourses() {
...@@ -108,11 +119,7 @@ export default { ...@@ -108,11 +119,7 @@ export default {
}, },
}, },
async created() { async created() {
this.course = await CourseService.getCourse(this.courseId); this.fetchDebounced();
const result = await CourseService.getCourseRegistrationsById(
this.course.id
);
this.course.registrations = result.registrations;
}, },
}; };
</script> </script>
...@@ -232,6 +232,7 @@ export default { ...@@ -232,6 +232,7 @@ export default {
this.$store.commit(SET_ERROR_MESSAGE, errorMessage); this.$store.commit(SET_ERROR_MESSAGE, errorMessage);
} }
this.fetchDebounced(); this.fetchDebounced();
this.$emit("removed-student");
}, },
sendEmailToStudents() { sendEmailToStudents() {
const userEmails = this.selectedUsers.map((item) => item.user.email); const userEmails = this.selectedUsers.map((item) => item.user.email);
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
Add Student Add Student
</v-btn> </v-btn>
<AddStudentsToCourseDialog <AddStudentsToCourseDialog
ref="addStudentsToCourseDialog"
:show-dialog="state.isAddingStudent" :show-dialog="state.isAddingStudent"
:course-id="Number.parseInt($route.params.trainingId)" :course-id="Number.parseInt($route.params.trainingId)"
v-on:close-dialog="closeAddStudentDialog" v-on:close-dialog="closeAddStudentDialog"
...@@ -306,6 +307,7 @@ ...@@ -306,6 +307,7 @@
v-if="trainingCourse.id" v-if="trainingCourse.id"
:trainingCourse="trainingCourse" :trainingCourse="trainingCourse"
:reload="trigger" :reload="trigger"
v-on:removed-student="fetchDebounced"
/> />
</v-skeleton-loader> </v-skeleton-loader>
</v-container> </v-container>
...@@ -493,6 +495,7 @@ export default { ...@@ -493,6 +495,7 @@ export default {
// delay new call // delay new call
this.fetchData(); this.fetchData();
this.$refs.trainingAttendance.fetchDebounced(); this.$refs.trainingAttendance.fetchDebounced();
this.$refs.addStudentsToCourseDialog.fetchDebounced();
}, },
async updateCourse() { async updateCourse() {
this.loading = true; this.loading = true;
...@@ -517,27 +520,6 @@ export default { ...@@ -517,27 +520,6 @@ export default {
cancelUpdateCourse() { cancelUpdateCourse() {
this.state.isEditingCourse = false; this.state.isEditingCourse = false;
}, },
async addStudent(student) {
if (!student) {
student = this.studentToAdd;
}
this.state.isAddingBusy = true;
try {
await TrainingService.addStudents(
this.currentTrainingCourse.id,
student
);
this.studentToAdd = student;
this.trigger = this.trigger + 1;
} catch (error) {
console.error("addStudent error!!: ", error);
this.$store.commit(SET_ERROR_MESSAGE, error);
} finally {
this.state.isAddingBusy = false;
this.state.isAddingStudent = false;
this.$refs.userSelect && this.$refs.userSelect.clear();
}
},
}, },
}; };
</script> </script>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment