Drawer korrigiert, Gruppenanlegen optimiert.
This commit is contained in:
@@ -14,7 +14,7 @@ public partial class GroupListViewModel : ObservableObject
|
||||
private readonly IGroupRepository _groups;
|
||||
private readonly SchoolYearService _sy;
|
||||
|
||||
public Action<Guid>? OnNavigateToDetail { get; set; }
|
||||
public Action<Guid, int>? OnNavigateToDetail { get; set; }
|
||||
public Action? OnAddGroup { get; set; }
|
||||
|
||||
[ObservableProperty] private string _selectedSchoolYear = "";
|
||||
@@ -33,10 +33,8 @@ public partial class GroupListViewModel : ObservableObject
|
||||
|
||||
partial void OnSelectedSchoolYearChanged(string value) => LoadGroups();
|
||||
partial void OnSearchTextChanged(string value) => LoadGroups();
|
||||
partial void OnSelectedGroupChanged(GroupListItem? value)
|
||||
{
|
||||
if (value is not null) OnNavigateToDetail?.Invoke(value.Id);
|
||||
}
|
||||
partial void OnSelectedGroupChanged(GroupListItem? value) =>
|
||||
NavigateToSectionCommand.NotifyCanExecuteChanged();
|
||||
|
||||
public void LoadGroups()
|
||||
{
|
||||
@@ -51,6 +49,15 @@ public partial class GroupListViewModel : ObservableObject
|
||||
|
||||
[RelayCommand] private void AddGroup() => OnAddGroup?.Invoke();
|
||||
[RelayCommand] private void Refresh() => LoadGroups();
|
||||
|
||||
[RelayCommand(CanExecute = nameof(HasSelectedGroup))]
|
||||
private void NavigateToSection(string? tabIndex)
|
||||
{
|
||||
if (SelectedGroup is null || !int.TryParse(tabIndex, out var tab)) return;
|
||||
OnNavigateToDetail?.Invoke(SelectedGroup.Id, tab);
|
||||
}
|
||||
|
||||
private bool HasSelectedGroup() => SelectedGroup is not null;
|
||||
}
|
||||
|
||||
public class GroupListItem
|
||||
@@ -61,6 +68,7 @@ public class GroupListItem
|
||||
public string DisplayName { get; }
|
||||
public string TypeLabel { get; }
|
||||
public string GradingLabel { get; }
|
||||
public string Subtitle { get; }
|
||||
|
||||
public GroupListItem(LearningGroup g)
|
||||
{
|
||||
@@ -69,7 +77,8 @@ public class GroupListItem
|
||||
Subject = g.Subject ?? "";
|
||||
TypeLabel = g.Type == GroupType.Class ? "Klasse" : "Kurs";
|
||||
GradingLabel = g.GradingSystem == GradingSystem.Grades1To6 ? "1–6" : "0–15";
|
||||
DisplayName = string.IsNullOrEmpty(Subject) ? Name : $"{Name} · {Subject}";
|
||||
DisplayName = string.IsNullOrEmpty(g.Subject) ? g.Name : $"{g.Name} · {g.Subject}";
|
||||
Subtitle = $"{TypeLabel} · Stufe {g.GradeLevel} · Noten {GradingLabel} · {g.SchoolYear}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,6 +95,7 @@ public partial class GroupDetailViewModel : ObservableObject
|
||||
[ObservableProperty] private string _groupTitle = "";
|
||||
[ObservableProperty] private string _groupSubtitle = "";
|
||||
[ObservableProperty] private int _studentCount;
|
||||
[ObservableProperty] private int _activeTabIndex = 0;
|
||||
|
||||
public ObservableCollection<StudentSummary> Students { get; } = [];
|
||||
public ObservableCollection<ExamSummary> Exams { get; } = [];
|
||||
@@ -153,6 +163,20 @@ public partial class AddGroupDialogViewModel : ObservableObject
|
||||
private readonly IGroupRepository _groups;
|
||||
private readonly SchoolYearService _sy;
|
||||
|
||||
public List<string> TypeOptions { get; } = ["Klasse", "Kurs"];
|
||||
[ObservableProperty] private string _selectedTypeName = "Kurs";
|
||||
|
||||
public bool IsKurs => SelectedTypeName == "Kurs";
|
||||
public string NameLabel => IsKurs ? "Kursname *" : "Klassenname *";
|
||||
public string NameHint => IsKurs ? "z.B. Q1, LK, GK" : "z.B. 10E, 5a, 11b";
|
||||
|
||||
partial void OnSelectedTypeNameChanged(string value)
|
||||
{
|
||||
OnPropertyChanged(nameof(IsKurs));
|
||||
OnPropertyChanged(nameof(NameLabel));
|
||||
OnPropertyChanged(nameof(NameHint));
|
||||
}
|
||||
|
||||
[ObservableProperty] private string _name = "";
|
||||
[ObservableProperty] private string _subject = "";
|
||||
[ObservableProperty] private int _gradeLevel = 10;
|
||||
@@ -168,7 +192,6 @@ public partial class AddGroupDialogViewModel : ObservableObject
|
||||
_groups = groups; _sy = sy;
|
||||
SchoolYears = sy.RecentSchoolYears(3);
|
||||
SelectedSchoolYear = sy.CurrentSchoolYear();
|
||||
// Notensystem automatisch nach Klassenstufe
|
||||
PropertyChanged += (_, e) =>
|
||||
{
|
||||
if (e.PropertyName == nameof(GradeLevel))
|
||||
@@ -180,13 +203,13 @@ public partial class AddGroupDialogViewModel : ObservableObject
|
||||
[RelayCommand]
|
||||
private void Save()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Name)) { ValidationMessage = "Name erforderlich."; return; }
|
||||
if (string.IsNullOrWhiteSpace(Name)) { ValidationMessage = "Bezeichnung erforderlich."; return; }
|
||||
if (GradeLevel is < 1 or > 13) { ValidationMessage = "Klassenstufe 1–13."; return; }
|
||||
Result = new LearningGroup
|
||||
{
|
||||
Name = Name.Trim(),
|
||||
Subject = string.IsNullOrWhiteSpace(Subject) ? null : Subject.Trim(),
|
||||
Type = GroupType.Course,
|
||||
Subject = IsKurs && !string.IsNullOrWhiteSpace(Subject) ? Subject.Trim() : null,
|
||||
Type = IsKurs ? GroupType.Course : GroupType.Class,
|
||||
GradeLevel = GradeLevel,
|
||||
GradingSystem = GradingSystem,
|
||||
SchoolYear = SelectedSchoolYear,
|
||||
|
||||
Reference in New Issue
Block a user