CI / build-and-test (push) Canceled after 0s
Ein Dokumentationseintrag kann jetzt weitere Schüler*innen betreffen (Documentation.AdditionalStudentIds, StudentId bleibt Hauptperson). Der Eintrag existiert nur einmal, erscheint aber im Dokumentations-Tab jeder beteiligten Person. Der Dokumentations-Dialog bietet in beiden Vorgänge-Tabs "Betrifft außerdem" mit den Beteiligten des Vorgangs an. Klassenlehrer-Listen, WebUntis-Abgleich, Löschfristen und Referenzzählung berücksichtigen die weiteren Beteiligten. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
85 lines
3.5 KiB
C#
85 lines
3.5 KiB
C#
using Avalonia.Controls;
|
|
using LehrerApp.Core.Interfaces;
|
|
using LehrerApp.Core.Models;
|
|
using LehrerApp.Desktop.Services;
|
|
using LehrerApp.Desktop.ViewModels.ClassTeacher;
|
|
using LehrerApp.Desktop.ViewModels.Students;
|
|
using LehrerApp.Desktop.Views.ClassTeacher;
|
|
using LehrerApp.Desktop.Views.Shared;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace LehrerApp.Desktop.Views.Students;
|
|
|
|
public partial class StudentVorgaengeTabView : UserControl
|
|
{
|
|
public StudentVorgaengeTabView() => InitializeComponent();
|
|
|
|
protected override void OnDataContextChanged(EventArgs e)
|
|
{
|
|
base.OnDataContextChanged(e);
|
|
if (DataContext is not StudentVorgaengeViewModel vm) return;
|
|
vm.OnEditVorgang = ShowVorgangDialog;
|
|
vm.OnConfirmDeleteVorgang = ShowDeleteVorgangDialog;
|
|
vm.OnEditDocumentation = ShowDocumentationDialog;
|
|
vm.OnConfirmCreateForWarning = ShowConfirmCreateDialog;
|
|
}
|
|
|
|
private async Task<Vorgang?> ShowVorgangDialog(List<StudentOption> students, Vorgang? editing)
|
|
{
|
|
var owner = TopLevel.GetTopLevel(this) as Window;
|
|
if (owner is null) return null;
|
|
|
|
var tab = DataContext as StudentVorgaengeViewModel;
|
|
var vm = new VorgangDialogViewModel(students, editing, tab?.BuildQuickBlocks(),
|
|
isNewDraft: editing is not null && tab?.IsPersisted(editing) == false,
|
|
phraseBlocks: VorgangPhraseBlocks.ForStudent(DateOnly.FromDateTime(DateTime.Today)));
|
|
var dialog = new VorgangDialog { DataContext = vm };
|
|
var saved = await dialog.ShowDialog<bool>(owner);
|
|
return saved ? vm.Result : null;
|
|
}
|
|
|
|
private async Task<bool> ShowDeleteVorgangDialog(VorgangItem item)
|
|
{
|
|
var info = new ConfirmDialogInfo
|
|
{
|
|
Title = "Vorgang löschen?",
|
|
Message = $"\"{item.Model.Title}\" wird als gelöscht markiert und nicht mehr angezeigt. " +
|
|
"Verknüpfte Dokumentation bleibt erhalten.",
|
|
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<Documentation?> ShowDocumentationDialog(
|
|
Guid studentId, List<StudentOption> coStudentOptions, Documentation? editing)
|
|
{
|
|
var owner = TopLevel.GetTopLevel(this) as Window;
|
|
if (owner is null) return null;
|
|
|
|
var isNewDraft = editing is not null
|
|
&& (DataContext as StudentVorgaengeViewModel)?.IsNewDocumentationDraft(editing) == true;
|
|
var vm = new DocumentationDialogViewModel(studentId, editing,
|
|
App.Services.GetRequiredService<IAttachmentStorage>(), isNewDraft: isNewDraft,
|
|
coStudentOptions: coStudentOptions);
|
|
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> ShowConfirmCreateDialog(string suggestedTag)
|
|
{
|
|
var info = new ConfirmDialogInfo
|
|
{
|
|
Title = "Neuen Vorgang anlegen?",
|
|
Message = $"Kein offener Vorgang zu \"{suggestedTag}\" gefunden. Neuen anlegen?",
|
|
ConfirmText = "Anlegen",
|
|
};
|
|
var dialog = new ConfirmDialog { DataContext = info };
|
|
var owner = TopLevel.GetTopLevel(this) as Window;
|
|
return owner is not null && await dialog.ShowDialog<bool>(owner);
|
|
}
|
|
}
|