From 83b15a392d28a2732bd9d944ec8531c06a6b3624 Mon Sep 17 00:00:00 2001 From: Joyelle Ndagijimana Date: Sat, 29 Mar 2025 22:32:16 +0100 Subject: [PATCH] feat: kleine correctie in form component --- frontend/src/components/GroupSelector.vue | 38 +++-------- frontend/src/utils/assignmentForm.ts | 14 +++- .../views/assignments/CreateAssignment.vue | 65 ++++++++++++------- 3 files changed, 64 insertions(+), 53 deletions(-) diff --git a/frontend/src/components/GroupSelector.vue b/frontend/src/components/GroupSelector.vue index 487e4c2a..b0a96e32 100644 --- a/frontend/src/components/GroupSelector.vue +++ b/frontend/src/components/GroupSelector.vue @@ -4,37 +4,30 @@ import { useI18n } from 'vue-i18n'; const props = defineProps({ students: Array, // All students - availableClasses: Array, // Selected classes + availableClass: Object, // Selected class groups: Array, // All groups }); const emit = defineEmits(['groupCreated']); const { t } = useI18n(); -const selectedClass = ref(null); const selectedStudents = ref([]); // Filter students based on the selected class and exclude students already in a group const filteredStudents = computed(() => { - if (selectedClass.value) { - // Find the class based on selectedClass id - const selected = props.availableClasses.find(cl => cl.id === selectedClass.value.id); - if (selected) { - // Get all students from the selected class - const studentsInClass = selected.students.map(st => ({ - title: `${st.firstName} ${st.lastName}`, - value: st.username, - })); + if (props.availableClass) { + const studentsInClass = props.availableClass.students.map(st => ({ + title: `${st.firstName} ${st.lastName}`, + value: st.username, + })); - // Get the list of students already in any group - const studentsInGroups = props.groups.flat(); + const studentsInGroups = props.groups.flat(); - // Filter out students that are already in a group - return studentsInClass.filter(student => !studentsInGroups.includes(student.value)); - } + return studentsInClass.filter(student => !studentsInGroups.includes(student.value)); } return []; }); + const createGroup = () => { if (selectedStudents.value.length) { // Extract only usernames (student.value) @@ -48,19 +41,6 @@ const createGroup = () => {