Edit Stammdaten Mitarbeitsessions
This commit is contained in:
@@ -48,6 +48,7 @@ public partial class ParticipationTabViewModel : ObservableObject
|
||||
public ObservableCollection<CompetencyTagGroup> CompetencyTagGroups { get; } = [];
|
||||
|
||||
public Func<Task<ParticipationSession?>>? OnAddSession { get; set; }
|
||||
public Func<ParticipationSession, Task<ParticipationSession?>>? OnEditSession { get; set; }
|
||||
public Func<ParticipationTabViewModel, Task>? OnQuickInput { get; set; }
|
||||
public Func<ParticipationTabViewModel, Task>? OnStatusQuickInput { get; set; }
|
||||
public Func<ParticipationTabViewModel, Task>? OnComputeGrade { get; set; }
|
||||
@@ -118,6 +119,7 @@ public partial class ParticipationTabViewModel : ObservableObject
|
||||
partial void OnSelectedSessionChanged(ParticipationSessionItem? value)
|
||||
{
|
||||
OnPropertyChanged(nameof(SelectedSessionDisplay));
|
||||
EditSessionCommand.NotifyCanExecuteChanged();
|
||||
if (value is null)
|
||||
{
|
||||
StudentRows.Clear();
|
||||
@@ -265,6 +267,23 @@ public partial class ParticipationTabViewModel : ObservableObject
|
||||
SelectedSession = Sessions.FirstOrDefault(s => s.Id == session.Id);
|
||||
}
|
||||
|
||||
[RelayCommand(CanExecute = nameof(CanEditSession))]
|
||||
private async Task EditSession()
|
||||
{
|
||||
if (SelectedSession is null || OnEditSession is null) return;
|
||||
var session = _sessions.GetById(SelectedSession.Id);
|
||||
if (session is null) return;
|
||||
var edited = await OnEditSession(session);
|
||||
if (edited is null) return;
|
||||
edited.GroupId = _groupId;
|
||||
_sessions.Save(edited);
|
||||
LoadSessions();
|
||||
}
|
||||
|
||||
private bool CanEditSession() => !IsReadOnly && SelectedSession is not null;
|
||||
|
||||
partial void OnIsReadOnlyChanged(bool value) => EditSessionCommand.NotifyCanExecuteChanged();
|
||||
|
||||
[RelayCommand(CanExecute = nameof(CanQuickInput))]
|
||||
private async Task QuickInput()
|
||||
{
|
||||
@@ -716,12 +735,26 @@ public class ParticipationSessionItem
|
||||
|
||||
public partial class AddSessionDialogViewModel : ObservableObject
|
||||
{
|
||||
private readonly ParticipationSession? _editingSession;
|
||||
|
||||
[ObservableProperty] private DateOnly _date = DateOnly.FromDateTime(DateTime.Today);
|
||||
[ObservableProperty] private string _comment = "";
|
||||
[ObservableProperty] private string _dateText = DateOnly.FromDateTime(DateTime.Today).ToString("dd.MM.yyyy");
|
||||
[ObservableProperty] private string _dateTextError = "";
|
||||
|
||||
public ParticipationSession? Result { get; private set; }
|
||||
public bool IsEditing => _editingSession is not null;
|
||||
public string DialogTitle => IsEditing ? "Bewertungszeitpunkt bearbeiten" : "Bewertungszeitpunkt anlegen";
|
||||
public string SaveButtonText => IsEditing ? "Speichern" : "Anlegen";
|
||||
|
||||
public AddSessionDialogViewModel(ParticipationSession? editingSession = null)
|
||||
{
|
||||
_editingSession = editingSession;
|
||||
if (editingSession is null) return;
|
||||
Date = editingSession.Date;
|
||||
DateText = editingSession.Date.ToString("dd.MM.yyyy");
|
||||
Comment = editingSession.Comment ?? "";
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void Save()
|
||||
@@ -733,7 +766,10 @@ public partial class AddSessionDialogViewModel : ObservableObject
|
||||
return;
|
||||
}
|
||||
DateTextError = "";
|
||||
Result = new ParticipationSession { Date = date, Comment = Comment.Trim() };
|
||||
var session = _editingSession ?? new ParticipationSession();
|
||||
session.Date = date;
|
||||
session.Comment = Comment.Trim();
|
||||
Result = session;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user