Skip to content

Commit 96776cf

Browse files
authored
Merge pull request #3295 from TechnologyEnhancedLearning/Develop/Fix/TD-5657-Review-Comment-validation
TD-5657-Issue when submitting the review on frameworks section
2 parents 61c9136 + a2a5da9 commit 96776cf

File tree

2 files changed

+67
-45
lines changed

2 files changed

+67
-45
lines changed

DigitalLearningSolutions.Web/Controllers/FrameworksController/Review.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,24 @@ public IActionResult SubmitFrameworkReview(int frameworkId, int reviewId, string
8585
var framework = frameworkService.GetBaseFrameworkByFrameworkId(frameworkId, adminId);
8686
if (framework.FrameworkReviewID == 0 || framework.FrameworkReviewID == null) return RedirectToAction("StatusCode", "LearningSolutions", new { code = 410 });
8787
int? commentId = null;
88-
if (!string.IsNullOrWhiteSpace(comment)) commentId = frameworkService.InsertComment(frameworkId, adminId, comment, null);
88+
if (string.IsNullOrWhiteSpace(comment))
89+
{
90+
ModelState.AddModelError("comment", "Please enter comment");
91+
var frameworkReview = frameworkService.GetFrameworkReview(frameworkId, adminId, reviewId);
92+
frameworkReview.SignedOff = signedOff;
93+
var model = new SubmitReviewViewModel()
94+
{
95+
FrameworkId = frameworkId,
96+
FrameworkName = framework.FrameworkName,
97+
FrameworkReview = frameworkReview
98+
};
99+
return View("Developer/SubmitReview", model);
100+
}
101+
else
102+
{
103+
commentId = frameworkService.InsertComment(frameworkId, adminId, comment, null);
104+
}
105+
89106
frameworkService.SubmitFrameworkReview(frameworkId, reviewId, signedOff, commentId);
90107
frameworkNotificationService.SendReviewOutcomeNotification(reviewId, User.GetCentreIdKnownNotNull());
91108
return RedirectToAction("ViewFramework", "Frameworks", new { frameworkId, tabname = "Structure" });
Lines changed: 49 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,60 @@
11
@using DigitalLearningSolutions.Web.ViewModels.Frameworks;
22
@model SubmitReviewViewModel;
33
@{
4-
ViewData["Title"] = Model.FrameworkName;
5-
ViewData["Application"] = "Framework Service";
6-
ViewData["HeaderPathName"] = "Framework Service";
4+
ViewData["Title"] = Model.FrameworkName;
5+
ViewData["Application"] = "Framework Service";
6+
ViewData["HeaderPathName"] = "Framework Service";
7+
var errorHasOccurred = !ViewData.ModelState.IsValid;
78
}
89
@section NavBreadcrumbs {
9-
<nav class="nhsuk-breadcrumb" aria-label="Breadcrumb">
10-
<div class="nhsuk-width-container">
11-
<ol class="nhsuk-breadcrumb__list">
12-
<li class="nhsuk-breadcrumb__item"><a class="nhsuk-breadcrumb__link trigger-loader" asp-action="ViewFrameworks" asp-route-tabname="Mine">Frameworks</a></li>
13-
<li class="nhsuk-breadcrumb__item"><a class="nhsuk-breadcrumb__link trigger-loader" asp-action="ViewFramework" asp-route-frameworkId="@Model.FrameworkId" asp-route-tabname="Structure">Framework Structure</a></li>
14-
<li class="nhsuk-breadcrumb__item">Send for Review</li>
15-
</ol>
16-
<p class="nhsuk-breadcrumb__back"><a class="nhsuk-breadcrumb__backlink" asp-action="ViewFramework" asp-route-frameworkId="@Model.FrameworkId" asp-route-tabname="Structure">Back to framework structure</a></p>
17-
</div>
18-
</nav>
10+
<nav class="nhsuk-breadcrumb" aria-label="Breadcrumb">
11+
<div class="nhsuk-width-container">
12+
<ol class="nhsuk-breadcrumb__list">
13+
<li class="nhsuk-breadcrumb__item"><a class="nhsuk-breadcrumb__link trigger-loader" asp-action="ViewFrameworks" asp-route-tabname="Mine">Frameworks</a></li>
14+
<li class="nhsuk-breadcrumb__item"><a class="nhsuk-breadcrumb__link trigger-loader" asp-action="ViewFramework" asp-route-frameworkId="@Model.FrameworkId" asp-route-tabname="Structure">Framework Structure</a></li>
15+
<li class="nhsuk-breadcrumb__item">Send for Review</li>
16+
</ol>
17+
<p class="nhsuk-breadcrumb__back"><a class="nhsuk-breadcrumb__backlink" asp-action="ViewFramework" asp-route-frameworkId="@Model.FrameworkId" asp-route-tabname="Structure">Back to framework structure</a></p>
18+
</div>
19+
</nav>
1920
}
20-
<h1>Submit review</h1>
21-
@if (Model.FrameworkReview.SignOffRequired)
21+
<h1>Submit review</h1>
22+
@if (Model.FrameworkReview.SignOffRequired)
2223
{
23-
<div class="nhsuk-warning-callout">
24-
<h2 class="nhsuk-warning-callout__label">
25-
<span role="text">
26-
<span class="nhsuk-u-visually-hidden">Important: </span>
27-
Approval required
28-
</span>
29-
</h2>
30-
<p>Your approval is required before this framework can be published.</p>
31-
</div>
24+
<div class="nhsuk-warning-callout">
25+
<h2 class="nhsuk-warning-callout__label">
26+
<span role="text">
27+
<span class="nhsuk-u-visually-hidden">Important: </span>
28+
Approval required
29+
</span>
30+
</h2>
31+
<p>Your approval is required before this framework can be published.</p>
32+
</div>
3233
}
3334
<form method="post">
34-
<div class="nhsuk-form-group">
35-
<label class="nhsuk-label" for="new-comment">
36-
Review comments
37-
</label>
38-
<input type="hidden" value="@Model.FrameworkReview.Comment" name="parentComment" />
39-
<textarea class="nhsuk-textarea" id="new-comment" asp-for="FrameworkReview.Comment" name="Comment" rows="3"></textarea>
40-
</div>
41-
<div class="nhsuk-form-group">
42-
<div class="nhsuk-checkboxes__item">
43-
<input class="nhsuk-checkboxes__input" id="signOff" name="SignedOff" asp-for="FrameworkReview.SignedOff" type="checkbox" aria-describedby="sign-off-hint">
44-
<label class="nhsuk-label nhsuk-checkboxes__label" for="signOff">
45-
Approve for publishing?
46-
</label>
47-
<div class="nhsuk-hint nhsuk-checkboxes__hint" id="sign-off-hint">
48-
I give my approval to publish this framework for use in its current state
49-
</div>
35+
@if (errorHasOccurred)
36+
{
37+
<vc:error-summary order-of-property-names="@(new[] { nameof(Model.FrameworkReview.Comment)})" />
38+
}
39+
<div class="nhsuk-form-group">
40+
<label class="nhsuk-label" for="comment">
41+
Review comments
42+
</label>
43+
<input type="hidden" value="@Model.FrameworkReview.Comment" name="parentComment" />
44+
<textarea class="nhsuk-textarea" id="comment" asp-for="FrameworkReview.Comment" name="Comment" rows="3"></textarea>
45+
</div>
46+
<div class="nhsuk-form-group">
47+
<div class="nhsuk-checkboxes__item">
48+
<input class="nhsuk-checkboxes__input" id="signOff" name="SignedOff" asp-for="FrameworkReview.SignedOff" type="checkbox" aria-describedby="sign-off-hint">
49+
<label class="nhsuk-label nhsuk-checkboxes__label" for="signOff">
50+
Approve for publishing?
51+
</label>
52+
<div class="nhsuk-hint nhsuk-checkboxes__hint" id="sign-off-hint">
53+
I give my approval to publish this framework for use in its current state
54+
</div>
55+
</div>
5056
</div>
51-
</div>
52-
<button class="nhsuk-button" type="submit">
53-
Submit
54-
</button>
57+
<button class="nhsuk-button" type="submit">
58+
Submit
59+
</button>
5560
</form>

0 commit comments

Comments
 (0)