Apply shared ticket activity capability to overview rows

This commit is contained in:
Meik
2026-07-20 08:55:15 +02:00
parent 4ed75c6e82
commit 30cc7a0482
6 changed files with 40 additions and 29 deletions

View File

@@ -24,7 +24,7 @@ namespace FasdDesktopUi.Basics.Services
{
#region Fields
private const string ServiceRequestsEnabledKey = "ServiceRequestsEnabled";
private const string TicketAndServiceRequestsEnabledKey = "TicketAndServiceRequestsEnabled";
private readonly ITicketOverviewCommunicationSource _communicationSource;
private static readonly string[] OverviewKeys = new[]
{
@@ -58,7 +58,7 @@ namespace FasdDesktopUi.Basics.Services
private bool _isDemo;
private bool _initialized;
private bool _isEnabled;
private bool _serviceRequestsEnabled;
private bool _ticketAndServiceRequestsEnabled;
private readonly Random _random = new Random();
#if isDemo
private readonly List<DemoTicketRecord> _persistedDemoTickets = new List<DemoTicketRecord>();
@@ -115,10 +115,10 @@ namespace FasdDesktopUi.Basics.Services
#region Public API
public event EventHandler<TicketOverviewCountsChangedEventArgs> OverviewCountsChanged;
public event EventHandler ServiceRequestsAvailabilityChanged;
public event EventHandler TicketAndServiceRequestsAvailabilityChanged;
public IReadOnlyDictionary<string, TileCounts> CurrentCounts => _currentCounts;
public bool ServiceRequestsEnabled => _serviceRequestsEnabled;
public bool TicketAndServiceRequestsEnabled => _ticketAndServiceRequestsEnabled;
public bool IsScopeInitialized(TileScope scope)
{
@@ -224,7 +224,7 @@ namespace FasdDesktopUi.Basics.Services
_currentCounts[key] = TileCounts.Empty;
}
UpdateServiceRequestsAvailability(false);
UpdateTicketAndServiceRequestsAvailability(false);
});
}
@@ -339,11 +339,11 @@ namespace FasdDesktopUi.Basics.Services
_isDemo = communication.IsDemo();
var requestedKeys = scope == TileScope.Personal
? OverviewKeys.Concat(new[] { ServiceRequestsEnabledKey }).ToArray()
? OverviewKeys.Concat(new[] { TicketAndServiceRequestsEnabledKey }).ToArray()
: OverviewKeys;
var rawCounts = await communication.GetTicketOverviewCounts(requestedKeys, scope == TileScope.Role).ConfigureAwait(false);
var counts = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
var serviceRequestsEnabled = _isDemo;
var ticketAndServiceRequestsEnabled = _isDemo;
if (rawCounts != null)
{
@@ -352,10 +352,10 @@ namespace FasdDesktopUi.Basics.Services
if (string.IsNullOrWhiteSpace(kvp.Key))
continue;
if (string.Equals(kvp.Key, ServiceRequestsEnabledKey, StringComparison.OrdinalIgnoreCase))
if (string.Equals(kvp.Key, TicketAndServiceRequestsEnabledKey, StringComparison.OrdinalIgnoreCase))
{
if (scope == TileScope.Personal)
serviceRequestsEnabled = _isDemo || kvp.Value > 0;
ticketAndServiceRequestsEnabled = _isDemo || kvp.Value > 0;
continue;
}
@@ -369,7 +369,7 @@ namespace FasdDesktopUi.Basics.Services
await _dispatcher.InvokeAsync(() =>
{
if (scope == TileScope.Personal)
UpdateServiceRequestsAvailability(serviceRequestsEnabled);
UpdateTicketAndServiceRequestsAvailability(ticketAndServiceRequestsEnabled);
ProcessScopeCounts(scope, counts);
});
@@ -389,13 +389,13 @@ namespace FasdDesktopUi.Basics.Services
#region Count Processing
private void UpdateServiceRequestsAvailability(bool isEnabled)
private void UpdateTicketAndServiceRequestsAvailability(bool isEnabled)
{
if (_serviceRequestsEnabled == isEnabled)
if (_ticketAndServiceRequestsEnabled == isEnabled)
return;
_serviceRequestsEnabled = isEnabled;
ServiceRequestsAvailabilityChanged?.Invoke(this, EventArgs.Empty);
_ticketAndServiceRequestsEnabled = isEnabled;
TicketAndServiceRequestsAvailabilityChanged?.Invoke(this, EventArgs.Empty);
}
private void RefreshTimerIntervals()

View File

@@ -120,7 +120,8 @@
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition x:Name="TicketsRow"
Height="0" />
<RowDefinition Height="Auto" />
<RowDefinition x:Name="ServiceRequestsRow"
Height="0" />

View File

@@ -274,10 +274,11 @@ namespace FasdDesktopUi.Basics.UserControls
vm.ResetSelection();
}
public void SetServiceRequestsVisibility(bool isVisible)
public void SetTicketAndServiceRequestsVisibility(bool isVisible)
{
Dispatcher.Invoke(() =>
{
TicketsRow.Height = isVisible ? GridLength.Auto : new GridLength(0);
ServiceRequestsRow.Height = isVisible ? GridLength.Auto : new GridLength(0);
});
}
@@ -324,7 +325,7 @@ namespace FasdDesktopUi.Basics.UserControls
if (counts == null || counts.Count == 0)
counts = await LoadCountsFallbackAsync(useRoleTickets).ConfigureAwait(false);
SetServiceRequestsVisibility(TicketOverviewUpdateService.Instance?.ServiceRequestsEnabled == true);
SetTicketAndServiceRequestsVisibility(TicketOverviewUpdateService.Instance?.TicketAndServiceRequestsEnabled == true);
await Dispatcher.InvokeAsync(() =>
{