Skip to content

Commit 046fab2

Browse files
committed
TD-5434_Made changes to the code and now we are loading the banner text information directly from the centre table into the view component based on the logged in user, instead of using the views to inject it into the view components, did some clean up of removing the unwanted bannerText viewdata assigning, cleaned up unwanted braces.
1 parent 1d5cbad commit 046fab2

File tree

10 files changed

+29
-18
lines changed

10 files changed

+29
-18
lines changed

DigitalLearningSolutions.Web/ViewComponents/DlsFooterBannerTextViewComponent.cs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,33 @@
1-
using DigitalLearningSolutions.Web.ViewModels.Common.ViewComponents;
1+
using System.Security.Claims;
2+
using DigitalLearningSolutions.Data.DataServices;
3+
using DigitalLearningSolutions.Web.Helpers;
24
using Microsoft.AspNetCore.Mvc;
5+
using DigitalLearningSolutions.Web.ViewModels.Common.ViewComponents;
6+
using DigitalLearningSolutions.Web.Services;
7+
using System;
8+
using System.Threading.Tasks;
39

410
namespace DigitalLearningSolutions.Web.ViewComponents
511
{
612
public class DlsFooterBannerTextViewComponent : ViewComponent
713
{
8-
public IViewComponentResult Invoke(string centreName)
14+
private readonly ICentresService centresService;
15+
16+
public DlsFooterBannerTextViewComponent(ICentresService centresService)
917
{
10-
var model = new DlsFooterBannerTextViewModel(centreName);
18+
this.centresService = centresService;
19+
}
20+
21+
public IViewComponentResult Invoke()
22+
{
23+
var centreId = ((ClaimsPrincipal)User).GetCustomClaimAsInt(CustomClaimTypes.UserCentreId);
24+
if (centreId == null)
25+
{
26+
return View(new DlsFooterBannerTextViewModel(null));
27+
}
28+
29+
var bannerText = centresService.GetBannerText(Convert.ToInt32(centreId));
30+
var model = new DlsFooterBannerTextViewModel(bannerText);
1131
return View(model);
1232
}
1333
}

DigitalLearningSolutions.Web/ViewModels/Common/ViewComponents/DlsFooterBannerTextViewModel.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
{
33
public class DlsFooterBannerTextViewModel
44
{
5-
public readonly string? CentreName;
5+
public readonly string? BannerText;
66

7-
public DlsFooterBannerTextViewModel(string centreName)
7+
public DlsFooterBannerTextViewModel(string bannerText)
88
{
9-
CentreName = centreName;
9+
BannerText = bannerText;
1010
}
1111

1212
}

DigitalLearningSolutions.Web/Views/LearningMenu/CoursePassword.cshtml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
ViewData["CustomisationId"] = Model.Id;
1313
ViewData["HeaderPath"] = $"{Configuration["AppRootPath"]}/LearningMenu/{Model.Id}/Password";
1414
ViewData["HeaderPathName"] = Model.Title;
15-
ViewData["BannerText"] = Model.BannerText;
1615
}
1716
@section NavMenuItems {
1817
<partial name="Shared/_NavMenuItems" />

DigitalLearningSolutions.Web/Views/LearningMenu/Index.cshtml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
ViewData["CustomisationId"] = Model.Id;
1313
ViewData["HeaderPath"] = $"{Configuration["AppRootPath"]}/LearningMenu/{Model.Id}";
1414
ViewData["HeaderPathName"] = Model.Title;
15-
ViewData["BannerText"] = Model.BannerText;
1615
}
1716
@section NavMenuItems {
1817
<partial name="Shared/_NavMenuItems" />

DigitalLearningSolutions.Web/Views/LearningPortal/Available/Available.cshtml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
ViewData["Title"] = "Available Activities";
1111
ViewData["HeaderPath"] = $"{Configuration["AppRootPath"]}/LearningPortal/Available";
1212
ViewData["HeaderPathName"] = "Learning Portal";
13-
ViewData["BannerText"] = Model.BannerText;
1413
}
1514

1615
@section NavMenuItems {

DigitalLearningSolutions.Web/Views/LearningPortal/Completed/Completed.cshtml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
ViewData["Title"] = "My Completed Activities";
1111
ViewData["HeaderPath"] = $"{Configuration["AppRootPath"]}/LearningPortal/Completed";
1212
ViewData["HeaderPathName"] = "Learning Portal";
13-
ViewData["BannerText"] = Model.BannerText;
1413
}
1514

1615
@if (Model.JavascriptSearchSortFilterPaginateEnabled)

DigitalLearningSolutions.Web/Views/LearningPortal/Current/Current.cshtml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
ViewData["Title"] = "My Current Activities";
1313
ViewData["HeaderPath"] = $"{Configuration["AppRootPath"]}/LearningPortal/Current";
1414
ViewData["HeaderPathName"] = "Learning Portal";
15-
ViewData["BannerText"] = Model.BannerText;
1615
}
1716

1817
@section NavMenuItems {

DigitalLearningSolutions.Web/Views/Shared/Components/DlsFooterBannerText/Default.cshtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
@using DigitalLearningSolutions.Web.ViewModels.Common.ViewComponents
22
@model DlsFooterBannerTextViewModel
33
@{
4-
if (!String.IsNullOrEmpty(Model.CentreName))
4+
if (!String.IsNullOrEmpty(Model.BannerText))
55
{
66
<h2 class="nhsuk-heading-xs nhsuk-u-margin-bottom-2 nhsuk-u-secondary-text-color">Need help?</h2>
77
<div class="nhsuk-footer nhsuk-u-font-size-16 nhsuk-u-secondary-text-color">
88
<ul class="nhsuk-footer__list">
99
<li class="nhsuk-footer__list-item">
10-
<span>Centre contact information:</span> <span>@Model.CentreName</span>
10+
<span>Centre contact information:</span> <span>@Model.BannerText</span>
1111
</li>
1212
</ul>
1313
</div>

DigitalLearningSolutions.Web/Views/Shared/_DlsFooter.cshtml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
@{
2-
3-
}
41
<footer role="contentinfo">
52
<div class="nhsuk-footer-container">
63
<div class="nhsuk-width-container">
7-
@await Component.InvokeAsync("DlsFooterBannerText", new { centreName = ViewData["BannerText"] })
4+
@await Component.InvokeAsync("DlsFooterBannerText")
85
<h2 class="nhsuk-u-visually-hidden">Support links</h2>
96
<div class="nhsuk-footer">
107
<ul class="nhsuk-footer__list">

DigitalLearningSolutions.Web/Views/Supervisor/Index.cshtml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
ViewData["Title"] = "Dashboard";
77
ViewData["Application"] = "Supervisor";
88
ViewData["HeaderPathName"] = "Supervisor";
9-
ViewData["BannerText"] = Model.BannerText;
109
}
1110
<link rel="stylesheet" href="@Url.Content("~/css/frameworks/frameworksShared.css")" asp-append-version="true">
1211
@section NavMenuItems {

0 commit comments

Comments
 (0)