Refactor StundePage and ViewModels: adjust grid padding, clean up commented code, add SelectEntryCommand, and improve navigation logic.
This commit is contained in:
@@ -74,6 +74,7 @@ public partial class StundeViewModel : ObservableObject, IQueryAttributable {
|
||||
public ICommand SaveCommand { get; private set; }
|
||||
public ICommand DeleteCommand { get; private set; }
|
||||
public ICommand DeleteConfirmCommand { get; private set; }
|
||||
public ICommand SelectEntryCommand { get; }
|
||||
//public ICommand LoadDataCommand { get; private set; }
|
||||
|
||||
|
||||
@@ -83,6 +84,7 @@ public partial class StundeViewModel : ObservableObject, IQueryAttributable {
|
||||
_alertService = alertService;
|
||||
SaveCommand = new AsyncRelayCommand(Save);
|
||||
DeleteConfirmCommand = new Command(async () => await DeleteConfirm());
|
||||
SelectEntryCommand = new AsyncRelayCommand<DayTime>(SelectEntryAsync);
|
||||
|
||||
_alertService.AlertRaised += (s, msg) => AlertEvent?.Invoke(this, msg);
|
||||
}
|
||||
@@ -136,7 +138,8 @@ public partial class StundeViewModel : ObservableObject, IQueryAttributable {
|
||||
|
||||
if (!exceptionOccurred) {
|
||||
if (DayTime.Id != null) {
|
||||
await Shell.Current.GoToAsync($"..?saved={DayTime.Id}");
|
||||
//await Shell.Current.GoToAsync($"..?saved={DayTime.Id}");
|
||||
await Shell.Current.GoToAsync($"//StundenPage?saved={DayTime.Id}");
|
||||
} else {
|
||||
await Shell.Current.GoToAsync($"..?date={DayTime.Day.ToString("yyyy-MM-dd")}");
|
||||
}
|
||||
@@ -173,6 +176,19 @@ public partial class StundeViewModel : ObservableObject, IQueryAttributable {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Öffnet eine bestehende Stundeneingabe
|
||||
/// </summary>
|
||||
private async Task SelectEntryAsync(DayTime entry) {
|
||||
if (entry != null && entry.Id != null) {
|
||||
//var navigationParameters = new Dictionary<string, object> { { "load", entry.id } };
|
||||
//await Shell.Current.GoToAsync($"{nameof(Views.StundePage)}", navigationParameters);
|
||||
await Shell.Current.GoToAsync($"{nameof(Views.StundePage)}?load={entry.Id}");
|
||||
} else AlertEvent?.Invoke(this, "Auswahl enthält keine Daten");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Anwenden der Query-Parameter
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user