CI / build-and-test (push) Canceled after 0s
Neuer 4. Tab in der Klassenlehreransicht: bündelt Titel, Beschreibung, Schlagwörter, verknüpfte Dokumentation und angeheftete (eingefrorene) WebUntis-Klassenbucheinträge zu einem laufenden Problem mit einer/einem oder mehreren Schüler*innen. Anheften direkt aus dem Klassenbuch-Tab per Rechtsklick. Sync-fähig nach dem bestehenden Documentation-Muster. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
66 lines
2.7 KiB
C#
66 lines
2.7 KiB
C#
using Avalonia.Controls;
|
|
using LehrerApp.Core.Interfaces;
|
|
using LehrerApp.Core.Models;
|
|
using LehrerApp.Desktop.ViewModels.ClassTeacher;
|
|
using LehrerApp.Desktop.ViewModels.Students;
|
|
using LehrerApp.Desktop.Views.Shared;
|
|
using LehrerApp.Desktop.Views.Students;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace LehrerApp.Desktop.Views.ClassTeacher;
|
|
|
|
public partial class ClassTeacherRegisterView : UserControl
|
|
{
|
|
public ClassTeacherRegisterView() => InitializeComponent();
|
|
|
|
protected override void OnDataContextChanged(EventArgs e)
|
|
{
|
|
base.OnDataContextChanged(e);
|
|
if (DataContext is not ClassTeacherDetailsViewModel vm) return;
|
|
vm.OnEditOwnDocumentation = ShowDocumentationDialog;
|
|
vm.OnConfirmDeleteOwnDocumentation = ShowDeleteDocumentationDialog;
|
|
vm.OnPickVorgangForPin = ShowPinToVorgangDialog;
|
|
}
|
|
|
|
private async Task<PinToVorgangChoice?> ShowPinToVorgangDialog(ClassTeacherClassRegisterRow row)
|
|
{
|
|
if (DataContext is not ClassTeacherDetailsViewModel vm) return null;
|
|
var owner = TopLevel.GetTopLevel(this) as Window;
|
|
if (owner is null) return null;
|
|
|
|
var summary = $"{row.DateLabel} · {row.StudentDisplayName} · {row.CategoryName}";
|
|
var matchingCases = vm.OpenCasesFor(row.StudentName);
|
|
var dialogVm = new PinToVorgangDialogViewModel(summary, matchingCases);
|
|
var dialog = new PinToVorgangDialog { DataContext = dialogVm };
|
|
var confirmed = await dialog.ShowDialog<bool>(owner);
|
|
return confirmed ? dialogVm.Result : null;
|
|
}
|
|
|
|
private async Task<Documentation?> ShowDocumentationDialog(
|
|
List<StudentOption> studentOptions, Documentation? editing)
|
|
{
|
|
var owner = TopLevel.GetTopLevel(this) as Window;
|
|
if (owner is null) return null;
|
|
|
|
var vm = new DocumentationDialogViewModel(editing?.StudentId ?? Guid.Empty, editing,
|
|
App.Services.GetRequiredService<IAttachmentStorage>(), studentOptions);
|
|
var dialog = new DocumentationDialog { DataContext = vm };
|
|
var saved = await dialog.ShowDialog<bool>(owner);
|
|
if (!saved) vm.DiscardUnsavedAttachments();
|
|
return saved ? vm.Result : null;
|
|
}
|
|
|
|
private async Task<bool> ShowDeleteDocumentationDialog(DocumentationItem item)
|
|
{
|
|
var info = new ConfirmDialogInfo
|
|
{
|
|
Title = "Eintrag löschen?",
|
|
Message = $"\"{item.Model.Title}\" ({item.StudentName}) wird als gelöscht markiert und nicht mehr angezeigt.",
|
|
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);
|
|
}
|
|
}
|