[#26] AreaComAdminWindow: Overhaul status bar and search filters
This commit is contained in:
@ -35,6 +35,7 @@ namespace Elwig.Windows {
|
||||
|
||||
InitializeDelayTimer(SearchInput, SearchInput_TextChanged);
|
||||
SearchInput.TextChanged -= SearchInput_TextChanged;
|
||||
ActiveAreaCommitmentInput.Content = ((string)ActiveAreaCommitmentInput.Content).Replace("2020", $"{Utils.CurrentLastSeason}");
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e) {
|
||||
@ -55,6 +56,9 @@ namespace Elwig.Windows {
|
||||
var areaComs = await areaComQuery
|
||||
.Include(a => a.Kg.AtKg)
|
||||
.Include(a => a.Rd!.Kg.AtKg)
|
||||
.Include(a => a.WineCult)
|
||||
.Include(a => a.AreaComType.WineAttr)
|
||||
.Include(a => a.AreaComType.WineVar)
|
||||
.ToListAsync();
|
||||
|
||||
if (filter.Count > 0 && areaComs.Count > 0) {
|
||||
@ -72,17 +76,21 @@ namespace Elwig.Windows {
|
||||
AreaCommitmentList_SelectionChanged, filter.Count > 0 ? ControlUtils.RenewSourceDefault.IfOnly : ControlUtils.RenewSourceDefault.None, !updateSort);
|
||||
RefreshInputs();
|
||||
|
||||
if(filter.Count == 0) {
|
||||
ViewModel.StatusAreaCommitments = $"Flächenbindungen: {await areaComQuery.CountAsync()}";
|
||||
ViewModel.StatusArea = $"Fläche: {await areaComQuery.Select(a => a.Area).SumAsync():N0} m²";
|
||||
if (filter.Count == 0) {
|
||||
ViewModel.StatusAreaCommitments = $"{await areaComQuery.CountAsync():N0}";
|
||||
var s = await ctx.Seasons.FindAsync(await ctx.Seasons.MaxAsync(s => s.Year));
|
||||
var (text, grid) = await AreaComService.GenerateToolTip(areaComQuery, s?.MaxKgPerHa ?? 10_000);
|
||||
ViewModel.StatusArea = text;
|
||||
ViewModel.StatusAreaToolTip = grid;
|
||||
} else {
|
||||
ViewModel.StatusAreaCommitments = $"Flächenbindungen: {areaComs.Count}";
|
||||
ViewModel.StatusArea = $"Fläche: {areaComs.Select(a => a.Area).Sum():N0} m²";
|
||||
ViewModel.StatusAreaCommitments = $"{areaComs.Count:N0}";
|
||||
ViewModel.StatusArea = $"{areaComs.Select(a => a.Area).Sum():N0} m²";
|
||||
ViewModel.StatusAreaToolTip = null;
|
||||
}
|
||||
var groups = areaComs.GroupBy(a => $"{a.AreaComType.SortId}{a.AreaComType.AttrId}").Select(a => (a.Key, a.Sum(b => b.Area))).OrderByDescending(a => a.Item2).ToList();
|
||||
ViewModel.StatusContracts = $"Vertragsarten: {groups.Count} (" + string.Join(", ", groups.Select(g => $"{g.Key}: {g.Item2:N0} m²")) + ")";
|
||||
groups = areaComs.GroupBy(a => a.AreaComType.DisplayName).Select(a => (a.Key, a.Sum(b => b.Area))).OrderByDescending(a => a.Item2).ToList();
|
||||
StatusContracts.ToolTip = $"Vertragsarten: {groups.Count}\n" + string.Join($"\n", groups.Select(g => $"{g.Key}: {g.Item2:N0} m²"));
|
||||
ViewModel.StatusContracts = $"{groups.Count:N0}";
|
||||
if (groups.Count > 0)
|
||||
ViewModel.StatusContracts += $" ({string.Join(", ", groups.Select(g => g.Key))})";
|
||||
}
|
||||
|
||||
private void RefreshInputs(bool validate = false) {
|
||||
|
Reference in New Issue
Block a user