Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group enhancement #202

Merged
merged 4 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/src/components/AllstudentsDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<v-card-text class="student-list">
<div v-if="students.length > 0">
<v-card-item v-for="(student, index) in students" :key="index">
{{ student.given_name }}
{{ student.given_name + " " + student.surname }}
</v-card-item>
</div>
<div v-else>
Expand Down
15 changes: 13 additions & 2 deletions frontend/src/components/buttons/GroupButtons.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template>
<v-btn v-if="canLeaveGroup" @click="() => leaveGroup({ groupId: group.id })">
<v-btn v-if="canLeaveGroup" @click="leaveGroupAndRedirect">
{{ $t("group.leave_group") }}
</v-btn>
<v-btn v-else-if="canJoinGroup" @click="() => joinGroup({ groupId: group.id })">
<v-btn v-else-if="canJoinGroup" @click="joinGroupAndRedirect">
{{ $t("group.join_group") }}
</v-btn>
<v-btn v-if="isTeacher" @click="() => removeGroup({ groupId: group.id })">
Expand All @@ -21,6 +21,7 @@ import {
useRemoveGroupMutation,
useUserGroupsQuery,
} from "@/queries/Group";
import router from "@/router";

const props = defineProps<{
group: Group;
Expand Down Expand Up @@ -64,6 +65,16 @@ const { mutateAsync: leaveGroup } = useLeaveGroupUserMutation();
const { mutateAsync: joinGroup } = useJoinGroupUserMutation();

const { mutateAsync: removeGroup } = useRemoveGroupMutation();

const joinGroupAndRedirect = async () => {
await joinGroup({ groupId: group.value.id });
router.push(`/groups/${group.value.id}`);
};

const leaveGroupAndRedirect = async () => {
await leaveGroup({ groupId: group.value.id });
router.push(`/project/${project.value.id}/groups`);
};
</script>

<style scoped></style>
9 changes: 8 additions & 1 deletion frontend/src/components/project/ProjectInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class="ma-2"
prepend-icon="mdi-account"
>
{{ instructor?.given_name }}
{{ getAbbreviatedName(instructor) }}
</v-chip>
</v-card-item>
<v-card-item>
Expand Down Expand Up @@ -56,6 +56,13 @@ const renderQuillContent = (content: string) => {
quill.root.innerHTML = content;
return quill.root.innerHTML;
};

const getAbbreviatedName = (instructor: User) => {
if (instructor) {
return instructor.given_name.charAt(0).toUpperCase() + ". " + instructor.surname;
}
return "";
};
</script>

<style scoped>
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/components/user/UserInfo.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<template>
<h2 class="welcome">{{ $t("home.welcome", { name: user.given_name }) }}!</h2>
<h2 class="welcome">
{{ $t("home.welcome", { name: user.given_name, surname: user.surname }) }}!
</h2>
<v-switch
:model-value="user.is_admin"
label="is_admin"
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/GroupView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
:key="index"
align="center"
>
<v-col>{{ member.given_name }}</v-col>
<v-col>{{ member.given_name + " " + member.surname }}</v-col>
<v-col>
<v-btn
v-if="isTeacher"
Expand Down
6 changes: 3 additions & 3 deletions frontend/tests/components/project/ProjectInfo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const mockProject = {
}

const mockInstructors = [
{uid: "1", given_name: "instructor 1"}
{uid: "1", given_name: "instructor 1", surname: "Doe"}
]

const mockSubject = {
Expand Down Expand Up @@ -46,7 +46,7 @@ describe("ProjectInfo", async () => {
expect(text).toContain("projectname")
expect(text).toContain("subjectname")
expect(text).toContain("Capaciteit: 2")
expect(text).toContain("instructor 1")
expect(text).toContain("I. Doe")
expect(text).toContain("this is a testassignment")

});
Expand All @@ -66,7 +66,7 @@ describe("ProjectInfo", async () => {
expect(text).toContain("projectname")
expect(text).toContain("subjectname")
expect(text).toContain("Capaciteit: 2")
expect(text).toContain("instructor 1")
expect(text).toContain("I. Doe")
expect(text).toContain("this is a testassignment")
})
});
Loading