Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void SetUp()
[TestCase("Mark", new[] { 10, 200 })]
[TestCase("MJ1", new[] { 10 })]
[TestCase("J1", new[] { 10, 12 })]
[TestCase("Harper H14", new[] { 14, 144 })]
[TestCase("Harper", new[] { 14, 144 })]
[TestCase("lo", new[] { 200, 202 })]
public void DelegateUsers_should_be_filtered_on_name_and_candidateNumber_correctly(
string searchString,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
namespace DigitalLearningSolutions.Data.Models.DelegateGroups
{
using System;
using DigitalLearningSolutions.Data.Helpers;

public class GroupDelegate
public class GroupDelegate : BaseSearchableItem
{
public int GroupDelegateId { get; set; }

Expand All @@ -21,7 +22,11 @@ public class GroupDelegate
public DateTime AddedDate { get; set; }

public string? ProfessionalRegistrationNumber { get; set; }

public string Name => $"{FirstName} {LastName}";

public override string SearchableName
{
get => SearchableNameOverrideForFuzzySharp ?? NameQueryHelper.GetSortableFullName(FirstName, LastName);
set => SearchableNameOverrideForFuzzySharp = value;
}
}
}
4 changes: 3 additions & 1 deletion DigitalLearningSolutions.Data/Models/User/User.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
namespace DigitalLearningSolutions.Data.Models.User
{
using DigitalLearningSolutions.Data.Helpers;

public abstract class User : BaseSearchableItem
{
public int Id { get; set; }
Expand Down Expand Up @@ -28,7 +30,7 @@ public abstract class User : BaseSearchableItem

public override string SearchableName
{
get => SearchableNameOverrideForFuzzySharp ?? $"{FirstName} {LastName}";
get => SearchableNameOverrideForFuzzySharp ?? NameQueryHelper.GetSortableFullName(FirstName, LastName);
set => SearchableNameOverrideForFuzzySharp = value;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void Centre_administrators_should_default_to_returning_the_first_ten_admi
using (new AssertionScope())
{
model.Admins.Count().Should().Be(10);
model.Admins.FirstOrDefault(adminUser => adminUser.Name == "k Surname").Should().BeNull();
model.Admins.FirstOrDefault(adminUser => adminUser.Name == "Surname, k").Should().BeNull();
}
}

Expand All @@ -74,7 +74,7 @@ public void Centre_administrators_should_correctly_return_the_second_page_of_adm
using (new AssertionScope())
{
model.Admins.Count().Should().Be(5);
model.Admins.First().Name.Should().BeEquivalentTo("k Surname");
model.Admins.First().Name.Should().BeEquivalentTo("Surname, k");
}
}

Expand Down Expand Up @@ -141,7 +141,7 @@ public void Centre_administrators_with_custom_items_per_page_should_return_the_s
using (new AssertionScope())
{
model.Admins.Count().Should().Be(itemsPerPage);
model.Admins.FirstOrDefault(adminUser => adminUser.Name == "m Surname").Should().BeNull();
model.Admins.FirstOrDefault(adminUser => adminUser.Name == "Surname, m").Should().BeNull();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
{
using System.Linq;
using DigitalLearningSolutions.Data.Models.DelegateGroups;
using DigitalLearningSolutions.Data.Tests.NBuilderHelpers;
using DigitalLearningSolutions.Web.Models.Enums;
using DigitalLearningSolutions.Web.ViewModels.TrackingSystem.Delegates.GroupDelegates;
using DigitalLearningSolutions.Web.ViewModels.TrackingSystem.Delegates.Shared;
using FizzWare.NBuilder;
using FluentAssertions;
using FluentAssertions.Execution;
using NUnit.Framework;
Expand All @@ -16,17 +14,24 @@ public class GroupDelegatesViewModelTests
private readonly DelegateGroupsSideNavViewModel expectedNavViewModel =
new DelegateGroupsSideNavViewModel(1, "Group name", DelegateGroupPage.Delegates);

private GroupDelegate[] groupDelegates = null!;

[SetUp]
public void SetUp()
private readonly GroupDelegate[] groupDelegates =
{
groupDelegates = Builder<GroupDelegate>.CreateListOfSize(15)
.All()
.With(g => g.LastName = "Surname")
.With((g, i) => g.FirstName = NBuilderAlphabeticalPropertyNamingHelper.IndexToAlphabeticalString(i))
.Build().ToArray();
}
new GroupDelegate { FirstName = "A", LastName = "Surname" },
new GroupDelegate { FirstName = "B", LastName = "Surname" },
new GroupDelegate { FirstName = "C", LastName = "Surname" },
new GroupDelegate { FirstName = "D", LastName = "Surname" },
new GroupDelegate { FirstName = "E", LastName = "Surname" },
new GroupDelegate { FirstName = "F", LastName = "Surname" },
new GroupDelegate { FirstName = "G", LastName = "Surname" },
new GroupDelegate { FirstName = "H", LastName = "Surname" },
new GroupDelegate { FirstName = "I", LastName = "Surname" },
new GroupDelegate { FirstName = "J", LastName = "Surname" },
new GroupDelegate { FirstName = "K", LastName = "Surname" },
new GroupDelegate { FirstName = "L", LastName = "Surname" },
new GroupDelegate { FirstName = "M", LastName = "Surname" },
new GroupDelegate { FirstName = "N", LastName = "Surname" },
new GroupDelegate { FirstName = "O", LastName = "Surname" },
};

[Test]
public void GroupDelegatesViewModel_should_return_the_first_page_worth_of_delegates()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public IActionResult ConfirmDelegateAdded(int groupId, int delegateId)
var centreId = User.GetCentreId();
var groupName = groupsService.GetGroupName(groupId, centreId);

var model = new ConfirmDelegateAddedViewModel(delegateUser!.FullName, groupName!, groupId);
var model = new ConfirmDelegateAddedViewModel(delegateUser!, groupName!, groupId);
return View(model);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
using DigitalLearningSolutions.Data.Services;
using DigitalLearningSolutions.Web.Attributes;
using DigitalLearningSolutions.Web.Helpers;
using DigitalLearningSolutions.Web.ServiceFilter;
using DigitalLearningSolutions.Web.Models.Enums;
using DigitalLearningSolutions.Web.ServiceFilter;
using DigitalLearningSolutions.Web.ViewModels.TrackingSystem.Delegates.SetDelegatePassword;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
Expand Down Expand Up @@ -41,7 +41,7 @@ public IActionResult Index(int delegateId, bool isFromViewDelegatePage, int? ret
}

var model = new SetDelegatePasswordViewModel(
delegateUser.FullName,
DisplayStringHelper.GetNonSortableFullNameForDisplayOnly(delegateUser.FirstName, delegateUser.LastName),
delegateId,
returnPage,
isFromViewDelegatePage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public IActionResult SendWelcomeEmail(int delegateId)
{
var delegateUser = userDataService.GetDelegateUserCardById(delegateId)!;

string baseUrl = ConfigHelper.GetAppConfig().GetAppRootPath();
var baseUrl = ConfigHelper.GetAppConfig().GetAppRootPath();

passwordResetService.GenerateAndSendDelegateWelcomeEmail(
delegateUser.EmailAddress!,
Expand Down Expand Up @@ -102,7 +102,10 @@ public IActionResult ConfirmRemoveFromCourse(int delegateId, int customisationId
DelegateId = delegateUser!.Id,
CustomisationId = customisationId,
CourseName = course!.CourseName,
Name = delegateUser.FullName,
Name = DisplayStringHelper.GetNonSortableFullNameForDisplayOnly(
delegateUser.FirstName,
delegateUser.LastName
),
Confirm = false,
};
return View("ConfirmRemoveFromCourse", model);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
using DigitalLearningSolutions.Data.Models;
using DigitalLearningSolutions.Data.Models.User;
using DigitalLearningSolutions.Web.Helpers;
using DigitalLearningSolutions.Web.Models.Enums;

public class AdminRolesFormData
Expand All @@ -10,7 +11,7 @@ public AdminRolesFormData() { }

public AdminRolesFormData(User user)
{
FullName = user.FullName;
FullName = DisplayStringHelper.GetNonSortableFullNameForDisplayOnly(user.FirstName, user.LastName);
}

public string? FullName { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
{
using DigitalLearningSolutions.Data.Models.User;
using DigitalLearningSolutions.Web.Attributes;
using DigitalLearningSolutions.Web.Helpers;

public class DeactivateAdminViewModel
{
public DeactivateAdminViewModel() { }

public DeactivateAdminViewModel(AdminUser user, int? returnPage)
{
FullName = user.FullName;
FullName = DisplayStringHelper.GetNonSortableFullNameForDisplayOnly(user.FirstName, user.LastName);
EmailAddress = user.EmailAddress;
ReturnPage = returnPage;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using DigitalLearningSolutions.Data.Helpers;
using DigitalLearningSolutions.Data.Models.CustomPrompts;
using DigitalLearningSolutions.Data.Models.User;
using DigitalLearningSolutions.Web.Helpers;
using DigitalLearningSolutions.Web.ViewModels.Common;
using DigitalLearningSolutions.Web.ViewModels.TrackingSystem.Delegates.Shared;
using DateHelper = DigitalLearningSolutions.Web.Helpers.DateHelper;
Expand All @@ -16,7 +17,7 @@ bool isDelegateSelected
)
{
Id = delegateUser.Id;
Name = delegateUser.SearchableName;
Name = DisplayStringHelper.GetNonSortableFullNameForDisplayOnly(delegateUser.FirstName, delegateUser.LastName);
Email = delegateUser.EmailAddress;
if (delegateUser.DateRegistered.HasValue)
{
Expand All @@ -35,7 +36,7 @@ IEnumerable<CustomPrompt> promptsWithOptions
)
{
Id = delegateUser.Id;
Name = delegateUser.SearchableName;
Name = DisplayStringHelper.GetNonSortableFullNameForDisplayOnly(delegateUser.FirstName, delegateUser.LastName);
Email = delegateUser.EmailAddress;
if (delegateUser.DateRegistered.HasValue)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
namespace DigitalLearningSolutions.Web.ViewModels.TrackingSystem.Delegates.GroupDelegates
{
using DigitalLearningSolutions.Data.Models.User;
using DigitalLearningSolutions.Web.Helpers;

public class ConfirmDelegateAddedViewModel
{
public ConfirmDelegateAddedViewModel() { }

public ConfirmDelegateAddedViewModel(string delegateName, string groupName, int groupId)
public ConfirmDelegateAddedViewModel(DelegateUser delegateUser, string groupName, int groupId)
{
DelegateName = delegateName;
DelegateName = DisplayStringHelper.GetNonSortableFullNameForDisplayOnly(
delegateUser.FirstName,
delegateUser.LastName
);
GroupName = groupName;
GroupId = groupId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public GroupDelegateViewModel(GroupDelegate groupDelegate)
GroupDelegateId = groupDelegate.GroupDelegateId;
GroupId = groupDelegate.GroupId;
DelegateId = groupDelegate.DelegateId;
TitleName = groupDelegate.SearchableName;
Name = DisplayStringHelper.GetNonSortableFullNameForDisplayOnly(groupDelegate.FirstName, groupDelegate.LastName);
EmailAddress = groupDelegate.EmailAddress;
CandidateNumber = groupDelegate.CandidateNumber;
Expand All @@ -22,6 +23,8 @@ public GroupDelegateViewModel(GroupDelegate groupDelegate)

public int DelegateId { get; set; }

public string TitleName { get; set; }

public string Name { get; set; }

public string? EmailAddress { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
using System.Collections.Generic;
using System.Linq;
using DigitalLearningSolutions.Data.Helpers;
using DigitalLearningSolutions.Data.Models.DelegateGroups;
using DigitalLearningSolutions.Web.Models.Enums;
using DigitalLearningSolutions.Web.ViewModels.Common.SearchablePage;
Expand All @@ -19,7 +20,11 @@ int page
GroupId = groupId;
NavViewModel = new DelegateGroupsSideNavViewModel(groupId, groupName, DelegateGroupPage.Delegates);

var sortedItems = groupDelegates.OrderBy(gd => gd.Name).ToList();
var sortedItems = GenericSortingHelper.SortAllItems(
groupDelegates.AsQueryable(),
nameof(GroupDelegate.SearchableName),
GenericSortingHelper.Ascending
).ToList();

MatchingSearchResults = sortedItems.Count;
SetTotalPages();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
namespace DigitalLearningSolutions.Web.ViewModels.TrackingSystem.Delegates.Shared
{
using System.Collections.Generic;
using System.Linq;
using DigitalLearningSolutions.Data.Enums;
using DigitalLearningSolutions.Data.Models.User;
using DigitalLearningSolutions.Web.Helpers;
Expand All @@ -12,7 +11,11 @@ public class DelegateInfoViewModel
public DelegateInfoViewModel(DelegateUserCard delegateUser, IEnumerable<CustomFieldViewModel> customFields)
{
Id = delegateUser.Id;
Name = delegateUser.SearchableName;
TitleName = delegateUser.SearchableName;
Name = DisplayStringHelper.GetNonSortableFullNameForDisplayOnly(
delegateUser.FirstName,
delegateUser.LastName
);
CandidateNumber = delegateUser.CandidateNumber;

IsActive = delegateUser.Active;
Expand All @@ -35,6 +38,7 @@ public DelegateInfoViewModel(DelegateUserCard delegateUser, IEnumerable<CustomFi
}

public int Id { get; set; }
public string TitleName { get; set; }
public string Name { get; set; }
public string CandidateNumber { get; set; }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace DigitalLearningSolutions.Web.ViewModels.TrackingSystem.Delegates.ViewDelegate
{
using DigitalLearningSolutions.Data.Models.User;
using DigitalLearningSolutions.Web.Helpers;

public class WelcomeEmailSentViewModel
{
Expand All @@ -9,7 +10,7 @@ public WelcomeEmailSentViewModel() { }
public WelcomeEmailSentViewModel(DelegateUserCard delegateUser)
{
Id = delegateUser.Id;
Name = delegateUser.SearchableName;
Name = DisplayStringHelper.GetNonSortableFullNameForDisplayOnly(delegateUser.FirstName, delegateUser.LastName);
CandidateNumber = delegateUser.CandidateNumber;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<details class="nhsuk-details nhsuk-expander">
<summary class="nhsuk-details__summary">
<span class="nhsuk-details__summary-text" id="@Model.DelegateInfo.Id-name">
<span class="searchable-element-title" name="name">@Model.DelegateInfo.Name</span> <span class="searchable-element-candidate-number">(@Model.DelegateInfo.CandidateNumber)</span>
<span class="searchable-element-title" name="name">@Model.DelegateInfo.TitleName</span> <span class="searchable-element-candidate-number">(@Model.DelegateInfo.CandidateNumber)</span>
</span>
</summary>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<div class="nhsuk-grid-column-full">
<div class="nhsuk-grid-row">
<div class="nhsuk-grid-column-full">
<h1 id="page-heading" class="nhsuk-heading-xl nhsuk-u-margin-bottom-8">@ViewData["Title"]</h1>
<h1 id="page-heading" class="nhsuk-heading-xl nhsuk-u-margin-bottom-8 word-break">@ViewData["Title"]</h1>
</div>
</div>
<input id="selected-group-Id" type="hidden" asp-for="@Model.GroupId" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<details class="nhsuk-details nhsuk-expander">
<summary class="nhsuk-details__summary">
<span class="nhsuk-details__summary-text" id="@Model.DelegateInfo.Id-name">
<span class="searchable-element-title" name="name">@Model.DelegateInfo.Name</span>@emailString
<span class="searchable-element-title" name="name">@Model.DelegateInfo.TitleName</span>@emailString
</span>
</summary>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<details class="nhsuk-details nhsuk-expander">
<summary class="nhsuk-details__summary">
<span class="nhsuk-details__summary-text" id="@Model.GroupDelegateId-name" name="name">
@Model.Name
@Model.TitleName
</span>
</summary>
<div class="nhsuk-details__text">
Expand Down