fix: deadline veld
This commit is contained in:
parent
368130c431
commit
b7486b4d1b
4 changed files with 31 additions and 37 deletions
|
@ -7,7 +7,7 @@ export interface AssignmentDTO {
|
|||
description: string;
|
||||
learningPath: string;
|
||||
language: string;
|
||||
deadline: Date;
|
||||
deadline: Date | null;
|
||||
groups: GroupDTO[] | string[][];
|
||||
}
|
||||
|
||||
|
|
|
@ -12,19 +12,6 @@ export const assignmentTitleRules = [
|
|||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* Validation rule for the learning path selection.
|
||||
*
|
||||
* Ensures that a valid learning path is selected.
|
||||
*/
|
||||
export const learningPathRules = [
|
||||
(value: { hruid: string; title: string }): string | boolean => {
|
||||
if (value && value.hruid) {
|
||||
return true; // Valid if hruid is present
|
||||
}
|
||||
return "You must select a learning path.";
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* Validation rule for the classes selection.
|
||||
|
|
|
@ -34,7 +34,9 @@
|
|||
|
||||
const selectedClass = ref(undefined);
|
||||
const assignmentTitle = ref("");
|
||||
console.log(route.query);
|
||||
const selectedLearningPath = ref(route.query.hruid || undefined);
|
||||
|
||||
const lpIsSelected = route.query.hruid !== undefined;
|
||||
|
||||
const { mutate, data, isSuccess } = useCreateAssignmentMutation();
|
||||
|
@ -49,26 +51,42 @@
|
|||
const { valid } = await form.value.validate();
|
||||
if (!valid) return;
|
||||
|
||||
console.log(selectedLearningPath.value);
|
||||
const lp = lpIsSelected
|
||||
? route.query.hruid
|
||||
: selectedLearningPath.value?.hruid;
|
||||
|
||||
let lp = selectedLearningPath.value;
|
||||
if (!lpIsSelected) {
|
||||
lp = selectedLearningPath.value?.hruid;
|
||||
if (!lp) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('Form values:', {
|
||||
title: assignmentTitle.value,
|
||||
class: selectedClass.value,
|
||||
lp: selectedLearningPath.value
|
||||
});
|
||||
|
||||
const assignmentDTO: AssignmentDTO = {
|
||||
id: 0,
|
||||
within: selectedClass.value?.id || "",
|
||||
title: assignmentTitle.value,
|
||||
title: assignmentTitle.value.toString(),
|
||||
description: "",
|
||||
learningPath: lp || "",
|
||||
deadline: new Date(),
|
||||
language: language.value,
|
||||
learningPath: lp.toString(),
|
||||
language: language.value.toString(),
|
||||
deadline: null,
|
||||
groups: [],
|
||||
};
|
||||
|
||||
mutate({ cid: assignmentDTO.within, data: assignmentDTO });
|
||||
}
|
||||
|
||||
const learningPathRules = [
|
||||
(value: any) => {
|
||||
// Skip validation if LP is selected from query
|
||||
if (route.query.hruid) return true;
|
||||
// Original validation logic
|
||||
return Boolean(value) || 'Learning path is required';
|
||||
}
|
||||
];
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -104,18 +122,14 @@
|
|||
v-model="selectedLearningPath"
|
||||
:items="data"
|
||||
:label="t('choose-lp')"
|
||||
:rules="learningPathRules"
|
||||
:rules="lpIsSelected ? [] : learningPathRules"
|
||||
variant="solo-filled"
|
||||
clearable
|
||||
density="comfortable"
|
||||
chips
|
||||
hide-no-data
|
||||
hide-selected
|
||||
:model-value="lpIsSelected ? data.find(lp => lp.hruid === route.query.hruid) : selectedLearningPath"
|
||||
item-title="title"
|
||||
item-value="hruid"
|
||||
:disabled="lpIsSelected"
|
||||
:filter="(item, query: string) => item.title.toLowerCase().includes(query.toLowerCase())"
|
||||
prepend-inner-icon="mdi-school"
|
||||
return-object
|
||||
/>
|
||||
</using-query-result>
|
||||
|
||||
|
|
|
@ -144,15 +144,8 @@ async function saveChanges(): Promise<void> {
|
|||
}
|
||||
|
||||
async function handleGroupsUpdated(updatedGroups: string[][]): Promise<void> {
|
||||
const formattedGroups = updatedGroups.map((members, index) => ({
|
||||
groupNumber: index + 1,
|
||||
class: assignmentQueryResult.data.value?.assignment.within,
|
||||
assignment: assignmentQueryResult.data.value?.assignment.id,
|
||||
members: members.map(username => ({ username })), // Convert to member objects
|
||||
// Add other required GroupDTO fields if needed
|
||||
}));
|
||||
const assignmentDTO: AssignmentDTO = {
|
||||
groups: formattedGroups,
|
||||
groups: updatedGroups,
|
||||
};
|
||||
mutate({
|
||||
cid: assignmentQueryResult.data.value?.assignment.within,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue