Skip to content

Commit 09b9737

Browse files
committed
TD-4704: LH Live: Issue not showing the 'elfh' logo on 'Catalogue details' screen when accessed 'Search' & 'Catalogue cards' screens
1 parent 16edce8 commit 09b9737

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

LearningHub.Nhs.WebUI/Views/Catalogue/Index.cshtml

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,6 @@
3434
return string.Empty;
3535
}
3636

37-
string GetBadgeUrl()
38-
{
39-
if (!string.IsNullOrEmpty(Model.Catalogue.BadgeUrl))
40-
{
41-
return GetFileLink(Model.Catalogue.BadgeUrl);
42-
}
43-
return string.Empty;
44-
}
45-
4637
string GetFileLink(string fileName)
4738
{
4839
return "/api/catalogue/download-image/" + Uri.EscapeDataString(fileName);
@@ -82,6 +73,9 @@
8273
CatalogueAccessRequest = Model.CatalogueAccessRequest,
8374
UserGroups = Model.UserGroups
8475
};
76+
77+
var provider = Model.Catalogue.Providers?.FirstOrDefault();
78+
var hasBadge = !string.IsNullOrWhiteSpace(Model.Catalogue.BadgeUrl);
8579
}
8680

8781
@section styles{
@@ -124,9 +118,13 @@
124118
}
125119

126120
<div class="catalogue-title nhsuk-u-margin-bottom-7">
127-
@if (!string.IsNullOrEmpty(Model.Catalogue.BadgeUrl))
121+
@if (provider != null)
122+
{
123+
<img src="~/images/provider-logos/@provider.Logo" alt="@provider.Name catalogue badge" class="provider-badge" />
124+
}
125+
else if (hasBadge)
128126
{
129-
<img alt="Provider's catalogue badge" src="@GetBadgeUrl()" class="catalogue-badge" />
127+
<img src="@("/api/catalogue/download-image/" + Uri.EscapeDataString(Model.Catalogue.BadgeUrl))" alt="Provider's catalogue badgeTest" class="catalogue-card-badge" />
130128
}
131129

132130
<h1 class="heading-lg title nhsuk-u-margin-bottom-0">@(ViewBag.ActiveTab == "browse" && Model.NodeDetails != null ? Model.NodeDetails.Name : Model.Catalogue.Name)</h1>

WebAPI/LearningHub.Nhs.Services/CatalogueService.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ public async Task<CatalogueViewModel> GetCatalogueAsync(string reference, int us
198198
var bookmark = this.bookmarkRepository.GetAll().Where(b => b.NodeId == catalogue.NodeId && b.UserId == userId).FirstOrDefault();
199199
catalogueVM.BookmarkId = bookmark?.Id;
200200
catalogueVM.IsBookmarked = !bookmark?.Deleted ?? false;
201+
catalogueVM.Providers = await this.providerService.GetByCatalogueVersionIdAsync(catalogueVM.Id);
201202
return catalogueVM;
202203
}
203204

WebAPI/LearningHub.Nhs.Services/DashboardService.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ public async Task<DashboardMyLearningResponseViewModel> GetMyAccessLearnings(str
5151

5252
var cataloguesResponse = dashboardType.ToLower() == "my-catalogues" ? this.catalogueNodeVersionRepository.GetCatalogues(dashboardType, pageNumber, userId) : (TotalCount: 0, Catalogues: new List<DashboardCatalogueDto>());
5353

54+
var catalogueList = cataloguesResponse.Catalogues.Any() ? this.mapper.Map<List<DashboardCatalogueViewModel>>(cataloguesResponse.Catalogues) : new List<DashboardCatalogueViewModel>();
55+
if (catalogueList.Any())
56+
{
57+
foreach (var catalogue in catalogueList)
58+
{
59+
catalogue.Providers = await this.providerService.GetByCatalogueVersionIdAsync(catalogue.NodeVersionId);
60+
}
61+
}
62+
5463
var resourceList = resources.Any() ? this.mapper.Map<List<DashboardResourceViewModel>>(resources) : new List<DashboardResourceViewModel>();
5564
if (resourceList.Any())
5665
{
@@ -64,7 +73,7 @@ public async Task<DashboardMyLearningResponseViewModel> GetMyAccessLearnings(str
6473
{
6574
Type = dashboardType,
6675
Resources = resourceList,
67-
Catalogues = cataloguesResponse.Catalogues.Any() ? this.mapper.Map<List<DashboardCatalogueViewModel>>(cataloguesResponse.Catalogues) : new List<DashboardCatalogueViewModel>(),
76+
Catalogues = catalogueList,
6877
TotalCount = dashboardType.ToLower() == "my-catalogues" ? cataloguesResponse.TotalCount : resourceCount,
6978
CurrentPage = pageNumber,
7079
};

0 commit comments

Comments
 (0)