Apply shared ticket activity capability to overview rows
This commit is contained in:
@@ -111,13 +111,13 @@ public class TicketOverviewUpdateServiceTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task FetchAsync_ServiceRequestsCapability_IsSeparatedFromCounts()
|
public async Task FetchAsync_TicketAndServiceRequestsCapability_IsSeparatedFromCounts()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var communication = new FakeCommunication();
|
var communication = new FakeCommunication();
|
||||||
communication.SetCounts(TileScope.Personal, new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase)
|
communication.SetCounts(TileScope.Personal, new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase)
|
||||||
{
|
{
|
||||||
["ServiceRequestsEnabled"] = 1,
|
["TicketAndServiceRequestsEnabled"] = 1,
|
||||||
["ServiceRequestsNew"] = 2
|
["ServiceRequestsNew"] = 2
|
||||||
});
|
});
|
||||||
communication.SetCounts(TileScope.Role, new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase)
|
communication.SetCounts(TileScope.Role, new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase)
|
||||||
@@ -127,18 +127,27 @@ public class TicketOverviewUpdateServiceTest
|
|||||||
|
|
||||||
var service = CreateService(communication, out _);
|
var service = CreateService(communication, out _);
|
||||||
var availabilityChanges = 0;
|
var availabilityChanges = 0;
|
||||||
service.ServiceRequestsAvailabilityChanged += (_, _) => availabilityChanges++;
|
service.TicketAndServiceRequestsAvailabilityChanged += (_, _) => availabilityChanges++;
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
service.UpdateAvailability(true);
|
service.UpdateAvailability(true);
|
||||||
await WaitUntilAsync(() => service.AreAllScopesInitialized);
|
await WaitUntilAsync(() => service.AreAllScopesInitialized);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.True(service.ServiceRequestsEnabled);
|
Assert.True(service.TicketAndServiceRequestsEnabled);
|
||||||
Assert.Equal(1, availabilityChanges);
|
Assert.Equal(1, availabilityChanges);
|
||||||
Assert.Equal(2, service.CurrentCounts["ServiceRequestsNew"].Personal);
|
Assert.Equal(2, service.CurrentCounts["ServiceRequestsNew"].Personal);
|
||||||
Assert.Equal(4, service.CurrentCounts["ServiceRequestsNew"].Role);
|
Assert.Equal(4, service.CurrentCounts["ServiceRequestsNew"].Role);
|
||||||
Assert.DoesNotContain("ServiceRequestsEnabled", service.CurrentCounts.Keys);
|
Assert.DoesNotContain("TicketAndServiceRequestsEnabled", service.CurrentCounts.Keys);
|
||||||
|
|
||||||
|
communication.SetCounts(TileScope.Personal, new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase)
|
||||||
|
{
|
||||||
|
["ServiceRequestsNew"] = 3
|
||||||
|
});
|
||||||
|
await service.FetchAsync(TileScope.Personal);
|
||||||
|
|
||||||
|
Assert.False(service.TicketAndServiceRequestsEnabled);
|
||||||
|
Assert.Equal(2, availabilityChanges);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TicketOverviewUpdateService CreateService(FakeCommunication communication, out FakeDispatcher dispatcher)
|
private static TicketOverviewUpdateService CreateService(FakeCommunication communication, out FakeDispatcher dispatcher)
|
||||||
|
|||||||
@@ -286,7 +286,7 @@ namespace C4IT.FASD.Cockpit.Communication
|
|||||||
if (string.IsNullOrWhiteSpace(key))
|
if (string.IsNullOrWhiteSpace(key))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (string.Equals(key, "ServiceRequestsEnabled", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(key, "TicketAndServiceRequestsEnabled", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
result[key] = 1;
|
result[key] = 1;
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace FasdDesktopUi.Basics.Services
|
|||||||
{
|
{
|
||||||
#region Fields
|
#region Fields
|
||||||
|
|
||||||
private const string ServiceRequestsEnabledKey = "ServiceRequestsEnabled";
|
private const string TicketAndServiceRequestsEnabledKey = "TicketAndServiceRequestsEnabled";
|
||||||
private readonly ITicketOverviewCommunicationSource _communicationSource;
|
private readonly ITicketOverviewCommunicationSource _communicationSource;
|
||||||
private static readonly string[] OverviewKeys = new[]
|
private static readonly string[] OverviewKeys = new[]
|
||||||
{
|
{
|
||||||
@@ -58,7 +58,7 @@ namespace FasdDesktopUi.Basics.Services
|
|||||||
private bool _isDemo;
|
private bool _isDemo;
|
||||||
private bool _initialized;
|
private bool _initialized;
|
||||||
private bool _isEnabled;
|
private bool _isEnabled;
|
||||||
private bool _serviceRequestsEnabled;
|
private bool _ticketAndServiceRequestsEnabled;
|
||||||
private readonly Random _random = new Random();
|
private readonly Random _random = new Random();
|
||||||
#if isDemo
|
#if isDemo
|
||||||
private readonly List<DemoTicketRecord> _persistedDemoTickets = new List<DemoTicketRecord>();
|
private readonly List<DemoTicketRecord> _persistedDemoTickets = new List<DemoTicketRecord>();
|
||||||
@@ -115,10 +115,10 @@ namespace FasdDesktopUi.Basics.Services
|
|||||||
#region Public API
|
#region Public API
|
||||||
|
|
||||||
public event EventHandler<TicketOverviewCountsChangedEventArgs> OverviewCountsChanged;
|
public event EventHandler<TicketOverviewCountsChangedEventArgs> OverviewCountsChanged;
|
||||||
public event EventHandler ServiceRequestsAvailabilityChanged;
|
public event EventHandler TicketAndServiceRequestsAvailabilityChanged;
|
||||||
|
|
||||||
public IReadOnlyDictionary<string, TileCounts> CurrentCounts => _currentCounts;
|
public IReadOnlyDictionary<string, TileCounts> CurrentCounts => _currentCounts;
|
||||||
public bool ServiceRequestsEnabled => _serviceRequestsEnabled;
|
public bool TicketAndServiceRequestsEnabled => _ticketAndServiceRequestsEnabled;
|
||||||
|
|
||||||
public bool IsScopeInitialized(TileScope scope)
|
public bool IsScopeInitialized(TileScope scope)
|
||||||
{
|
{
|
||||||
@@ -224,7 +224,7 @@ namespace FasdDesktopUi.Basics.Services
|
|||||||
_currentCounts[key] = TileCounts.Empty;
|
_currentCounts[key] = TileCounts.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateServiceRequestsAvailability(false);
|
UpdateTicketAndServiceRequestsAvailability(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -339,11 +339,11 @@ namespace FasdDesktopUi.Basics.Services
|
|||||||
_isDemo = communication.IsDemo();
|
_isDemo = communication.IsDemo();
|
||||||
|
|
||||||
var requestedKeys = scope == TileScope.Personal
|
var requestedKeys = scope == TileScope.Personal
|
||||||
? OverviewKeys.Concat(new[] { ServiceRequestsEnabledKey }).ToArray()
|
? OverviewKeys.Concat(new[] { TicketAndServiceRequestsEnabledKey }).ToArray()
|
||||||
: OverviewKeys;
|
: OverviewKeys;
|
||||||
var rawCounts = await communication.GetTicketOverviewCounts(requestedKeys, scope == TileScope.Role).ConfigureAwait(false);
|
var rawCounts = await communication.GetTicketOverviewCounts(requestedKeys, scope == TileScope.Role).ConfigureAwait(false);
|
||||||
var counts = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
|
var counts = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
|
||||||
var serviceRequestsEnabled = _isDemo;
|
var ticketAndServiceRequestsEnabled = _isDemo;
|
||||||
|
|
||||||
if (rawCounts != null)
|
if (rawCounts != null)
|
||||||
{
|
{
|
||||||
@@ -352,10 +352,10 @@ namespace FasdDesktopUi.Basics.Services
|
|||||||
if (string.IsNullOrWhiteSpace(kvp.Key))
|
if (string.IsNullOrWhiteSpace(kvp.Key))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (string.Equals(kvp.Key, ServiceRequestsEnabledKey, StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(kvp.Key, TicketAndServiceRequestsEnabledKey, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
if (scope == TileScope.Personal)
|
if (scope == TileScope.Personal)
|
||||||
serviceRequestsEnabled = _isDemo || kvp.Value > 0;
|
ticketAndServiceRequestsEnabled = _isDemo || kvp.Value > 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -369,7 +369,7 @@ namespace FasdDesktopUi.Basics.Services
|
|||||||
await _dispatcher.InvokeAsync(() =>
|
await _dispatcher.InvokeAsync(() =>
|
||||||
{
|
{
|
||||||
if (scope == TileScope.Personal)
|
if (scope == TileScope.Personal)
|
||||||
UpdateServiceRequestsAvailability(serviceRequestsEnabled);
|
UpdateTicketAndServiceRequestsAvailability(ticketAndServiceRequestsEnabled);
|
||||||
|
|
||||||
ProcessScopeCounts(scope, counts);
|
ProcessScopeCounts(scope, counts);
|
||||||
});
|
});
|
||||||
@@ -389,13 +389,13 @@ namespace FasdDesktopUi.Basics.Services
|
|||||||
|
|
||||||
#region Count Processing
|
#region Count Processing
|
||||||
|
|
||||||
private void UpdateServiceRequestsAvailability(bool isEnabled)
|
private void UpdateTicketAndServiceRequestsAvailability(bool isEnabled)
|
||||||
{
|
{
|
||||||
if (_serviceRequestsEnabled == isEnabled)
|
if (_ticketAndServiceRequestsEnabled == isEnabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_serviceRequestsEnabled = isEnabled;
|
_ticketAndServiceRequestsEnabled = isEnabled;
|
||||||
ServiceRequestsAvailabilityChanged?.Invoke(this, EventArgs.Empty);
|
TicketAndServiceRequestsAvailabilityChanged?.Invoke(this, EventArgs.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RefreshTimerIntervals()
|
private void RefreshTimerIntervals()
|
||||||
|
|||||||
@@ -120,7 +120,8 @@
|
|||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition x:Name="TicketsRow"
|
||||||
|
Height="0" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition x:Name="ServiceRequestsRow"
|
<RowDefinition x:Name="ServiceRequestsRow"
|
||||||
Height="0" />
|
Height="0" />
|
||||||
|
|||||||
@@ -274,10 +274,11 @@ namespace FasdDesktopUi.Basics.UserControls
|
|||||||
vm.ResetSelection();
|
vm.ResetSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetServiceRequestsVisibility(bool isVisible)
|
public void SetTicketAndServiceRequestsVisibility(bool isVisible)
|
||||||
{
|
{
|
||||||
Dispatcher.Invoke(() =>
|
Dispatcher.Invoke(() =>
|
||||||
{
|
{
|
||||||
|
TicketsRow.Height = isVisible ? GridLength.Auto : new GridLength(0);
|
||||||
ServiceRequestsRow.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)
|
if (counts == null || counts.Count == 0)
|
||||||
counts = await LoadCountsFallbackAsync(useRoleTickets).ConfigureAwait(false);
|
counts = await LoadCountsFallbackAsync(useRoleTickets).ConfigureAwait(false);
|
||||||
|
|
||||||
SetServiceRequestsVisibility(TicketOverviewUpdateService.Instance?.ServiceRequestsEnabled == true);
|
SetTicketAndServiceRequestsVisibility(TicketOverviewUpdateService.Instance?.TicketAndServiceRequestsEnabled == true);
|
||||||
|
|
||||||
await Dispatcher.InvokeAsync(() =>
|
await Dispatcher.InvokeAsync(() =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ namespace FasdDesktopUi.Pages.SearchPage
|
|||||||
if (TicketOverviewUpdateService.Instance != null)
|
if (TicketOverviewUpdateService.Instance != null)
|
||||||
{
|
{
|
||||||
TicketOverviewUpdateService.Instance.OverviewCountsChanged += TicketOverviewUpdateService_OverviewCountsChanged;
|
TicketOverviewUpdateService.Instance.OverviewCountsChanged += TicketOverviewUpdateService_OverviewCountsChanged;
|
||||||
TicketOverviewUpdateService.Instance.ServiceRequestsAvailabilityChanged += TicketOverviewUpdateService_ServiceRequestsAvailabilityChanged;
|
TicketOverviewUpdateService.Instance.TicketAndServiceRequestsAvailabilityChanged += TicketOverviewUpdateService_TicketAndServiceRequestsAvailabilityChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
UiSettingsChanged(null, null);
|
UiSettingsChanged(null, null);
|
||||||
@@ -735,7 +735,7 @@ namespace FasdDesktopUi.Pages.SearchPage
|
|||||||
if (TicketOverviewUpdateService.Instance != null)
|
if (TicketOverviewUpdateService.Instance != null)
|
||||||
{
|
{
|
||||||
TicketOverviewUpdateService.Instance.OverviewCountsChanged -= TicketOverviewUpdateService_OverviewCountsChanged;
|
TicketOverviewUpdateService.Instance.OverviewCountsChanged -= TicketOverviewUpdateService_OverviewCountsChanged;
|
||||||
TicketOverviewUpdateService.Instance.ServiceRequestsAvailabilityChanged -= TicketOverviewUpdateService_ServiceRequestsAvailabilityChanged;
|
TicketOverviewUpdateService.Instance.TicketAndServiceRequestsAvailabilityChanged -= TicketOverviewUpdateService_TicketAndServiceRequestsAvailabilityChanged;
|
||||||
}
|
}
|
||||||
_pipeServer?.Dispose();
|
_pipeServer?.Dispose();
|
||||||
}
|
}
|
||||||
@@ -1304,7 +1304,7 @@ namespace FasdDesktopUi.Pages.SearchPage
|
|||||||
if (service == null)
|
if (service == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TicketOverviewUc?.SetServiceRequestsVisibility(service.ServiceRequestsEnabled);
|
TicketOverviewUc?.SetTicketAndServiceRequestsVisibility(service.TicketAndServiceRequestsEnabled);
|
||||||
var counts = service.GetCountsForScope(IsFilterChecked);
|
var counts = service.GetCountsForScope(IsFilterChecked);
|
||||||
if (counts == null || counts.Count == 0)
|
if (counts == null || counts.Count == 0)
|
||||||
return;
|
return;
|
||||||
@@ -1313,10 +1313,10 @@ namespace FasdDesktopUi.Pages.SearchPage
|
|||||||
TicketOverviewUc?.RefreshHighlightState(IsFilterChecked);
|
TicketOverviewUc?.RefreshHighlightState(IsFilterChecked);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TicketOverviewUpdateService_ServiceRequestsAvailabilityChanged(object sender, EventArgs e)
|
private void TicketOverviewUpdateService_TicketAndServiceRequestsAvailabilityChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var isVisible = TicketOverviewUpdateService.Instance?.ServiceRequestsEnabled == true;
|
var isVisible = TicketOverviewUpdateService.Instance?.TicketAndServiceRequestsEnabled == true;
|
||||||
TicketOverviewUc?.SetServiceRequestsVisibility(isVisible);
|
TicketOverviewUc?.SetTicketAndServiceRequestsVisibility(isVisible);
|
||||||
ScheduleSearchResultMaxHeightUpdate();
|
ScheduleSearchResultMaxHeightUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user