Unterrichtsplanung: Einheiten, Verlaufsplan-Editor, Kürzel-Katalog (Kapitel 4.1/4.2)

Neuer Tab "Planung" in GroupDetailView ersetzt den Platzhalter: Einheiten anlegen/bearbeiten/
als Vorlage in andere Gruppe kopieren, Stunden je Einheit mit Verschieben (inkl. Nachrücken
der Folgestunden). Stundeneditor als tabellarischer Verlaufsplan (Phase/Dauer/Tätigkeit/
Material/Kurzsymbol je Zeile, Uhrzeit aus optionalem Stundenbeginn abgeleitet) statt eines
einzelnen Phase-Felds mit Methoden-/Materialien-Chips — Kurzsymbol als Freitext mit
Vorschlägen aus neuem Kürzel-Katalog (Einstellungen) plus bisher verwendeten Werten.
Schema-Migrationen v1-v3 überführen bestehende Daten verlustfrei. 4.2.5 bewusst offen
gelassen (hängt an Stundenplan, Kapitel 4.3).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-14 00:50:57 +02:00
co-authored by Claude Sonnet 5
parent 27359794f7
commit de6ea001e7
28 changed files with 2372 additions and 32 deletions
@@ -0,0 +1,114 @@
using Avalonia.Controls;
using LehrerApp.Core.Interfaces;
using LehrerApp.Core.Models;
using LehrerApp.Desktop.ViewModels.Groups;
using LehrerApp.Desktop.Views.Shared;
using Microsoft.Extensions.DependencyInjection;
namespace LehrerApp.Desktop.Views.Groups;
public partial class PlanningTabView : UserControl
{
public PlanningTabView() => InitializeComponent();
protected override void OnDataContextChanged(EventArgs e)
{
base.OnDataContextChanged(e);
if (DataContext is PlanningTabViewModel vm)
{
vm.OnAddUnit = groupId => ShowUnitDialog(groupId, editingUnit: null);
vm.OnEditUnit = unit => ShowUnitDialog(unit.GroupId, editingUnit: unit);
vm.OnConfirmDeleteUnit = ShowDeleteUnitDialog;
vm.OnPickCopyTarget = ShowCopyUnitDialog;
vm.OnAddLesson = (unitId, groupId, materials, shorthands) =>
ShowLessonDialog(unitId, groupId, materials, shorthands, editingLesson: null);
vm.OnEditLesson = (lesson, materials, shorthands) =>
ShowLessonDialog(lesson.UnitId, lesson.GroupId, materials, shorthands, editingLesson: lesson);
vm.OnConfirmDeleteLesson = ShowDeleteLessonDialog;
vm.OnPickMoveTarget = ShowMoveLessonDialog;
}
}
private async Task<bool> ShowUnitDialog(Guid groupId, Unit? editingUnit)
{
if (DataContext is not PlanningTabViewModel vm) return false;
var dialogVm = new UnitDialogViewModel(
App.Services.GetRequiredService<IUnitRepository>(),
App.Services.GetRequiredService<ICompetencyDomainRepository>(),
groupId, vm.SubjectId, vm.GradeLevel, vm.SubjectName, editingUnit);
var dialog = new UnitDialog { DataContext = dialogVm };
var owner = TopLevel.GetTopLevel(this) as Window;
if (owner is null) return false;
var ok = await dialog.ShowDialog<bool>(owner);
return ok && dialogVm.Result is not null;
}
private async Task<bool> ShowDeleteUnitDialog(UnitSummary unit)
{
var info = new ConfirmDialogInfo
{
Title = "Einheit löschen?",
Message = $"\"{unit.Title}\" wird inkl. aller zugehörigen Stunden endgültig gelöscht.",
ConfirmText = "Löschen",
};
var dialog = new ConfirmDialog { DataContext = info };
var owner = TopLevel.GetTopLevel(this) as Window;
return owner is not null && await dialog.ShowDialog<bool>(owner);
}
private async Task<CopyUnitTarget?> ShowCopyUnitDialog(Unit unit)
{
var dialogVm = new CopyUnitDialogViewModel(
App.Services.GetRequiredService<IGroupRepository>(), unit.GroupId);
var dialog = new CopyUnitDialog { DataContext = dialogVm };
var owner = TopLevel.GetTopLevel(this) as Window;
if (owner is null) return null;
var ok = await dialog.ShowDialog<bool>(owner);
return ok ? dialogVm.Result : null;
}
private async Task<bool> ShowLessonDialog(Guid unitId, Guid groupId,
List<string> materialSuggestions, List<string> shorthandHistorySuggestions, Lesson? editingLesson)
{
var dialogVm = new LessonDialogViewModel(
App.Services.GetRequiredService<ILessonRepository>(),
App.Services.GetRequiredService<IShorthandCodeRepository>(),
unitId, groupId, materialSuggestions, shorthandHistorySuggestions, editingLesson);
var dialog = new LessonDialog { DataContext = dialogVm };
var owner = TopLevel.GetTopLevel(this) as Window;
if (owner is null) return false;
var ok = await dialog.ShowDialog<bool>(owner);
return ok && dialogVm.Result is not null;
}
private async Task<bool> ShowDeleteLessonDialog(LessonSummary lesson)
{
var info = new ConfirmDialogInfo
{
Title = "Stunde löschen?",
Message = $"Die Stunde vom {lesson.DateDisplay} wird endgültig gelöscht.",
ConfirmText = "Löschen",
};
var dialog = new ConfirmDialog { DataContext = info };
var owner = TopLevel.GetTopLevel(this) as Window;
return owner is not null && await dialog.ShowDialog<bool>(owner);
}
private async Task<MoveLessonTarget?> ShowMoveLessonDialog(Lesson lesson)
{
var dialogVm = new MoveLessonDialogViewModel(lesson.Date);
var dialog = new MoveLessonDialog { DataContext = dialogVm };
var owner = TopLevel.GetTopLevel(this) as Window;
if (owner is null) return null;
var ok = await dialog.ShowDialog<bool>(owner);
return ok ? dialogVm.Result : null;
}
}