Planung: Stunde einer anderen Einheit zuweisen ("Einheit wechseln")
Bisher war die Einheit einer Stunde nach dem Anlegen fix - bei falscher Auswahl im Erstellen-Dialog blieb nur Löschen+Neuanlegen. Neuer Button öffnet einen Dialog zur Auswahl der Ziel-Einheit; die Ansicht springt danach automatisch dorthin mit der Stunde vorausgewählt. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@ using LehrerApp.Core.Interfaces;
|
||||
using LehrerApp.Core.Models;
|
||||
using LehrerApp.Core.Services;
|
||||
using LehrerApp.Desktop.Services;
|
||||
using LehrerApp.Desktop.ViewModels.Planning;
|
||||
using LehrerApp.Desktop.ViewModels.Students;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Globalization;
|
||||
@@ -75,6 +76,7 @@ public partial class PlanningTabViewModel : ObservableObject
|
||||
public Func<Lesson, List<string>, List<string>, Task<bool>>? OnEditLesson { get; set; }
|
||||
public Func<LessonSummary, Task<bool>>? OnConfirmDeleteLesson { get; set; }
|
||||
public Func<Lesson, Task<MoveLessonTarget?>>? OnPickMoveTarget { get; set; }
|
||||
public Func<Lesson, Task<Unit?>>? OnPickUnitChange { get; set; }
|
||||
public Func<Lesson, Task>? OnShowLesson { get; set; }
|
||||
public Func<Unit, Task<LessonSeriesResult?>>? OnGenerateLessonSeries { get; set; }
|
||||
public Func<Unit, Task<bool>>? OnAiAssist { get; set; }
|
||||
@@ -160,6 +162,7 @@ public partial class PlanningTabViewModel : ObservableObject
|
||||
EditLessonCommand.NotifyCanExecuteChanged();
|
||||
DeleteLessonCommand.NotifyCanExecuteChanged();
|
||||
MoveLessonCommand.NotifyCanExecuteChanged();
|
||||
ChangeLessonUnitCommand.NotifyCanExecuteChanged();
|
||||
AdvanceLessonStatusCommand.NotifyCanExecuteChanged();
|
||||
}
|
||||
|
||||
@@ -349,6 +352,23 @@ public partial class PlanningTabViewModel : ObservableObject
|
||||
new LessonSchedulingService(_lessons).Move(moved, newDate, newPeriod, shiftFollowing);
|
||||
}
|
||||
|
||||
/// Ordnet eine bereits angelegte Stunde einer anderen Einheit derselben Gruppe zu (Korrektur
|
||||
/// einer im Erstellen-Dialog falsch gewählten Einheit, Nutzer-Feedback) — bisher war das nur
|
||||
/// über Löschen + Neuanlegen möglich. Datum/Stundennummer bleiben unverändert, nur UnitId ändert
|
||||
/// sich. Nach dem Speichern springt die Ansicht direkt zur Ziel-Einheit mit der Stunde
|
||||
/// vorausgewählt, damit sichtbar bleibt, wohin sie verschoben wurde.
|
||||
[RelayCommand(CanExecute = nameof(HasSelectedLesson))]
|
||||
private async Task ChangeLessonUnit()
|
||||
{
|
||||
if (OnPickUnitChange is null || SelectedLesson is null) return;
|
||||
var lesson = SelectedLesson.Model;
|
||||
var targetUnit = await OnPickUnitChange(lesson);
|
||||
if (targetUnit is null) return;
|
||||
lesson.UnitId = targetUnit.Id;
|
||||
_lessons.Save(lesson);
|
||||
RefreshPlanning(selectUnitId: targetUnit.Id, selectLessonId: lesson.Id);
|
||||
}
|
||||
|
||||
[RelayCommand(CanExecute = nameof(HasSelectedLesson))]
|
||||
private void AdvanceLessonStatus()
|
||||
{
|
||||
@@ -1206,6 +1226,38 @@ public partial class MoveLessonDialogViewModel : ObservableObject
|
||||
}
|
||||
}
|
||||
|
||||
// ── Dialog: Stunde einer anderen Einheit zuweisen (Korrektur der Einheit) ────
|
||||
|
||||
public partial class ChangeLessonUnitDialogViewModel : ObservableObject
|
||||
{
|
||||
[ObservableProperty] private TimetableUnitOption? _selectedUnit;
|
||||
[ObservableProperty] private string _error = "";
|
||||
|
||||
public string CurrentUnitLabel { get; }
|
||||
public ObservableCollection<TimetableUnitOption> Units { get; } = [];
|
||||
public bool HasUnits => Units.Count > 0;
|
||||
public Unit? Result { get; private set; }
|
||||
|
||||
public ChangeLessonUnitDialogViewModel(IUnitRepository units, Guid groupId, Guid currentUnitId,
|
||||
string currentUnitTitle)
|
||||
{
|
||||
CurrentUnitLabel = currentUnitTitle;
|
||||
foreach (var unit in units.GetByGroup(groupId).Where(u => u.Id != currentUnitId)
|
||||
.OrderBy(u => u.Status == UnitStatus.Active ? 0 : u.Status == UnitStatus.Planned ? 1 : 2)
|
||||
.ThenByDescending(u => u.StartDate)
|
||||
.ThenBy(u => u.Title, StringComparer.CurrentCultureIgnoreCase))
|
||||
Units.Add(new TimetableUnitOption(unit));
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void Save()
|
||||
{
|
||||
Error = "";
|
||||
if (SelectedUnit is null) { Error = "Bitte eine Ziel-Einheit auswählen."; return; }
|
||||
Result = SelectedUnit.Model;
|
||||
}
|
||||
}
|
||||
|
||||
// ── Dialog: Stunden serienweise aus dem Stundenplan erzeugen (4.2.5) ────────
|
||||
|
||||
public partial class GenerateLessonSeriesDialogViewModel : ObservableObject
|
||||
|
||||
Reference in New Issue
Block a user