Skip to content

Commit

Permalink
Merge pull request #1057 from DFE-Digital/feature/165916-scheme-of-de…
Browse files Browse the repository at this point in the history
…legation

Feature/165916 scheme of delegation
  • Loading branch information
dneed-nimble authored May 22, 2024
2 parents 77f6b0b + 815c627 commit dd91371
Show file tree
Hide file tree
Showing 16 changed files with 162 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public AdvisoryBoardDecision()
public DateTime? AdvisoryBoardDecisionDate { get; set; }
public DecisionMadeBy? DecisionMadeBy { get; set; }
public DateTime? AcademyOrderDate { get; set; }
public string DecisionMakerName { get; set; }


public AdvisoryBoardDecisions? Decision
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ public enum DecisionMadeBy
OtherRegionalDirector = 1,
[Description("Minister")] Minister = 2,
[Description("Director General")] DirectorGeneral = 3,
[Description("None")] None = 4
[Description("Deputy Director")] DeputyDirector = 4,
[Description("Grade 6")] Grade6 = 5,
[Description("None")] None = 6
}
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ public static class Decision
public static readonly LinkItem DeclineReason = AddLinkItem(backText: "Back", page: "/TaskList/Decision/DeclineReason");
public static readonly LinkItem AnyConditions = AddLinkItem(backText: "Back", page: "/TaskList/Decision/AnyConditions");
public static readonly LinkItem DecisionDate = AddLinkItem(backText: "Back", page: "/TaskList/Decision/DecisionDate");
public static readonly LinkItem DecisionMaker = AddLinkItem(backText: "Back", page: "/TaskList/Decision/DecisionMaker");
public static readonly LinkItem WhyDeferred = AddLinkItem(backText: "Back", page: "/TaskList/Decision/WhyDeferred");
public static readonly LinkItem WhyWithdrawn = AddLinkItem(backText: "Back", page: "/TaskList/Decision/WhyWithdrawn");
public static readonly LinkItem Summary = AddLinkItem(backText: "Back", page: "/TaskList/Decision/Summary");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,25 @@
<dd class="govuk-summary-list__actions"></dd>
</div>

<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">
Decision maker's name
</dt>
<dd class="govuk-summary-list__value">

@if (Model.Decision != null && Model.Decision.DecisionMakerName != null)
{
<div id="decision-made-by">@Model.Decision.DecisionMakerName</div>
}
else
{
<span class="empty">Empty</span>
}

</dd>
<dd class="govuk-summary-list__actions"></dd>
</div>

@if (Model.Decision.Decision == AdvisoryBoardDecisions.Declined)
{
<div class="govuk-summary-list__row">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<partial name="_ErrorSummary"/>
}

<span id="selection-span" class="govuk-caption-l">@Model.SchoolName</span>
<span id="selection-span" class="govuk-caption-l">Record the decision</span>
<h1 class="govuk-heading-l">Date the academy order (AO) was sent</h1>

<form method="post">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">

<span id="selection-span" class="govuk-caption-l">@Model.SchoolName</span>
<span id="selection-span" class="govuk-caption-l">Record the decision</span>
<h1 class="govuk-heading-l">Were any conditions set?</h1>

<form method="post">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<partial name="_ErrorSummary"/>
}

<span id="selection-span" class="govuk-caption-l">@Model.SchoolName</span>
<span id="selection-span" class="govuk-caption-l">Record the decision</span>
<h1 class="govuk-heading-l">Date conversion was @Model.DecisionText</h1>

<form method="post">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
@page "/task-list/{id:int}/decision/decision-maker"
@using Dfe.PrepareConversions.Extensions
@using Dfe.PrepareConversions.TagHelpers
@model Dfe.PrepareConversions.Pages.TaskList.Decision.DecisionMaker
@{
ViewData["Title"] = $"Decision maker's name";
Layout = "_Layout";
}

@section BeforeMain
{
<partial name="_BackLink" model="@Model.BackLinkModel"/>
<partial name="_ErrorSummary"/>
}

<span id="selection-span" class="govuk-caption-l">Record the decision</span>
<h1 class="govuk-heading-l">Decision maker's name</h1>

<form method="post">
<div class="govuk-form-group @ModelState.GetErrorStyleClass()">
<label class="govuk-hint" for="decision-maker-name">
Enter the name of the person who made the decision
</label>
<input class="govuk-input govuk-!-width-two-thirds" id="decision-maker-name" name="decision-maker-name" type="text" value="@Model.DecisionMakerName">
</div>


<button class="govuk-button" data-module="govuk-button" id="submit-btn">
Continue
</button>
</form>
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
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;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;

namespace Dfe.PrepareConversions.Pages.TaskList.Decision;

public class DecisionMaker : DecisionBaseModel
{
private readonly ErrorService _errorService;

public DecisionMaker(ErrorService errorService, IAcademyConversionProjectRepository repository, ISession session)
: base(repository, session)
{
_errorService = errorService;
}

[BindProperty(Name = "decision-maker-name")]
[Required]
public string DecisionMakerName { get; set; }


public AdvisoryBoardDecision Decision { get; set; }

public IActionResult OnGet(int id)
{

Decision = GetDecisionFromSession(id);
DecisionMakerName = Decision.DecisionMakerName;

SetBackLinkModel(Links.Decision.WhoDecided, id);

return Page();
}

public IActionResult OnPost(int id)
{
if (!ModelState.IsValid)
{
_errorService.AddError("decision-maker-name", "Enter the decision maker's name");
return OnGet(id);
}

AdvisoryBoardDecision decision = GetDecisionFromSession(id);
decision.DecisionMakerName = DecisionMakerName;

SetDecisionInSession(id, decision);

return decision.Decision switch
{
AdvisoryBoardDecisions.Approved => RedirectToPage(Links.Decision.AnyConditions.Page, LinkParameters),
AdvisoryBoardDecisions.Declined => RedirectToPage(Links.Decision.DeclineReason.Page, LinkParameters),
AdvisoryBoardDecisions.Deferred => RedirectToPage(Links.Decision.WhyDeferred.Page, LinkParameters),
AdvisoryBoardDecisions.Withdrawn => RedirectToPage(Links.Decision.WhyWithdrawn.Page, LinkParameters),
_ => RedirectToPage(Links.Decision.AnyConditions.Page, LinkParameters)
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<partial name="_ErrorSummary"/>
}

<span id="selection-span" class="govuk-caption-l">@Model.SchoolName</span>
<span id="selection-span" class="govuk-caption-l">Record the decision</span>

<form method="post">

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<partial name="_ErrorSummary"/>
}

<span id="selection-span" class="govuk-caption-l">@Model.SchoolName</span>
<span id="selection-span" class="govuk-caption-l">Record the decision</span>
<h1 class="govuk-heading-l">Record the decision</h1>

<form method="post">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<a asp-page="@Links.Decision.DecisionDate.Page" asp-route-id="@Model.Id" class="govuk-back-link">Back</a>
}

<span id="selection-span" class="govuk-caption-l">@Model.SchoolName</span>
<span id="selection-span" class="govuk-caption-l">Record the decision</span>
<h1 class="govuk-heading-l">Check your answers before recording this decision</h1>

<dl class="govuk-summary-list">
Expand Down Expand Up @@ -71,6 +71,27 @@
</a>
</dd>
</div>
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">
Decision maker's name
</dt>
<dd class="govuk-summary-list__value">

@if (Model.Decision.DecisionMakerName != null)
{
<div id="decision-made-by">@Model.Decision.DecisionMakerName</div>
}
else
{
<span class="empty">Empty</span>
}
</dd>
<dd class="govuk-summary-list__actions">
<a class="govuk-link" asp-page="@Links.Decision.DecisionMaker.Page" asp-route-id="@Model.Id" asp-route-obl="true" id="decision-maker-btn">
Change<span class="govuk-visually-hidden">decision maker's name</span>
</a>
</dd>
</div>

@if (Model.Decision.Decision == AdvisoryBoardDecisions.Declined)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<partial name="_ErrorSummary"/>
}

<span id="selection-span" class="govuk-caption-l">@Model.SchoolName</span>
<span id="selection-span" class="govuk-caption-l">Record the decision</span>
<h1 class="govuk-heading-l">Who made this decision?</h1>

<form method="post">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,25 @@ public IActionResult OnPost(int id)

AdvisoryBoardDecision decision = GetDecisionFromSession(id) ?? new AdvisoryBoardDecision();
decision.DecisionMadeBy = DecisionMadeBy;
decision.DecisionMakerName = decision.DecisionMadeBy == Data.Models.AdvisoryBoardDecision.DecisionMadeBy.None ? null : decision.DecisionMakerName;

SetDecisionInSession(id, decision);

return decision.Decision switch
return DetermineRedirectPage(decision);
}


private IActionResult DetermineRedirectPage(AdvisoryBoardDecision decision)
{
var pageToReturnTo = decision.Decision switch
{
AdvisoryBoardDecisions.Approved => RedirectToPage(Links.Decision.AnyConditions.Page, LinkParameters),
AdvisoryBoardDecisions.Declined => RedirectToPage(Links.Decision.DeclineReason.Page, LinkParameters),
AdvisoryBoardDecisions.Deferred => RedirectToPage(Links.Decision.WhyDeferred.Page, LinkParameters),
AdvisoryBoardDecisions.Withdrawn => RedirectToPage(Links.Decision.WhyWithdrawn.Page, LinkParameters),
_ => RedirectToPage(Links.Decision.AnyConditions.Page, LinkParameters)
};

return decision.DecisionMadeBy == Data.Models.AdvisoryBoardDecision.DecisionMadeBy.None ? pageToReturnTo : RedirectToPage(Links.Decision.DecisionMaker.Page, LinkParameters);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<partial name="_ErrorSummary"/>
}

<span id="selection-span" class="govuk-caption-l">@Model.SchoolName</span>
<span id="selection-span" class="govuk-caption-l">Record the decision</span>
<h1 class="govuk-heading-l">Why was this project deferred?</h1>

<form method="post">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<partial name="_ErrorSummary"/>
}

<span id="selection-span" class="govuk-caption-l">@Model.SchoolName</span>
<span id="selection-span" class="govuk-caption-l">Record the decision</span>
<h1 class="govuk-heading-l">Why was this project withdrawn?</h1>

<form method="post">
Expand Down

0 comments on commit dd91371

Please sign in to comment.