-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into query-refactor
- Loading branch information
Showing
25 changed files
with
836 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<template> | ||
<v-btn v-if="canLeaveGroup" @click="() => leaveGroup({ groupId: group.id })"> | ||
{{ $t("group.leave_group") }} | ||
</v-btn> | ||
<v-btn v-else-if="canJoinGroup" @click="() => joinGroup({ groupId: group.id })"> | ||
{{ $t("group.join_group") }} | ||
</v-btn> | ||
<v-btn v-if="isTeacher" @click="() => removeGroup({ groupId: group.id })"> | ||
{{ $t("group.remove_group") }} | ||
</v-btn> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import type Group from "@/models/Group.js"; | ||
import type Project from "@/models/Project.js"; | ||
import type User from "@/models/User.js"; | ||
import { computed, toRefs } from "vue"; | ||
import { | ||
useJoinGroupUserMutation, | ||
useLeaveGroupUserMutation, | ||
useRemoveGroupMutation, | ||
useUserGroupsQuery, | ||
} from "@/queries/Group"; | ||
const props = defineProps<{ | ||
group: Group; | ||
project: Project; | ||
user: User; | ||
amountOfMembers: number; | ||
}>(); | ||
const { group, project, user, amountOfMembers } = toRefs(props); | ||
const canJoinGroup = computed(() => { | ||
return ( | ||
!isUserInGroup.value && | ||
amountOfMembers.value < project.value.capacity && | ||
!isTeacher.value && | ||
!isUserInAnotherGroup.value | ||
); | ||
}); | ||
const canLeaveGroup = computed(() => { | ||
return project.value.capacity !== 1 && isUserInGroup.value && !isTeacher.value; | ||
}); | ||
const isTeacher = computed(() => user.value.is_teacher || false); | ||
const isUserInGroup = computed(() => { | ||
return group.value.members.some((member) => member.uid === user.value.uid); | ||
}); | ||
const { data: groups } = useUserGroupsQuery(); | ||
const isUserInAnotherGroup = computed(() => { | ||
if (!groups.value) return true; | ||
return groups.value.some((groupelem) => { | ||
return groupelem.project_id === project.value.id && groupelem.id !== group.value.id; | ||
}); | ||
}); | ||
const { mutateAsync: leaveGroup } = useLeaveGroupUserMutation(); | ||
const { mutateAsync: joinGroup } = useJoinGroupUserMutation(); | ||
const { mutateAsync: removeGroup } = useRemoveGroupMutation(); | ||
</script> | ||
|
||
<style scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<template> | ||
<v-card class="v-card-padding"> | ||
<v-row> | ||
<v-col cols="8"> | ||
<router-link :to="`/groups/${group.id}`"> | ||
{{ group.team_name }} | ||
</router-link> | ||
</v-col> | ||
<v-col cols="2"> | ||
{{ amountOfMembers + "/" + project.capacity }} | ||
</v-col> | ||
<v-col cols="2"> | ||
<GroupButtons | ||
:amountOfMembers="amountOfMembers" | ||
:group="group" | ||
:project="project" | ||
:user="user" | ||
/> | ||
</v-col> | ||
</v-row> | ||
</v-card> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { computed, toRefs } from "vue"; | ||
import type Project from "@/models/Project"; | ||
import type Group from "@/models/Group"; | ||
import type User from "@/models/User"; | ||
import GroupButtons from "@/components/buttons/GroupButtons.vue"; | ||
const props = defineProps<{ | ||
group: Group; | ||
project: Project; | ||
user: User; | ||
}>(); | ||
const { group, project, user } = toRefs(props); | ||
const amountOfMembers = computed(() => { | ||
return group.value.members.length; | ||
}); | ||
</script> | ||
|
||
<style scoped> | ||
.v-card-padding { | ||
padding: 5px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.