This commit is contained in:
1 parent
cbcb739097
commit
fb38b6bb04
5 files changed
+53
-1
No files matched your search
@@ -789,6 +789,10 @@ public partial class LessonDialogViewModel : ObservableObject
|
||||
// Für die KI-Unterstützung mit Fokus auf genau diese Stunde (4.5.22) — nur für bereits
|
||||
// gespeicherte Stunden sinnvoll, eine gerade erst angelegte, noch ungespeicherte Stunde hat
|
||||
// keine echte Id, auf die sich die KI beziehen könnte.
|
||||
// Persist a pending parent only after validation and before writing its first lesson.
|
||||
public Action? BeforeSave { get; set; }
|
||||
public void EnsureParentSaved() => BeforeSave?.Invoke();
|
||||
|
||||
public Guid UnitId => _unitId;
|
||||
public Guid GroupId => _groupId;
|
||||
public Lesson? EditingLesson => _editingLesson;
|
||||
@@ -1079,6 +1083,7 @@ public partial class LessonDialogViewModel : ObservableObject
|
||||
|
||||
if (!valid) return;
|
||||
|
||||
EnsureParentSaved();
|
||||
Result = _editingLesson ?? new Lesson { UnitId = _unitId, GroupId = _groupId };
|
||||
Result.UnitId = _unitId;
|
||||
Result.GroupId = _groupId;
|
||||
|
||||
@@ -265,6 +265,7 @@ public partial class LessonDialog : Window
|
||||
chosen = picked;
|
||||
}
|
||||
|
||||
vm.EnsureParentSaved();
|
||||
chosen.UnitId = vm.UnitId;
|
||||
chosen.Date = date;
|
||||
chosen.LessonNumber = vm.LessonNumber;
|
||||
|
||||
@@ -121,10 +121,14 @@ public partial class TimetableView : UserControl
|
||||
App.Services.GetRequiredService<IAttachmentStorage>(),
|
||||
unit.Id, group.Id, group.Name, subject?.Name ?? "", materials, shorthands,
|
||||
editingLesson: null, suggestedDate: request.Date, suggestedPeriod: request.PeriodNumber);
|
||||
if (pickerVm.ResultIsNew)
|
||||
lessonVm.BeforeSave = () =>
|
||||
{
|
||||
if (units.GetById(unit.Id) is null) units.Save(unit);
|
||||
};
|
||||
var lessonDialog = new LessonDialog { DataContext = lessonVm };
|
||||
if (await lessonDialog.ShowDialog<bool>(owner) && lessonVm.Result is not null)
|
||||
{
|
||||
if (pickerVm.ResultIsNew) units.Save(unit);
|
||||
(DataContext as TimetableViewModel)?.Load();
|
||||
App.Services.GetRequiredService<NotificationService>().ShowSuccess("Stunde angelegt.");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user