-
Notifications
You must be signed in to change notification settings - Fork 1
HEEDLS-490 All delegates - display delegate cards #464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ibrahimmunir14
merged 23 commits into
master
from
HEEDLS-490-all-delegates-display-cards
Jul 7, 2021
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
9417bb4
HEEDLS-490 Create AllDelegates controller with CentreAdmin policy; cr…
ibrahimmunir14 34711fe
HEEDLS-490 Link to AllDelegates from nav bar, nav sidebar and centre …
ibrahimmunir14 9384f41
HEEDLS-490 Add register/email/upload/download buttons and style
ibrahimmunir14 e5155cc
HEEDLS-490 Create AllDelegates and SearchableDelegate view models
ibrahimmunir14 0beed4d
HEEDLS-490 Create SearchableDelegateCard view; update Index to displa…
ibrahimmunir14 e7231bd
HEEDLS-490 Update controller to fetch and display delegate cards
ibrahimmunir14 6d7adec
HEEDLS-490 Create DelegateUserCard subclass; update dataservice metho…
ibrahimmunir14 8b29325
HEEDLS-490 Add SelfReg/Active/Admin/PasswordSet tags to DelegateCard
ibrahimmunir14 f2bcd95
HEEDLS-490 Add Name/Id/Email/RegDate/JobGroup to DelegateCard
ibrahimmunir14 4338e46
HEEDLS-490 Add buttons at bottom of DelegateCard
ibrahimmunir14 01829f9
HEEDLS-490 Add custom prompt fields to DelegateCard
ibrahimmunir14 ed2214f
HEEDLS-490 Fix bug with admin tag; change tag colour and ordering
ibrahimmunir14 3e40f39
HEEDLS-490 Use styled links instead of buttons; update sass; remove r…
ibrahimmunir14 3234e80
HEEDLS-490 Change tag colours, HeaderPath, and other minor changes
ibrahimmunir14 11fc107
HEEDLS-490 Move tag name logic into viewmodel; test
ibrahimmunir14 7dd943a
HEEDLS-490 Perform DelegateUserCard to SearchableDelegateViewModels m…
ibrahimmunir14 e522ddb
HEEDLS-490 Minor refactor and add comments in SearchableDelegateViewM…
ibrahimmunir14 c159ea1
HEEDLS-490 Write tests for GetDelegateUserCardsByCentreId; add AllDel…
ibrahimmunir14 ee1292a
HEEDLS-490 Inline reg status/admin tag css strings
ibrahimmunir14 2f846f2
HEEDLS-490 Fix SearchableDelegateViewModel date test
ibrahimmunir14 afba14c
HEEDLS-490 Rename test for clarity
ibrahimmunir14 f67b40a
Merge branch 'master' into HEEDLS-490-all-delegates-display-cards
ibrahimmunir14 1c483ae
HEEDLS-490 Display date string in en-gb format
ibrahimmunir14 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
DigitalLearningSolutions.Data/Models/User/DelegateUserCard.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| namespace DigitalLearningSolutions.Data.Models.User | ||
| { | ||
| public class DelegateUserCard : DelegateUser | ||
| { | ||
| public bool SelfReg { get; set; } | ||
| public bool ExternalReg { get; set; } | ||
| public bool Active { get; set; } | ||
| public int? AdminId { get; set; } | ||
| } | ||
| } |
113 changes: 57 additions & 56 deletions
113
DigitalLearningSolutions.Web.AutomatedUiTests/AccessibilityTests/BasicAccessibilityTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,56 +1,57 @@ | ||
| namespace DigitalLearningSolutions.Web.AutomatedUiTests.AccessibilityTests | ||
| { | ||
| using DigitalLearningSolutions.Web.AutomatedUiTests.TestHelpers; | ||
| using Xunit; | ||
|
|
||
| public class BasicAccessibilityTests : AccessibilityTestsBase | ||
| { | ||
| public BasicAccessibilityTests(SeleniumServerFactory<Startup> factory) : base(factory) { } | ||
|
|
||
| [Theory] | ||
| [InlineData("/Home/Welcome", "Welcome - Digital Learning Solutions")] | ||
| [InlineData("/Home/Products", "Products - Digital Learning Solutions")] | ||
| [InlineData("/Home/LearningContent", "Learning Content - Digital Learning Solutions")] | ||
| [InlineData("/Login", "Log in")] | ||
| [InlineData("/ForgotPassword", "Reset your password")] | ||
| [InlineData("/ResetPassword/Error", "Something went wrong...")] | ||
| public void Page_has_no_accessibility_errors(string url, string pageTitle) | ||
| { | ||
| // when | ||
| Driver.Navigate().GoToUrl(BaseUrl + url); | ||
|
|
||
| // then | ||
| AnalyzePageHeadingAndAccessibility(pageTitle); | ||
| } | ||
|
|
||
| [Theory] | ||
| [InlineData("/MyAccount", "My account")] | ||
| [InlineData("/MyAccount/EditDetails", "Edit details")] | ||
| [InlineData("/TrackingSystem/Centre/Administrators", "Centre administrators")] | ||
| [InlineData("/TrackingSystem/Centre/Dashboard", "Centre dashboard")] | ||
| [InlineData("/TrackingSystem/Centre/Ranking", "Centre ranking")] | ||
| [InlineData("/TrackingSystem/Centre/ContractDetails", "Contract details")] | ||
| [InlineData("/TrackingSystem/CentreConfiguration", "Centre configuration")] | ||
| [InlineData("/TrackingSystem/CentreConfiguration/EditCentreManagerDetails", "Edit centre manager details")] | ||
| [InlineData("/TrackingSystem/CentreConfiguration/EditCentreWebsiteDetails", "Edit centre content on DLS website")] | ||
| [InlineData("/TrackingSystem/CentreConfiguration/RegistrationPrompts", "Manage delegate registration prompts")] | ||
| [InlineData("/TrackingSystem/CentreConfiguration/RegistrationPrompts/1/Remove", "Remove delegate registration prompt")] | ||
| [InlineData("/TrackingSystem/Centre/Reports", "Centre reports")] | ||
| [InlineData("/TrackingSystem/Centre/TopCourses", "Top courses")] | ||
| [InlineData("/TrackingSystem/Delegates/Approve", "Approve delegate registrations")] | ||
| [InlineData("/NotificationPreferences", "Notification preferences")] | ||
| [InlineData("/NotificationPreferences/Edit/AdminUser", "Update notification preferences")] | ||
| [InlineData("/NotificationPreferences/Edit/DelegateUser", "Update notification preferences")] | ||
| [InlineData("/ChangePassword", "Change password")] | ||
| [InlineData("/TrackingSystem/Support", "Support")] | ||
| public void Authenticated_page_has_no_accessibility_errors(string url, string pageTitle) | ||
| { | ||
| // when | ||
| Driver.LogUserInAsAdminAndDelegate(BaseUrl); | ||
| Driver.Navigate().GoToUrl(BaseUrl + url); | ||
|
|
||
| // then | ||
| AnalyzePageHeadingAndAccessibility(pageTitle); | ||
| } | ||
| } | ||
| } | ||
| namespace DigitalLearningSolutions.Web.AutomatedUiTests.AccessibilityTests | ||
| { | ||
| using DigitalLearningSolutions.Web.AutomatedUiTests.TestHelpers; | ||
| using Xunit; | ||
|
|
||
| public class BasicAccessibilityTests : AccessibilityTestsBase | ||
| { | ||
| public BasicAccessibilityTests(SeleniumServerFactory<Startup> factory) : base(factory) { } | ||
|
|
||
| [Theory] | ||
| [InlineData("/Home/Welcome", "Welcome - Digital Learning Solutions")] | ||
| [InlineData("/Home/Products", "Products - Digital Learning Solutions")] | ||
| [InlineData("/Home/LearningContent", "Learning Content - Digital Learning Solutions")] | ||
| [InlineData("/Login", "Log in")] | ||
| [InlineData("/ForgotPassword", "Reset your password")] | ||
| [InlineData("/ResetPassword/Error", "Something went wrong...")] | ||
| public void Page_has_no_accessibility_errors(string url, string pageTitle) | ||
| { | ||
| // when | ||
| Driver.Navigate().GoToUrl(BaseUrl + url); | ||
|
|
||
| // then | ||
| AnalyzePageHeadingAndAccessibility(pageTitle); | ||
| } | ||
|
|
||
| [Theory] | ||
| [InlineData("/MyAccount", "My account")] | ||
| [InlineData("/MyAccount/EditDetails", "Edit details")] | ||
| [InlineData("/TrackingSystem/Centre/Administrators", "Centre administrators")] | ||
| [InlineData("/TrackingSystem/Centre/Dashboard", "Centre dashboard")] | ||
| [InlineData("/TrackingSystem/Centre/Ranking", "Centre ranking")] | ||
| [InlineData("/TrackingSystem/Centre/ContractDetails", "Contract details")] | ||
| [InlineData("/TrackingSystem/CentreConfiguration", "Centre configuration")] | ||
| [InlineData("/TrackingSystem/CentreConfiguration/EditCentreManagerDetails", "Edit centre manager details")] | ||
| [InlineData("/TrackingSystem/CentreConfiguration/EditCentreWebsiteDetails", "Edit centre content on DLS website")] | ||
| [InlineData("/TrackingSystem/CentreConfiguration/RegistrationPrompts", "Manage delegate registration prompts")] | ||
| [InlineData("/TrackingSystem/CentreConfiguration/RegistrationPrompts/1/Remove", "Remove delegate registration prompt")] | ||
| [InlineData("/TrackingSystem/Centre/Reports", "Centre reports")] | ||
| [InlineData("/TrackingSystem/Delegates/All", "Delegates")] | ||
| [InlineData("/TrackingSystem/Centre/TopCourses", "Top courses")] | ||
| [InlineData("/TrackingSystem/Delegates/Approve", "Approve delegate registrations")] | ||
| [InlineData("/NotificationPreferences", "Notification preferences")] | ||
| [InlineData("/NotificationPreferences/Edit/AdminUser", "Update notification preferences")] | ||
| [InlineData("/NotificationPreferences/Edit/DelegateUser", "Update notification preferences")] | ||
| [InlineData("/ChangePassword", "Change password")] | ||
| [InlineData("/TrackingSystem/Support", "Support")] | ||
| public void Authenticated_page_has_no_accessibility_errors(string url, string pageTitle) | ||
| { | ||
| // when | ||
| Driver.LogUserInAsAdminAndDelegate(BaseUrl); | ||
| Driver.Navigate().GoToUrl(BaseUrl + url); | ||
|
|
||
| // then | ||
| AnalyzePageHeadingAndAccessibility(pageTitle); | ||
| } | ||
| } | ||
| } |
80 changes: 80 additions & 0 deletions
80
...ests/ViewModels/TrackingSystem/Delegates/AllDelegates/SearchableDelegateViewModelTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| 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 SearchableDelegateViewModelTests | ||
| { | ||
| private readonly List<CustomFieldViewModel> customFields = new List<CustomFieldViewModel>(); | ||
|
|
||
| [Test] | ||
| public void SearchableDelegateViewModel_sets_active_tag_name_correctly() | ||
| { | ||
| // Given | ||
| var activeUser = new DelegateUserCard { Active = true }; | ||
| var inactiveUser = new DelegateUserCard { Active = false }; | ||
|
|
||
| // When | ||
| var activeModel = new SearchableDelegateViewModel(activeUser, customFields); | ||
| var inactiveModel = new SearchableDelegateViewModel(inactiveUser, customFields); | ||
|
|
||
| // Then | ||
| activeModel.ActiveTagName.Should().Be("Active"); | ||
| inactiveModel.ActiveTagName.Should().Be("Inactive"); | ||
| } | ||
|
|
||
| [Test] | ||
| public void SearchableDelegateViewModel_sets_password_tag_name_correctly() | ||
| { | ||
| // Given | ||
| var pwSetUser = new DelegateUserCard { Password = "pw" }; | ||
| var pwNotSetUser = new DelegateUserCard { Password = null }; | ||
|
|
||
| // When | ||
| var pwSetModel = new SearchableDelegateViewModel(pwSetUser, customFields); | ||
| var pwNotSetModel = new SearchableDelegateViewModel(pwNotSetUser, customFields); | ||
|
|
||
| // Then | ||
| pwSetModel.PasswordTagName.Should().Be("Password set"); | ||
| pwNotSetModel.PasswordTagName.Should().Be("Password not set"); | ||
| } | ||
|
|
||
| [Test] | ||
| public void SearchableDelegateViewModel_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 SearchableDelegateViewModel(selfRegUser, customFields); | ||
| var selfRegExternalModel = new SearchableDelegateViewModel(selfRegExternalUser, customFields); | ||
| var centreRegModel = new SearchableDelegateViewModel(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"); | ||
| } | ||
| } | ||
| } |
39 changes: 39 additions & 0 deletions
39
DigitalLearningSolutions.Web/Controllers/TrackingSystem/Delegates/AllDelegatesController.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| namespace DigitalLearningSolutions.Web.Controllers.TrackingSystem.Delegates | ||
| { | ||
| using System.Linq; | ||
| using DigitalLearningSolutions.Data.DataServices; | ||
| using DigitalLearningSolutions.Web.Helpers; | ||
| using DigitalLearningSolutions.Web.ViewModels.TrackingSystem.Delegates; | ||
| using Microsoft.AspNetCore.Authorization; | ||
| using Microsoft.AspNetCore.Mvc; | ||
|
|
||
| [Authorize(Policy = CustomPolicies.UserCentreAdmin)] | ||
| [Route("TrackingSystem/Delegates/All")] | ||
| public class AllDelegatesController : Controller | ||
| { | ||
| private readonly CustomPromptHelper customPromptHelper; | ||
| private readonly IUserDataService userDataService; | ||
|
|
||
| public AllDelegatesController(IUserDataService userDataService, CustomPromptHelper customPromptHelper) | ||
| { | ||
| this.userDataService = userDataService; | ||
| this.customPromptHelper = customPromptHelper; | ||
| } | ||
|
|
||
| public IActionResult Index() | ||
| { | ||
| var centreId = User.GetCentreId(); | ||
| var delegateUsers = userDataService.GetDelegateUserCardsByCentreId(centreId).Take(10); | ||
| var searchableDelegateViewModels = delegateUsers.Select( | ||
| delegateUser => | ||
| { | ||
| var customFields = customPromptHelper.GetCustomFieldViewModelsForCentre(centreId, delegateUser); | ||
| return new SearchableDelegateViewModel(delegateUser, customFields); | ||
| } | ||
| ); | ||
| var model = new AllDelegatesViewModel(centreId, searchableDelegateViewModels); | ||
|
|
||
| return View(model); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
DigitalLearningSolutions.Web/Styles/trackingSystem/allDelegates.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| @import "~nhsuk-frontend/packages/core/all"; | ||
stellake marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| .all-delegates-button-group { | ||
| text-align: right; | ||
|
|
||
| @media (max-width: 1024px) { | ||
| width: 100%; | ||
| text-align: unset; | ||
| margin-bottom: nhsuk-spacing(4); | ||
| } | ||
| } | ||
|
|
||
| .all-delegates-button { | ||
| padding-top: nhsuk-spacing(2); | ||
| padding-bottom: nhsuk-spacing(2); | ||
|
|
||
| @media (max-width: 1024px) { | ||
| margin-top: nhsuk-spacing(1); | ||
| margin-bottom: nhsuk-spacing(1); | ||
| } | ||
|
|
||
| @media (max-width: 425px) { | ||
| width: calc(50% - 4px); | ||
| } | ||
|
|
||
| @media (max-width: 375px) { | ||
| width: 100%; | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.