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:
@@ -0,0 +1,47 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="clr-namespace:LehrerApp.Desktop.ViewModels.Groups"
|
||||
xmlns:vmp="clr-namespace:LehrerApp.Desktop.ViewModels.Planning"
|
||||
x:Class="LehrerApp.Desktop.Views.Groups.ChangeLessonUnitDialog"
|
||||
x:DataType="vm:ChangeLessonUnitDialogViewModel"
|
||||
Title="Einheit wechseln"
|
||||
Width="440" Height="360" MinWidth="400" MinHeight="320"
|
||||
CanResize="False" WindowStartupLocation="CenterOwner">
|
||||
|
||||
<Grid RowDefinitions="*,Auto" Margin="24">
|
||||
<StackPanel Grid.Row="0" Spacing="14">
|
||||
<TextBlock Text="Einheit wechseln" Classes="dialogtitle"/>
|
||||
<TextBlock FontSize="12" Opacity="0.6">
|
||||
<Run Text="Bisherige Einheit: "/>
|
||||
<Run Text="{Binding CurrentUnitLabel}"/>
|
||||
</TextBlock>
|
||||
|
||||
<StackPanel Spacing="5" IsVisible="{Binding HasUnits}">
|
||||
<TextBlock Text="Neue Einheit" FontSize="12" Opacity="0.7"/>
|
||||
<ComboBox ItemsSource="{Binding Units}" SelectedItem="{Binding SelectedUnit}"
|
||||
HorizontalAlignment="Stretch">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="vmp:TimetableUnitOption">
|
||||
<StackPanel>
|
||||
<TextBlock Text="{Binding Label}" FontWeight="SemiBold"/>
|
||||
<TextBlock Text="{Binding Detail}" FontSize="11" Opacity="0.6"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock Text="Keine andere Einheit in dieser Gruppe vorhanden."
|
||||
FontSize="12" Opacity="0.7" TextWrapping="Wrap"
|
||||
IsVisible="{Binding !HasUnits}"/>
|
||||
|
||||
<TextBlock Text="{Binding Error}" Foreground="Red" FontSize="11"
|
||||
IsVisible="{Binding Error, 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="Verschieben" HorizontalAlignment="Stretch" Click="OnSave"
|
||||
IsEnabled="{Binding HasUnits}"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,21 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using LehrerApp.Desktop.ViewModels.Groups;
|
||||
|
||||
namespace LehrerApp.Desktop.Views.Groups;
|
||||
|
||||
public partial class ChangeLessonUnitDialog : Window
|
||||
{
|
||||
public ChangeLessonUnitDialog() => InitializeComponent();
|
||||
|
||||
private void OnSave(object? s, RoutedEventArgs e)
|
||||
{
|
||||
if (DataContext is ChangeLessonUnitDialogViewModel vm && vm.SaveCommand.CanExecute(null))
|
||||
{
|
||||
vm.SaveCommand.Execute(null);
|
||||
if (vm.Result is not null) Close(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCancel(object? s, RoutedEventArgs e) => Close(false);
|
||||
}
|
||||
@@ -91,6 +91,8 @@
|
||||
ToolTip.Tip="Verlaufsplan schreibgeschützt und größer anzeigen — zum Mitnehmen in den Unterricht."/>
|
||||
<Button Content="Bearbeiten" Command="{Binding EditLessonCommand}" IsEnabled="{Binding !IsReadOnly}"/>
|
||||
<Button Content="Verschieben" Command="{Binding MoveLessonCommand}" IsEnabled="{Binding !IsReadOnly}"/>
|
||||
<Button Content="Einheit wechseln" Command="{Binding ChangeLessonUnitCommand}" IsEnabled="{Binding !IsReadOnly}"
|
||||
ToolTip.Tip="Ordnet die ausgewählte Stunde einer anderen Einheit derselben Gruppe zu."/>
|
||||
<Button Content="Status weiter" Command="{Binding AdvanceLessonStatusCommand}" IsEnabled="{Binding !IsReadOnly}"
|
||||
ToolTip.Tip="Entwurf/Geplant → Bereit → Durchgeführt"/>
|
||||
<Button Content="Sitzung erzeugen" Command="{Binding CreateParticipationSessionCommand}"
|
||||
|
||||
@@ -38,6 +38,7 @@ public partial class PlanningTabView : UserControl
|
||||
ShowLessonDialog(lesson.UnitId, lesson.GroupId, materials, shorthands, editingLesson: lesson);
|
||||
vm.OnConfirmDeleteLesson = ShowDeleteLessonDialog;
|
||||
vm.OnPickMoveTarget = ShowMoveLessonDialog;
|
||||
vm.OnPickUnitChange = ShowChangeLessonUnitDialog;
|
||||
vm.OnShowLesson = ShowLessonViewerDialog;
|
||||
vm.OnGenerateLessonSeries = ShowGenerateLessonSeriesDialog;
|
||||
vm.OnAiAssist = ShowAiAssistDialog;
|
||||
@@ -136,6 +137,20 @@ public partial class PlanningTabView : UserControl
|
||||
return ok ? dialogVm.Result : null;
|
||||
}
|
||||
|
||||
private async Task<Unit?> ShowChangeLessonUnitDialog(Lesson lesson)
|
||||
{
|
||||
var dialogVm = new ChangeLessonUnitDialogViewModel(
|
||||
App.Services.GetRequiredService<IUnitRepository>(),
|
||||
lesson.GroupId, lesson.UnitId,
|
||||
(DataContext as PlanningTabViewModel)?.SelectedUnit?.Title ?? "");
|
||||
var dialog = new ChangeLessonUnitDialog { DataContext = dialogVm };
|
||||
var owner = TopLevel.GetTopLevel(this) as Window;
|
||||
if (owner is null) return null;
|
||||
|
||||
var ok = await dialog.ShowDialog<bool>(owner);
|
||||
return ok ? dialogVm.Result : null;
|
||||
}
|
||||
|
||||
private async Task ShowLessonViewerDialog(Lesson lesson)
|
||||
{
|
||||
var viewerVm = new LessonViewerViewModel(lesson,
|
||||
|
||||
Reference in New Issue
Block a user