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;
|
description: string;
|
||||||
learningPath: string;
|
learningPath: string;
|
||||||
language: string;
|
language: string;
|
||||||
deadline: Date;
|
deadline: Date | null;
|
||||||
groups: GroupDTO[] | string[][];
|
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.
|
* Validation rule for the classes selection.
|
||||||
|
|
|
@ -34,7 +34,9 @@
|
||||||
|
|
||||||
const selectedClass = ref(undefined);
|
const selectedClass = ref(undefined);
|
||||||
const assignmentTitle = ref("");
|
const assignmentTitle = ref("");
|
||||||
|
console.log(route.query);
|
||||||
const selectedLearningPath = ref(route.query.hruid || undefined);
|
const selectedLearningPath = ref(route.query.hruid || undefined);
|
||||||
|
|
||||||
const lpIsSelected = route.query.hruid !== undefined;
|
const lpIsSelected = route.query.hruid !== undefined;
|
||||||
|
|
||||||
const { mutate, data, isSuccess } = useCreateAssignmentMutation();
|
const { mutate, data, isSuccess } = useCreateAssignmentMutation();
|
||||||
|
@ -49,26 +51,42 @@
|
||||||
const { valid } = await form.value.validate();
|
const { valid } = await form.value.validate();
|
||||||
if (!valid) return;
|
if (!valid) return;
|
||||||
|
|
||||||
console.log(selectedLearningPath.value);
|
const lp = lpIsSelected
|
||||||
|
? route.query.hruid
|
||||||
|
: selectedLearningPath.value?.hruid;
|
||||||
|
|
||||||
let lp = selectedLearningPath.value;
|
if (!lp) {
|
||||||
if (!lpIsSelected) {
|
return;
|
||||||
lp = selectedLearningPath.value?.hruid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('Form values:', {
|
||||||
|
title: assignmentTitle.value,
|
||||||
|
class: selectedClass.value,
|
||||||
|
lp: selectedLearningPath.value
|
||||||
|
});
|
||||||
|
|
||||||
const assignmentDTO: AssignmentDTO = {
|
const assignmentDTO: AssignmentDTO = {
|
||||||
id: 0,
|
id: 0,
|
||||||
within: selectedClass.value?.id || "",
|
within: selectedClass.value?.id || "",
|
||||||
title: assignmentTitle.value,
|
title: assignmentTitle.value.toString(),
|
||||||
description: "",
|
description: "",
|
||||||
learningPath: lp || "",
|
learningPath: lp.toString(),
|
||||||
deadline: new Date(),
|
language: language.value.toString(),
|
||||||
language: language.value,
|
deadline: null,
|
||||||
groups: [],
|
groups: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
mutate({ cid: assignmentDTO.within, data: assignmentDTO });
|
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>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -104,18 +122,14 @@
|
||||||
v-model="selectedLearningPath"
|
v-model="selectedLearningPath"
|
||||||
:items="data"
|
:items="data"
|
||||||
:label="t('choose-lp')"
|
:label="t('choose-lp')"
|
||||||
:rules="learningPathRules"
|
:rules="lpIsSelected ? [] : learningPathRules"
|
||||||
variant="solo-filled"
|
variant="solo-filled"
|
||||||
clearable
|
clearable
|
||||||
density="comfortable"
|
:model-value="lpIsSelected ? data.find(lp => lp.hruid === route.query.hruid) : selectedLearningPath"
|
||||||
chips
|
|
||||||
hide-no-data
|
|
||||||
hide-selected
|
|
||||||
item-title="title"
|
item-title="title"
|
||||||
item-value="hruid"
|
item-value="hruid"
|
||||||
:disabled="lpIsSelected"
|
:disabled="lpIsSelected"
|
||||||
:filter="(item, query: string) => item.title.toLowerCase().includes(query.toLowerCase())"
|
return-object
|
||||||
prepend-inner-icon="mdi-school"
|
|
||||||
/>
|
/>
|
||||||
</using-query-result>
|
</using-query-result>
|
||||||
|
|
||||||
|
|
|
@ -144,15 +144,8 @@ async function saveChanges(): Promise<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleGroupsUpdated(updatedGroups: string[][]): 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 = {
|
const assignmentDTO: AssignmentDTO = {
|
||||||
groups: formattedGroups,
|
groups: updatedGroups,
|
||||||
};
|
};
|
||||||
mutate({
|
mutate({
|
||||||
cid: assignmentQueryResult.data.value?.assignment.within,
|
cid: assignmentQueryResult.data.value?.assignment.within,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue