diff --git a/DigitalLearningSolutions.Data.Tests/DataServices/UserDataServiceTests.cs b/DigitalLearningSolutions.Data.Tests/DataServices/UserDataServiceTests.cs index 7324f917de..d6e982dc45 100644 --- a/DigitalLearningSolutions.Data.Tests/DataServices/UserDataServiceTests.cs +++ b/DigitalLearningSolutions.Data.Tests/DataServices/UserDataServiceTests.cs @@ -6,7 +6,6 @@ using System.Transactions; using DigitalLearningSolutions.Data.DataServices; using DigitalLearningSolutions.Data.Mappers; - using DigitalLearningSolutions.Data.Models.User; using DigitalLearningSolutions.Data.Tests.TestHelpers; using FluentAssertions; using FluentAssertions.Execution; @@ -446,19 +445,121 @@ public void GetDelegateUserCardsByCentreId_populates_DelegateUser_fields_correct } [Test] - public void GetDelegateUserCardsByCentreId_populates_DelegateUserCard_admin_fields_correctly() + public void GetDelegateUserCardsByCentreId_populates_DelegateUserCard_fields_correctly() + { + // When + var userCards = userDataService.GetDelegateUserCardsByCentreId(101); + + // Then + var userCard = userCards.Single(user => user.Id == 3); + userCard.Active.Should().BeTrue(); + userCard.SelfReg.Should().BeFalse(); + userCard.ExternalReg.Should().BeFalse(); + userCard.AdminId.Should().Be(1); + userCard.AliasId.Should().Be(""); + userCard.JobGroupId.Should().Be(10); + } + + [Test] + public void GetDelegateUserCardsByCentreId_does_not_match_admin_if_not_admin_in_this_centre() + { + // When + var userCards = userDataService.GetDelegateUserCardsByCentreId(409); + + // Then + var userCard = userCards.Single(user => user.Id == 268530); + userCard.AdminId.Should().BeNull(); + } + + [Test] + public void GetDelegateUserCardsByCentreId_does_not_match_admin_if_admin_email_address_is_blank() { // When var userCards = userDataService.GetDelegateUserCardsByCentreId(279); // Then - var userCard = userCards.Single(user => user.Id == 97055); + var userCard = userCards.First(user => user.EmailAddress == ""); + userCard.AdminId.Should().BeNull(); + } + + [Test] + public void GetDelegateUserCardsByCentreId_does_not_match_admin_if_password_does_not_match() + { + // When + var userCards = userDataService.GetDelegateUserCardsByCentreId(101); + + // Then + var adminUser = userDataService.GetAdminUserById(1)!; + var userCard = userCards.Single(user => user.Id == 254480); + userCard.EmailAddress.Should().Be(adminUser.EmailAddress); + userCard.CentreId.Should().Be(adminUser.CentreId); + userCard.Password.Should().NotBe(adminUser.Password); + userCard.AdminId.Should().BeNull(); + } + + [Test] + public void GetDelegateUserCardById_populates_DelegateUser_fields_correctly() + { + // Given + var expected = UserTestHelper.GetDefaultDelegateUser( + dateRegistered: DateTime.Parse("2010-09-22 06:52:09.080"), + jobGroupName: "Nursing / midwifery" + ); + + // When + var userCard = userDataService.GetDelegateUserCardById(2); + + // Then + userCard.Should().BeEquivalentTo(expected); + } + + [Test] + public void GetDelegateUserCardById_populates_DelegateUserCard_fields_correctly() + { + // When + var userCard = userDataService.GetDelegateUserCardById(3)!; + + // Then userCard.Active.Should().BeTrue(); - userCard.SelfReg.Should().BeTrue(); + userCard.SelfReg.Should().BeFalse(); userCard.ExternalReg.Should().BeFalse(); - userCard.AdminId.Should().Be(74); + userCard.AdminId.Should().Be(1); userCard.AliasId.Should().Be(""); - userCard.JobGroupId.Should().Be(6); + userCard.JobGroupId.Should().Be(10); + } + + [Test] + public void GetDelegateUserCardById_does_not_match_admin_if_not_admin_in_this_centre() + { + // When + var userCard = userDataService.GetDelegateUserCardById(268530)!; + + // Then + userCard.AdminId.Should().BeNull(); + } + + [Test] + public void GetDelegateUserCardById_does_not_match_admin_if_admin_email_address_is_blank() + { + // When + var userCard = userDataService.GetDelegateUserCardById(41300)!; + + // Then + userCard.AdminId.Should().BeNull(); + } + + [Test] + public void GetDelegateUserCardById_does_not_match_admin_if_password_does_not_match() + { + // When + var userCard = userDataService.GetDelegateUserCardById(254480)!; + + // Then + var adminUser = userDataService.GetAdminUserById(1)!; + userCard.EmailAddress.Should().Be(adminUser.EmailAddress); + userCard.CentreId.Should().Be(adminUser.CentreId); + userCard.Password.Should().NotBe(adminUser.Password); + userCard.AdminId.Should().BeNull(); } } } diff --git a/DigitalLearningSolutions.Data/DataServices/UserDataService.cs b/DigitalLearningSolutions.Data/DataServices/UserDataService.cs index 25819941a4..aa99e2513f 100644 --- a/DigitalLearningSolutions.Data/DataServices/UserDataService.cs +++ b/DigitalLearningSolutions.Data/DataServices/UserDataService.cs @@ -11,6 +11,7 @@ public interface IUserDataService { public AdminUser? GetAdminUserById(int id); public DelegateUser? GetDelegateUserById(int id); + public DelegateUserCard? GetDelegateUserCardById(int id); public List GetAdminUsersByCentreId(int centreId); public List GetDelegateUserCardsByCentreId(int centreId); public AdminUser? GetAdminUserByUsername(string username); @@ -136,6 +137,51 @@ FROM Candidates AS cd return user; } + public DelegateUserCard? GetDelegateUserCardById(int id) + { + var user = connection.Query( + @"SELECT + cd.CandidateID AS Id, + cd.CandidateNumber, + ct.CentreName, + cd.CentreID, + cd.DateRegistered, + ct.Active AS CentreActive, + cd.EmailAddress, + cd.FirstName, + cd.LastName, + cd.Password, + cd.Approved, + cd.Answer1, + cd.Answer2, + cd.Answer3, + cd.Answer4, + cd.Answer5, + cd.Answer6, + cd.JobGroupId, + jg.JobGroupName, + cd.SelfReg, + cd.ExternalReg, + cd.Active, + (SELECT AdminID + FROM AdminUsers au + WHERE (au.Email = cd.EmailAddress + OR au.Email = cd.AliasID) + AND au.Password = cd.Password + AND au.CentreID = cd.CentreID + AND au.Email != '' + ) AS AdminID, + cd.AliasID + FROM Candidates AS cd + INNER JOIN Centres AS ct ON ct.CentreID = cd.CentreID + INNER JOIN JobGroups AS jg ON jg.JobGroupID = cd.JobGroupID + WHERE cd.CandidateId = @id", + new { id } + ).SingleOrDefault(); + + return user; + } + public List GetAdminUsersByCentreId(int centreId) { var users = connection.Query( @@ -205,7 +251,11 @@ public List GetDelegateUserCardsByCentreId(int centreId) cd.Active, (SELECT AdminID FROM AdminUsers au - WHERE au.Email = cd.EmailAddress AND au.CentreID = cd.CentreID + WHERE (au.Email = cd.EmailAddress + OR au.Email = cd.AliasID) + AND au.Password = cd.Password + AND au.CentreID = cd.CentreID + AND au.Email != '' ) AS AdminID, cd.AliasID FROM Candidates AS cd diff --git a/DigitalLearningSolutions.Web.AutomatedUiTests/AccessibilityTests/BasicAccessibilityTests.cs b/DigitalLearningSolutions.Web.AutomatedUiTests/AccessibilityTests/BasicAccessibilityTests.cs index 61e5032f61..00ed3e37c7 100644 --- a/DigitalLearningSolutions.Web.AutomatedUiTests/AccessibilityTests/BasicAccessibilityTests.cs +++ b/DigitalLearningSolutions.Web.AutomatedUiTests/AccessibilityTests/BasicAccessibilityTests.cs @@ -39,6 +39,7 @@ public void Page_has_no_accessibility_errors(string url, string pageTitle) [InlineData("/TrackingSystem/Centre/TopCourses", "Top courses")] [InlineData("/TrackingSystem/CourseSetup", "Centre course setup")] [InlineData("/TrackingSystem/Delegates/All", "Delegates")] + [InlineData("/TrackingSystem/Delegates/View/1", "xxxxx xxxxxxxxx")] [InlineData("/TrackingSystem/Delegates/Approve", "Approve delegate registrations")] [InlineData("/TrackingSystem/Delegates/BulkUpload", "Bulk upload/update delegates")] [InlineData("/NotificationPreferences", "Notification preferences")] diff --git a/DigitalLearningSolutions.Web.Tests/ViewModels/TrackingSystem/Delegates/AllDelegates/DelegateInfoViewModelTests.cs b/DigitalLearningSolutions.Web.Tests/ViewModels/TrackingSystem/Delegates/AllDelegates/DelegateInfoViewModelTests.cs new file mode 100644 index 0000000000..ae3f695786 --- /dev/null +++ b/DigitalLearningSolutions.Web.Tests/ViewModels/TrackingSystem/Delegates/AllDelegates/DelegateInfoViewModelTests.cs @@ -0,0 +1,29 @@ +namespace DigitalLearningSolutions.Web.Tests.ViewModels.TrackingSystem.Delegates.AllDelegates +{ + using System; + using System.Collections.Generic; + using DigitalLearningSolutions.Data.Models.User; + using DigitalLearningSolutions.Web.ViewModels.Common; + using DigitalLearningSolutions.Web.ViewModels.TrackingSystem.Delegates; + using FluentAssertions; + using NUnit.Framework; + + public class DelegateInfoViewModelTests + { + private readonly List customFields = new List(); + + [Test] + public void DelegateInfoViewModel_sets_reg_date_string_correctly() + { + // Given + var date = new DateTime(2021, 05, 13); + var user = new DelegateUserCard { DateRegistered = date }; + + // When + var model = new DelegateInfoViewModel(user, customFields); + + // Then + model.RegistrationDate.Should().Be("13/05/2021"); + } + } +} diff --git a/DigitalLearningSolutions.Web.Tests/ViewModels/TrackingSystem/Delegates/AllDelegates/SearchableDelegateViewModelTests.cs b/DigitalLearningSolutions.Web.Tests/ViewModels/TrackingSystem/Delegates/AllDelegates/SearchableDelegateViewModelTests.cs index d0625b03d1..8deb88c0bf 100644 --- a/DigitalLearningSolutions.Web.Tests/ViewModels/TrackingSystem/Delegates/AllDelegates/SearchableDelegateViewModelTests.cs +++ b/DigitalLearningSolutions.Web.Tests/ViewModels/TrackingSystem/Delegates/AllDelegates/SearchableDelegateViewModelTests.cs @@ -1,6 +1,5 @@ namespace DigitalLearningSolutions.Web.Tests.ViewModels.TrackingSystem.Delegates.AllDelegates { - using System; using System.Collections.Generic; using DigitalLearningSolutions.Data.Models.User; using DigitalLearningSolutions.Web.ViewModels.Common; @@ -20,8 +19,8 @@ public void SearchableDelegateViewModel_sets_active_tag_name_correctly() var inactiveUser = new DelegateUserCard { Active = false }; // When - var activeModel = new SearchableDelegateViewModel(activeUser, customFields); - var inactiveModel = new SearchableDelegateViewModel(inactiveUser, customFields); + var activeModel = new SearchableDelegateViewModel(new DelegateInfoViewModel(activeUser, customFields)); + var inactiveModel = new SearchableDelegateViewModel(new DelegateInfoViewModel(inactiveUser, customFields)); // Then activeModel.ActiveTagName.Should().Be("Active"); @@ -36,8 +35,8 @@ public void SearchableDelegateViewModel_sets_password_tag_name_correctly() var pwNotSetUser = new DelegateUserCard { Password = null }; // When - var pwSetModel = new SearchableDelegateViewModel(pwSetUser, customFields); - var pwNotSetModel = new SearchableDelegateViewModel(pwNotSetUser, customFields); + var pwSetModel = new SearchableDelegateViewModel(new DelegateInfoViewModel(pwSetUser, customFields)); + var pwNotSetModel = new SearchableDelegateViewModel(new DelegateInfoViewModel(pwNotSetUser, customFields)); // Then pwSetModel.PasswordTagName.Should().Be("Password set"); @@ -53,28 +52,16 @@ public void SearchableDelegateViewModel_sets_regstatus_tag_name_correctly() var centreRegUser = new DelegateUserCard { SelfReg = false }; // When - var selfRegModel = new SearchableDelegateViewModel(selfRegUser, customFields); - var selfRegExternalModel = new SearchableDelegateViewModel(selfRegExternalUser, customFields); - var centreRegModel = new SearchableDelegateViewModel(centreRegUser, customFields); + var selfRegModel = new SearchableDelegateViewModel(new DelegateInfoViewModel(selfRegUser, customFields)); + var selfRegExternalModel = + new SearchableDelegateViewModel(new DelegateInfoViewModel(selfRegExternalUser, customFields)); + var centreRegModel = + new SearchableDelegateViewModel(new DelegateInfoViewModel(centreRegUser, customFields)); // Then selfRegModel.RegStatusTagName.Should().Be("Self registered"); selfRegExternalModel.RegStatusTagName.Should().Be("Self registered (External)"); centreRegModel.RegStatusTagName.Should().Be("Registered by centre"); } - - [Test] - public void SearchableDelegateViewModel_sets_reg_date_string_correctly() - { - // Given - var date = new DateTime(2021, 05, 13); - var user = new DelegateUserCard { DateRegistered = date }; - - // When - var model = new SearchableDelegateViewModel(user, customFields); - - // Then - model.RegistrationDate.Should().Be("13/05/2021"); - } } } diff --git a/DigitalLearningSolutions.Web.Tests/ViewModels/TrackingSystem/Delegates/AllDelegates/ViewDelegateViewModelTests.cs b/DigitalLearningSolutions.Web.Tests/ViewModels/TrackingSystem/Delegates/AllDelegates/ViewDelegateViewModelTests.cs new file mode 100644 index 0000000000..3889a9ab71 --- /dev/null +++ b/DigitalLearningSolutions.Web.Tests/ViewModels/TrackingSystem/Delegates/AllDelegates/ViewDelegateViewModelTests.cs @@ -0,0 +1,67 @@ +namespace DigitalLearningSolutions.Web.Tests.ViewModels.TrackingSystem.Delegates.AllDelegates +{ + using System.Collections.Generic; + using DigitalLearningSolutions.Data.Models.User; + using DigitalLearningSolutions.Web.ViewModels.Common; + using DigitalLearningSolutions.Web.ViewModels.TrackingSystem.Delegates; + using FluentAssertions; + using NUnit.Framework; + + public class ViewDelegateViewModelTests + { + private readonly List customFields = new List(); + + [Test] + public void ViewDelegateViewModel_sets_active_tag_name_correctly() + { + // Given + var activeUser = new DelegateUserCard { Active = true }; + var inactiveUser = new DelegateUserCard { Active = false }; + + // When + var activeModel = new ViewDelegateViewModel(new DelegateInfoViewModel(activeUser, customFields)); + var inactiveModel = new ViewDelegateViewModel(new DelegateInfoViewModel(inactiveUser, customFields)); + + // Then + activeModel.ActiveTagName.Should().Be("Active"); + inactiveModel.ActiveTagName.Should().Be("Inactive"); + } + + [Test] + public void ViewDelegateViewModel_sets_password_tag_name_correctly() + { + // Given + var pwSetUser = new DelegateUserCard { Password = "pw" }; + var pwNotSetUser = new DelegateUserCard { Password = null }; + + // When + var pwSetModel = new ViewDelegateViewModel(new DelegateInfoViewModel(pwSetUser, customFields)); + var pwNotSetModel = new ViewDelegateViewModel(new DelegateInfoViewModel(pwNotSetUser, customFields)); + + // Then + pwSetModel.PasswordTagName.Should().Be("Password set"); + pwNotSetModel.PasswordTagName.Should().Be("Password not set"); + } + + [Test] + public void ViewDelegateViewModel_sets_regstatus_tag_name_correctly() + { + // Given + var selfRegUser = new DelegateUserCard { SelfReg = true, ExternalReg = false }; + var selfRegExternalUser = new DelegateUserCard { SelfReg = true, ExternalReg = true }; + var centreRegUser = new DelegateUserCard { SelfReg = false }; + + // When + var selfRegModel = new ViewDelegateViewModel(new DelegateInfoViewModel(selfRegUser, customFields)); + var selfRegExternalModel = + new ViewDelegateViewModel(new DelegateInfoViewModel(selfRegExternalUser, customFields)); + var centreRegModel = + new ViewDelegateViewModel(new DelegateInfoViewModel(centreRegUser, customFields)); + + // Then + selfRegModel.RegStatusTagName.Should().Be("Self registered"); + selfRegExternalModel.RegStatusTagName.Should().Be("Self registered (External)"); + centreRegModel.RegStatusTagName.Should().Be("Registered by centre"); + } + } +} diff --git a/DigitalLearningSolutions.Web/Controllers/TrackingSystem/Delegates/AllDelegatesController.cs b/DigitalLearningSolutions.Web/Controllers/TrackingSystem/Delegates/AllDelegatesController.cs index 3392a82222..cb13c25e12 100644 --- a/DigitalLearningSolutions.Web/Controllers/TrackingSystem/Delegates/AllDelegatesController.cs +++ b/DigitalLearningSolutions.Web/Controllers/TrackingSystem/Delegates/AllDelegatesController.cs @@ -30,7 +30,8 @@ public IActionResult Index() delegateUser => { var customFields = customPromptHelper.GetCustomFieldViewModelsForCentre(centreId, delegateUser); - return new SearchableDelegateViewModel(delegateUser, customFields); + var delegateInfoViewModel = new DelegateInfoViewModel(delegateUser, customFields); + return new SearchableDelegateViewModel(delegateInfoViewModel); } ); var model = new AllDelegatesViewModel(centreId, searchableDelegateViewModels); diff --git a/DigitalLearningSolutions.Web/Controllers/TrackingSystem/Delegates/ViewDelegateController.cs b/DigitalLearningSolutions.Web/Controllers/TrackingSystem/Delegates/ViewDelegateController.cs new file mode 100644 index 0000000000..2c09d67c58 --- /dev/null +++ b/DigitalLearningSolutions.Web/Controllers/TrackingSystem/Delegates/ViewDelegateController.cs @@ -0,0 +1,41 @@ +namespace DigitalLearningSolutions.Web.Controllers.TrackingSystem.Delegates +{ + using DigitalLearningSolutions.Data.DataServices; + using DigitalLearningSolutions.Web.Helpers; + using DigitalLearningSolutions.Web.ViewModels.TrackingSystem.Delegates; + using Microsoft.AspNetCore.Authorization; + using Microsoft.AspNetCore.Mvc; + using Microsoft.FeatureManagement.Mvc; + + [FeatureGate(FeatureFlags.RefactoredTrackingSystem)] + [Authorize(Policy = CustomPolicies.UserCentreAdmin)] + [Route("TrackingSystem/Delegates/View/{delegateId:int}")] + public class ViewDelegateController : Controller + { + private readonly CustomPromptHelper customPromptHelper; + private readonly IUserDataService userDataService; + + public ViewDelegateController(IUserDataService userDataService, CustomPromptHelper customPromptHelper) + { + this.userDataService = userDataService; + this.customPromptHelper = customPromptHelper; + } + + public IActionResult Index(int delegateId) + { + var centreId = User.GetCentreId(); + var delegateUser = userDataService.GetDelegateUserCardById(delegateId); + + if (delegateUser == null || delegateUser.CentreId != centreId) + { + return new NotFoundResult(); + } + + var customFields = customPromptHelper.GetCustomFieldViewModelsForCentre(centreId, delegateUser); + var delegateInfo = new DelegateInfoViewModel(delegateUser, customFields); + var model = new ViewDelegateViewModel(delegateInfo); + + return View(model); + } + } +} diff --git a/DigitalLearningSolutions.Web/Styles/trackingSystem/viewDelegate.scss b/DigitalLearningSolutions.Web/Styles/trackingSystem/viewDelegate.scss new file mode 100644 index 0000000000..d926f51ff8 --- /dev/null +++ b/DigitalLearningSolutions.Web/Styles/trackingSystem/viewDelegate.scss @@ -0,0 +1,25 @@ +@import "~nhsuk-frontend/packages/core/all"; + +.view-delegate-top-button-group { + text-align: right; + + @media (max-width: 768px) { + text-align: unset; + margin-bottom: nhsuk-spacing(4); + } +} + +.view-delegate-button { + padding-top: nhsuk-spacing(2); + padding-bottom: nhsuk-spacing(2); + margin-bottom: nhsuk-spacing(2); + + @media (max-width: 1024px) { + margin-top: nhsuk-spacing(1); + margin-bottom: nhsuk-spacing(1); + } + + @media (max-width: 375px) { + width: 100%; + } +} diff --git a/DigitalLearningSolutions.Web/ViewModels/TrackingSystem/CentreConfiguration/CentreConfigurationViewModel.cs b/DigitalLearningSolutions.Web/ViewModels/TrackingSystem/CentreConfiguration/CentreConfigurationViewModel.cs index faf4dec13f..d128a204e1 100644 --- a/DigitalLearningSolutions.Web/ViewModels/TrackingSystem/CentreConfiguration/CentreConfigurationViewModel.cs +++ b/DigitalLearningSolutions.Web/ViewModels/TrackingSystem/CentreConfiguration/CentreConfigurationViewModel.cs @@ -32,8 +32,8 @@ public CentreConfigurationViewModel(Centre centre) public int CentreId { get; set; } public string CentreName { get; set; } public string RegionName { get; set; } - public string NotifyEmail { get; set; } - public string BannerText { get; set; } + public string? NotifyEmail { get; set; } + public string? BannerText { get; set; } public byte[]? SignatureImage { get; set; } public byte[]? CentreLogo { get; set; } public string? ContactForename { get; set; } diff --git a/DigitalLearningSolutions.Web/ViewModels/TrackingSystem/Delegates/DelegateInfoViewModel.cs b/DigitalLearningSolutions.Web/ViewModels/TrackingSystem/Delegates/DelegateInfoViewModel.cs new file mode 100644 index 0000000000..fa2562cf15 --- /dev/null +++ b/DigitalLearningSolutions.Web/ViewModels/TrackingSystem/Delegates/DelegateInfoViewModel.cs @@ -0,0 +1,49 @@ +namespace DigitalLearningSolutions.Web.ViewModels.TrackingSystem.Delegates +{ + using System.Collections.Generic; + using DigitalLearningSolutions.Data.Models.User; + using DigitalLearningSolutions.Web.ViewModels.Common; + + public class DelegateInfoViewModel + { + public DelegateInfoViewModel(DelegateUserCard delegateUser, List customFields) + { + Id = delegateUser.Id; + Name = delegateUser.SearchableName; + CandidateNumber = delegateUser.CandidateNumber; + + IsSelfReg = delegateUser.SelfReg; + IsExternalReg = delegateUser.ExternalReg; + IsActive = delegateUser.Active; + IsAdmin = delegateUser.AdminId.HasValue; + IsPasswordSet = delegateUser.Password != null; + + Email = delegateUser.EmailAddress; + JobGroup = delegateUser.JobGroupName; + if (delegateUser.DateRegistered.HasValue) + { + RegistrationDate = delegateUser.DateRegistered.Value.ToString("dd/MM/yyyy"); + } + AliasId = delegateUser.AliasId; + + CustomFields = customFields; + } + + public int Id { get; set; } + public string Name { get; set; } + public string CandidateNumber { get; set; } + + public bool IsSelfReg { get; set; } + public bool IsExternalReg { get; set; } + public bool IsActive { get; set; } + public bool IsAdmin { get; set; } + public bool IsPasswordSet { get; set; } + + public string? Email { get; set; } + public string? JobGroup { get; set; } + public string? RegistrationDate { get; set; } + public string? AliasId { get; set; } + + public List CustomFields { get; set; } + } +} diff --git a/DigitalLearningSolutions.Web/ViewModels/TrackingSystem/Delegates/SearchableDelegateViewModel.cs b/DigitalLearningSolutions.Web/ViewModels/TrackingSystem/Delegates/SearchableDelegateViewModel.cs index ad10620c25..60736aceb2 100644 --- a/DigitalLearningSolutions.Web/ViewModels/TrackingSystem/Delegates/SearchableDelegateViewModel.cs +++ b/DigitalLearningSolutions.Web/ViewModels/TrackingSystem/Delegates/SearchableDelegateViewModel.cs @@ -1,59 +1,23 @@ namespace DigitalLearningSolutions.Web.ViewModels.TrackingSystem.Delegates { - using System.Collections.Generic; - using System.Globalization; - using DigitalLearningSolutions.Data.Models.User; - using DigitalLearningSolutions.Web.ViewModels.Common; - /* TODO: Search and sort functionality is part of HEEDLS-491. Filename includes 'Searchable' to avoid having to change name later */ public class SearchableDelegateViewModel { - public SearchableDelegateViewModel(DelegateUserCard delegateUser, List customFields) + public SearchableDelegateViewModel(DelegateInfoViewModel delegateInfoViewModel) { - Id = delegateUser.Id; - Name = delegateUser.SearchableName; - CandidateNumber = delegateUser.CandidateNumber; - - IsSelfReg = delegateUser.SelfReg; - IsExternalReg = delegateUser.ExternalReg; - IsActive = delegateUser.Active; - IsAdmin = delegateUser.AdminId.HasValue; - IsPasswordSet = delegateUser.Password != null; - - Email = delegateUser.EmailAddress; - JobGroup = delegateUser.JobGroupName; - if (delegateUser.DateRegistered.HasValue) - { - CultureInfo originalCulture = CultureInfo.CurrentCulture; - CultureInfo.CurrentCulture = new CultureInfo("en-GB"); - RegistrationDate = delegateUser.DateRegistered.Value.ToShortDateString(); - CultureInfo.CurrentCulture = originalCulture; - } - - CustomFields = customFields; + DelegateInfo = delegateInfoViewModel; } - public int Id { get; set; } - public string Name { get; set; } - public string CandidateNumber { get; set; } - - public bool IsSelfReg { get; set; } - public bool IsExternalReg { get; set; } - public bool IsActive { get; set; } - public bool IsAdmin { get; set; } - public bool IsPasswordSet { get; set; } + public DelegateInfoViewModel DelegateInfo { get; set; } public string RegStatusTagName => - IsSelfReg ? "Self registered" + (IsExternalReg ? " (External)" : "") : "Registered by centre"; - public string ActiveTagName => IsActive ? "Active" : "Inactive"; - public string PasswordTagName => IsPasswordSet ? "Password set" : "Password not set"; - - public string? Email { get; set; } - public string? JobGroup { get; set; } - public string? RegistrationDate { get; set; } + DelegateInfo.IsSelfReg + ? "Self registered" + (DelegateInfo.IsExternalReg ? " (External)" : "") + : "Registered by centre"; - public List CustomFields { get; set; } + public string ActiveTagName => DelegateInfo.IsActive ? "Active" : "Inactive"; + public string PasswordTagName => DelegateInfo.IsPasswordSet ? "Password set" : "Password not set"; } } diff --git a/DigitalLearningSolutions.Web/ViewModels/TrackingSystem/Delegates/ViewDelegateViewModel.cs b/DigitalLearningSolutions.Web/ViewModels/TrackingSystem/Delegates/ViewDelegateViewModel.cs new file mode 100644 index 0000000000..815c6b5067 --- /dev/null +++ b/DigitalLearningSolutions.Web/ViewModels/TrackingSystem/Delegates/ViewDelegateViewModel.cs @@ -0,0 +1,20 @@ +namespace DigitalLearningSolutions.Web.ViewModels.TrackingSystem.Delegates +{ + public class ViewDelegateViewModel + { + public ViewDelegateViewModel(DelegateInfoViewModel delegateInfoViewModel) + { + DelegateInfo = delegateInfoViewModel; + } + + public DelegateInfoViewModel DelegateInfo { get; set; } + + public string RegStatusTagName => + DelegateInfo.IsSelfReg + ? "Self registered" + (DelegateInfo.IsExternalReg ? " (External)" : "") + : "Registered by centre"; + + public string ActiveTagName => DelegateInfo.IsActive ? "Active" : "Inactive"; + public string PasswordTagName => DelegateInfo.IsPasswordSet ? "Password set" : "Password not set"; + } +} diff --git a/DigitalLearningSolutions.Web/Views/MyAccount/_AccountSummaryCard.cshtml b/DigitalLearningSolutions.Web/Views/MyAccount/_AccountSummaryCard.cshtml index ea89760b80..5afbed44ba 100644 --- a/DigitalLearningSolutions.Web/Views/MyAccount/_AccountSummaryCard.cshtml +++ b/DigitalLearningSolutions.Web/Views/MyAccount/_AccountSummaryCard.cshtml @@ -8,9 +8,7 @@
Centre
-
- @Model.Centre -
+ @if (Model.User?.Length > 0) { @@ -18,9 +16,7 @@
User
-
- @Model.User -
+ } @@ -29,9 +25,7 @@
Delegate id
-
- @Model.DelegateNumber -
+ } diff --git a/DigitalLearningSolutions.Web/Views/MyAccount/_MyDetailsCard.cshtml b/DigitalLearningSolutions.Web/Views/MyAccount/_MyDetailsCard.cshtml index 0a4f73aed8..0eba131922 100644 --- a/DigitalLearningSolutions.Web/Views/MyAccount/_MyDetailsCard.cshtml +++ b/DigitalLearningSolutions.Web/Views/MyAccount/_MyDetailsCard.cshtml @@ -12,27 +12,21 @@
First name
-
- @Model.FirstName -
+
Last name
-
- @Model.Surname -
+
Email address
-
- @Model.User -
+
@if (Model.DelegateNumber != null) { @@ -40,9 +34,7 @@
Job group
-
- @Model.JobGroup -
+ foreach (var customField in Model.CustomFields) { diff --git a/DigitalLearningSolutions.Web/Views/Shared/_CustomPromptSummaryListRow.cshtml b/DigitalLearningSolutions.Web/Views/Shared/_CustomPromptSummaryListRow.cshtml index 1d4fd7eb11..b73b6cc2fe 100644 --- a/DigitalLearningSolutions.Web/Views/Shared/_CustomPromptSummaryListRow.cshtml +++ b/DigitalLearningSolutions.Web/Views/Shared/_CustomPromptSummaryListRow.cshtml @@ -5,7 +5,5 @@
@Model.CustomPrompt@(Model.Mandatory ? "" : " (optional)")
-
- @Model.Answer -
+ diff --git a/DigitalLearningSolutions.Web/Views/Shared/_SummaryFieldValue.cshtml b/DigitalLearningSolutions.Web/Views/Shared/_SummaryFieldValue.cshtml new file mode 100644 index 0000000000..701bec233b --- /dev/null +++ b/DigitalLearningSolutions.Web/Views/Shared/_SummaryFieldValue.cshtml @@ -0,0 +1,11 @@ +@model string? + +@if (string.IsNullOrEmpty(Model)) { +
+ - No value set +
+} else { +
+ @Model +
+} diff --git a/DigitalLearningSolutions.Web/Views/TrackingSystem/Centre/Dashboard/_DashboardCentreDetails.cshtml b/DigitalLearningSolutions.Web/Views/TrackingSystem/Centre/Dashboard/_DashboardCentreDetails.cshtml index f193f650bc..e3ba6a1c38 100644 --- a/DigitalLearningSolutions.Web/Views/TrackingSystem/Centre/Dashboard/_DashboardCentreDetails.cshtml +++ b/DigitalLearningSolutions.Web/Views/TrackingSystem/Centre/Dashboard/_DashboardCentreDetails.cshtml @@ -16,99 +16,77 @@
Centre ranking
-
- @Model.CentreDetails.CentreRank -
+
Centre name
-
- @Model.CentreDetails.CentreName -
+
Centre number
-
- @Model.CentreDetails.CentreId -
+
Region
-
- @Model.CentreDetails.Region -
+
Contract type
-
- @Model.CentreDetails.ContractType -
+
Centre manager
-
- @Model.CentreDetails.CentreManager -
+
Email
-
- @Model.CentreDetails.Email -
+
Contact number
-
- @Model.CentreDetails.Telephone -
+
Centre support details
-
- @Model.CentreDetails.BannerText -
+
Your IP address
-
- @Model.CentreDetails.IpAddress -
+
Pre-approved IPs
-
- @Model.CentreDetails.ApprovedIps -
+
diff --git a/DigitalLearningSolutions.Web/Views/TrackingSystem/CentreConfiguration/_CentreConfigurationCentreContentDetails.cshtml b/DigitalLearningSolutions.Web/Views/TrackingSystem/CentreConfiguration/_CentreConfigurationCentreContentDetails.cshtml index 95e9d7de11..f5d800a9da 100644 --- a/DigitalLearningSolutions.Web/Views/TrackingSystem/CentreConfiguration/_CentreConfigurationCentreContentDetails.cshtml +++ b/DigitalLearningSolutions.Web/Views/TrackingSystem/CentreConfiguration/_CentreConfigurationCentreContentDetails.cshtml @@ -17,81 +17,63 @@
Centre telephone
-
- @Model.CentreTelephone -
+
Centre email
-
- @Model.CentreEmail -
+
Centre postcode
-
- @Model.CentrePostcode -
+
Show centre on map
-
- @showCentreOnMap -
+
Opening hours
-
- @Model.OpeningHours -
+
Centre web address
-
- @Model.CentreWebAddress -
+
Organisations covered
-
- @Model.OrganisationsCovered -
+
Training venues
-
- @Model.TrainingVenues -
+
Other information
-
- @Model.OtherInformation -
+
diff --git a/DigitalLearningSolutions.Web/Views/TrackingSystem/CentreConfiguration/_CentreConfigurationCentreDetails.cshtml b/DigitalLearningSolutions.Web/Views/TrackingSystem/CentreConfiguration/_CentreConfigurationCentreDetails.cshtml index 81e149b821..1d4f5614de 100644 --- a/DigitalLearningSolutions.Web/Views/TrackingSystem/CentreConfiguration/_CentreConfigurationCentreDetails.cshtml +++ b/DigitalLearningSolutions.Web/Views/TrackingSystem/CentreConfiguration/_CentreConfigurationCentreDetails.cshtml @@ -15,18 +15,14 @@
Notify email
-
- @Model.NotifyEmail -
+
Banner text
-
- @Model.BannerText -
+
diff --git a/DigitalLearningSolutions.Web/Views/TrackingSystem/CentreConfiguration/_CentreConfigurationCentreManagerDetails.cshtml b/DigitalLearningSolutions.Web/Views/TrackingSystem/CentreConfiguration/_CentreConfigurationCentreManagerDetails.cshtml index ebbc48d4ed..159f26aab5 100644 --- a/DigitalLearningSolutions.Web/Views/TrackingSystem/CentreConfiguration/_CentreConfigurationCentreManagerDetails.cshtml +++ b/DigitalLearningSolutions.Web/Views/TrackingSystem/CentreConfiguration/_CentreConfigurationCentreManagerDetails.cshtml @@ -13,36 +13,28 @@
First name
-
- @Model.ContactForename -
+
Last name
-
- @Model.ContactSurname -
+
Email
-
- @Model.ContactEmail -
+
Telephone
-
- @Model.ContactTelephone -
+
diff --git a/DigitalLearningSolutions.Web/Views/TrackingSystem/Delegates/AllDelegates/_SearchableDelegateCard.cshtml b/DigitalLearningSolutions.Web/Views/TrackingSystem/Delegates/AllDelegates/_SearchableDelegateCard.cshtml index d0bacf2832..18eb36810f 100644 --- a/DigitalLearningSolutions.Web/Views/TrackingSystem/Delegates/AllDelegates/_SearchableDelegateCard.cshtml +++ b/DigitalLearningSolutions.Web/Views/TrackingSystem/Delegates/AllDelegates/_SearchableDelegateCard.cshtml @@ -2,18 +2,18 @@ @using DigitalLearningSolutions.Web.ViewModels.TrackingSystem.Delegates @model SearchableDelegateViewModel @{ - var activeTagCss = Model.IsActive ? "nhsuk-tag nhsuk-tag--green" : "nhsuk-tag nhsuk-tag--red"; - var passwordTagCss = Model.IsPasswordSet ? "nhsuk-tag nhsuk-tag--green" : "nhsuk-tag nhsuk-tag--red"; + var activeTagCss = Model.DelegateInfo.IsActive ? "nhsuk-tag nhsuk-tag--green" : "nhsuk-tag nhsuk-tag--red"; + var passwordTagCss = Model.DelegateInfo.IsPasswordSet ? "nhsuk-tag nhsuk-tag--green" : "nhsuk-tag nhsuk-tag--red"; } @*TODO: Search and sort functionality is part of HEEDLS-491. Filename includes 'Searchable' to avoid having to change name later*@ -
+
- - @Model.Name (@Model.CandidateNumber) + + @Model.DelegateInfo.Name (@Model.DelegateInfo.CandidateNumber) @@ -22,46 +22,56 @@ @(Model.ActiveTagName) @(Model.RegStatusTagName) @(Model.PasswordTagName) - @if (Model.IsAdmin) { + @if (Model.DelegateInfo.IsAdmin) { Admin }
-
Name
-
@Model.Name
+
+ Name +
+
-
Email
-
@Model.Email
+
+ Email +
+
-
ID
-
@Model.CandidateNumber
+
+ ID +
+
-
Registration date
-
@Model.RegistrationDate
+
+ Registration date +
+
-
Job group
-
@Model.JobGroup
+
+ Job group +
+
- @foreach (CustomFieldViewModel customField in Model.CustomFields) { + @foreach (CustomFieldViewModel customField in Model.DelegateInfo.CustomFields) {
@customField.CustomPrompt
-
@customField.Answer
+
}
- Manage delegate + Manage delegate Set password
diff --git a/DigitalLearningSolutions.Web/Views/TrackingSystem/Delegates/ViewDelegate/Index.cshtml b/DigitalLearningSolutions.Web/Views/TrackingSystem/Delegates/ViewDelegate/Index.cshtml new file mode 100644 index 0000000000..2b95a56776 --- /dev/null +++ b/DigitalLearningSolutions.Web/Views/TrackingSystem/Delegates/ViewDelegate/Index.cshtml @@ -0,0 +1,123 @@ +@inject IConfiguration Configuration +@using DigitalLearningSolutions.Web.ViewModels.Common +@using DigitalLearningSolutions.Web.ViewModels.TrackingSystem.Delegates +@using Microsoft.Extensions.Configuration +@model ViewDelegateViewModel + + + +@{ + ViewData["Title"] = "View delegate"; + ViewData["Application"] = "Tracking System"; + ViewData["HeaderPath"] = $"{Configuration["AppRootPath"]}/TrackingSystem/Centre/Dashboard"; + ViewData["HeaderPathName"] = "Tracking System"; + var activeTagCss = Model.DelegateInfo.IsActive ? "nhsuk-tag nhsuk-tag--green" : "nhsuk-tag nhsuk-tag--red"; + var passwordTagCss = Model.DelegateInfo.IsPasswordSet ? "nhsuk-tag nhsuk-tag--green" : "nhsuk-tag nhsuk-tag--red"; +} + +@section NavMenuItems { + +} + +@section NavBreadcrumbs { + +} + +
+
+

@Model.DelegateInfo.Name

+
+ @if (Model.DelegateInfo.IsActive) { + + } + +
+
+ @(Model.ActiveTagName) + @(Model.RegStatusTagName) + @(Model.PasswordTagName) + @if (Model.DelegateInfo.IsAdmin) { + Admin + } +
+ +

Details

+
+
+
+ Name +
+ +
+ +
+
+ Email +
+ +
+ +
+
+ ID +
+ +
+ +
+
+ Alias +
+ +
+ +
+
+ Registration date +
+ +
+ +
+
+ Job group +
+ +
+ + @foreach (CustomFieldViewModel customField in Model.DelegateInfo.CustomFields) { +
+
@customField.CustomPrompt
+ +
+ } +
+ + +
+