From 3e35231b2130d4e0819377923ed368568906912c Mon Sep 17 00:00:00 2001 From: mattiscauwel Date: Sat, 18 May 2024 16:07:43 +0200 Subject: [PATCH 01/39] added router to create SubjectsView.vue --- frontend/src/router/index.ts | 6 +++++- .../src/views/subject/CreateSubjectView.vue | 17 +++++++++++++++++ frontend/src/views/subject/SubjectsView.vue | 2 +- 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 frontend/src/views/subject/CreateSubjectView.vue diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts index 60bc0e7e..6680770f 100644 --- a/frontend/src/router/index.ts +++ b/frontend/src/router/index.ts @@ -74,7 +74,11 @@ const router = createRouter({ path: "/subjects", name: "subjects", component: () => import("../views/subject/SubjectsView.vue"), - children: [], + }, + { + path: "/subjects/create", + name: "create-subject", + component: () => import("../views/subject/CreateSubjectView.vue"), }, { path: "/subjects/:subjectId(\\d+)", diff --git a/frontend/src/views/subject/CreateSubjectView.vue b/frontend/src/views/subject/CreateSubjectView.vue new file mode 100644 index 00000000..12065005 --- /dev/null +++ b/frontend/src/views/subject/CreateSubjectView.vue @@ -0,0 +1,17 @@ + + + + + + diff --git a/frontend/src/views/subject/SubjectsView.vue b/frontend/src/views/subject/SubjectsView.vue index a5aec499..680672fa 100644 --- a/frontend/src/views/subject/SubjectsView.vue +++ b/frontend/src/views/subject/SubjectsView.vue @@ -38,7 +38,7 @@
- + {{ $t("subjects.create_subject") }} From ac97ec722bfe9fc34d1c3b01d1d1b2059291816c Mon Sep 17 00:00:00 2001 From: mattiscauwel Date: Sat, 18 May 2024 17:10:40 +0200 Subject: [PATCH 02/39] added first form elements --- .../src/views/subject/CreateSubjectView.vue | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/frontend/src/views/subject/CreateSubjectView.vue b/frontend/src/views/subject/CreateSubjectView.vue index 12065005..6bcd99af 100644 --- a/frontend/src/views/subject/CreateSubjectView.vue +++ b/frontend/src/views/subject/CreateSubjectView.vue @@ -1,6 +1,30 @@ @@ -50,6 +52,7 @@ import {ref} from "vue"; import useAcademicYear from "@/composables/useAcademicYear"; import {useCreateSubjectMutation} from "@/queries/Subject"; import type SubjectForm from "@/models/Subject"; +import UserSearchList from "@/components/subject/createSubjectView/UserSearchList.vue"; const form = ref(null); const project_name = ref(""); From b62cde62714b47ea01d49be0fb1da0801e3277dc Mon Sep 17 00:00:00 2001 From: mattiscauwel Date: Sat, 18 May 2024 21:51:43 +0200 Subject: [PATCH 06/39] add users to instructors --- .../createSubjectView/UserSearchList.vue | 28 ++++++++++++++++++- .../src/views/subject/CreateSubjectView.vue | 12 +++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/subject/createSubjectView/UserSearchList.vue b/frontend/src/components/subject/createSubjectView/UserSearchList.vue index 242a8fe9..35388986 100644 --- a/frontend/src/components/subject/createSubjectView/UserSearchList.vue +++ b/frontend/src/components/subject/createSubjectView/UserSearchList.vue @@ -11,6 +11,7 @@ single-line hide-details @click:prepend-inner="onSearchIconClicked" + @keydown.enter="onSearchIconClicked" > @@ -24,6 +25,13 @@ {{ user.given_name }} {{ user.surname }} + + Add +
@@ -35,9 +43,15 @@ diff --git a/frontend/src/views/subject/CreateSubjectView.vue b/frontend/src/views/subject/CreateSubjectView.vue index bbe31cff..f882ad0c 100644 --- a/frontend/src/views/subject/CreateSubjectView.vue +++ b/frontend/src/views/subject/CreateSubjectView.vue @@ -40,7 +40,10 @@ - + @@ -53,10 +56,12 @@ import useAcademicYear from "@/composables/useAcademicYear"; import {useCreateSubjectMutation} from "@/queries/Subject"; import type SubjectForm from "@/models/Subject"; import UserSearchList from "@/components/subject/createSubjectView/UserSearchList.vue"; +import type User from "@/models/User"; const form = ref(null); const project_name = ref(""); const activeAcademicYear = ref(useAcademicYear()); +const instructors = ref([]); const createSubjectMutation = useCreateSubjectMutation(); @@ -67,6 +72,11 @@ const rules = { length: (value: string) => value.length > 2 || "Title must be at least 3 characters long.", }; +const addInstructor = (user: User) => { + instructors.value.push(user); + console.log(instructors.value); +}; + async function handleSubmit() { const {valid} = await form.value.validate(); if (!valid) { From 3cc9c312ca469e32e78b2dd8e9f9626f222e86fd Mon Sep 17 00:00:00 2001 From: mattiscauwel Date: Sat, 18 May 2024 23:10:49 +0200 Subject: [PATCH 07/39] assign and delete users from instructors --- .../createSubjectView/UserSearchList.vue | 11 +++-- .../src/views/subject/CreateSubjectView.vue | 45 ++++++++++++++++++- 2 files changed, 51 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/subject/createSubjectView/UserSearchList.vue b/frontend/src/components/subject/createSubjectView/UserSearchList.vue index 35388986..51ec6e47 100644 --- a/frontend/src/components/subject/createSubjectView/UserSearchList.vue +++ b/frontend/src/components/subject/createSubjectView/UserSearchList.vue @@ -48,9 +48,10 @@ import type User from "@/models/User"; const props = defineProps<{ instructors: User[]; + currentUser: User; }>(); -const { instructors } = toRefs(props); +const {instructors, currentUser} = toRefs(props); const {data: users, isLoading, isError} = useUsersQuery(); @@ -64,8 +65,10 @@ const filteredUsers = computed(() => { return []; } return [...(users.value || [])].filter((user: User) => { - const fullName = `${user?.given_name} ${user.surname}`; - return fullName.toLowerCase().includes(search.value.toLowerCase()); + return ( + user?.uid !== currentUser.value?.uid && + `${user?.given_name} ${user.surname}`.toLowerCase().includes(search.value.toLowerCase()) + ); }).slice(0, 5); }); @@ -87,7 +90,7 @@ const onAddInstructorButtonClicked = (user: User) => { }; const userIsInstructor = (user: User) => { - return instructors.value.some((instructor: User) => instructor.id === user.id); + return instructors.value.some((instructor: User) => instructor?.uid === user?.uid); }; diff --git a/frontend/src/views/subject/CreateSubjectView.vue b/frontend/src/views/subject/CreateSubjectView.vue index f882ad0c..6c71ba88 100644 --- a/frontend/src/views/subject/CreateSubjectView.vue +++ b/frontend/src/views/subject/CreateSubjectView.vue @@ -1,4 +1,8 @@ diff --git a/frontend/src/components/subject/createSubjectView/body/SubjectInstructorsCard.vue b/frontend/src/components/subject/createSubjectView/body/SubjectInstructorsCard.vue index 8dbf5af0..a355634a 100644 --- a/frontend/src/components/subject/createSubjectView/body/SubjectInstructorsCard.vue +++ b/frontend/src/components/subject/createSubjectView/body/SubjectInstructorsCard.vue @@ -1,5 +1,5 @@