ContextWindow: Add HasContextLoaded property
This commit is contained in:
@@ -104,6 +104,7 @@ namespace Elwig.Windows {
|
||||
cb.SelectionChanged += ComboBox_SelectionChanged;
|
||||
foreach (var lb in ListBoxInputs)
|
||||
lb.SelectionChanged += ComboBox_SelectionChanged;
|
||||
LockInputs();
|
||||
}
|
||||
|
||||
private void OnClosing(object? sender, CancelEventArgs evt) {
|
||||
|
||||
@@ -39,10 +39,6 @@ namespace Elwig.Windows {
|
||||
ViewModel.FilterSeason = Utils.CurrentYear;
|
||||
}
|
||||
|
||||
protected override async Task OnInit(AppDbContext ctx) {
|
||||
LockInputs();
|
||||
}
|
||||
|
||||
private void FocusSearchInput(object sender, RoutedEventArgs evt) {
|
||||
if (!IsEditing && !IsCreating) {
|
||||
SearchInput.Focus();
|
||||
@@ -451,17 +447,19 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
private async void ActiveAreaCommitmentInput_Changed(object sender, RoutedEventArgs evt) {
|
||||
if (!HasContextLoaded) return;
|
||||
await RefreshList();
|
||||
}
|
||||
|
||||
private async void SearchInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
if (!HasContextLoaded) return;
|
||||
var binding = ((TextBox)sender).GetBindingExpression(TextBox.TextProperty);
|
||||
binding?.UpdateSource();
|
||||
await RefreshList(true);
|
||||
}
|
||||
|
||||
private async void SeasonInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||
if (ViewModel.FilterSeason == null) return;
|
||||
if (!HasContextLoaded || ViewModel.FilterSeason == null) return;
|
||||
await RefreshList();
|
||||
}
|
||||
|
||||
|
||||
@@ -153,10 +153,6 @@ namespace Elwig.Windows {
|
||||
ParameterExportEbicsAddress.IsEnabled = true;
|
||||
}
|
||||
|
||||
protected override async Task OnInit(AppDbContext ctx) {
|
||||
LockInputs();
|
||||
}
|
||||
|
||||
protected override async Task OnRenewContext(AppDbContext ctx) {
|
||||
await base.OnRenewContext(ctx);
|
||||
FillInputs(App.Client, await ctx.FetchSeasons(Utils.CurrentLastSeason).SingleOrDefaultAsync());
|
||||
|
||||
@@ -18,6 +18,8 @@ namespace Elwig.Windows {
|
||||
}
|
||||
}
|
||||
|
||||
protected bool HasContextLoaded { get; private set; }
|
||||
|
||||
private bool _renewPending = false;
|
||||
|
||||
private readonly RoutedCommand CtrlR = new("CtrlR", typeof(ContextWindow), [new KeyGesture(Key.R, ModifierKeys.Control)]);
|
||||
@@ -51,6 +53,7 @@ namespace Elwig.Windows {
|
||||
Mouse.OverrideCursor = Cursors.AppStarting;
|
||||
using var ctx = new AppDbContext();
|
||||
await OnRenewContext(ctx);
|
||||
HasContextLoaded = true;
|
||||
await OnInit(ctx);
|
||||
Mouse.OverrideCursor = null;
|
||||
}
|
||||
|
||||
@@ -122,7 +122,8 @@ namespace Elwig.Windows {
|
||||
Menu_Export_UploadSeason.IsEnabled = App.Config.SyncUrl != null;
|
||||
}
|
||||
|
||||
public DeliveryAdminWindow(int mgnr) : this() {
|
||||
public DeliveryAdminWindow(int mgnr) :
|
||||
this() {
|
||||
ViewModel.FilterMember = DeliveryService.GetMember(mgnr) ?? throw new ArgumentException("MgNr argument has invalid value");
|
||||
ViewModel.Title = $"Lieferungen - {ViewModel.FilterMember.AdministrativeName} - Elwig";
|
||||
ViewModel.EnableAllSeasons = true;
|
||||
@@ -132,7 +133,6 @@ namespace Elwig.Windows {
|
||||
await base.OnInit(ctx);
|
||||
OnSecondPassed(null, null);
|
||||
SecondsTimer.Start();
|
||||
LockInputs();
|
||||
if (ViewModel.IsReceipt) {
|
||||
NewDeliveryButton_Click(null, null);
|
||||
if (await ctx.FetchSeasons(Utils.CurrentYear).SingleOrDefaultAsync() == null) {
|
||||
@@ -541,8 +541,6 @@ namespace Elwig.Windows {
|
||||
|
||||
await RefreshList();
|
||||
|
||||
var d = DeliveryList.SelectedItem as Delivery;
|
||||
var y = d?.Year ?? ViewModel.FilterSeason ?? Utils.CurrentYear;
|
||||
ControlUtils.RenewItemsSource(MemberInput, await ctx.FetchMembers(includeNotActive: !IsCreating, includeContactInfo: true).ToListAsync());
|
||||
ControlUtils.RenewItemsSource(BranchInput, await ctx.FetchBranches().ToListAsync());
|
||||
ControlUtils.RenewItemsSource(WineVarietyInput, await ctx.FetchWineVarieties().ToListAsync());
|
||||
@@ -678,17 +676,19 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
private async void SearchInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
if (!HasContextLoaded) return;
|
||||
await RefreshList(true);
|
||||
}
|
||||
|
||||
private async void SeasonInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||
if (ViewModel.FilterSeason == null || TodayOnlyInput == null || AllSeasonsInput == null) return;
|
||||
if (!HasContextLoaded || ViewModel.FilterSeason == null || TodayOnlyInput == null || AllSeasonsInput == null) return;
|
||||
TodayOnlyInput.IsChecked = false;
|
||||
AllSeasonsInput.IsChecked = false;
|
||||
await RefreshList();
|
||||
}
|
||||
|
||||
private async void TodayOnlyInput_Changed(object sender, RoutedEventArgs evt) {
|
||||
if (!HasContextLoaded) return;
|
||||
if (TodayOnlyInput.IsChecked == true && AllSeasonsInput.IsChecked == false) {
|
||||
ViewModel.FilterSeason = Utils.Today.Year;
|
||||
ViewModel.FilterTodayOnly = true;
|
||||
@@ -697,6 +697,7 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
private async void AllSeasonsInput_Changed(object sender, RoutedEventArgs evt) {
|
||||
if (!HasContextLoaded) return;
|
||||
if (AllSeasonsInput.IsChecked == true) {
|
||||
SeasonInput.IsEnabled = false;
|
||||
ViewModel.FilterSeason = null;
|
||||
|
||||
@@ -39,10 +39,6 @@ namespace Elwig.Windows {
|
||||
ViewModel.FilterOnlyUpcoming = true;
|
||||
}
|
||||
|
||||
protected override async Task OnInit(AppDbContext ctx) {
|
||||
LockInputs();
|
||||
}
|
||||
|
||||
private void Input_KeyUp(object sender, KeyEventArgs evt) {
|
||||
if (sender is not Control ctrl) return;
|
||||
if (evt.Key != Key.Enter) return;
|
||||
@@ -193,6 +189,7 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
private async void DeliveryScheduleList_SelectionChanged(object sender, RoutedEventArgs evt) {
|
||||
if (!HasContextLoaded) return;
|
||||
await RefreshList();
|
||||
if (DeliveryScheduleList.SelectedItem is DeliverySchedule s) {
|
||||
Menu_DeliveryAncmtList_SaveSelected.IsEnabled = !IsEditing && !IsCreating;
|
||||
@@ -214,11 +211,13 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
private async void OnlyUpcomingInput_Changed(object sender, RoutedEventArgs evt) {
|
||||
if (!HasContextLoaded) return;
|
||||
await RefreshDeliveryScheduleList();
|
||||
await RefreshList(true);
|
||||
}
|
||||
|
||||
private async void FromAllSchedulesInput_Changed(object sender, RoutedEventArgs evt) {
|
||||
if (!HasContextLoaded) return;
|
||||
if (ViewModel.FilterFromAllSchedules) {
|
||||
DeliveryScheduleList.SelectedItem = null;
|
||||
} else if (DeliveryScheduleList.SelectedItem == null) {
|
||||
@@ -228,11 +227,12 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
private async void SearchInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||
if (!HasContextLoaded) return;
|
||||
await RefreshList(true);
|
||||
}
|
||||
|
||||
private async void SeasonInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||
if (ViewModel.FilterSeason == null) return;
|
||||
if (!HasContextLoaded || ViewModel.FilterSeason == null) return;
|
||||
ViewModel.FilterOnlyUpcoming = false;
|
||||
await RefreshDeliveryScheduleList();
|
||||
await RefreshList();
|
||||
|
||||
@@ -33,10 +33,6 @@ namespace Elwig.Windows {
|
||||
ViewModel.FilterOnlyUpcoming = true;
|
||||
}
|
||||
|
||||
protected override async Task OnInit(AppDbContext ctx) {
|
||||
LockInputs();
|
||||
}
|
||||
|
||||
private async Task RefreshList(bool updateSort = false) {
|
||||
var vm = ViewModel;
|
||||
var cursor = Mouse.OverrideCursor != null;
|
||||
@@ -124,15 +120,17 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
private async void OnlyUpcomingInput_Changed(object sender, RoutedEventArgs evt) {
|
||||
if (!HasContextLoaded) return;
|
||||
await RefreshList();
|
||||
}
|
||||
|
||||
private async void SearchInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||
if (!HasContextLoaded) return;
|
||||
await RefreshList(true);
|
||||
}
|
||||
|
||||
private async void SeasonInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||
if (ViewModel.FilterSeason == null) return;
|
||||
if (!HasContextLoaded || ViewModel.FilterSeason == null) return;
|
||||
ViewModel.FilterOnlyUpcoming = false;
|
||||
await RefreshList();
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
protected override async Task OnInit(AppDbContext ctx) {
|
||||
await base.OnInit(ctx);
|
||||
if (Utils.HasInternetConnectivity()) {
|
||||
CheckSync(200);
|
||||
}
|
||||
|
||||
@@ -83,11 +83,8 @@ namespace Elwig.Windows {
|
||||
Menu_Export_UploadFilters.IsEnabled = App.Config.SyncUrl != null;
|
||||
Menu_Export_UploadAll.IsEnabled = App.Config.SyncUrl != null;
|
||||
ViewModel.ShowOnlyActiveMembers = true;
|
||||
}
|
||||
|
||||
protected override async Task OnInit(AppDbContext ctx) {
|
||||
UpdateContactInfoVisibility();
|
||||
LockInputs();
|
||||
}
|
||||
|
||||
public void FocusMember(int mgnr) {
|
||||
@@ -334,7 +331,7 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
private async void ActiveMemberInput_Changed(object sender, RoutedEventArgs evt) {
|
||||
if (!IsInitialized) return;
|
||||
if (!HasContextLoaded) return;
|
||||
await RefreshList();
|
||||
}
|
||||
|
||||
@@ -491,6 +488,7 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
private async void SearchInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
if (!HasContextLoaded) return;
|
||||
await RefreshList(true);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user