diff --git a/frontend/src/components/assignments/DeadlineSelector.vue b/frontend/src/components/assignments/DeadlineSelector.vue
index 304c544c..13ac96ca 100644
--- a/frontend/src/components/assignments/DeadlineSelector.vue
+++ b/frontend/src/components/assignments/DeadlineSelector.vue
@@ -2,15 +2,21 @@
import { ref, watch } from "vue";
import { deadlineRules } from "@/utils/assignment-rules.ts";
- const emit = defineEmits<(e: "update:deadline", value: Date) => void>();
+ const emit = defineEmits<(e: "update:deadline", value: Date | null) => void>();
+ const props = defineProps<{ deadline: Date | null }>();
const datetime = ref("");
+ datetime.value = props.deadline ? new Date(props.deadline).toISOString().slice(0, 16) : ""
+
+
// Watch the datetime value and emit the update
watch(datetime, (val) => {
const newDate = new Date(val);
if (!isNaN(newDate.getTime())) {
emit("update:deadline", newDate);
+ } else {
+ emit("update:deadline", null);
}
});
diff --git a/frontend/src/i18n/locale/en.json b/frontend/src/i18n/locale/en.json
index a9307b6e..bf74fc32 100644
--- a/frontend/src/i18n/locale/en.json
+++ b/frontend/src/i18n/locale/en.json
@@ -166,5 +166,11 @@
"pathContainsNonExistingLearningObjects": "At least one of the learning objects referenced in this path does not exist.",
"targetAgesMandatory": "Target ages must be specified.",
"hintRemoveIfUnconditionalTransition": "(remove this if this should be an unconditional transition)",
- "hintKeywordsSeparatedBySpaces": "Keywords separated by spaces"
+ "hintKeywordsSeparatedBySpaces": "Keywords separated by spaces",
+ "title-required": "Title cannot be empty.",
+ "class-required": "You must select at least one class.",
+ "deadline-invalid": "Invalid date or time.",
+ "deadline-past": "The deadline must be in the future.",
+ "lp-required": "You must select a learning path.",
+ "lp-invalied": "The selected learning path doesn't exist."
}
diff --git a/frontend/src/utils/assignment-rules.ts b/frontend/src/utils/assignment-rules.ts
index 51380960..4fdde0d7 100644
--- a/frontend/src/utils/assignment-rules.ts
+++ b/frontend/src/utils/assignment-rules.ts
@@ -1,3 +1,7 @@
+import {useI18n} from "vue-i18n";
+
+const { t } = useI18n();
+
/**
* Validation rule for the assignment title.
*
@@ -8,7 +12,7 @@ export const assignmentTitleRules = [
if (value?.length >= 1) {
return true;
} // Title must not be empty
- return "Title cannot be empty.";
+ return t("title-required");
},
];
@@ -23,7 +27,7 @@ export const classRules = [
if (value) {
return true;
}
- return "You must select at least one class.";
+ return t("class-required");
},
];
@@ -34,30 +38,18 @@ export const classRules = [
*/
export const deadlineRules = [
(value: string): string | boolean => {
- if (!value) {
- return "You must set a deadline.";
- }
const selectedDateTime = new Date(value);
const now = new Date();
if (isNaN(selectedDateTime.getTime())) {
- return "Invalid date or time.";
+ return t("deadline-invalid");
}
if (selectedDateTime <= now) {
- return "The deadline must be in the future.";
+ return t("deadline-past");
}
return true;
},
];
-
-export const descriptionRules = [
- (value: string): string | boolean => {
- if (!value || value.trim() === "") {
- return "Description cannot be empty.";
- }
- return true;
- },
-];
diff --git a/frontend/src/views/assignments/CreateAssignment.vue b/frontend/src/views/assignments/CreateAssignment.vue
index 0e7f7124..ef07c443 100644
--- a/frontend/src/views/assignments/CreateAssignment.vue
+++ b/frontend/src/views/assignments/CreateAssignment.vue
@@ -1,91 +1,101 @@
@@ -118,7 +128,6 @@
v-slot="{ data }: { data: LearningPath[] }"
>
diff --git a/frontend/src/views/assignments/TeacherAssignment.vue b/frontend/src/views/assignments/TeacherAssignment.vue
index 475f6677..0fe068a9 100644
--- a/frontend/src/views/assignments/TeacherAssignment.vue
+++ b/frontend/src/views/assignments/TeacherAssignment.vue
@@ -1,5 +1,5 @@