From e3bbd2dfd64b4b3c543a492788b8c82f127be46c Mon Sep 17 00:00:00 2001 From: Oluwatobi Awe Date: Thu, 13 Oct 2022 06:39:38 +0100 Subject: [PATCH 1/2] Framework Contributor and Reviewer Error Display --- .../FrameworksController/Frameworks.cs | 33 ++++++++++++++----- .../Frameworks/Developer/Collaborators.cshtml | 16 ++++++--- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/DigitalLearningSolutions.Web/Controllers/FrameworksController/Frameworks.cs b/DigitalLearningSolutions.Web/Controllers/FrameworksController/Frameworks.cs index 12d37c4902..47b82deb4e 100644 --- a/DigitalLearningSolutions.Web/Controllers/FrameworksController/Frameworks.cs +++ b/DigitalLearningSolutions.Web/Controllers/FrameworksController/Frameworks.cs @@ -183,7 +183,7 @@ public IActionResult CreateNewFramework(DetailFramework detailFramework, string } if (actionname == "New") { - if(TempData[MultiPageFormDataFeature.AddNewFramework.TempDataKey] == null) + if (TempData[MultiPageFormDataFeature.AddNewFramework.TempDataKey] == null) { return StatusCode((int)HttpStatusCode.NotFound); } @@ -279,7 +279,7 @@ public IActionResult FrameworkDescription(string actionname, int frameworkId = 0 DetailFramework? framework; if (actionname == "New") { - if(TempData[MultiPageFormDataFeature.AddNewFramework.TempDataKey] == null) + if (TempData[MultiPageFormDataFeature.AddNewFramework.TempDataKey] == null) { return StatusCode((int)HttpStatusCode.NotFound); } @@ -317,7 +317,7 @@ public IActionResult FrameworkDescription(DetailFramework detailFramework, strin { if (actionname == "New") { - if(TempData[MultiPageFormDataFeature.AddNewFramework.TempDataKey] == null) + if (TempData[MultiPageFormDataFeature.AddNewFramework.TempDataKey] == null) { return StatusCode((int)HttpStatusCode.NotFound); } @@ -585,7 +585,7 @@ public IActionResult EditFrameworkFlags(int frameworkId, bool error = false) public IActionResult RemoveFrameworkFlag(int flagId, int frameworkId) { var flag = frameworkService.GetCustomFlagsByFrameworkId(frameworkId, flagId).FirstOrDefault(); - if(flag == null) + if (flag == null) { return StatusCode((int)HttpStatusCode.NotFound); } @@ -624,7 +624,7 @@ public IActionResult EditFrameworkFlag(CustomFlagViewModel model, int frameworkI } return RedirectToAction("EditFrameworkFlags", "Frameworks", new { frameworkId }); } - return View("Developer/EditCustomFlag", model); + return View("Developer/EditCustomFlag", model); } [HttpGet] @@ -647,7 +647,7 @@ public IActionResult EditFrameworkFlag(int frameworkId, string actionname, int f } [Route("/Frameworks/Collaborators/{actionname}/{frameworkId}/")] - public IActionResult AddCollaborators(string actionname, int frameworkId, bool error = false) + public IActionResult AddCollaborators(string actionname, int frameworkId) { var adminId = GetAdminId(); var collaborators = frameworkService.GetCollaboratorsForFrameworkId(frameworkId); @@ -659,7 +659,7 @@ public IActionResult AddCollaborators(string actionname, int frameworkId, bool e { BaseFramework = framework, Collaborators = collaborators, - Error = error, + Error = false, }; return View("Developer/Collaborators", model); } @@ -676,7 +676,24 @@ public IActionResult AddCollaborator(string actionname, string userEmail, bool c } else { - return RedirectToAction("AddCollaborators", "Frameworks", new { frameworkId, actionname, error = true }); + if (collaboratorId == -3) + { + TempData["FrameworkError"] = "Email address should not be empty"; + + } + else if (collaboratorId == -2) + { + TempData["FrameworkError"] = $"User with the email address {userEmail} has been previously added"; + } + else if (collaboratorId == -4) + { + TempData["FrameworkError"] = $"The email address {userEmail} must match registered DLS Admin account"; + } + else + { + TempData["FrameworkError"] = "User not added,Kindly try again;"; + } + return RedirectToAction("AddCollaborators", "Frameworks", new { frameworkId, actionname }); } } diff --git a/DigitalLearningSolutions.Web/Views/Frameworks/Developer/Collaborators.cshtml b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/Collaborators.cshtml index 75b6ceb185..e9063f4491 100644 --- a/DigitalLearningSolutions.Web/Views/Frameworks/Developer/Collaborators.cshtml +++ b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/Collaborators.cshtml @@ -1,8 +1,10 @@ @using DigitalLearningSolutions.Web.ViewModels.Frameworks @model CollaboratorsViewModel @{ - ViewData["Title"] = "Framework Collaborators"; - ViewData["Application"] = "Framework Service"; + ViewData["Title"] = "Framework Collaborators"; + ViewData["Application"] = "Framework Service"; + string errMsg = TempData["FrameworkError"]?.ToString(); + if (!string.IsNullOrWhiteSpace(errMsg)) { Model.Error = true; } } @section NavMenuItems { @@ -57,6 +59,12 @@ else @if ((string)ViewContext.RouteData.Values["actionname"] == "New") {

Your framework has been created. Use this page to identify individuals who will be working on it with you.

+} +@if (Model.Error) +{ + + Error: @errMsg + }

Working Group Members

@@ -120,14 +128,14 @@ else - +
Provide the email address of a user with a registered DLS admin account to add as a Contributor (to help create your framework) or Reviewer (to sign off your framework). Working group members can be added and removed later.
@if(Model.Error) { - Error: The email address must match a registered DLS admin account. + Error: @errMsg } From ead459b628486c536721f89d62d2681702d2ca37 Mon Sep 17 00:00:00 2001 From: Oluwatobi Awe Date: Thu, 13 Oct 2022 07:41:01 +0100 Subject: [PATCH 2/2] accessibility fix --- .../Views/Frameworks/Developer/Collaborators.cshtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DigitalLearningSolutions.Web/Views/Frameworks/Developer/Collaborators.cshtml b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/Collaborators.cshtml index 656341cda3..b41d1e3c69 100644 --- a/DigitalLearningSolutions.Web/Views/Frameworks/Developer/Collaborators.cshtml +++ b/DigitalLearningSolutions.Web/Views/Frameworks/Developer/Collaborators.cshtml @@ -126,7 +126,7 @@ else
-