UNCLASSIFIED

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