Skip to content

Commit e80d7ac

Browse files
committed
Merge branch 'DLS-Release-v1.2.3' into UAT
2 parents 2a5c06d + 8757b67 commit e80d7ac

File tree

6 files changed

+83
-28
lines changed

6 files changed

+83
-28
lines changed

DigitalLearningSolutions.Web/Helpers/CompetencyFilterHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public static IEnumerable<Competency> FilterCompetencies(IEnumerable<Competency>
3030
return filteredCompetencies;
3131
}
3232

33-
public static void ApplyResponseStatusFilters(ref IEnumerable<Competency> competencies, IEnumerable<int> filters, string searchText = "")
33+
private static void ApplyResponseStatusFilters(ref IEnumerable<Competency> competencies, IEnumerable<int> filters, string searchText = "")
3434
{
3535
var appliedResponseStatusFilters = filters.Where(IsResponseStatusFilter).ToList();
3636

DigitalLearningSolutions.Web/Helpers/SupervisorCompetencyFilterHelper.cs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public static IEnumerable<Competency> FilterCompetencies(IEnumerable<Competency>
1717
var searchText = search.SearchText?.Trim() ?? string.Empty;
1818
var filters = search.AppliedFilters?.Select(f => int.Parse(f.FilterValue)) ?? Enumerable.Empty<int>();
1919
search.CompetencyFlags = competencyFlags.ToList();
20-
CompetencyFilterHelper.ApplyResponseStatusFilters(ref filteredCompetencies, filters, searchText);
20+
ApplyResponseStatusFilters(ref filteredCompetencies, filters, searchText);
2121
UpdateRequirementsFilterDropdownOptionsVisibility(search, filteredCompetencies);
2222
ApplyRequirementsFilters(ref filteredCompetencies, filters);
2323

@@ -28,6 +28,39 @@ public static IEnumerable<Competency> FilterCompetencies(IEnumerable<Competency>
2828
}
2929
return filteredCompetencies;
3030
}
31+
private static void ApplyResponseStatusFilters(ref IEnumerable<Competency> competencies, IEnumerable<int> filters, string searchText = "")
32+
{
33+
var appliedFilters = filters.Where(f => IsResponseStatusFilter(f)).ToList();
34+
var wordsInSearchText = searchText.Split(' ', StringSplitOptions.RemoveEmptyEntries);
35+
36+
if (!appliedFilters.Any() && string.IsNullOrWhiteSpace(searchText))
37+
return;
38+
39+
competencies = competencies.Where(c =>
40+
{
41+
// Search text match
42+
bool searchTextMatches = !wordsInSearchText.Any() ||
43+
wordsInSearchText.All(w =>
44+
(c.CompetencyGroup?.Contains(w, StringComparison.CurrentCultureIgnoreCase) ?? false) ||
45+
(c.Description?.Contains(w, StringComparison.CurrentCultureIgnoreCase) ?? false) ||
46+
(c.Name?.Contains(w, StringComparison.CurrentCultureIgnoreCase) ?? false)
47+
);
48+
49+
// All filters must match (AND)
50+
bool allFiltersMatch = appliedFilters.All(f =>
51+
(f == (int)SelfAssessmentCompetencyFilter.Verified && c.AssessmentQuestions.Any(q => q.Verified.HasValue && q.SignedOff == true)) ||
52+
(f == (int)SelfAssessmentCompetencyFilter.Optional && c.Optional) ||
53+
(f == (int)SelfAssessmentCompetencyFilter.ConfirmationRejected && c.AssessmentQuestions.Any(q => q.Verified.HasValue && q.SignedOff != true)) ||
54+
(f == (int)SelfAssessmentCompetencyFilter.PendingConfirmation && c.AssessmentQuestions.Any(q => q.ResultId != null && q.Verified == null && q.Requested != null && q.UserIsVerifier == false)) ||
55+
(f == (int)SelfAssessmentCompetencyFilter.AwaitingConfirmation && c.AssessmentQuestions.Any(q => q.Verified == null && q.Requested != null && q.UserIsVerifier == true)) ||
56+
(f == (int)SelfAssessmentCompetencyFilter.RequiresSelfAssessment && c.AssessmentQuestions.Any(q => q.ResultId == null)) ||
57+
(f == (int)SelfAssessmentCompetencyFilter.SelfAssessed && c.AssessmentQuestions.Any(q => q.ResultId != null && q.Requested == null && q.SignedOff == null))
58+
);
59+
60+
return searchTextMatches && allFiltersMatch;
61+
}).ToList();
62+
}
63+
3164
private static void ApplyRequirementsFilters(ref IEnumerable<Competency> competencies, IEnumerable<int> filters)
3265
{
3366
var filteredCompetencies = competencies;

DigitalLearningSolutions.Web/Views/MyAccount/EditDetails.cshtml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,15 @@
3232
nameof(Model.Answer5),
3333
nameof(Model.Answer6),
3434
};
35-
35+
var professionalRegistrationNumberError = ViewData.ModelState["ProfessionalRegistrationNumber"]?.Errors.FirstOrDefault();
36+
if (professionalRegistrationNumberError == null)
37+
{
3638
<vc:error-summary order-of-property-names="@orderOfPropertyNames" />
39+
}
40+
if (professionalRegistrationNumberError != null)
41+
{
42+
<partial name="_ProfessionalRegistrationNumberError" model=@(professionalRegistrationNumberError.ErrorMessage) />
43+
}
3744
}
3845

3946
<h1 class="nhsuk-heading-xl" id="app-page-heading">Edit details</h1>

DigitalLearningSolutions.Web/Views/Register/LearnerInformation.cshtml

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,28 @@
1111
<div class="nhsuk-grid-row">
1212
<div class="nhsuk-grid-column-full">
1313
@if (errorHasOccurred)
14-
{
15-
<vc:error-summary order-of-property-names="@(new[] {
16-
nameof(Model.JobGroup),
17-
nameof(Model.HasProfessionalRegistrationNumber),
18-
nameof(Model.ProfessionalRegistrationNumber),
19-
nameof(Model.Answer1),
20-
nameof(Model.Answer2),
21-
nameof(Model.Answer3),
22-
nameof(Model.Answer4),
23-
nameof(Model.Answer5),
24-
nameof(Model.Answer6) })" />
25-
}
14+
{
15+
16+
var professionalRegistrationNumberError = ViewData.ModelState["ProfessionalRegistrationNumber"]?.Errors.FirstOrDefault();
17+
if (professionalRegistrationNumberError == null)
18+
{
19+
<vc:error-summary order-of-property-names="@(new[] {
20+
nameof(Model.JobGroup),
21+
nameof(Model.HasProfessionalRegistrationNumber),
22+
nameof(Model.ProfessionalRegistrationNumber),
23+
nameof(Model.Answer1),
24+
nameof(Model.Answer2),
25+
nameof(Model.Answer3),
26+
nameof(Model.Answer4),
27+
nameof(Model.Answer5),
28+
nameof(Model.Answer6) })" />
29+
}
30+
if (professionalRegistrationNumberError != null)
31+
{
32+
<partial name="_ProfessionalRegistrationNumberError" model=@(professionalRegistrationNumberError.ErrorMessage) />
33+
34+
}
35+
}
2636

2737
<h1 class="nhsuk-heading-xl">Learner information</h1>
2838

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
@model string
2+
@{
3+
4+
}
5+
<div class="nhsuk-error-summary" aria-labelledby="error-summary-title" role="alert" tabindex="-1">
6+
<h2 class="nhsuk-error-summary__title" id="error-summary-title">
7+
There is a problem
8+
</h2>
9+
<div class="nhsuk-error-summary__body">
10+
<span class="nhsuk-error-message" id="ProfessionalRegistrationNumber-error">
11+
<span class="nhsuk-u-visually-hidden">Error:</span> <span class="nhsuk-error-message" id="ProfessionalRegistrationNumber-error">
12+
<span class="nhsuk-u-visually-hidden">Error:</span>
13+
@Html.Raw(Model)
14+
</span>
15+
</span>
16+
</div>
17+
</div>

DigitalLearningSolutions.Web/Views/TrackingSystem/Delegates/EditDelegate/Index.cshtml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,7 @@
3434
}
3535
if (professionalRegistrationNumberError != null)
3636
{
37-
<div class="nhsuk-error-summary" aria-labelledby="error-summary-title" role="alert" tabindex="-1">
38-
<h2 class="nhsuk-error-summary__title" id="error-summary-title">
39-
There is a problem
40-
</h2>
41-
<div class="nhsuk-error-summary__body">
42-
<span class="nhsuk-error-message" id="ProfessionalRegistrationNumber-error">
43-
<span class="nhsuk-u-visually-hidden">Error:</span> <span class="nhsuk-error-message" id="ProfessionalRegistrationNumber-error">
44-
<span class="nhsuk-u-visually-hidden">Error:</span>
45-
@Html.Raw(professionalRegistrationNumberError.ErrorMessage)
46-
</span>
47-
</span>
48-
</div>
49-
</div>
37+
<partial name="_ProfessionalRegistrationNumberError" model=@(professionalRegistrationNumberError.ErrorMessage) />
5038
}
5139
}
5240

0 commit comments

Comments
 (0)