Details Lerngruppe, Archiv, Stub Import

This commit is contained in:
2026-08-11 17:54:10 +02:00
parent 7a1f89cd4a
commit fd715dd5a5
11 changed files with 281 additions and 40 deletions
@@ -3,13 +3,13 @@
xmlns:vm="clr-namespace:LehrerApp.Desktop.ViewModels.Groups"
x:Class="LehrerApp.Desktop.Views.Groups.AddGroupDialog"
x:DataType="vm:AddGroupDialogViewModel"
Title="Neue Lerngruppe"
Title="{Binding DialogTitle}"
Width="420" SizeToContent="Height"
CanResize="False" WindowStartupLocation="CenterOwner">
<Grid RowDefinitions="*,Auto" Margin="24">
<StackPanel Grid.Row="0" Spacing="14">
<TextBlock Text="Neue Lerngruppe anlegen" FontSize="18" FontWeight="SemiBold"/>
<TextBlock Text="{Binding DialogTitle}" FontSize="18" FontWeight="SemiBold"/>
<!-- Typ: Klasse oder Kurs -->
<StackPanel Spacing="4">
@@ -49,13 +49,28 @@
</StackPanel>
</Grid>
<Grid ColumnDefinitions="*,12,*">
<StackPanel Grid.Column="0" Spacing="4">
<TextBlock Text="Bewertungssystem" FontSize="12" Opacity="0.7"/>
<ComboBox ItemsSource="{Binding GradingOptions}"
SelectedItem="{Binding SelectedGradingName}"
HorizontalAlignment="Stretch"/>
</StackPanel>
<StackPanel Grid.Column="2" Spacing="4">
<TextBlock Text="Wochenstunden (optional)" FontSize="12" Opacity="0.7"/>
<NumericUpDown Value="{Binding HoursPerWeek}" Minimum="1" Maximum="40" FormatString="0"
HorizontalAlignment="Stretch"/>
</StackPanel>
</Grid>
<TextBlock Text="{Binding ValidationMessage}" Foreground="Red" FontSize="12"
IsVisible="{Binding ValidationMessage, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"/>
</StackPanel>
<Grid Grid.Row="1" ColumnDefinitions="*,8,*" Margin="0,20,0,0">
<Button Grid.Column="0" Content="Abbrechen" HorizontalAlignment="Stretch" Click="OnCancel"/>
<Button Grid.Column="2" Content="Anlegen" HorizontalAlignment="Stretch" Click="OnSave"/>
<Button Grid.Column="2" Content="{Binding SaveButtonText}"
HorizontalAlignment="Stretch" Click="OnSave"/>
</Grid>
</Grid>
</Window>
@@ -0,0 +1,20 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="LehrerApp.Desktop.Views.Groups.DeleteGroupDialog"
x:CompileBindings="False"
Title="Lerngruppe löschen"
Width="430" SizeToContent="Height"
CanResize="False" WindowStartupLocation="CenterOwner">
<Grid RowDefinitions="*,Auto" Margin="24">
<StackPanel Grid.Row="0" Spacing="12">
<TextBlock Text="Lerngruppe wirklich löschen?" FontSize="18" FontWeight="SemiBold"/>
<TextBlock Text="{Binding}" FontSize="15" FontWeight="SemiBold" TextWrapping="Wrap"/>
<TextBlock Text="Dabei werden auch Einschreibungen, Klausuren, Noten, Unterrichtsplanung und Mitarbeitseinträge dieser Lerngruppe dauerhaft gelöscht. Wenn du die Gruppe nur ausblenden möchtest, nutze stattdessen das Archiv."
TextWrapping="Wrap" Opacity="0.7"/>
</StackPanel>
<Grid Grid.Row="1" ColumnDefinitions="*,8,*" Margin="0,20,0,0">
<Button Grid.Column="0" Content="Abbrechen" HorizontalAlignment="Stretch" Click="OnCancel"/>
<Button Grid.Column="2" Content="Endgültig löschen" HorizontalAlignment="Stretch" Click="OnDelete"/>
</Grid>
</Grid>
</Window>
@@ -0,0 +1,12 @@
using Avalonia.Controls;
using Avalonia.Interactivity;
namespace LehrerApp.Desktop.Views.Groups;
public partial class DeleteGroupDialog : Window
{
public DeleteGroupDialog() => InitializeComponent();
private void OnDelete(object? sender, RoutedEventArgs e) => Close(true);
private void OnCancel(object? sender, RoutedEventArgs e) => Close(false);
}
@@ -13,11 +13,7 @@
<Grid ColumnDefinitions="*,Auto,Auto">
<StackPanel Grid.Column="0">
<TextBlock Text="Lerngruppen" FontSize="22" FontWeight="SemiBold"/>
<TextBlock FontSize="12" Opacity="0.5">
<Run Text="{Binding Groups.Count}"/>
<Run Text=" Gruppen · "/>
<Run Text="{Binding SelectedSchoolYear}"/>
</TextBlock>
<TextBlock Text="{Binding ListSummary}" FontSize="12" Opacity="0.5"/>
</StackPanel>
<ComboBox Grid.Column="1" ItemsSource="{Binding SchoolYears}"
SelectedItem="{Binding SelectedSchoolYear}"
@@ -35,8 +31,13 @@
BorderBrush="{DynamicResource SystemControlForegroundBaseLowBrush}"
BorderThickness="0,0,1,0">
<DockPanel>
<TextBox DockPanel.Dock="Top" Text="{Binding SearchText}"
PlaceholderText="Suchen…" Margin="12,8"/>
<StackPanel DockPanel.Dock="Top" Margin="12,8" Spacing="8">
<TextBox Text="{Binding SearchText}" PlaceholderText="Suchen…"/>
<ToggleSwitch Content="Archiv anzeigen" IsChecked="{Binding ShowArchived}"/>
</StackPanel>
<TextBlock Text="{Binding EmptyListMessage}" TextWrapping="Wrap"
Margin="16,12" FontSize="12" Opacity="0.45"
IsVisible="{Binding HasNoGroups}"/>
<ListBox ItemsSource="{Binding Groups}"
SelectedItem="{Binding SelectedGroup}">
<ListBox.ItemTemplate>
@@ -79,12 +80,31 @@
<StackPanel Margin="28,24" Spacing="20">
<!-- Gruppenname und Kurzinfos -->
<StackPanel Spacing="4">
<TextBlock Text="{Binding SelectedGroupDisplayName}"
FontSize="24" FontWeight="SemiBold" TextWrapping="Wrap"/>
<TextBlock Text="{Binding SelectedGroupSubtitle}"
FontSize="12" Opacity="0.55"/>
</StackPanel>
<Grid ColumnDefinitions="*,Auto">
<StackPanel Grid.Column="0" Spacing="4">
<TextBlock Text="{Binding SelectedGroupDisplayName}"
FontSize="24" FontWeight="SemiBold" TextWrapping="Wrap"/>
<TextBlock Text="{Binding SelectedGroupSubtitle}"
FontSize="12" Opacity="0.55"/>
</StackPanel>
<Button Grid.Column="1" Content="⋯ Verwalten" VerticalAlignment="Top"
Margin="16,0,0,0">
<Button.Flyout>
<MenuFlyout>
<MenuItem Header="Details bearbeiten"
Command="{Binding EditGroupCommand}"/>
<MenuItem Header="{Binding SelectedGroup.ArchiveActionLabel}"
Command="{Binding ToggleArchiveCommand}"/>
<Separator/>
<MenuItem Header="Teilnehmer importieren (bald)" IsEnabled="False"
ToolTip.Tip="Import aus dem Teilnehmerexport der Lernplattform folgt."/>
<Separator/>
<MenuItem Header="Lerngruppe löschen"
Command="{Binding DeleteGroupCommand}"/>
</MenuFlyout>
</Button.Flyout>
</Button>
</Grid>
<Separator/>
@@ -12,7 +12,11 @@ public partial class GroupListView : UserControl
{
base.OnDataContextChanged(e);
if (DataContext is GroupListViewModel vm)
{
vm.OnAddGroup = ShowAddGroupDialog;
vm.OnEditGroup = ShowEditGroupDialog;
vm.OnConfirmDelete = ShowDeleteGroupDialog;
}
}
private async Task ShowAddGroupDialog()
@@ -23,4 +27,25 @@ public partial class GroupListView : UserControl
if (owner is not null)
await dialog.ShowDialog(owner);
}
private async Task ShowEditGroupDialog(Guid groupId)
{
var group = App.Services.GetRequiredService<LehrerApp.Core.Interfaces.IGroupRepository>()
.GetById(groupId);
if (group is null) return;
var dialogVm = App.Services.GetRequiredService<AddGroupDialogViewModel>();
dialogVm.LoadForEdit(group);
var dialog = new AddGroupDialog { DataContext = dialogVm };
var owner = TopLevel.GetTopLevel(this) as Window;
if (owner is not null)
await dialog.ShowDialog<bool>(owner);
}
private async Task<bool> ShowDeleteGroupDialog(GroupListItem group)
{
var dialog = new DeleteGroupDialog { DataContext = group.DisplayName };
var owner = TopLevel.GetTopLevel(this) as Window;
return owner is not null && await dialog.ShowDialog<bool>(owner);
}
}