-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #992 from DFE-Digital/feature/156275-withdrawn-dec…
…ision-option withdrawn status for conversions
- Loading branch information
Showing
12 changed files
with
285 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,6 @@ public enum AdvisoryBoardDecisions | |
{ | ||
Approved = 0, | ||
Declined = 1, | ||
Deferred = 2 | ||
Deferred = 2, | ||
Withdrawn = 3 | ||
} |
14 changes: 14 additions & 0 deletions
14
.../Dfe.PrepareConversions.Data/Models/AdvisoryBoardDecision/AdvisoryBoardWithdrawnReason.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System.ComponentModel; | ||
|
||
namespace Dfe.PrepareConversions.Data.Models.AdvisoryBoardDecision; | ||
|
||
public enum AdvisoryBoardWithdrawnReason | ||
{ | ||
[Description("Additional information needed")] | ||
AdditionalInformationNeeded = 0, | ||
|
||
[Description("Awaiting next ofsted report")] | ||
AwaitingNextOfstedReport = 1, | ||
[Description("Performance concerns")] PerformanceConcerns = 2, | ||
[Description("Other")] Other = 3 | ||
} |
17 changes: 17 additions & 0 deletions
17
...epareConversions.Data/Models/AdvisoryBoardDecision/AdvisoryBoardWithdrawnReasonDetails.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace Dfe.PrepareConversions.Data.Models.AdvisoryBoardDecision; | ||
|
||
public class AdvisoryBoardWithdrawnReasonDetails | ||
{ | ||
public AdvisoryBoardWithdrawnReasonDetails() | ||
{ | ||
} | ||
|
||
public AdvisoryBoardWithdrawnReasonDetails(AdvisoryBoardWithdrawnReason reason, string details) | ||
{ | ||
Reason = reason; | ||
Details = details; | ||
} | ||
|
||
public AdvisoryBoardWithdrawnReason Reason { get; set; } | ||
public string Details { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/Decision/WhyWithdrawn.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
@page "/task-list/{id:int}/decision/why-withdrawn" | ||
@using Dfe.PrepareConversions.Data.Models.AdvisoryBoardDecision | ||
@using Dfe.Academisation.ExtensionMethods | ||
@using Dfe.PrepareConversions.Extensions | ||
@model Dfe.PrepareConversions.Pages.TaskList.Decision.WhyWithdrawnModel | ||
@{ | ||
ViewData["Title"] = $"Why project was {Model.DecisionText}"; | ||
Layout = "_Layout"; | ||
} | ||
|
||
@section BeforeMain | ||
{ | ||
<partial name="_BackLink" model="@Model.BackLinkModel"/> | ||
<partial name="_ErrorSummary"/> | ||
} | ||
|
||
<span id="selection-span" class="govuk-caption-l">@Model.SchoolName</span> | ||
<h1 class="govuk-heading-l">Why was this project withdrawn?</h1> | ||
|
||
<form method="post"> | ||
<div class="govuk-form-group"> | ||
<fieldset class="govuk-fieldset"> | ||
<legend class="govuk-fieldset__legend govuk-fieldset__legend--l"> | ||
</legend> | ||
<div class="govuk-checkboxes @ModelState.GetErrorStyleClass()" data-module="govuk-checkboxes" id="WasReasonGiven"> | ||
|
||
<input type="hidden" asp-for="@Model.WasReasonGiven"/> | ||
|
||
@{ | ||
CheckBoxAndLabel(AdvisoryBoardWithdrawnReason.AdditionalInformationNeeded, Model.AdditionalInformationNeededIsChecked, Model.AdditionalInformationNeededDetails); | ||
CheckBoxAndLabel(AdvisoryBoardWithdrawnReason.AwaitingNextOfstedReport, Model.AwaitingNextOfstedReportIsChecked, Model.AwaitingNextOfstedReportDetails); | ||
CheckBoxAndLabel(AdvisoryBoardWithdrawnReason.PerformanceConcerns, Model.PerformanceConcernsIsChecked, Model.PerformanceConcernsDetails); | ||
CheckBoxAndLabel(AdvisoryBoardWithdrawnReason.Other, Model.OtherIsChecked, Model.OtherDetails); | ||
} | ||
</div> | ||
</fieldset> | ||
</div> | ||
|
||
<button class="govuk-button" data-module="govuk-button" id="submit-btn"> | ||
Continue | ||
</button> | ||
</form> | ||
|
||
@{ | ||
void CheckBoxAndLabel(AdvisoryBoardWithdrawnReason withdrawnReason, bool isChecked, string details) | ||
{ | ||
<div class="govuk-checkboxes__item" id="@(withdrawnReason)Details"> | ||
<input class="govuk-checkboxes__input" id="@withdrawnReason.ToString().ToLower()-checkbox" name="@(withdrawnReason)IsChecked" type="checkbox" | ||
data-aria-controls="conditional-@withdrawnReason" value="true" @(isChecked ? "checked" : "")> | ||
<label class="govuk-label govuk-checkboxes__label" for="@withdrawnReason.ToString().ToLower()-checkbox"> | ||
@withdrawnReason.ToDescription() | ||
</label> | ||
</div> | ||
<div class="govuk-checkboxes__conditional govuk-checkboxes__conditional--hidden" id="conditional-@withdrawnReason"> | ||
<div class="govuk-form-group"> | ||
<label class="govuk-label" for="@withdrawnReason.ToString().ToLower()-txtarea"> | ||
Give reasons | ||
</label> | ||
<textarea class="govuk-textarea govuk-!-width-three-quarters" id="@withdrawnReason.ToString().ToLower()-txtarea" | ||
name="@(withdrawnReason)Details" rows="5" aria-describedby="more-detail-hint">@details</textarea> | ||
</div> | ||
|
||
</div> | ||
} | ||
} |
108 changes: 108 additions & 0 deletions
108
Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/Decision/WhyWithdrawn.cshtml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
using Dfe.Academisation.ExtensionMethods; | ||
using Dfe.PrepareConversions.Data.Models.AdvisoryBoardDecision; | ||
using Dfe.PrepareConversions.Data.Services; | ||
using Dfe.PrepareConversions.Extensions; | ||
using Dfe.PrepareConversions.Models; | ||
using Dfe.PrepareConversions.Pages.TaskList.Decision.Models; | ||
using Dfe.PrepareConversions.Services; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
using System.Collections.Generic; | ||
|
||
namespace Dfe.PrepareConversions.Pages.TaskList.Decision; | ||
|
||
public class WhyWithdrawnModel : DecisionBaseModel | ||
{ | ||
private readonly ErrorService _errorService; | ||
|
||
public WhyWithdrawnModel(IAcademyConversionProjectRepository repository, | ||
ISession session, | ||
ErrorService errorService | ||
) | ||
: base(repository, session) | ||
{ | ||
_errorService = errorService; | ||
} | ||
|
||
[BindProperty] | ||
public string AdditionalInformationNeededDetails { get; set; } | ||
|
||
[BindProperty] | ||
public bool AdditionalInformationNeededIsChecked { get; set; } | ||
|
||
[BindProperty] | ||
public string AwaitingNextOfstedReportDetails { get; set; } | ||
|
||
[BindProperty] | ||
public bool AwaitingNextOfstedReportIsChecked { get; set; } | ||
|
||
[BindProperty] | ||
public string PerformanceConcernsDetails { get; set; } | ||
|
||
[BindProperty] | ||
public bool PerformanceConcernsIsChecked { get; set; } | ||
|
||
[BindProperty] | ||
public string OtherDetails { get; set; } | ||
|
||
[BindProperty] | ||
public bool OtherIsChecked { get; set; } | ||
|
||
[BindProperty] | ||
public bool WasReasonGiven => AdditionalInformationNeededIsChecked || AwaitingNextOfstedReportIsChecked || PerformanceConcernsIsChecked || OtherIsChecked; | ||
|
||
public string DecisionText { get; set; } | ||
|
||
public IActionResult OnGet(int id) | ||
{ | ||
SetBackLinkModel(Links.Decision.WhoDecided, id); | ||
|
||
AdvisoryBoardDecision decision = GetDecisionFromSession(id); | ||
DecisionText = decision.Decision.ToDescription().ToLowerInvariant(); | ||
|
||
List<AdvisoryBoardWithdrawnReasonDetails> reasons = decision.WithdrawnReasons; | ||
SetReasonsModel(reasons); | ||
|
||
return Page(); | ||
} | ||
|
||
public IActionResult OnPost(int id) | ||
{ | ||
AdvisoryBoardDecision decision = GetDecisionFromSession(id); | ||
|
||
decision.WithdrawnReasons.Clear(); | ||
decision.WithdrawnReasons | ||
.AddReasonIfValid(AdditionalInformationNeededIsChecked, AdvisoryBoardWithdrawnReason.AdditionalInformationNeeded, AdditionalInformationNeededDetails, ModelState) | ||
.AddReasonIfValid(AwaitingNextOfstedReportIsChecked, AdvisoryBoardWithdrawnReason.AwaitingNextOfstedReport, AwaitingNextOfstedReportDetails, ModelState) | ||
.AddReasonIfValid(PerformanceConcernsIsChecked, AdvisoryBoardWithdrawnReason.PerformanceConcerns, PerformanceConcernsDetails, ModelState) | ||
.AddReasonIfValid(OtherIsChecked, AdvisoryBoardWithdrawnReason.Other, OtherDetails, ModelState); | ||
|
||
SetDecisionInSession(id, decision); | ||
|
||
if (!WasReasonGiven) ModelState.AddModelError("WasReasonGiven", "Select at least one reason"); | ||
|
||
_errorService.AddErrors(ModelState.Keys, ModelState); | ||
if (_errorService.HasErrors()) return OnGet(id); | ||
|
||
return RedirectToPage(Links.Decision.DecisionDate.Page, LinkParameters); | ||
} | ||
|
||
private void SetReasonsModel(List<AdvisoryBoardWithdrawnReasonDetails> reasons) | ||
{ | ||
AdvisoryBoardWithdrawnReasonDetails additionalInfo = reasons.GetReason(AdvisoryBoardWithdrawnReason.AdditionalInformationNeeded); | ||
AdditionalInformationNeededIsChecked = additionalInfo != null; | ||
AdditionalInformationNeededDetails = additionalInfo?.Details; | ||
|
||
AdvisoryBoardWithdrawnReasonDetails ofsted = reasons.GetReason(AdvisoryBoardWithdrawnReason.AwaitingNextOfstedReport); | ||
AwaitingNextOfstedReportIsChecked = ofsted != null; | ||
AwaitingNextOfstedReportDetails = ofsted?.Details; | ||
|
||
AdvisoryBoardWithdrawnReasonDetails perf = reasons.GetReason(AdvisoryBoardWithdrawnReason.PerformanceConcerns); | ||
PerformanceConcernsIsChecked = perf != null; | ||
PerformanceConcernsDetails = perf?.Details; | ||
|
||
AdvisoryBoardWithdrawnReasonDetails other = reasons.GetReason(AdvisoryBoardWithdrawnReason.Other); | ||
OtherIsChecked = other != null; | ||
OtherDetails = other?.Details; | ||
} | ||
} |