Refactor dueDate frontent

This commit is contained in:
Daniel Egger 2023-08-23 12:31:17 +02:00
parent 279b6c1dd5
commit 2fa17e1204
7 changed files with 234 additions and 73 deletions

View File

@ -4,23 +4,33 @@ import type { DueDate } from "@/types";
const props = defineProps<{ const props = defineProps<{
dueDate: DueDate; dueDate: DueDate;
singleLine?: boolean;
}>(); }>();
</script> </script>
<template> <template>
<div class="flex items-center justify-between py-4"> <div
class="flex justify-between py-4"
:class="{ 'flex-col': props.singleLine, 'items-center': !props.singleLine }"
>
<div class="space-y-1"> <div class="space-y-1">
<div>
<a class="text-bold underline" :href="props.dueDate.url"> <a class="text-bold underline" :href="props.dueDate.url">
{{ props.dueDate.title }} {{ props.dueDate.title }}
</a> </a>
<p class="text-small text-gray-900">
{{ props.dueDate.learning_content_description }}
<span v-if="props.dueDate.description !== ''">:</span>
{{ props.dueDate.description }}
</p>
</div> </div>
<p> <div class="text-small text-gray-900">
<div v-if="props.dueDate.date_type_translation_key">
{{ $t(props.dueDate.assignment_type_translation_key) }}:
{{ $t(props.dueDate.date_type_translation_key) }}
</div>
<div v-else>
{{ $t(props.dueDate.assignment_type_translation_key) }}
</div>
</div>
</div>
<div>
{{ formatDate(props.dueDate.start, props.dueDate.end) }} {{ formatDate(props.dueDate.start, props.dueDate.end) }}
</p> </div>
</div> </div>
</template> </template>

View File

@ -1,4 +1,5 @@
{ {
"Alle": "Alle",
"Anwesenheit Präsenzkurse": "Anwesenheit Präsenzkurse", "Anwesenheit Präsenzkurse": "Anwesenheit Präsenzkurse",
"Anwesenheit bestätigen": "Anwesenheit bestätigen", "Anwesenheit bestätigen": "Anwesenheit bestätigen",
"Anwesenheit prüfen": "Anwesenheit prüfen", "Anwesenheit prüfen": "Anwesenheit prüfen",
@ -7,6 +8,7 @@
"Ergebnisse anschauen": "Ergebnisse anschauen", "Ergebnisse anschauen": "Ergebnisse anschauen",
"Feedback": "Feedback", "Feedback": "Feedback",
"Feedback anschauen": "Feedback anschauen", "Feedback anschauen": "Feedback anschauen",
"Feedback: Feedback zum Lehrgang": "Feedback: Feedback zum Lehrgang",
"MS Teams öffnen": "MS Teams öffnen", "MS Teams öffnen": "MS Teams öffnen",
"Nächste Termine": "Nächste Termine", "Nächste Termine": "Nächste Termine",
"Passwort": "Passwort", "Passwort": "Passwort",
@ -22,8 +24,8 @@
"assignmentSubmitted": "Du hast deine Ergebnisse erfolgreich abgegeben.", "assignmentSubmitted": "Du hast deine Ergebnisse erfolgreich abgegeben.",
"confirmSubmitPerson": "Hiermit bestätige ich, dass die folgende Person meine Ergebnisse bewerten soll.", "confirmSubmitPerson": "Hiermit bestätige ich, dass die folgende Person meine Ergebnisse bewerten soll.",
"confirmSubmitResults": "Hiermit bestätige ich, dass ich die Zusammenfassung meiner Ergebnisse überprüft habe und so abgeben will.", "confirmSubmitResults": "Hiermit bestätige ich, dass ich die Zusammenfassung meiner Ergebnisse überprüft habe und so abgeben will.",
"dueDateEvaluation": "assignment.dueDateEvaluation",
"dueDateIntroduction": "Reiche deine Ergebnisse pünktlich ein bis am: ", "dueDateIntroduction": "Reiche deine Ergebnisse pünktlich ein bis am: ",
"dueDateEvaluation": "Freigabetermin Bewertung",
"dueDateNotSet": "Keine Abgabedaten wurden erfasst für diese Durchführung", "dueDateNotSet": "Keine Abgabedaten wurden erfasst für diese Durchführung",
"dueDateSubmission": "Abgabetermin", "dueDateSubmission": "Abgabetermin",
"edit": "Bearbeiten", "edit": "Bearbeiten",
@ -107,7 +109,7 @@
"showAllDueDates": "Alle Termine anzeigen" "showAllDueDates": "Alle Termine anzeigen"
}, },
"edoniqTest": { "edoniqTest": {
"qualifiesForExtendedTime": "Ich habe Anrecht auf einen Nachteilsausgleich." "qualifiesForExtendedTime": "edoniqTest.qualifiesForExtendedTime"
}, },
"feedback": { "feedback": {
"answers": "Antworten", "answers": "Antworten",
@ -272,7 +274,7 @@
"selfEvaluationNo": "@:selfEvaluation: Muss ich nochmals anschauen.", "selfEvaluationNo": "@:selfEvaluation: Muss ich nochmals anschauen.",
"selfEvaluationYes": "@:selfEvaluation: Ich kann das.", "selfEvaluationYes": "@:selfEvaluation: Ich kann das.",
"steps": "Schritt {{current}} von {{max}}", "steps": "Schritt {{current}} von {{max}}",
"title": "Selbsteinschätzung {{title}}", "title": "@:selfEvaluation.selfEvaluation {{title}}",
"yes": "Ja, ich kann das" "yes": "Ja, ich kann das"
}, },
"settings": { "settings": {

View File

@ -1,22 +1,9 @@
<script setup lang="ts"> <script setup lang="ts">
import { useCurrentCourseSession } from "@/composables"; import { useCurrentCourseSession } from "@/composables";
import type { Dayjs } from "dayjs"; import DueDateSingle from "@/components/dueDates/DueDateSingle.vue";
import type { DueDate } from "@/types";
const courseSession = useCurrentCourseSession(); const courseSession = useCurrentCourseSession();
const dueDates = courseSession.value.due_dates.slice(0, 2); const dueDates = courseSession.value.due_dates.slice(0, 2);
const formatDate = (date: Dayjs) => {
return date.format("DD.MM.YYYY");
};
const formatDateLine = (dueDate: DueDate) => {
let line = `${formatDate(dueDate.start)} - ${dueDate.learning_content_description}`;
if (dueDate.description.length !== 0) {
line += `: ${dueDate.description}`;
}
return line;
};
</script> </script>
<template> <template>
@ -27,7 +14,7 @@ const formatDateLine = (dueDate: DueDate) => {
:key="dueDate.id" :key="dueDate.id"
class="border-t border-gray-500 pt-2" class="border-t border-gray-500 pt-2"
> >
{{ formatDateLine(dueDate) }} <DueDateSingle :due-date="dueDate" :single-line="true"></DueDateSingle>
</div> </div>
<div v-if="dueDates.length === 0">{{ $t("dueDates.noDueDatesAvailable") }}</div> <div v-if="dueDates.length === 0">{{ $t("dueDates.noDueDatesAvailable") }}</div>
<a class="border-t border-gray-500 pt-8 underline" href=""> <a class="border-t border-gray-500 pt-8 underline" href="">

View File

@ -575,8 +575,9 @@ export type DueDate = {
start: Dayjs; start: Dayjs;
end: Dayjs; end: Dayjs;
title: string; title: string;
learning_content_description: string; assignment_type_translation_key: string;
description: string; date_type_translation_key: string;
subtitle: string;
url: string; url: string;
course_session: number | null; course_session: number | null;
page: number | null; page: number | null;

View File

@ -1,25 +1,158 @@
# Generated by Django 3.2.20 on 2023-08-23 09:27 # Generated by Django 3.2.20 on 2023-08-23 09:27
from django.db import migrations
import wagtail.blocks import wagtail.blocks
import wagtail.fields import wagtail.fields
from django.db import migrations
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
('assignment', '0005_alter_assignment_assignment_type'), ("assignment", "0005_alter_assignment_assignment_type"),
] ]
operations = [ operations = [
migrations.AlterField( migrations.AlterField(
model_name='assignment', model_name="assignment",
name='evaluation_tasks', name="evaluation_tasks",
field=wagtail.fields.StreamField([('task', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock()), ('description', wagtail.blocks.RichTextBlock(blank=True, features=['ul', 'bold', 'italic', 'link'], required=False)), ('max_points', wagtail.blocks.IntegerBlock()), ('sub_tasks', wagtail.blocks.ListBlock(wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock()), ('description', wagtail.blocks.RichTextBlock(blank=True, features=['ul', 'bold', 'italic', 'link'], required=False)), ('points', wagtail.blocks.IntegerBlock())]), blank=True, use_json_field=True))]))], blank=True, help_text='Beurteilungsschritte', use_json_field=True), field=wagtail.fields.StreamField(
[
(
"task",
wagtail.blocks.StructBlock(
[
("title", wagtail.blocks.TextBlock()),
(
"description",
wagtail.blocks.RichTextBlock(
blank=True,
features=["ul", "bold", "italic", "link"],
required=False,
),
),
("max_points", wagtail.blocks.IntegerBlock()),
(
"sub_tasks",
wagtail.blocks.ListBlock(
wagtail.blocks.StructBlock(
[
("title", wagtail.blocks.TextBlock()),
(
"description",
wagtail.blocks.RichTextBlock(
blank=True,
features=[
"ul",
"bold",
"italic",
"link",
],
required=False,
),
),
(
"points",
wagtail.blocks.IntegerBlock(),
),
]
),
blank=True,
use_json_field=True,
),
),
]
),
)
],
blank=True,
help_text="Beurteilungsschritte",
use_json_field=True,
),
),
migrations.AlterField(
model_name="assignment",
name="tasks",
field=wagtail.fields.StreamField(
[
(
"task",
wagtail.blocks.StructBlock(
[
("title", wagtail.blocks.TextBlock()),
(
"file_submission_required",
wagtail.blocks.BooleanBlock(required=False),
),
(
"content",
wagtail.blocks.StreamBlock(
[
(
"explanation",
wagtail.blocks.StructBlock(
[
(
"text",
wagtail.blocks.RichTextBlock(
features=[
"ul",
"bold",
"italic",
"link",
]
),
)
]
),
),
(
"user_text_input",
wagtail.blocks.StructBlock(
[
(
"text",
wagtail.blocks.RichTextBlock(
blank=True,
features=[
"ul",
"bold",
"italic",
"link",
],
required=False,
),
)
]
),
),
(
"user_confirmation",
wagtail.blocks.StructBlock(
[
(
"text",
wagtail.blocks.RichTextBlock(
features=[
"ul",
"bold",
"italic",
"link",
]
),
)
]
),
),
],
blank=True,
),
),
]
),
)
],
blank=True,
help_text="Teilaufgaben",
use_json_field=True,
), ),
migrations.AlterField(
model_name='assignment',
name='tasks',
field=wagtail.fields.StreamField([('task', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock()), ('file_submission_required', wagtail.blocks.BooleanBlock(required=False)), ('content', wagtail.blocks.StreamBlock([('explanation', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['ul', 'bold', 'italic', 'link']))])), ('user_text_input', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(blank=True, features=['ul', 'bold', 'italic', 'link'], required=False))])), ('user_confirmation', wagtail.blocks.StructBlock([('text', wagtail.blocks.RichTextBlock(features=['ul', 'bold', 'italic', 'link']))]))], blank=True))]))], blank=True, help_text='Teilaufgaben', use_json_field=True),
), ),
] ]

View File

@ -4,62 +4,91 @@ from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
('duedate', '0002_alter_duedate_start'), ("duedate", "0002_alter_duedate_start"),
] ]
operations = [ operations = [
migrations.AlterModelOptions( migrations.AlterModelOptions(
name='duedate', name="duedate",
options={'ordering': ['start', 'end']}, options={"ordering": ["start", "end"]},
), ),
migrations.RemoveField( migrations.RemoveField(
model_name='duedate', model_name="duedate",
name='description', name="description",
), ),
migrations.RemoveField( migrations.RemoveField(
model_name='duedate', model_name="duedate",
name='learning_content_description', name="learning_content_description",
), ),
migrations.AddField( migrations.AddField(
model_name='duedate', model_name="duedate",
name='assignment_type_translation_key', name="assignment_type_translation_key",
field=models.CharField(blank=True, default='', help_text='Translation Key aus dem Frontend', max_length=1024), field=models.CharField(
blank=True,
default="",
help_text="Translation Key aus dem Frontend",
max_length=1024,
),
), ),
migrations.AddField( migrations.AddField(
model_name='duedate', model_name="duedate",
name='date_type_translation_key', name="date_type_translation_key",
field=models.CharField(blank=True, default='', help_text='Translation Key aus dem Frontend', max_length=1024), field=models.CharField(
blank=True,
default="",
help_text="Translation Key aus dem Frontend",
max_length=1024,
),
), ),
migrations.AddField( migrations.AddField(
model_name='duedate', model_name="duedate",
name='manual_override_fields', name="manual_override_fields",
field=models.BooleanField(default=False, help_text='Nur aktivieren, wenn man die Felder manuell überschreiben will'), field=models.BooleanField(
default=False,
help_text="Nur aktivieren, wenn man die Felder manuell überschreiben will",
),
), ),
migrations.AddField( migrations.AddField(
model_name='duedate', model_name="duedate",
name='subtitle', name="subtitle",
field=models.TextField(blank=True, default='', help_text='Überschreibt den Untertitel bei `assignment_type_translation_key` und `date_type_translation_key`'), field=models.TextField(
blank=True,
default="",
help_text="Überschreibt den Untertitel bei `assignment_type_translation_key` und `date_type_translation_key`",
),
), ),
migrations.AlterField( migrations.AlterField(
model_name='duedate', model_name="duedate",
name='end', name="end",
field=models.DateTimeField(blank=True, db_index=True, help_text='Enddatum ist optional', null=True), field=models.DateTimeField(
blank=True, db_index=True, help_text="Enddatum ist optional", null=True
),
), ),
migrations.AlterField( migrations.AlterField(
model_name='duedate', model_name="duedate",
name='start', name="start",
field=models.DateTimeField(blank=True, db_index=True, help_text='Startdatum ist Pflicht', null=True), field=models.DateTimeField(
blank=True, db_index=True, help_text="Startdatum ist Pflicht", null=True
),
), ),
migrations.AlterField( migrations.AlterField(
model_name='duedate', model_name="duedate",
name='title', name="title",
field=models.CharField(default='', help_text='Title wird standarmässig vom LearningContent übernommen', max_length=1024), field=models.CharField(
default="",
help_text="Title wird standarmässig vom LearningContent übernommen",
max_length=1024,
),
), ),
migrations.AlterField( migrations.AlterField(
model_name='duedate', model_name="duedate",
name='url', name="url",
field=models.CharField(blank=True, default='', help_text='URL wird vom LearningContent übernommen', max_length=1024), field=models.CharField(
blank=True,
default="",
help_text="URL wird vom LearningContent übernommen",
max_length=1024,
),
), ),
] ]

View File

@ -2,7 +2,6 @@ import datetime
from django.db import models from django.db import models
from django.utils import timezone from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from wagtail.models import Page from wagtail.models import Page
from vbv_lernwelt.core.models import User from vbv_lernwelt.core.models import User