Add warning detail popup and quick blocks for Vorgänge
CI / build-and-test (push) Canceled after 0s

Dashboard warnings (attendance, homework, lateness) get a "Details" flyout
with key figures, a list of dates and the compact month calendar from the
class teacher overview, now extracted as a shared control. The calendar
now aligns days under their weekday (Mo-So header, blank leading cells).

Creating Vorgänge and documentation is supported by quick blocks with the
current figures, dated standard phrases (e.g. "Klassenleitung informiert")
and documentation templates (status snapshot, conversation, informing the
class/subject teachers, parent call, parent letter). The class teacher
Vorgänge tab uses WebUntis figures (absences across all subjects, class
register) for the same blocks and templates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 5.5 committed 2026-09-26 11:16:13 +02:00
1 parent 0f6cadc9c8
commit aa326cf8b6
25 files changed
+1571 -75

No files matched your search

@@ -3,6 +3,7 @@ using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using LehrerApp.Core.Interfaces;
using LehrerApp.Core.Models;
using LehrerApp.Desktop.Services;
using LehrerApp.Desktop.ViewModels.ClassTeacher;
namespace LehrerApp.Desktop.ViewModels.Students;
@@ -21,8 +22,12 @@ public partial class StudentVorgaengeViewModel : ObservableObject
private readonly IVorgangRepository _vorgaenge;
private readonly IDocumentationRepository _documentation;
private readonly IStudentRepository _students;
private readonly StudentWarningEvidenceService? _evidence;
private Guid _studentId;
// Id eines aus einer Vorlage erzeugten, noch ungespeicherten Dokumentations-Entwurfs — damit
// der Dialog "hinzufügen" statt "bearbeiten" titelt (siehe IsNewDocumentationDraft).
private Guid? _documentationDraftId;
private string _studentName = "";
private List<StudentOption> _studentOptions = [];
@@ -39,14 +44,29 @@ public partial class StudentVorgaengeViewModel : ObservableObject
/// (siehe <see cref="HandleWarningNavigation"/>) — Parameter ist das gesuchte Tag.
public Func<string, Task<bool>>? OnConfirmCreateForWarning { get; set; }
/// <param name="evidence">Quelle für Schnellbausteine/Vorlagen mit dem aktuellen Stand
/// (Fehlquote, Hausaufgaben, Verspätungen). Optional, damit Tests ohne Mitarbeits-Repositories
/// auskommen — ohne sie entfallen Bausteine und Vorlagen einfach.</param>
public StudentVorgaengeViewModel(IVorgangRepository vorgaenge, IDocumentationRepository documentation,
IStudentRepository students)
IStudentRepository students, StudentWarningEvidenceService? evidence = null)
{
_vorgaenge = vorgaenge;
_documentation = documentation;
_students = students;
_evidence = evidence;
}
/// Frisch berechnet bei jedem Dialog-Aufruf statt beim Laden gecacht — der Tab kann lange offen
/// bleiben, während im Unterricht weiter Anwesenheit erfasst wird.
public IReadOnlyList<VorgangQuickBlock> BuildQuickBlocks() =>
_evidence is null ? [] : StudentEvidenceText.QuickBlocks(_evidence.Build(_studentId));
/// Ob ein an OnEditVorgang übergebener Vorgang schon gespeichert ist oder nur ein vorbefüllter
/// Entwurf (HandleWarningNavigation) — steuert den Dialogtitel "anlegen"/"bearbeiten".
public bool IsPersisted(Vorgang vorgang) => _vorgaenge.GetById(vorgang.Id) is not null;
public bool IsNewDocumentationDraft(Documentation doc) => doc.Id == _documentationDraftId;
partial void OnOnlyOpenChanged(bool value) => Load(_studentId);
[RelayCommand] private void Refresh() => Load(_studentId);
@@ -80,7 +100,10 @@ public partial class StudentVorgaengeViewModel : ObservableObject
.Where(n => !string.IsNullOrEmpty(n)));
var item = new VorgangItem(vorgang, names, LinkDocumentation, UnlinkDocumentation,
RemoveClassRegisterEntry, EditDocumentation)
{ IsRevealed = revealedIds.Contains(vorgang.Id) };
{
IsRevealed = revealedIds.Contains(vorgang.Id),
OnCreateFromTemplate = _evidence is null ? null : CreateDocumentationFromTemplate,
};
var linkedIds = vorgang.DocumentationIds.ToHashSet();
foreach (var doc in ownDocs.Where(d => linkedIds.Contains(d.Id)))
@@ -146,6 +169,27 @@ public partial class StudentVorgaengeViewModel : ObservableObject
Load(_studentId);
}
/// Erzeugt aus einer Vorlage (VorgangDocumentationTemplates) einen vorbefüllten Entwurf mit dem
/// aktuellen Stand, öffnet ihn im normalen Dokumentations-Dialog und verknüpft ihn nach dem
/// Speichern mit dem Vorgang — gleicher Abschluss wie CreateAndLinkDocumentation.
private async Task CreateDocumentationFromTemplate(VorgangItem item, string key)
{
if (_evidence is null || OnEditDocumentation is null) return;
var draft = VorgangDocumentationTemplates.Build(key, item.Model, _evidence.Build(_studentId));
if (draft is null) return;
_documentationDraftId = draft.Id;
Documentation? result;
try { result = await OnEditDocumentation(_studentId, draft); }
finally { _documentationDraftId = null; }
if (result is null) return;
_documentation.Save(result);
item.Model.DocumentationIds.Add(result.Id);
_vorgaenge.Save(item.Model);
Load(_studentId);
var reloaded = Cases.FirstOrDefault(c => c.Model.Id == item.Model.Id);
if (reloaded is not null) reloaded.IsRevealed = true;
}
private async Task EditDocumentation(DocumentationItem doc)
{
if (OnEditDocumentation is null) return;
@@ -199,7 +243,14 @@ public partial class StudentVorgaengeViewModel : ObservableObject
if (OnConfirmCreateForWarning is null || OnEditVorgang is null) return;
if (!await OnConfirmCreateForWarning(suggestedTag)) return;
var draft = new Vorgang { Title = suggestedTitle, StudentIds = [_studentId], Tags = [suggestedTag] };
// Nutzer-Feedback: die Zahlen, die die Warnung ausgelöst haben, gleich als Beschreibung
// mitgeben, statt sie im Dialog von Hand abzutippen — bleibt im Dialog frei editierbar.
var description = _evidence is null ? ""
: StudentEvidenceText.StatusBlockForTag(suggestedTag, _evidence.Build(_studentId)) ?? "";
var draft = new Vorgang
{
Title = suggestedTitle, Description = description, StudentIds = [_studentId], Tags = [suggestedTag],
};
var result = await OnEditVorgang(_studentOptions, draft);
if (result is null) return;
_vorgaenge.Save(result);