UNCLASSIFIED

Commits (9)
......@@ -59,9 +59,9 @@ export default {
await this.addStudent(courseId, { userId: student.id });
}
},
async addStudentsToCourses(courses, students) {
async addStudentsToCourses(courses, students, pmId) {
for (const { id: courseId } of courses) {
await this.addStudents(courseId, students);
await this.addPendingStudents(courseId, students, pmId);
}
},
async exportCourses() {
......@@ -98,4 +98,12 @@ export default {
params
);
},
async addPendingStudent(courseId, student) {
return HTTP.post(`/courses/${courseId}/pending-registrations`, student);
},
async addPendingStudents(courseId, students, pmId) {
for (const student of students) {
await this.addPendingStudent(courseId, { userId: student.id, pmId: pmId });
}
},
};
......@@ -114,7 +114,8 @@ export default {
try {
await CourseService.addStudentsToCourses(
[this.course],
this.selectedMembers
this.selectedMembers,
this.$store.state.user.user.id
);
this.$emit("update-students");
} catch (error) {
......
......@@ -80,6 +80,8 @@ export default {
const errorMessage = error;
this.$store.commit(SET_ERROR_MESSAGE, errorMessage);
this.$store.commit(SET_ERROR_DIALOG, true);
} finally {
this.fetchData();
}
},
},
......
......@@ -53,7 +53,7 @@
v-bind:courseId="currentCourseId"
v-bind:id="item.user.id"
v-bind:pm="item.pm.id"
v-bind:mainMessage="`Your request to add a team member into ${$props.trainingCourse.name} - ${$props.trainingCourse.startDate}-${$props.trainingCourse.endDate} has been denied due to the following reasons:`"
v-bind:mainMessage="mainMessage"
class="mx-2"
@change="fetchReload"
/>
......@@ -82,7 +82,7 @@ import {
DEFAULT_TABLE_OPTIONS,
} from "@/config/table-constants";
export default {
name: "TrainingAttendance",
name: "PendingRequests",
components: { DenialNotification },
props: {
trainingCourse: {
......@@ -157,6 +157,14 @@ export default {
};
},
async mounted() {
this.mainMesseage =
"Your request to add a team member into " +
this.$props.trainingCourse.name +
" - " +
this.$props.trainingCourse.startDate +
"-" +
this.$props.trainingCourse.endDate +
" has been denied due to the following reasons:";
await this.fetchData();
},
methods: {
......@@ -180,12 +188,13 @@ export default {
this.total = response.meta?.total || 0;
} catch (error) {
const errorMessage = error;
console.log("ERROR");
console.error("ERROR");
this.$store.commit(SET_ERROR_MESSAGE, errorMessage);
this.$store.commit(SET_ERROR_DIALOG, true);
}
this.loading = false;
this.fetchingData = false;
console.log(this.mainMessage);
},
async acceptPendingRegistration(userId, pmId) {
try {
......@@ -223,6 +232,17 @@ export default {
currentCourseId() {
return this.trainingCourse.id;
},
mainMessage() {
return (
"Your request to add a team member into" +
this.$props.trainingCourse.name +
" - " +
this.$props.trainingCourse.startDate +
"-" +
this.$props.trainingCourse.endDate +
"has been denied due to the following reasons:"
);
},
},
};
</script>
......
......@@ -407,6 +407,7 @@ export default {
const team = await TeamService.getMyTeam();
if (team && Object.keys(team).length !== 0) {
this.team = await TeamService.getTeam(team[0].id);
console.log(this.team);
isTeamLead = team[0].TeamMember.isTeamLead;
}
}
......
......@@ -370,7 +370,7 @@
</v-btn>
</div>
<PendingRequests
ref="trainingAttendance"
ref="pendingRequests"
class="px-0"
v-if="trainingCourse.id"
:trainingCourse="trainingCourse"
......@@ -518,7 +518,6 @@ export default {
methods: {
fetchReload(value) {
if (value) {
console.log("reload");
this.trigger += 1;
}
},
......@@ -594,7 +593,7 @@ export default {
// delay new call
this.fetchData();
this.$refs.trainingAttendance.fetchDebounced();
this.$refs.addStudentsToCourseDialog.fetchDebounced();
this.$refs.trainingAttendance.fetchDebounced();
},
async updateCourse() {
this.loading = true;
......
......@@ -112,6 +112,15 @@ describe("SelectAddStudentsToCourseDialog", () => {
});
it("addSelectedUsersToSelectedCourses should call addStudentsToCourses", async () => {
const wrapper = shallowMount(SelectAddStudentsToCourseDialog, {
mocks: {
$store: {
state: {
error: {},
user: { user: { id: 1 } },
},
commit: jest.fn(),
},
},
propsData: {
value: [],
selectedMembers: [],
......@@ -139,6 +148,10 @@ describe("SelectAddStudentsToCourseDialog", () => {
},
mocks: {
$store: {
state: {
error: {},
user: { user: { id: 1 } },
},
commit: jest.fn(),
},
},
......@@ -168,6 +181,10 @@ describe("SelectAddStudentsToCourseDialog", () => {
},
mocks: {
$store: {
state: {
error: {},
user: { user: { id: 1 } },
},
commit: jest.fn(),
},
},
......