From 3eb687d08b700ae13e141a0e091440ac0faa3939 Mon Sep 17 00:00:00 2001
From: kevwhitt-hee
Date: Mon, 12 Sep 2022 09:31:10 +0100
Subject: [PATCH 01/12] DLSV2-548 Adds required to text-input vc model
Populates aria-required attribute as true or false accordingly and appends "(optional)" to labels if not already present.
---
.../ViewComponents/TextInputViewComponent.cs | 7 +++++--
.../Common/ViewComponents/TextInputViewModel.cs | 7 +++++--
.../Views/ChangePassword/Index.cshtml | 9 ++++++---
.../Views/Login/Index.cshtml | 6 ++++--
.../Views/MyAccount/EditDetails.cshtml | 15 ++++++++++-----
.../Views/Register/LearnerInformation.cshtml | 3 ++-
.../Views/Register/Password.cshtml | 6 ++++--
.../Views/Register/PersonalInformation.cshtml | 9 ++++++---
.../Views/RegisterAdmin/Password.cshtml | 6 ++++--
.../RegisterAdmin/PersonalInformation.cshtml | 9 ++++++---
.../LearnerInformation.cshtml | 3 ++-
.../RegisterDelegateByCentre/Password.cshtml | 3 ++-
.../PersonalInformation.cshtml | 12 ++++++++----
.../Views/ResetPassword/Index.cshtml | 6 ++++--
.../Views/SetPassword/Index.cshtml | 6 ++++--
.../Shared/Components/TextInput/Default.cshtml | 5 +++--
.../Views/Shared/_EditRegistrationNumber.cshtml | 3 ++-
.../Views/Supervisor/MyStaffList.cshtml | 3 ++-
.../Centre/Configuration/EditCentreDetails.cshtml | 6 ++++--
.../Configuration/EditCentreManagerDetails.cshtml | 12 ++++++++----
.../Configuration/EditCentreWebsiteDetails.cshtml | 15 ++++++++++-----
.../AddRegistrationPromptConfigureAnswers.cshtml | 3 ++-
.../EditRegistrationPrompt.cshtml | 3 ++-
.../CourseSetup/AdminFields/AddAdminField.cshtml | 3 ++-
.../CourseSetup/AdminFields/EditAdminField.cshtml | 3 ++-
.../CourseSetup/Shared/_EditCourseName.cshtml | 3 ++-
.../Shared/_EditCoursePasswordAndEmail.cshtml | 6 ++++--
.../DelegateGroups/AddDelegateGroup.cshtml | 3 ++-
.../Delegates/DelegateGroups/EditGroupName.cshtml | 3 ++-
.../EditDelegateCourseAdminField.cshtml | 3 ++-
.../Delegates/EditDelegate/Index.cshtml | 15 ++++++++++-----
.../Delegates/SetDelegatePassword/Index.cshtml | 3 ++-
32 files changed, 133 insertions(+), 66 deletions(-)
diff --git a/DigitalLearningSolutions.Web/ViewComponents/TextInputViewComponent.cs b/DigitalLearningSolutions.Web/ViewComponents/TextInputViewComponent.cs
index 29738bcdab..b767f54680 100644
--- a/DigitalLearningSolutions.Web/ViewComponents/TextInputViewComponent.cs
+++ b/DigitalLearningSolutions.Web/ViewComponents/TextInputViewComponent.cs
@@ -17,6 +17,7 @@ public class TextInputViewComponent : ViewComponent
/// Leave blank for no hint.
/// Leave blank to set no autocomplete on the input element.
///
+ ///
///
public IViewComponentResult Invoke(
string aspFor,
@@ -26,7 +27,8 @@ public IViewComponentResult Invoke(
bool spellCheck,
string hintText,
string autocomplete,
- string cssClass
+ string cssClass,
+ bool required
)
{
var model = ViewData.Model;
@@ -47,7 +49,8 @@ string cssClass
string.IsNullOrEmpty(autocomplete) ? null : autocomplete,
errorMessages,
string.IsNullOrEmpty(cssClass) ? null : cssClass,
- string.IsNullOrEmpty(hintText) ? null : hintText
+ string.IsNullOrEmpty(hintText) ? null : hintText,
+ required
);
return View(textBoxViewModel);
}
diff --git a/DigitalLearningSolutions.Web/ViewModels/Common/ViewComponents/TextInputViewModel.cs b/DigitalLearningSolutions.Web/ViewModels/Common/ViewComponents/TextInputViewModel.cs
index 72c97aefff..c293aa1942 100644
--- a/DigitalLearningSolutions.Web/ViewModels/Common/ViewComponents/TextInputViewModel.cs
+++ b/DigitalLearningSolutions.Web/ViewModels/Common/ViewComponents/TextInputViewModel.cs
@@ -15,7 +15,8 @@ public TextInputViewModel(
string? autocomplete,
IEnumerable errorMessages,
string? cssClass = null,
- string? hintText = null
+ string? hintText = null,
+ bool required = false
)
{
var errorMessageList = errorMessages.ToList();
@@ -23,12 +24,13 @@ public TextInputViewModel(
Id = id;
Class = cssClass;
Name = name;
- Label = label;
+ Label = (!required && !label.EndsWith("(optional)") ? label + " (optional)" : label);
Value = value;
Type = type;
SpellCheck = spellCheck;
Autocomplete = autocomplete;
HintText = hintText;
+ Required = required;
ErrorMessages = errorMessageList;
HasError = errorMessageList.Any();
}
@@ -42,6 +44,7 @@ public TextInputViewModel(
public bool SpellCheck { get; set; }
public string? Autocomplete { get; set; }
public string? HintText { get; set; }
+ public bool Required { get; set; }
public IEnumerable ErrorMessages { get; set; }
public readonly bool HasError;
}
diff --git a/DigitalLearningSolutions.Web/Views/ChangePassword/Index.cshtml b/DigitalLearningSolutions.Web/Views/ChangePassword/Index.cshtml
index 427ebca147..0f7884fa6d 100644
--- a/DigitalLearningSolutions.Web/Views/ChangePassword/Index.cshtml
+++ b/DigitalLearningSolutions.Web/Views/ChangePassword/Index.cshtml
@@ -29,7 +29,8 @@
spell-check="false"
hint-text=""
autocomplete="current-password"
- css-class="nhsuk-u-width-one-half" />
+ css-class="nhsuk-u-width-one-half"
+ required="true" />
+ css-class="nhsuk-u-width-one-half"
+ required="true" />
+ css-class="nhsuk-u-width-one-half"
+ required="true" />
diff --git a/DigitalLearningSolutions.Web/Views/Login/Index.cshtml b/DigitalLearningSolutions.Web/Views/Login/Index.cshtml
index 5be566fef0..31d14de10b 100644
--- a/DigitalLearningSolutions.Web/Views/Login/Index.cshtml
+++ b/DigitalLearningSolutions.Web/Views/Login/Index.cshtml
@@ -28,7 +28,8 @@
spell-check="false"
hint-text=""
autocomplete="username"
- css-class="nhsuk-u-width-one-half" />
+ css-class="nhsuk-u-width-one-half"
+ required="true" />
+ css-class="nhsuk-u-width-one-half"
+ required="true" />
diff --git a/DigitalLearningSolutions.Web/Views/MyAccount/EditDetails.cshtml b/DigitalLearningSolutions.Web/Views/MyAccount/EditDetails.cshtml
index 8e2d306212..275f818e2d 100644
--- a/DigitalLearningSolutions.Web/Views/MyAccount/EditDetails.cshtml
+++ b/DigitalLearningSolutions.Web/Views/MyAccount/EditDetails.cshtml
@@ -51,7 +51,8 @@
spell-check="false"
autocomplete="given-name"
hint-text=""
- css-class="nhsuk-u-width-one-half" />
+ css-class="nhsuk-u-width-one-half"
+ required="true"/>
+ css-class="nhsuk-u-width-one-half"
+ required="true" />
+ css-class="nhsuk-u-width-one-half"
+ required="true" />
@if (Model.IsDelegateUser) {
@@ -113,7 +116,8 @@
spell-check="false"
autocomplete=""
hint-text=""
- css-class="nhsuk-u-width-one-half" />
+ css-class="nhsuk-u-width-one-half"
+ required="@customField.Mandatory" />
}
}
@@ -158,7 +162,8 @@
spell-check="false"
autocomplete=""
hint-text=""
- css-class="nhsuk-u-width-one-half" />
+ css-class="nhsuk-u-width-one-half"
+ required="true"/>
diff --git a/DigitalLearningSolutions.Web/Views/Register/LearnerInformation.cshtml b/DigitalLearningSolutions.Web/Views/Register/LearnerInformation.cshtml
index a54c4e4868..cdc342e695 100644
--- a/DigitalLearningSolutions.Web/Views/Register/LearnerInformation.cshtml
+++ b/DigitalLearningSolutions.Web/Views/Register/LearnerInformation.cshtml
@@ -56,7 +56,8 @@
spell-check="false"
hint-text=""
autocomplete=""
- css-class="nhsuk-u-width-one-half" />
+ css-class="nhsuk-u-width-one-half"
+ required="@customField.Mandatory" />
}
}
diff --git a/DigitalLearningSolutions.Web/Views/Register/Password.cshtml b/DigitalLearningSolutions.Web/Views/Register/Password.cshtml
index 41c9d2be4f..c19876e260 100644
--- a/DigitalLearningSolutions.Web/Views/Register/Password.cshtml
+++ b/DigitalLearningSolutions.Web/Views/Register/Password.cshtml
@@ -23,7 +23,8 @@
spell-check="false"
autocomplete="new-password"
hint-text="Your new password should have a minimum of 8 characters with at least 1 letter, 1 number and 1 symbol."
- css-class="nhsuk-u-width-one-half" />
+ css-class="nhsuk-u-width-one-half"
+ required="true" />
+ css-class="nhsuk-u-width-one-half"
+ required="true" />
Back
diff --git a/DigitalLearningSolutions.Web/Views/Register/PersonalInformation.cshtml b/DigitalLearningSolutions.Web/Views/Register/PersonalInformation.cshtml
index 315bcc223b..dc6d086c3e 100644
--- a/DigitalLearningSolutions.Web/Views/Register/PersonalInformation.cshtml
+++ b/DigitalLearningSolutions.Web/Views/Register/PersonalInformation.cshtml
@@ -61,7 +61,8 @@
spell-check="false"
hint-text=""
autocomplete="given-name"
- css-class="nhsuk-u-width-one-half" />
+ css-class="nhsuk-u-width-one-half"
+ required="true"/>
+ css-class="nhsuk-u-width-one-half"
+ required="true" />
+ css-class="nhsuk-u-width-one-half"
+ required="true" />
diff --git a/DigitalLearningSolutions.Web/Views/RegisterAdmin/Password.cshtml b/DigitalLearningSolutions.Web/Views/RegisterAdmin/Password.cshtml
index 130eaaa776..c394f3a566 100644
--- a/DigitalLearningSolutions.Web/Views/RegisterAdmin/Password.cshtml
+++ b/DigitalLearningSolutions.Web/Views/RegisterAdmin/Password.cshtml
@@ -23,7 +23,8 @@
spell-check="false"
autocomplete="new-password"
hint-text="Your new password should have a minimum of 8 characters with at least 1 letter, 1 number and 1 symbol."
- css-class="nhsuk-u-width-one-half" />
+ css-class="nhsuk-u-width-one-half"
+ required="true"/>
+ css-class="nhsuk-u-width-one-half"
+ required="true" />
Back
diff --git a/DigitalLearningSolutions.Web/Views/RegisterAdmin/PersonalInformation.cshtml b/DigitalLearningSolutions.Web/Views/RegisterAdmin/PersonalInformation.cshtml
index 81a980d286..239f198c42 100644
--- a/DigitalLearningSolutions.Web/Views/RegisterAdmin/PersonalInformation.cshtml
+++ b/DigitalLearningSolutions.Web/Views/RegisterAdmin/PersonalInformation.cshtml
@@ -31,7 +31,8 @@
spell-check="false"
hint-text=""
autocomplete="given-name"
- css-class="nhsuk-u-width-one-half" />
+ css-class="nhsuk-u-width-one-half"
+ required="true" />
+ css-class="nhsuk-u-width-one-half"
+ required="true" />
+ css-class="nhsuk-u-width-one-half"
+ required="true" />
diff --git a/DigitalLearningSolutions.Web/Views/RegisterDelegateByCentre/LearnerInformation.cshtml b/DigitalLearningSolutions.Web/Views/RegisterDelegateByCentre/LearnerInformation.cshtml
index b4ec861aee..fe7bcb3294 100644
--- a/DigitalLearningSolutions.Web/Views/RegisterDelegateByCentre/LearnerInformation.cshtml
+++ b/DigitalLearningSolutions.Web/Views/RegisterDelegateByCentre/LearnerInformation.cshtml
@@ -59,7 +59,8 @@
spell-check="false"
hint-text=""
autocomplete=""
- css-class="nhsuk-u-width-one-half" />
+ css-class="nhsuk-u-width-one-half"
+ required="@customField.Mandatory" />
}
}
diff --git a/DigitalLearningSolutions.Web/Views/RegisterDelegateByCentre/Password.cshtml b/DigitalLearningSolutions.Web/Views/RegisterDelegateByCentre/Password.cshtml
index 605ba9160d..7b89b8f83a 100644
--- a/DigitalLearningSolutions.Web/Views/RegisterDelegateByCentre/Password.cshtml
+++ b/DigitalLearningSolutions.Web/Views/RegisterDelegateByCentre/Password.cshtml
@@ -34,7 +34,8 @@
spell-check="false"
autocomplete=""
hint-text="Password should have a minimum of 8 characters with at least 1 letter, 1 number and 1 symbol."
- css-class="nhsuk-u-width-one-half" />
+ css-class="nhsuk-u-width-one-half"
+ required="false" />
Back
diff --git a/DigitalLearningSolutions.Web/Views/RegisterDelegateByCentre/PersonalInformation.cshtml b/DigitalLearningSolutions.Web/Views/RegisterDelegateByCentre/PersonalInformation.cshtml
index af696d84ae..8a34d1cf10 100644
--- a/DigitalLearningSolutions.Web/Views/RegisterDelegateByCentre/PersonalInformation.cshtml
+++ b/DigitalLearningSolutions.Web/Views/RegisterDelegateByCentre/PersonalInformation.cshtml
@@ -35,7 +35,8 @@
spell-check="false"
hint-text=""
autocomplete="given-name"
- css-class="nhsuk-u-width-one-half" />
+ css-class="nhsuk-u-width-one-half"
+ required="true" />
+ css-class="nhsuk-u-width-one-half"
+ required="true" />
+ css-class="nhsuk-u-width-one-half"
+ required="true" />
+ css-class="nhsuk-u-width-one-half"
+ required="false"/>
diff --git a/DigitalLearningSolutions.Web/Views/ResetPassword/Index.cshtml b/DigitalLearningSolutions.Web/Views/ResetPassword/Index.cshtml
index 055fe4130c..29ad530909 100644
--- a/DigitalLearningSolutions.Web/Views/ResetPassword/Index.cshtml
+++ b/DigitalLearningSolutions.Web/Views/ResetPassword/Index.cshtml
@@ -33,7 +33,8 @@
spell-check="false"
hint-text="Your new password should have a minimum of 8 characters with at least 1 letter, 1 number and 1 symbol."
autocomplete="new-password"
- css-class="nhsuk-u-width-one-half" />
+ css-class="nhsuk-u-width-one-half"
+ required="true" />
+ css-class="nhsuk-u-width-one-half"
+ required="true" />
diff --git a/DigitalLearningSolutions.Web/Views/SetPassword/Index.cshtml b/DigitalLearningSolutions.Web/Views/SetPassword/Index.cshtml
index 76b3e4ab3c..4652cc5fd5 100644
--- a/DigitalLearningSolutions.Web/Views/SetPassword/Index.cshtml
+++ b/DigitalLearningSolutions.Web/Views/SetPassword/Index.cshtml
@@ -33,7 +33,8 @@
spell-check="false"
hint-text="Your new password should have a minimum of 8 characters with at least 1 letter, 1 number and 1 symbol."
autocomplete="new-password"
- css-class="nhsuk-u-width-one-half" />
+ css-class="nhsuk-u-width-one-half"
+ required="true" />
+ css-class="nhsuk-u-width-one-half"
+ required="true"/>
diff --git a/DigitalLearningSolutions.Web/Views/Shared/Components/TextInput/Default.cshtml b/DigitalLearningSolutions.Web/Views/Shared/Components/TextInput/Default.cshtml
index 5aeca9c0ea..6ab537d313 100644
--- a/DigitalLearningSolutions.Web/Views/Shared/Components/TextInput/Default.cshtml
+++ b/DigitalLearningSolutions.Web/Views/Shared/Components/TextInput/Default.cshtml
@@ -40,6 +40,7 @@
type="@Model.Type"
spellcheck="@Model.SpellCheck"
autocomplete="@Model.Autocomplete"
- aria-invalid="@(Model.HasError ? "true" : null)"
- aria-describedby="@(describedBy!= "" ? @describedBy : null)" />
+ aria-invalid="@(Model.HasError ? "true" : null )"
+ aria-describedby="@(describedBy!= "" ? @describedBy : null)"
+ aria-required="@(Model.Required ? "true" : "false" )" />
diff --git a/DigitalLearningSolutions.Web/Views/Shared/_EditRegistrationNumber.cshtml b/DigitalLearningSolutions.Web/Views/Shared/_EditRegistrationNumber.cshtml
index 576819e38a..dafa8a2298 100644
--- a/DigitalLearningSolutions.Web/Views/Shared/_EditRegistrationNumber.cshtml
+++ b/DigitalLearningSolutions.Web/Views/Shared/_EditRegistrationNumber.cshtml
@@ -74,7 +74,8 @@
spell-check="false"
hint-text=""
autocomplete="off"
- css-class="nhsuk-u-width-one-half" />
+ css-class="nhsuk-u-width-one-half"
+ required="true" />
diff --git a/DigitalLearningSolutions.Web/Views/Supervisor/MyStaffList.cshtml b/DigitalLearningSolutions.Web/Views/Supervisor/MyStaffList.cshtml
index 90701a07ab..9f2f07833b 100644
--- a/DigitalLearningSolutions.Web/Views/Supervisor/MyStaffList.cshtml
+++ b/DigitalLearningSolutions.Web/Views/Supervisor/MyStaffList.cshtml
@@ -86,7 +86,8 @@
spell-check="false"
hint-text="Provide the work email address of a member of staff to add to your supervision list."
autocomplete="email"
- css-class="nhsuk-input" />
+ css-class="nhsuk-input"
+ required="true" />
diff --git a/DigitalLearningSolutions.Web/Views/Frameworks/Developer/SubmitReview.cshtml b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/SubmitReview.cshtml
index 35a2b4d583..230d2f1cd2 100644
--- a/DigitalLearningSolutions.Web/Views/Frameworks/Developer/SubmitReview.cshtml
+++ b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/SubmitReview.cshtml
@@ -34,7 +34,7 @@
-
+
diff --git a/DigitalLearningSolutions.Web/Views/Frameworks/Shared/_CommentCard.cshtml b/DigitalLearningSolutions.Web/Views/Frameworks/Shared/_CommentCard.cshtml
index d0c4b80e6c..ee1a35c678 100644
--- a/DigitalLearningSolutions.Web/Views/Frameworks/Shared/_CommentCard.cshtml
+++ b/DigitalLearningSolutions.Web/Views/Frameworks/Shared/_CommentCard.cshtml
@@ -74,7 +74,7 @@
-
+
diff --git a/DigitalLearningSolutions.Web/Views/LearningContent/Index.cshtml b/DigitalLearningSolutions.Web/Views/LearningContent/Index.cshtml
index cfcccc8215..0abd45fd43 100644
--- a/DigitalLearningSolutions.Web/Views/LearningContent/Index.cshtml
+++ b/DigitalLearningSolutions.Web/Views/LearningContent/Index.cshtml
@@ -57,7 +57,7 @@
}
-
+
@if (Model.JavascriptSearchSortFilterPaginateEnabled) {
@section scripts {
diff --git a/DigitalLearningSolutions.Web/Views/LearningPortal/Current/MarkActionPlanResourceAsComplete.cshtml b/DigitalLearningSolutions.Web/Views/LearningPortal/Current/MarkActionPlanResourceAsComplete.cshtml
index 5103ffbf06..ad9e5657ca 100644
--- a/DigitalLearningSolutions.Web/Views/LearningPortal/Current/MarkActionPlanResourceAsComplete.cshtml
+++ b/DigitalLearningSolutions.Web/Views/LearningPortal/Current/MarkActionPlanResourceAsComplete.cshtml
@@ -30,10 +30,10 @@
}