Consume ticket overview capabilities separately
This commit is contained in:
@@ -12,7 +12,7 @@ namespace FasdDesktopUi.Basics.Services.Models
|
||||
{
|
||||
bool IsDemo();
|
||||
|
||||
Task<Dictionary<string, int>> GetTicketOverviewCounts(string[] overviewKeys, bool useRoleScope);
|
||||
Task<cF4sdTicketOverviewCountsResult> GetTicketOverviewCounts(string[] overviewKeys, bool useRoleScope);
|
||||
|
||||
#if isDemo
|
||||
void RegisterGeneratedTicket(DemoTicketRecord record);
|
||||
@@ -47,12 +47,15 @@ namespace FasdDesktopUi.Basics.Services.Models
|
||||
return _communication.IsDemo();
|
||||
}
|
||||
|
||||
public async Task<Dictionary<string, int>> GetTicketOverviewCounts(string[] overviewKeys, bool useRoleScope)
|
||||
public async Task<cF4sdTicketOverviewCountsResult> GetTicketOverviewCounts(string[] overviewKeys, bool useRoleScope)
|
||||
{
|
||||
var rawCounts = await _communication.GetTicketOverviewCounts(overviewKeys, useRoleScope).ConfigureAwait(false);
|
||||
return rawCounts == null
|
||||
var result = await _communication.GetTicketOverviewCounts(overviewKeys, useRoleScope).ConfigureAwait(false)
|
||||
?? new cF4sdTicketOverviewCountsResult();
|
||||
result.Counts = result.Counts == null
|
||||
? new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase)
|
||||
: new Dictionary<string, int>(rawCounts, StringComparer.OrdinalIgnoreCase);
|
||||
: new Dictionary<string, int>(result.Counts, StringComparer.OrdinalIgnoreCase);
|
||||
result.Capabilities = result.Capabilities ?? new cF4sdTicketOverviewCapabilities();
|
||||
return result;
|
||||
}
|
||||
|
||||
#if isDemo
|
||||
|
||||
@@ -24,7 +24,6 @@ namespace FasdDesktopUi.Basics.Services
|
||||
{
|
||||
#region Fields
|
||||
|
||||
private const string TicketAndServiceRequestsEnabledKey = "TicketAndServiceRequestsEnabled";
|
||||
private const bool TicketAndServiceRequestsEnabledDefault = true;
|
||||
private readonly ITicketOverviewCommunicationSource _communicationSource;
|
||||
private static readonly string[] OverviewKeys = new[]
|
||||
@@ -339,12 +338,11 @@ namespace FasdDesktopUi.Basics.Services
|
||||
|
||||
_isDemo = communication.IsDemo();
|
||||
|
||||
var requestedKeys = scope == TileScope.Personal
|
||||
? OverviewKeys.Concat(new[] { TicketAndServiceRequestsEnabledKey }).ToArray()
|
||||
: OverviewKeys;
|
||||
var rawCounts = await communication.GetTicketOverviewCounts(requestedKeys, scope == TileScope.Role).ConfigureAwait(false);
|
||||
var result = await communication.GetTicketOverviewCounts(OverviewKeys, scope == TileScope.Role).ConfigureAwait(false);
|
||||
var rawCounts = result?.Counts;
|
||||
var counts = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
|
||||
var ticketAndServiceRequestsEnabled = TicketAndServiceRequestsEnabledDefault;
|
||||
var ticketAndServiceRequestsEnabled =
|
||||
result?.Capabilities?.TicketAndServiceRequestsEnabled ?? TicketAndServiceRequestsEnabledDefault;
|
||||
|
||||
if (rawCounts != null)
|
||||
{
|
||||
@@ -353,13 +351,6 @@ namespace FasdDesktopUi.Basics.Services
|
||||
if (string.IsNullOrWhiteSpace(kvp.Key))
|
||||
continue;
|
||||
|
||||
if (string.Equals(kvp.Key, TicketAndServiceRequestsEnabledKey, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (scope == TileScope.Personal)
|
||||
ticketAndServiceRequestsEnabled = _isDemo || kvp.Value > 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
counts[kvp.Key] = Math.Max(0, kvp.Value);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user