diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Dfe.PrepareConversions.Data.csproj b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Dfe.PrepareConversions.Data.csproj index d07f42509..4505df22c 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Dfe.PrepareConversions.Data.csproj +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Dfe.PrepareConversions.Data.csproj @@ -23,8 +23,4 @@ - - - - diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/ApiClient.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/ApiClient.cs index 9f6f36ff7..f09677d0c 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/ApiClient.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/ApiClient.cs @@ -168,4 +168,27 @@ public async Task SetFormAMatProjectReference(int id, SetFo { return await AcademisationClient.PutAsync(string.Format(PathFor.SetFormAMatProjectReference, id), JsonContent.Create(setFormAMatProjectReference)); } + + public async Task SetProjectDates(int id, SetProjectDatesModel updatedProjectDates) + { + var payload = new + { + id = updatedProjectDates.Id, + advisoryBoardDate = updatedProjectDates.AdvisoryBoardDate ?? null, + previousAdvisoryBoard = updatedProjectDates.PreviousAdvisoryBoard ?? null, + proposedConversionDate = updatedProjectDates.ProposedConversionDate ?? null, + projectDatesSectionComplete = updatedProjectDates.ProjectDatesSectionComplete ?? null, + changedBy = updatedProjectDates.ChangedBy ?? null, + reasonsChanged = updatedProjectDates.ReasonsChanged ?? null, + }; + + var formattedString = string.Format(PathFor.SetProjectDates, id); + return await AcademisationClient.PutAsync(formattedString, JsonContent.Create(payload)); + } + + public async Task GetOpeningDateHistoryForConversionProject(int id) + { + HttpResponseMessage getHistoryResponse = await AcademisationClient.GetAsync(string.Format(PathFor.GetOpeningDateHistoryForConversionProject, id)); + return getHistoryResponse; + } } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/IApiClient.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/IApiClient.cs index 159df8c59..e5bd28a90 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/IApiClient.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/IApiClient.cs @@ -27,4 +27,6 @@ public interface IApiClient Task GetFormAMatProjectsAsync(AcademyConversionSearchModelV2 searchModel); Task SearchFormAMatProjects(string searchTerm); Task SetFormAMatProjectReference(int id, SetFormAMatProjectReference setFormAMatProjectReference); + Task SetProjectDates(int id, SetProjectDatesModel updatedProjectDates); + Task GetOpeningDateHistoryForConversionProject(int id); } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/PathFor.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/PathFor.cs index d95cefcf1..32fdc867e 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/PathFor.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Features/PathFor.cs @@ -32,5 +32,6 @@ public PathFor(IFeatureManager features) public static string GetFormAMatProjects => "/conversion-project/FormAMatProjects"; public static string SearchFormAMatProjects => "/conversion-project/search-formamatprojects"; public static string SetFormAMatProjectReference => "/conversion-project/{0}/SetFormAMatProjectReference"; - + public static string SetProjectDates => "/conversion-project/{0}/SetProjectDates"; + public static string GetOpeningDateHistoryForConversionProject => "/conversion-project/{0}/conversion-date-history"; } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademyConversion/ConversionDateReasonForChangeFuture.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademyConversion/ConversionDateReasonForChangeFuture.cs new file mode 100644 index 000000000..de6b2bdd8 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademyConversion/ConversionDateReasonForChangeFuture.cs @@ -0,0 +1,24 @@ +using System.ComponentModel; + +namespace Dfe.PrepareConversions.Data.Models.AcademyConversion; + +public enum ConversionDateReasonForChangeFuture +{ + [Description("Incoming trust")] IncomingTrust = 1, + [Description("School")] School = 2, + [Description("LA (local authority)")] LA = 3, + [Description("Diocese")] Diocese = 4, + [Description("TuPE (Transfer of Undertakings Protection of Employments rights)")] TuPE = 5, + [Description("Pensions")] Pensions = 6, + [Description("Union")] Union = 7, + [Description("Negative press coverage")] NegativePressCoverage = 8, + [Description("Governance")] Governance = 9, + [Description("Finance")] Finance = 10, + [Description("Viability")] Viability = 11, + [Description("Land")] Land = 12, + [Description("Buildings")] Buildings = 13, + [Description("Legal documents")] LegalDocuments = 14, + [Description("Correcting an error")] CorrectingAnError = 15, + [Description("Voluntary deferral")] VoluntaryDeferral = 16, + [Description("In a federation")] InAFederation = 17, +} diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademyConversion/ConversionDateReasonForChangePast.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademyConversion/ConversionDateReasonForChangePast.cs new file mode 100644 index 000000000..8c8ae0e5a --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademyConversion/ConversionDateReasonForChangePast.cs @@ -0,0 +1,9 @@ +using System.ComponentModel; + +namespace Dfe.PrepareConversions.Data.Models.AcademyConversion; + +public enum ConversionDateReasonForChangePast +{ + [Description("Conversion is progressing faster than expected")] ProgressingFaster = 1, + [Description("Correcting an error")] CorrectingAnError = 2 +} diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademyConversionProject.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademyConversionProject.cs index f485207fb..bd656d9b5 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademyConversionProject.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademyConversionProject.cs @@ -137,4 +137,9 @@ public class AcademyConversionProject // notes public ICollection Notes { get; set; } = new List(); + //Project Dates + public DateTime? ProposedConversionDate { get; set; } + + public bool ProjectDatesSectionComplete { get; set; } + } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/OpeningDateHistoryDto.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/OpeningDateHistoryDto.cs new file mode 100644 index 000000000..c5e735b7f --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/OpeningDateHistoryDto.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Dfe.PrepareConversions.Data.Models +{ + public class OpeningDateHistoryDto + { + public DateTime ChangedAt { get; set; } + public string ChangedBy { get; set; } + public DateTime? OldDate { get; set; } + public DateTime? NewDate { get; set; } + public List ReasonsChanged { get; set; } + } + + + public class ReasonChange + { + public ReasonChange(string heading, string details) + { + Heading = heading; + Details = details; + } + + public string Heading { get; set; } + public string Details { get; set; } + + } +} diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/SetProjectDatesModel.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/SetProjectDatesModel.cs new file mode 100644 index 000000000..5c4ba0b65 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/SetProjectDatesModel.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; + +namespace Dfe.PrepareConversions.Data.Models +{ + public class SetProjectDatesModel + { + public int Id { get; set; } + public DateTime? AdvisoryBoardDate { get; set; } + public DateTime? PreviousAdvisoryBoard { get; set; } + public DateTime? ProposedConversionDate { get; set; } + public bool? ProjectDatesSectionComplete { get; set; } + public IEnumerable? ReasonsChanged { get; set; } + public string? ChangedBy { get; set; } + + public SetProjectDatesModel() { } + + public SetProjectDatesModel(int id, DateTime? advisoryBoardDate, DateTime? previousAdvisoryBoard, DateTime? proposedConversionDate, bool? projectDatesSectionComplete, string? changedBy = default, IEnumerable? reasonsChanged = default) + { + Id = id; + AdvisoryBoardDate = advisoryBoardDate; + PreviousAdvisoryBoard = previousAdvisoryBoard; + ProposedConversionDate = proposedConversionDate; + ProjectDatesSectionComplete = projectDatesSectionComplete; + ChangedBy = changedBy; + ReasonsChanged = reasonsChanged; + } + } +} diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/AcademyConversionProjectRepository.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/AcademyConversionProjectRepository.cs index e7383f09a..36588942c 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/AcademyConversionProjectRepository.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/AcademyConversionProjectRepository.cs @@ -375,4 +375,23 @@ public async Task UpdateSchoolImprovementPlan(int id, UpdateSchoolImprovementPla if (!result.Success) throw new ApiResponseException($"Request to Api failed | StatusCode - {result.StatusCode}"); } + + public async Task SetProjectDates(int id, SetProjectDatesModel updatedProjectDates) + { + HttpResponseMessage result = await _apiClient.SetProjectDates(id, updatedProjectDates); + if (result.IsSuccessStatusCode is false) throw new ApiResponseException($"Request to Api failed | StatusCode - {result.StatusCode}"); + } + + public async Task>> GetOpeningDateHistoryForConversionProject(int id) + { + HttpResponseMessage response = await _apiClient.GetOpeningDateHistoryForConversionProject(id); + if (!response.IsSuccessStatusCode) + { + return new ApiResponse>(response.StatusCode, null); + } + + IEnumerable history = await ReadFromJsonAndThrowIfNull>(response.Content); + return new ApiResponse>(response.StatusCode, history); + } + } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/IAcademyConversionProjectRepository.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/IAcademyConversionProjectRepository.cs index 94f8f5b32..3bad3a5ee 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/IAcademyConversionProjectRepository.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/IAcademyConversionProjectRepository.cs @@ -70,4 +70,6 @@ Task>>> GetFormAMatProject Task>> GetSchoolImprovementPlansForProject(int id); Task UpdateSchoolImprovementPlan(int id, UpdateSchoolImprovementPlan updateSchoolImprovementPlan); + Task SetProjectDates(int id, SetProjectDatesModel updatedProjectDates); + Task>> GetOpeningDateHistoryForConversionProject(int id); } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/ApplicationForm/ApplicationFormIntegrationTests.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/ApplicationForm/ApplicationFormIntegrationTests.cs index bed82865a..d288df35d 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/ApplicationForm/ApplicationFormIntegrationTests.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/ApplicationForm/ApplicationFormIntegrationTests.cs @@ -77,7 +77,6 @@ public async Task Should_Display_About_The_Conversion_Section(string path) Document.QuerySelectorAll("h2").Where(contents => contents.InnerHtml == "About the conversion").Should().NotBeEmpty(); Document.QuerySelectorAll("h3").Where(contents => contents.InnerHtml == "The school joining the trust").Should().NotBeEmpty(); Document.QuerySelectorAll("h3").Where(contents => contents.InnerHtml == "Contact details").Should().NotBeEmpty(); - Document.QuerySelectorAll("h3").Where(contents => contents.InnerHtml == "Date for conversion").Should().NotBeEmpty(); Document.QuerySelectorAll("h3").Where(contents => contents.InnerHtml == "Reasons for joining").Should().NotBeEmpty(); Document.QuerySelectorAll("h3").Where(contents => contents.InnerHtml == "Name changes").Should().NotBeEmpty(); } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/PreviewHTBTemplate/PreviewHTBIntegrationTests.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/PreviewHTBTemplate/PreviewHTBIntegrationTests.cs index 48bf7d3e0..e4f9c20b7 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/PreviewHTBTemplate/PreviewHTBIntegrationTests.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/PreviewHTBTemplate/PreviewHTBIntegrationTests.cs @@ -537,8 +537,6 @@ public async Task Should_display_school_and_trust_information_section() Document.QuerySelector("#project-recommendation")!.TextContent.Should().Be(project.RecommendationForProject); Document.QuerySelector("#author")!.TextContent.Should().Be(project.Author); Document.QuerySelector("#cleared-by")!.TextContent.Should().Be(project.ClearedBy); - Document.QuerySelector("#advisory-board-date")!.TextContent.Should().Be(project.HeadTeacherBoardDate.ToDateString()); - Document.QuerySelector("#previous-advisory-board")!.TextContent.Should().Be(project.PreviousHeadTeacherBoardDate.ToDateString()); Document.QuerySelector("#school-name")!.TextContent.Should().Be(project.SchoolName); Document.QuerySelector("#unique-reference-number")!.TextContent.Should().Be(project.Urn.ToString()); Document.QuerySelector("#local-authority")!.TextContent.Should().Be(project.LocalAuthority); @@ -549,7 +547,6 @@ public async Task Should_display_school_and_trust_information_section() Document.QuerySelector("#academy-type-and-route")!.TextContent.Should().Contain(project.AcademyTypeAndRoute); Document.QuerySelector("#grant-funding-amount")!.TextContent.Should().Contain(project.ConversionSupportGrantAmount?.ToMoneyString()); Document.QuerySelector("#grant-funding-reason")!.TextContent.Should().Contain(project.ConversionSupportGrantChangeReason); - Document.QuerySelector("#proposed-academy-opening-date")!.TextContent.Should().Be(project.ProposedAcademyOpeningDate.ToDateString(true)); } [Fact] @@ -597,223 +594,6 @@ public async Task Should_update_school_and_trust_recommendation_and_navigate_bac Document.Url.Should().Contain($"/task-list/{project.Id}/preview-project-template"); } - [Fact] - public async Task Should_navigate_to_school_and_trust_prev_htb_page_and_back() - { - AcademyConversionProject project = AddGetProject(x => x.AcademyTypeAndRoute = AcademyTypeAndRoutes.Voluntary); - AddGetKeyStagePerformance(project.Urn.Value); - - await OpenAndConfirmPathAsync($"/task-list/{project.Id}/preview-project-template"); - - await NavigateAsync("Change", 19); - Document.Url.Should().Contain($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/previous-advisory-board"); - - await NavigateAsync("Back"); - Document.Url.Should().Contain($"/task-list/{project.Id}/preview-project-template"); - } - - [Fact] - public async Task Should_navigate_to_school_and_trust_prev_htb_question_page_and_submit_to_prev_htb_page_when_user_selects_yes() - { - AcademyConversionProject project = AddGetProject(p => - { - p.PreviousHeadTeacherBoardDateQuestion = null; - p.PreviousHeadTeacherBoardDate = null; - p.AcademyTypeAndRoute = AcademyTypeAndRoutes.Voluntary; - }); - - AddPatchConfiguredProject(project, x => - { - x.PreviousHeadTeacherBoardDateQuestion = "Yes"; - x.Urn = project.Urn; - }); - - UpdateAcademyConversionProject secondPatchRequest = AddPatchConfiguredProject(project, x => - { - x.PreviousHeadTeacherBoardDate = _fixture.Create(); - x.Urn = project.Urn; - }); - - await OpenAndConfirmPathAsync($"/task-list/{project.Id}/preview-project-template"); - - await NavigateAsync("Change", 19); - Document.Url.Should().Contain($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/previous-advisory-board"); - - Document.QuerySelector("#previous-head-teacher-board-date-question")!.IsChecked.Should().BeFalse(); - Document.QuerySelector("#previous-head-teacher-board-date-question-2")!.IsChecked.Should().BeFalse(); - - Document.QuerySelector("#previous-head-teacher-board-date-question")!.IsChecked = true; - - await Document.QuerySelector("form")!.SubmitAsync(); - Document.Url.Should().Contain($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/previous-advisory-board-date?"); - - Document.QuerySelector("#previous-head-teacher-board-date-day")!.Value.Should().Be(""); - Document.QuerySelector("#previous-head-teacher-board-date-month")!.Value.Should().Be(""); - Document.QuerySelector("#previous-head-teacher-board-date-year")!.Value.Should().Be(""); - - Document.QuerySelector("#previous-head-teacher-board-date-day")!.Value = secondPatchRequest.PreviousHeadTeacherBoardDate?.Day.ToString()!; - Document.QuerySelector("#previous-head-teacher-board-date-month")!.Value = secondPatchRequest.PreviousHeadTeacherBoardDate?.Month.ToString()!; - Document.QuerySelector("#previous-head-teacher-board-date-year")!.Value = secondPatchRequest.PreviousHeadTeacherBoardDate?.Year.ToString()!; - - await Document.QuerySelector("form")!.SubmitAsync(); - Document.Url.Should().Contain($"/task-list/{project.Id}/preview-project-template"); - } - - [Fact] - public async Task Should_navigate_to_school_and_trust_prev_htb_question_page_and_submit_preview_page_when_user_selects_no() - { - AcademyConversionProject project = AddGetProject(p => p.PreviousHeadTeacherBoardDateQuestion = null); - AddPatchProjectMany(project, composer => composer - .With(r => r.PreviousHeadTeacherBoardDateQuestion, "No") - .With(r => r.PreviousHeadTeacherBoardDate, default(DateTime)) - .With(r => r.Urn, project.Urn)); - - await OpenAndConfirmPathAsync($"/task-list/{project.Id}/preview-project-template"); - - await NavigateAsync("Change", 19); - Document.Url.Should().Contain($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/previous-advisory-board"); - - Document.QuerySelector("#previous-head-teacher-board-date-question")!.IsChecked.Should().BeFalse(); - Document.QuerySelector("#previous-head-teacher-board-date-question-2")!.IsChecked.Should().BeFalse(); - - Document.QuerySelector("#previous-head-teacher-board-date-question-2")!.IsChecked = true; - - await Document.QuerySelector("form")!.SubmitAsync(); - - Document.Url.Should().Contain($"/task-list/{project.Id}/preview-project-template"); - } - - [Fact] - public async Task Should_navigate_to_school_and_trust_prev_htb_question_page_and_back() - { - AcademyConversionProject project = AddGetProject(x => x.AcademyTypeAndRoute = AcademyTypeAndRoutes.Voluntary); - - await OpenAndConfirmPathAsync($"/task-list/{project.Id}/preview-project-template"); - - await NavigateAsync("Change", 19); - Document.Url.Should().Contain($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/previous-advisory-board"); - - await NavigateAsync("Back"); - Document.Url.Should().Contain($"/task-list/{project.Id}/preview-project-template"); - } - - [Fact] - public async Task Should_navigate_to_school_and_trust_prev_htb_input_page_and_back() - { - AcademyConversionProject project = AddGetProject(x => x.AcademyTypeAndRoute = AcademyTypeAndRoutes.Voluntary); - AddPatchConfiguredProject(project, x => - { - x.ConversionSupportGrantAmountChanged = null; - x.PreviousHeadTeacherBoardDateQuestion = "Yes"; - x.Urn = project.Urn; - }); - - await OpenAndConfirmPathAsync($"/task-list/{project.Id}/preview-project-template"); - - await NavigateAsync("Change", 19); - Document.Url.Should().Contain($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/previous-advisory-board"); - - Document.QuerySelector("#previous-head-teacher-board-date-question").IsChecked = true; - await Document.QuerySelector("form").SubmitAsync(); - Document.Url.Should().Contain($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/previous-advisory-board-date?"); - - await NavigateAsync("Back"); - Document.Url.Should().Contain($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/previous-advisory-board"); - - await NavigateAsync("Back"); - Document.Url.Should().Contain($"/task-list/{project.Id}/preview-project-template"); - } - - [Fact] - public async Task Should_navigate_to_school_and_trust_prev_htb_input_page_and_back_to_question_and_submit_again() - { - AcademyConversionProject project = AddGetProject(p => - { - p.PreviousHeadTeacherBoardDateQuestion = "Yes"; - p.AcademyTypeAndRoute = AcademyTypeAndRoutes.Voluntary; - }); - AddPatchConfiguredProject(project, x => - { - x.PreviousHeadTeacherBoardDateQuestion = "Yes"; - x.Urn = project.Urn; - }); - - UpdateAcademyConversionProject secondPatchRequest = AddPatchConfiguredProject(project, x => - { - x.PreviousHeadTeacherBoardDate = _fixture.Create(); - x.Urn = project.Urn; - }); - - await OpenAndConfirmPathAsync($"/task-list/{project.Id}/preview-project-template"); - - await NavigateAsync("Change", 19); - Document.Url.Should().Contain($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/previous-advisory-board"); - - Document.QuerySelector("#previous-head-teacher-board-date-question")!.IsChecked.Should().BeTrue(); - - await Document.QuerySelector("form")!.SubmitAsync(); - Document.Url.Should().Contain($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/previous-advisory-board-date?"); - - await NavigateAsync("Back"); - Document.Url.Should().Contain($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/previous-advisory-board"); - Document.QuerySelector("#previous-head-teacher-board-date-question")!.IsChecked.Should().BeTrue(); - - await Document.QuerySelector("form")!.SubmitAsync(); - Document.Url.Should().Contain($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/previous-advisory-board-date?"); - - Document.QuerySelector("#previous-head-teacher-board-date-day")!.Value = secondPatchRequest.PreviousHeadTeacherBoardDate?.Day.ToString()!; - Document.QuerySelector("#previous-head-teacher-board-date-month")!.Value = secondPatchRequest.PreviousHeadTeacherBoardDate?.Month.ToString()!; - Document.QuerySelector("#previous-head-teacher-board-date-year")!.Value = secondPatchRequest.PreviousHeadTeacherBoardDate?.Year.ToString()!; - - await Document.QuerySelector("form")!.SubmitAsync(); - - Document.Url.Should().Contain($"/task-list/{project.Id}/preview-project-template"); - } - - [Fact] - public async Task Should_navigate_to_school_and_trust_prev_htb_input_page_and_back_to_question_and_submit_to_input_and_back() - { - AcademyConversionProject project = AddGetProject(p => - { - p.PreviousHeadTeacherBoardDateQuestion = "Yes"; - p.AcademyTypeAndRoute = AcademyTypeAndRoutes.Voluntary; - }); - AddPatchConfiguredProject(project, x => - { - x.PreviousHeadTeacherBoardDateQuestion = "Yes"; - x.Urn = project.Urn; - }); - - AddPatchConfiguredProject(project, x => - { - x.PreviousHeadTeacherBoardDate = _fixture.Create(); - x.Urn = project.Urn; - }); - - await OpenAndConfirmPathAsync($"/task-list/{project.Id}/preview-project-template"); - - await NavigateAsync("Change", 19); - Document.Url.Should().Contain($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/previous-advisory-board"); - - Document.QuerySelector("#previous-head-teacher-board-date-question")!.IsChecked.Should().BeTrue(); - - await Document.QuerySelector("form")!.SubmitAsync(); - Document.Url.Should().Contain($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/previous-advisory-board-date?"); - - await NavigateAsync("Back"); - Document.Url.Should().Contain($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/previous-advisory-board"); - Document.QuerySelector("#previous-head-teacher-board-date-question")!.IsChecked.Should().BeTrue(); - - await Document.QuerySelector("form")!.SubmitAsync(); - Document.Url.Should().Contain($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/previous-advisory-board-date?"); - - await NavigateAsync("Back"); - Document.Url.Should().Contain($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/previous-advisory-board"); - - await NavigateAsync("Back"); - Document.Url.Should().Contain($"/task-list/{project.Id}/preview-project-template"); - } - private static string AsPercentageOf(string numberOfPupils, string schoolCapacity) { int? a = int.Parse(numberOfPupils); diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolAndTrustInformation/AuthorIntegrationTests.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolAndTrustInformation/AuthorIntegrationTests.cs index d226d83c6..536a10007 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolAndTrustInformation/AuthorIntegrationTests.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolAndTrustInformation/AuthorIntegrationTests.cs @@ -24,7 +24,7 @@ public async Task Should_navigate_to_and_update_author() }); await OpenAndConfirmPathAsync($"/task-list/{project.Id}/conversion-details"); - await NavigateAsync("Change", 6); + await NavigateAsync("Change", 4); Document.Url.Should().BeUrl($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/author"); Document.QuerySelector("#author")!.Value.Should().Be(project.Author); diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolAndTrustInformation/ClearedByIntegrationTests.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolAndTrustInformation/ClearedByIntegrationTests.cs index 64aa037bd..495a8daba 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolAndTrustInformation/ClearedByIntegrationTests.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolAndTrustInformation/ClearedByIntegrationTests.cs @@ -24,7 +24,7 @@ public async Task Should_navigate_to_and_update_cleared_by() }); await OpenAndConfirmPathAsync($"/task-list/{project.Id}/conversion-details"); - await NavigateAsync("Change", 7); + await NavigateAsync("Change", 5); Document.Url.Should().BeUrl($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/clear-head-teacher-board-template"); diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolAndTrustInformation/ConfirmSchoolAndTrustInformationIntegrationTests.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolAndTrustInformation/ConfirmSchoolAndTrustInformationIntegrationTests.cs index 038e7ff82..ec91d9257 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolAndTrustInformation/ConfirmSchoolAndTrustInformationIntegrationTests.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolAndTrustInformation/ConfirmSchoolAndTrustInformationIntegrationTests.cs @@ -34,8 +34,6 @@ public async Task Should_be_in_progress_and_display_school_and_trust_information Document.QuerySelector("#project-recommendation")!.TextContent.Should().Be(project.RecommendationForProject); Document.QuerySelector("#author")!.TextContent.Should().Be(project.Author); Document.QuerySelector("#cleared-by")!.TextContent.Should().Be(project.ClearedBy); - Document.QuerySelector("#advisory-board-date")!.TextContent.Should().Be(project.HeadTeacherBoardDate.ToDateString()); - Document.QuerySelector("#previous-advisory-board")!.TextContent.Should().Be(project.PreviousHeadTeacherBoardDate.ToDateString()); Document.QuerySelector("#school-name")!.TextContent.Should().Be(project.SchoolName); Document.QuerySelector("#unique-reference-number")!.TextContent.Should().Be(project.Urn.ToString()); Document.QuerySelector("#local-authority")!.TextContent.Should().Be(project.LocalAuthority); @@ -49,17 +47,6 @@ public async Task Should_be_in_progress_and_display_school_and_trust_information Document.QuerySelector("#proposed-academy-opening-date")!.TextContent.Should().Be(project.ProposedAcademyOpeningDate.ToDateString(true)); } - [Fact] - public async Task Previous_head_teacher_board_date_should_be_no_when_question_field_set_to_no() - { - AcademyConversionProject project = AddGetProject(p => p.PreviousHeadTeacherBoardDateQuestion = "No"); - - await OpenAndConfirmPathAsync($"/task-list/{project.Id}"); - await NavigateAsync("Conversion details"); - - Document.QuerySelector("#previous-advisory-board")!.TextContent.Should().Be("No"); - } - [Fact] public async Task Should_display_an_error_when_school_and_trust_information_is_marked_as_complete_without_advisory_board_date_set() { @@ -142,8 +129,6 @@ public async Task Should_be_not_started_and_display_empty_when_school_and_trust_ Document.QuerySelector("#project-recommendation")!.TextContent.Should().Be("Empty"); Document.QuerySelector("#author")!.TextContent.Should().Be("Empty"); Document.QuerySelector("#cleared-by")!.TextContent.Should().Be("Empty"); - Document.QuerySelector("#advisory-board-date")!.TextContent.Should().Be("Empty"); - Document.QuerySelector("#previous-advisory-board")!.TextContent.Should().Be("Empty"); Document.QuerySelector("#school-name")!.TextContent.Should().Be("Empty"); Document.QuerySelector("#unique-reference-number")!.TextContent.Should().Be("Empty"); Document.QuerySelector("#local-authority")!.TextContent.Should().Be("Empty"); diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolAndTrustInformation/HeadTeacherBoardDateIntegrationTests.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolAndTrustInformation/HeadTeacherBoardDateIntegrationTests.cs deleted file mode 100644 index efbe44130..000000000 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolAndTrustInformation/HeadTeacherBoardDateIntegrationTests.cs +++ /dev/null @@ -1,77 +0,0 @@ -using AngleSharp.Dom; -using AngleSharp.Html.Dom; -using AutoFixture; -using Dfe.PrepareConversions.Data.Models; -using Dfe.PrepareConversions.Tests.Customisations; -using Dfe.PrepareConversions.Tests.Extensions; -using FluentAssertions; -using System; -using System.Threading.Tasks; -using Xunit; - -namespace Dfe.PrepareConversions.Tests.Pages.TaskList.SchoolAndTrustInformation; - -public class HeadTeacherBoardDateIntegrationTests : BaseIntegrationTests -{ - public HeadTeacherBoardDateIntegrationTests(IntegrationTestingWebApplicationFactory factory) : base(factory) - { - _fixture.Customizations.Add(new RandomDateBuilder(DateTime.Now.AddDays(1), DateTime.Now.AddMonths(12))); - } - - [Fact] - public async Task Should_navigate_to_and_update_head_teacher_board_date() - { - AcademyConversionProject project = AddGetProject(); - UpdateAcademyConversionProject request = AddPatchConfiguredProject(project, x => - { - x.HeadTeacherBoardDate = _fixture.Create(); - x.Urn = project.Urn; - }); - - await OpenAndConfirmPathAsync($"/task-list/{project.Id}/conversion-details"); - await NavigateDataTestAsync("change-advisory-board-date"); - - Document.Url.Should().BeUrl($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/advisory-board-date"); - - Document.QuerySelector("#head-teacher-board-date-day")!.Value = request.HeadTeacherBoardDate?.Day.ToString()!; - Document.QuerySelector("#head-teacher-board-date-month")!.Value = request.HeadTeacherBoardDate?.Month.ToString()!; - Document.QuerySelector("#head-teacher-board-date-year")!.Value = request.HeadTeacherBoardDate?.Year.ToString()!; - await Document.QuerySelector("form")!.SubmitAsync(); - - Document.Url.Should().BeUrl($"/task-list/{project.Id}/conversion-details"); - } - - [Fact] - public async Task Should_show_error_summary_when_there_is_an_API_error() - { - AcademyConversionProject project = AddGetProject(); - AddPatchError(project.Id); - - await OpenAndConfirmPathAsync($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/advisory-board-date"); - - await Document.QuerySelector("form")!.SubmitAsync(); - - Document.QuerySelector(".govuk-error-summary").Should().NotBeNull(); - } - - [Fact] - public async Task Should_navigate_back_to_head_teacher_board_date() - { - AcademyConversionProject project = AddGetProject(); - - await OpenAndConfirmPathAsync($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/advisory-board-date"); - await NavigateAsync("Back"); - - Document.Url.Should().BeUrl($"/task-list/{project.Id}/conversion-details"); - } - - [Fact] - public async Task Should_show_the_advisory_board_schedule_link() - { - AcademyConversionProject project = AddGetProject(); - - await OpenAndConfirmPathAsync($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/advisory-board-date"); - - Document.QuerySelector("#advisory-board-meeting-schedules").Should().NotBeNull(); - } -} diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolAndTrustInformation/PreviousHeadTeacherBoardDateIntegrationTests.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolAndTrustInformation/PreviousHeadTeacherBoardDateIntegrationTests.cs deleted file mode 100644 index 7c0d5446e..000000000 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolAndTrustInformation/PreviousHeadTeacherBoardDateIntegrationTests.cs +++ /dev/null @@ -1,253 +0,0 @@ -using AngleSharp.Dom; -using AngleSharp.Html.Dom; -using AutoFixture; -using Dfe.PrepareConversions.Data.Models; -using Dfe.PrepareConversions.Tests.Customisations; -using Dfe.PrepareConversions.Tests.Extensions; -using FluentAssertions; -using System; -using System.Threading.Tasks; -using Xunit; - -namespace Dfe.PrepareConversions.Tests.Pages.TaskList.SchoolAndTrustInformation; - -public class PreviousHeadTeacherBoardDateIntegrationTests : BaseIntegrationTests -{ - public PreviousHeadTeacherBoardDateIntegrationTests(IntegrationTestingWebApplicationFactory factory) : base(factory) - { - _fixture.Customizations.Add(new RandomDateBuilder(DateTime.Now.AddMonths(-2), DateTime.Now.AddDays(-1))); - } - - [Fact] - public async Task Should_navigate_to_and_update_previous_head_teacher_board_date_and_question_when_user_selects_yes() - { - AcademyConversionProject project = AddGetProject(p => - { - p.PreviousHeadTeacherBoardDateQuestion = null; - p.PreviousHeadTeacherBoardDate = null; - p.AcademyTypeAndRoute = AcademyTypeAndRoutes.Voluntary; - }); - - AddPatchConfiguredProject(project, x => - { - x.PreviousHeadTeacherBoardDateQuestion = "Yes"; - x.Urn = project.Urn; - }); - - UpdateAcademyConversionProject secondPatchRequest = AddPatchConfiguredProject(project, x => - { - x.PreviousHeadTeacherBoardDate = _fixture.Create(); - x.Urn = project.Urn; - }); - - await OpenAndConfirmPathAsync($"/task-list/{project.Id}/conversion-details"); - await NavigateAsync("Change", 5); - - Document.Url.Should().BeUrl($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/previous-advisory-board"); - - Document.QuerySelector("#previous-head-teacher-board-date-question")!.IsChecked.Should().BeFalse(); - Document.QuerySelector("#previous-head-teacher-board-date-question-2")!.IsChecked.Should().BeFalse(); - - Document.QuerySelector("#previous-head-teacher-board-date-question")!.IsChecked = true; - Document.QuerySelector("#previous-head-teacher-board-date-question")!.IsChecked.Should().BeTrue(); - - await Document.QuerySelector("form")!.SubmitAsync(); - - Document.Url.Should().BeUrl($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/previous-advisory-board-date"); - - Document.QuerySelector("#previous-head-teacher-board-date-day")!.Value.Should().Be(""); - Document.QuerySelector("#previous-head-teacher-board-date-month")!.Value.Should().Be(""); - Document.QuerySelector("#previous-head-teacher-board-date-year")!.Value.Should().Be(""); - - Document.QuerySelector("#previous-head-teacher-board-date-day")!.Value = secondPatchRequest.PreviousHeadTeacherBoardDate?.Day.ToString()!; - Document.QuerySelector("#previous-head-teacher-board-date-month")!.Value = secondPatchRequest.PreviousHeadTeacherBoardDate?.Month.ToString()!; - Document.QuerySelector("#previous-head-teacher-board-date-year")!.Value = secondPatchRequest.PreviousHeadTeacherBoardDate?.Year.ToString()!; - - await Document.QuerySelector("form")!.SubmitAsync(); - - Document.Url.Should().BeUrl($"/task-list/{project.Id}/conversion-details"); - } - - [Fact] - public async Task Should_navigate_to_confirm_page_when_user_does_not_select_value_for_question() - { - AcademyConversionProject project = AddGetProject(p => - { - p.PreviousHeadTeacherBoardDateQuestion = null; - p.AcademyTypeAndRoute = AcademyTypeAndRoutes.Voluntary; - }); - AddPatchConfiguredProject(project, x => - { - x.PreviousHeadTeacherBoardDateQuestion = null; - x.Urn = project.Urn; - }); - - await OpenAndConfirmPathAsync($"/task-list/{project.Id}/conversion-details"); - await NavigateAsync("Change", 5); - - Document.Url.Should().BeUrl($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/previous-advisory-board"); - - Document.QuerySelector("#previous-head-teacher-board-date-question")!.IsChecked.Should().BeFalse(); - Document.QuerySelector("#previous-head-teacher-board-date-question-2")!.IsChecked.Should().BeFalse(); - - await Document.QuerySelector("form")!.SubmitAsync(); - - Document.Url.Should().BeUrl($"/task-list/{project.Id}/conversion-details"); - } - - [Fact] - public async Task Should_update_previous_head_teacher_board_date_question_and_navigate_to_confirm_page_when_user_selects_no() - { - AcademyConversionProject project = AddGetProject(p => - { - p.PreviousHeadTeacherBoardDateQuestion = null; - p.AcademyTypeAndRoute = AcademyTypeAndRoutes.Voluntary; - }); - AddPatchProjectMany(project, composer => composer - .With(r => r.PreviousHeadTeacherBoardDateQuestion, "No") - .With(r => r.PreviousHeadTeacherBoardDate, default(DateTime)) - .With(r => r.Urn, project.Urn)); - - await OpenAndConfirmPathAsync($"/task-list/{project.Id}/conversion-details"); - await NavigateAsync("Change", 5); - - Document.Url.Should().BeUrl($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/previous-advisory-board"); - - Document.QuerySelector("#previous-head-teacher-board-date-question")!.IsChecked.Should().BeFalse(); - Document.QuerySelector("#previous-head-teacher-board-date-question-2")!.IsChecked.Should().BeFalse(); - - Document.QuerySelector("#previous-head-teacher-board-date-question-2")!.IsChecked = true; - Document.QuerySelector("#previous-head-teacher-board-date-question-2")!.IsChecked.Should().BeTrue(); - - await Document.QuerySelector("form")!.SubmitAsync(); - - Document.Url.Should().BeUrl($"/task-list/{project.Id}/conversion-details"); - } - - [Fact] - public async Task Should_display_question_value_and_navigate_back_to_confirm_page_from_previous_head_teacher_board_date_question() - { - AcademyConversionProject project = AddGetProject(p => p.PreviousHeadTeacherBoardDateQuestion = "Yes"); - - await OpenAndConfirmPathAsync($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/previous-advisory-board"); - - Document.QuerySelector("#previous-head-teacher-board-date-question")!.IsChecked.Should().BeTrue(); - Document.QuerySelector("#previous-head-teacher-board-date-question-2")!.IsChecked.Should().BeFalse(); - - await NavigateAsync("Back"); - - Document.Url.Should().BeUrl($"/task-list/{project.Id}/conversion-details"); - } - - [Fact] - public async Task Should_display_date_and_navigate_back_to_previous_head_teacher_board_date_question_from_previous_head_teacher_board_date() - { - AcademyConversionProject project = AddGetProject(); - - await OpenAndConfirmPathAsync($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/previous-advisory-board-date"); - - Document.QuerySelector("#previous-head-teacher-board-date-day")!.Value.Should().Be(project.PreviousHeadTeacherBoardDate?.Day.ToString()); - Document.QuerySelector("#previous-head-teacher-board-date-month")!.Value.Should().Be(project.PreviousHeadTeacherBoardDate?.Month.ToString()); - Document.QuerySelector("#previous-head-teacher-board-date-year")!.Value.Should().Be(project.PreviousHeadTeacherBoardDate?.Year.ToString()); - - await NavigateAsync("Back"); - - Document.Url.Should().BeUrl($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/previous-advisory-board"); - } - - [Fact] - public async Task Should_display_error_when_date_entered_is_not_in_the_past() - { - DateTime today = DateTime.Today; - AcademyConversionProject project = AddGetProject(); - AddPatchProject(project, r => r.PreviousHeadTeacherBoardDate, today); - - await OpenAndConfirmPathAsync($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/previous-advisory-board-date"); - - Document.QuerySelector("#previous-head-teacher-board-date-day")!.Value = today.Day.ToString(); - Document.QuerySelector("#previous-head-teacher-board-date-month")!.Value = today.Month.ToString(); - Document.QuerySelector("#previous-head-teacher-board-date-year")!.Value = today.Year.ToString(); - - await Document.QuerySelector("form")!.SubmitAsync(); - - Document.Url.Should().BeUrl($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/previous-advisory-board-date"); - - Document.QuerySelector(".govuk-error-summary").Should().NotBeNull(); - - Document.QuerySelector(".govuk-error-summary")!.TextContent.Should().Contain("Previous advisory board date must be in the past"); - } - - [Fact] - public async Task Should_display_error_when_user_attempts_to_save_without_entering_a_date() - { - AcademyConversionProject project = AddGetProject(); - AddPatchProject(project, r => r.PreviousHeadTeacherBoardDate, default(DateTime)); - - await OpenAndConfirmPathAsync($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/previous-advisory-board-date"); - - Document.QuerySelector("#previous-head-teacher-board-date-day")!.Value = ""; - Document.QuerySelector("#previous-head-teacher-board-date-month")!.Value = ""; - Document.QuerySelector("#previous-head-teacher-board-date-year")!.Value = ""; - - await Document.QuerySelector("form")!.SubmitAsync(); - - Document.Url.Should().BeUrl($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/previous-advisory-board-date"); - - Document.QuerySelector(".govuk-error-summary").Should().NotBeNull(); - Document.QuerySelector(".govuk-error-summary")!.TextContent.Should().Contain("Enter a date for the previous advisory board"); - } - - [Fact] - public async Task Should_display_error_when_user_attempts_to_an_invalid_date() - { - AcademyConversionProject project = AddGetProject(); - AddPatchProject(project, r => r.PreviousHeadTeacherBoardDate, default(DateTime)); - - await OpenAndConfirmPathAsync($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/previous-advisory-board-date"); - - Document.QuerySelector("#previous-head-teacher-board-date-day")!.Value = "230"; - Document.QuerySelector("#previous-head-teacher-board-date-month")!.Value = "2"; - Document.QuerySelector("#previous-head-teacher-board-date-year")!.Value = "2021"; - - await Document.QuerySelector("form")!.SubmitAsync(); - - Document.Url.Should().BeUrl($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/previous-advisory-board-date"); - - Document.QuerySelector(".govuk-error-summary").Should().NotBeNull(); - Document.QuerySelector(".govuk-error-summary")!.TextContent.Should().Contain("Day must be between 1 and 28"); - } - - [Fact] - public async Task Should_display_error_when_user_attempts_to_an_invalid_characters() - { - AcademyConversionProject project = AddGetProject(); - AddPatchProject(project, r => r.PreviousHeadTeacherBoardDate, default(DateTime)); - - await OpenAndConfirmPathAsync($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/previous-advisory-board-date"); - - Document.QuerySelector("#previous-head-teacher-board-date-day")!.Value = "testday"; - Document.QuerySelector("#previous-head-teacher-board-date-month")!.Value = "testmonth"; - Document.QuerySelector("#previous-head-teacher-board-date-year")!.Value = "testyear"; - - - await Document.QuerySelector("form")!.SubmitAsync(); - - Document.Url.Should().BeUrl($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/previous-advisory-board-date"); - - Document.QuerySelector(".govuk-error-summary").Should().NotBeNull(); - Document.QuerySelector(".govuk-error-summary")!.TextContent.Should().Contain("Enter a date in the correct format"); - } - - [Fact] - public async Task Should_show_error_summary_when_there_is_an_API_error() - { - AcademyConversionProject project = AddGetProject(); - AddPatchError(project.Id); - - await OpenAndConfirmPathAsync($"/task-list/{project.Id}/confirm-school-trust-information-project-dates/previous-advisory-board"); - - await Document.QuerySelector("form")!.SubmitAsync(); - - Document.QuerySelector(".govuk-error-summary").Should().NotBeNull(); - } -} diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Models/Links.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Models/Links.cs index c32b6e663..7a71cbb34 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Models/Links.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Models/Links.cs @@ -133,8 +133,6 @@ public static class SchoolAndTrustInformationSection public static readonly LinkItem Author = AddLinkItem(page: "/TaskList/SchoolAndTrustInformation/Author"); public static readonly LinkItem ClearedBy = AddLinkItem(page: "/TaskList/SchoolAndTrustInformation/ClearedBy"); public static readonly LinkItem HeadTeacherBoardDate = AddLinkItem(page: "/TaskList/SchoolAndTrustInformation/AdvisoryBoardDate"); - public static readonly LinkItem PreviousHeadTeacherBoardDateQuestion = AddLinkItem(page: "/TaskList/SchoolAndTrustInformation/PreviousAdvisoryBoard"); - public static readonly LinkItem PreviousHeadTeacherBoardDate = AddLinkItem(page: "/TaskList/SchoolAndTrustInformation/PreviousAdvisoryBoardDate"); public static readonly LinkItem Form7Received = AddLinkItem(page: "/TaskList/SchoolAndTrustInformation/Form7Received"); public static readonly LinkItem Form7ReceivedDate = AddLinkItem(page: "/TaskList/SchoolAndTrustInformation/Form7ReceivedDate"); public static readonly LinkItem ProposedAcademyOpeningDate = AddLinkItem(page: "/TaskList/SchoolAndTrustInformation/ProposedAcademyOpeningDate"); @@ -268,6 +266,16 @@ public static class NewProject public static readonly LinkItem CreateNewFormAMat = AddLinkItem(page: "/NewProject/CreateNewFormAMat"); public static readonly LinkItem Summary = AddLinkItem(page: "/NewProject/Summary"); } + + public static class ProjectDates + { + public static readonly LinkItem ConfirmProjectDates = AddLinkItem(page: "/TaskList/ProjectDates/ConfirmProjectDates"); + public static readonly LinkItem AdvisoryBoardDate = AddLinkItem(page: "/TaskList/ProjectDates/AdvisoryBoardDate"); + public static readonly LinkItem PreviousAdvisoryBoard = AddLinkItem(page: "/TaskList/ProjectDates/PreviousAdvisoryBoardDate"); + public static readonly LinkItem PropsedConversionDate = AddLinkItem(page: "/TaskList/ProjectDates/ProposedConversionDate"); + public static readonly LinkItem ReasonForConversionDateChange = AddLinkItem(page: "/TaskList/ProjectDates/ReasonForConversionDateChange"); + public static readonly LinkItem ConversionDateHistory = AddLinkItem(page: "/TaskList/ProjectDates/ConversionDateHistory"); + } } public class LinkItem diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Components/SchoolAndTrustInformation/default.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Components/SchoolAndTrustInformation/default.cshtml index 4405a4c1f..2e2a5816d 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Components/SchoolAndTrustInformation/default.cshtml +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Components/SchoolAndTrustInformation/default.cshtml @@ -30,9 +30,7 @@ - - diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_DateInput.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_DateInput.cshtml index e0400587f..a5dc69c44 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_DateInput.cshtml +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_DateInput.cshtml @@ -22,6 +22,32 @@ } } + @if (string.IsNullOrWhiteSpace(Model.PreviousInformation) is false) + { +
+

+ @Model.PreviousInformation @(Model.DateString) +

+
+ } + + @if (string.IsNullOrWhiteSpace(Model.SubLabel) is false) + { + + @Model.SubLabel + + } + + @if (string.IsNullOrWhiteSpace(Model.AdditionalInformation) is false) + { +
+

+ @Model.AdditionalInformation +

+
+ } + +
@Model.Hint diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_SubMenu.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_SubMenu.cshtml index 7f3b229c8..212c73f8f 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_SubMenu.cshtml +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_SubMenu.cshtml @@ -74,5 +74,13 @@ +
  • + + Conversion date history + +
  • + \ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_SummaryListRow.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_SummaryListRow.cshtml index 6e7b4ece2..7ae732cc8 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_SummaryListRow.cshtml +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_SummaryListRow.cshtml @@ -35,25 +35,12 @@ { if (ViewData["IncludeFragment"] is bool includeFragment && includeFragment) { - if (Model.Page == Links.SchoolAndTrustInformationSection.PreviousHeadTeacherBoardDateQuestion.Page) - { - - Change@Model.HiddenText - - } - else - { - - Change@Model.HiddenText - - } + + Change@Model.HiddenText + } else if (!string.IsNullOrEmpty(Model.Fragment)) { diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/Index.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/Index.cshtml index 57f9a7c59..f5adc3bfa 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/Index.cshtml +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/Index.cshtml @@ -31,6 +31,21 @@

    You can complete them in any order.

    +

    Advisory board and conversion dates

    +
    + +
    + +

    Add school information

    diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/ProjectDates/AdvisoryBoardDate.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/ProjectDates/AdvisoryBoardDate.cshtml new file mode 100644 index 000000000..5b83bffe7 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/ProjectDates/AdvisoryBoardDate.cshtml @@ -0,0 +1,26 @@ +@page "/task-list/{id:int}/advisory-board-date" +@using Dfe.PrepareConversions.TagHelpers +@using Dfe.Academisation.ExtensionMethods +@model Dfe.PrepareConversions.Pages.TaskList.ProjectDates.AdvisoryBoardDateModel; +@{ + Layout = "_QuestionLayout"; + ViewData["Title"] = (ViewData.ModelState.IsValid ? "" : "Error: ") + "Advisory board date"; + ViewData["ShowScheduleOfAdvisoryBoardMeetingsLink"] = true; + ViewData["SchoolName"] = Model.Project.SchoolName; + ViewData["ProjectId"] = Model.Project.Id; + ViewData["AcademyTypeAndRoute"] = Model.Project.AcademyTypeAndRoute; +} + +@section BeforeMain +{ + +} + +@if (!Model.Project.HeadTeacherBoardDate.HasValue) +{ + +}else{ + + +} + diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/ProjectDates/AdvisoryBoardDate.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/ProjectDates/AdvisoryBoardDate.cshtml.cs new file mode 100644 index 000000000..1c2f61212 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/ProjectDates/AdvisoryBoardDate.cshtml.cs @@ -0,0 +1,66 @@ +using Dfe.PrepareConversions.Data.Models; +using Dfe.PrepareConversions.Data.Services; +using Dfe.PrepareConversions.Models; +using Dfe.PrepareConversions.Services; +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Threading.Tasks; + +namespace Dfe.PrepareConversions.Pages.TaskList.ProjectDates; + +public class AdvisoryBoardDateModel : BaseAcademyConversionProjectPageModel, IDateValidationMessageProvider +{ + private readonly ErrorService _errorService; + + public AdvisoryBoardDateModel(IAcademyConversionProjectRepository repository, + ErrorService errorService) + : base(repository) + { + _errorService = errorService; + } + + [BindProperty(Name = "advisory-board-date", BinderType = typeof(DateInputModelBinder))] + //[DateValidation(DateRangeValidationService.DateRange.PastOrToday)] + [Required] + public DateTime? AdvisoryBoardDate { get; set; } + + public bool ShowError { get; set; } + + string IDateValidationMessageProvider.SomeMissing(string displayName, IEnumerable missingParts) + { + return $"Date must include a {string.Join(" and ", missingParts)}"; + } + + string IDateValidationMessageProvider.AllMissing(string displayName) + { + return $"Enter the advisory board date"; + } + + public override async Task OnGetAsync(int id) + { + await base.OnGetAsync(id); + + + return Page(); + } + + public override async Task OnPostAsync(int id) + { + await base.OnGetAsync(id); + + if (!ModelState.IsValid) + { + _errorService.AddErrors(Request.Form.Keys, ModelState); + ShowError = true; + return await base.OnGetAsync(id); + } + + var projectDatesModel = new SetProjectDatesModel(id, AdvisoryBoardDate, Project.PreviousHeadTeacherBoardDate, Project.ProposedConversionDate, Project.ProjectDatesSectionComplete); + + await _repository.SetProjectDates(id, projectDatesModel); + + return RedirectToPage(Links.ProjectDates.ConfirmProjectDates.Page, new { id }); + } +} diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/ProjectDates/ConfirmProjectDates.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/ProjectDates/ConfirmProjectDates.cshtml new file mode 100644 index 000000000..c5e27284e --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/ProjectDates/ConfirmProjectDates.cshtml @@ -0,0 +1,37 @@ +@page "/task-list/{id:int}/confirm-project-dates" +@using Dfe.Academisation.ExtensionMethods +@using Dfe.PrepareConversions.TagHelpers +@model Dfe.PrepareConversions.Pages.TaskList.ProjectDates.ConfirmProjectDatesModel +@{ + ViewData["Title"] = "Confirm project dates"; +} + +@section BeforeMain +{ + +} + +
    +
    + @Model.Project.SchoolName +

    + Confirm project dates +

    +
    +
    +
    + + + +
    +
    +
    +
    + + + + +
    +
    \ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/ProjectDates/ConfirmProjectDates.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/ProjectDates/ConfirmProjectDates.cshtml.cs new file mode 100644 index 000000000..7eeaa75b9 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/ProjectDates/ConfirmProjectDates.cshtml.cs @@ -0,0 +1,42 @@ +using Dfe.PrepareConversions.Data.Models; +using Dfe.PrepareConversions.Data.Services; +using Dfe.PrepareConversions.Models; +using Dfe.PrepareConversions.Services; +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Threading.Tasks; + +namespace Dfe.PrepareConversions.Pages.TaskList.ProjectDates; + +public class ConfirmProjectDatesModel : BaseAcademyConversionProjectPageModel +{ + private readonly ErrorService _errorService; + + public ConfirmProjectDatesModel(IAcademyConversionProjectRepository repository, ErrorService errorService): base(repository) + { + _errorService = errorService; + } + + [BindProperty(Name = "project-dates-complete", BinderType = typeof(CheckboxInputModelBinder))] + public bool ProjectDatesSectionComplete { get; set; } + + public override async Task OnGetAsync(int id) + { + await SetProject(id); + + return Page(); + } + + public override async Task OnPostAsync(int id) + { + await SetProject(id); + + var projectDatesModel = new SetProjectDatesModel(id, Project.HeadTeacherBoardDate, Project.PreviousHeadTeacherBoardDate, Project.ProposedConversionDate, ProjectDatesSectionComplete); + + await _repository.SetProjectDates(id, projectDatesModel); + + return RedirectToPage(Links.TaskList.Index.Page , new { id }); + } +} diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/ProjectDates/ConversionDateHistory.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/ProjectDates/ConversionDateHistory.cshtml new file mode 100644 index 000000000..440c2fc39 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/ProjectDates/ConversionDateHistory.cshtml @@ -0,0 +1,74 @@ +@page "/task-list/{id:int}/conversion-date-history" +@using Dfe.PrepareConversions.TagHelpers +@using Dfe.Academisation.ExtensionMethods +@model Dfe.PrepareConversions.Pages.TaskList.ProjectDates.ConversionDateHistoryPageModel; +@{ + ViewData["Title"] = (ViewData.ModelState.IsValid ? "" : "Error: ") + "Conversion date history"; + +} + +@section BeforeMain +{ + +} + + + + +
    + + @if (Model.Project.ProposedConversionDate.HasValue) + { +

    Current proposed conversion date

    + +

    The current proposed conversion date is @Model.Project.ProposedConversionDate.ToDateString().

    + }else + { +

    The proposed conversion date has not been entered yet. When it has been it will be displayed here.

    +

    Any future changes to the proposed conversion date will also be shown here.

    + } + + @if (Model.History != null && Model.History.Any()) + { +

    Conversion date changes

    + @foreach (var history in Model.History.OrderByDescending(h => h.ChangedAt)) + { +
    +
    +

    + Changed on @history.ChangedAt.ToString("dd MMMM yyyy h:mmtt") +

    +
    +
    +
    +
    +
    Changed by
    +
    @history.ChangedBy
    +
    +
    +
    Date changed to
    +
    @history.NewDate?.ToString("d MMMM yyyy")
    +
    +
    +
    Date changed from
    +
    @history.OldDate?.ToString("d MMMM yyyy")
    +
    +
    + +
    Reason for new date
    + @foreach (var reason in history.ReasonsChanged) + { +
    + @reason.Heading
    + @reason.Details +
    + } + +
    +
    +
    +
    + } + } + +
    diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/ProjectDates/ConversionDateHistory.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/ProjectDates/ConversionDateHistory.cshtml.cs new file mode 100644 index 000000000..d5d691a3d --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/ProjectDates/ConversionDateHistory.cshtml.cs @@ -0,0 +1,35 @@ +using Dfe.PrepareConversions.Data.Models; +using Dfe.PrepareConversions.Data.Services; +using Dfe.PrepareConversions.Services; +using DocumentFormat.OpenXml.Office2010.ExcelAc; +using Microsoft.AspNetCore.Mvc; +using System.Collections; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Dfe.PrepareConversions.Pages.TaskList.ProjectDates; + +public class ConversionDateHistoryPageModel : BaseAcademyConversionProjectPageModel +{ + private readonly ErrorService _errorService; + + public IEnumerable History { get; set; } + + + public ConversionDateHistoryPageModel(IAcademyConversionProjectRepository repository, + ErrorService errorService) + : base(repository) + { + _errorService = errorService; + } + + + public override async Task OnGetAsync(int id) + { + await base.OnGetAsync(id); + + History = (await _repository.GetOpeningDateHistoryForConversionProject(id)).Body; + + return Page(); + } +} diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/ProjectDates/PreviousAdvisoryBoardDate.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/ProjectDates/PreviousAdvisoryBoardDate.cshtml new file mode 100644 index 000000000..f24c86ba1 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/ProjectDates/PreviousAdvisoryBoardDate.cshtml @@ -0,0 +1,15 @@ +@page "/task-list/{id:int}/previous-advisory-board-date" +@using Dfe.PrepareConversions.TagHelpers +@model Dfe.PrepareConversions.Pages.TaskList.ProjectDates.PreviousAdvisoryBoardDateModel +@{ + Layout = "_QuestionLayout"; + ViewData["Title"] = (ViewData.ModelState.IsValid ? "" : "Error: ") + "Date of previous advisory board"; + ViewData["AcademyTypeAndRoute"] = Model.Project.AcademyTypeAndRoute; +} + +@section BeforeMain +{ + +} + + \ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/ProjectDates/PreviousAdvisoryBoardDate.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/ProjectDates/PreviousAdvisoryBoardDate.cshtml.cs new file mode 100644 index 000000000..25b1410b4 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/ProjectDates/PreviousAdvisoryBoardDate.cshtml.cs @@ -0,0 +1,66 @@ +using Dfe.PrepareConversions.Data.Models; +using Dfe.PrepareConversions.Data.Services; +using Dfe.PrepareConversions.Models; +using Dfe.PrepareConversions.Services; +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Threading.Tasks; + +namespace Dfe.PrepareConversions.Pages.TaskList.ProjectDates; + +public class PreviousAdvisoryBoardDateModel : BaseAcademyConversionProjectPageModel, IDateValidationMessageProvider +{ + private readonly ErrorService _errorService; + + public PreviousAdvisoryBoardDateModel(IAcademyConversionProjectRepository repository, + ErrorService errorService) + : base(repository) + { + _errorService = errorService; + } + + [BindProperty(Name = "previous-advisory-board", BinderType = typeof(DateInputModelBinder))] + //[DateValidation(DateRangeValidationService.DateRange.PastOrToday)] + [Required] + public DateTime? PreviousAdvisoryBoard { get; set; } + + public bool ShowError { get; set; } + + string IDateValidationMessageProvider.SomeMissing(string displayName, IEnumerable missingParts) + { + return $"Date must include a {string.Join(" and ", missingParts)}"; + } + + string IDateValidationMessageProvider.AllMissing(string displayName) + { + return $"Enter the previous advisory board"; + } + + public override async Task OnGetAsync(int id) + { + await base.OnGetAsync(id); + + + return Page(); + } + + public override async Task OnPostAsync(int id) + { + await base.OnGetAsync(id); + + if (!ModelState.IsValid) + { + _errorService.AddErrors(Request.Form.Keys, ModelState); + ShowError = true; + return await base.OnGetAsync(id); + } + + var projectDatesModel = new SetProjectDatesModel(id, Project.HeadTeacherBoardDate, PreviousAdvisoryBoard, Project.ProposedConversionDate, Project.ProjectDatesSectionComplete); + + await _repository.SetProjectDates(id, projectDatesModel); + + return RedirectToPage(Links.ProjectDates.ConfirmProjectDates.Page, new { id }); + } +} diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/ProjectDates/ProposedConversionDate.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/ProjectDates/ProposedConversionDate.cshtml new file mode 100644 index 000000000..46da769a1 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/ProjectDates/ProposedConversionDate.cshtml @@ -0,0 +1,109 @@ +@page "/task-list/{id:int}/proposed-conversion-date" +@using Dfe.PrepareConversions.TagHelpers +@using Dfe.Academisation.ExtensionMethods +@model Dfe.PrepareConversions.Pages.TaskList.ProjectDates.ProposedConversionDate +@{ + Layout = "_QuestionLayout"; + ViewData["Title"] = (ViewData.ModelState.IsValid ? "" : "Error: ") + "Proposed conversion date"; + ViewData["AcademyTypeAndRoute"] = Model.Project.AcademyTypeAndRoute; + var showError = Model.ShowError; +} + +@section BeforeMain +{ + +} + +
    +
    + + +

    + Proposed conversion date +

    +
    + + @if (Model.Project.ProposedConversionDate.HasValue) + { +

    + The current proposed conversion is @Model.Project.ProposedConversionDate.ToDateString(). +

    + } + +
    +

    + You can change the conversion date at any time during the project. Any new date must be agreed with the school and all other stakeholders +

    +
    + + + Enter proposed conversion date + + + + @if (Model.Project.ProposedConversionDate.HasValue) + { +
    + + + Changing the proposed conversion date + + +
    +

    + You can change the conversion date at any time during the project. Any new date must be agreed with the school and all other stakeholders. +

    +

    + You should change the proposed conversion date if there are delays or complications that mean it is likely the current date will not be met. +

    +

    + It is essential you enter a new date if it changes. This information is used by funding teams to prepare and organise grant payments. +

    +

    + If you do not update this information, schools may not get their funding on time. +

    +
    +
    + } + +
    + You only need to enter a month and a year as all schools convert on the first day of the month. +
    + For example, 3 2021 +
    + + @if (showError) + { + + Error: @Model.ErrorMessage + + } + +
    +
    + + +
    +
    +
    +
    + + +
    +
    + + +
    +
    \ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/ProjectDates/ProposedConversionDate.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/ProjectDates/ProposedConversionDate.cshtml.cs new file mode 100644 index 000000000..b412baa23 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/ProjectDates/ProposedConversionDate.cshtml.cs @@ -0,0 +1,130 @@ +using Dfe.PrepareConversions.Data.Models; +using Dfe.PrepareConversions.Data.Services; +using Dfe.PrepareConversions.Models; +using Dfe.PrepareConversions.Services; +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Dfe.PrepareConversions.Pages.TaskList.ProjectDates; + +public class ProposedConversionDate : BaseAcademyConversionProjectPageModel +{ + private readonly ErrorService _errorService; + + public ProposedConversionDate(IAcademyConversionProjectRepository repository, + ErrorService errorService) + : base(repository) + { + _errorService = errorService; + } + + [BindProperty(Name = "proposed-conversion-month")] + public string Month { get; set; } + + [BindProperty(Name = "proposed-conversion-year")] + public string Year { get; set; } + + public bool MonthIsValid { get;set; } + public bool YearIsValid { get; set; } + + public bool ShowError => _errorService.HasErrors(); + public string ErrorMessage => _errorService.GetErrors().ToList().Last().Message; + + public override async Task OnGetAsync(int id) + { + await base.OnGetAsync(id); + + + var conversionDate = Project.ProposedConversionDate; + if (conversionDate.HasValue) + { + Month = conversionDate?.Month.ToString(); + Year = conversionDate?.Year.ToString(); + } + + return Page(); + } + + public override async Task OnPostAsync(int id) + { + await base.OnGetAsync(id); + + ValidateDate(); + if (_errorService.HasErrors()) + { + return await OnGetAsync(id); + } + + var conversionDate = $"{Year}-{Month}-1"; + + if (!Project.ProposedConversionDate.HasValue) + { + var parsedConversionDate = DateTime.Parse(conversionDate); + var projectDatesModel = new SetProjectDatesModel(id, Project.HeadTeacherBoardDate, Project.PreviousHeadTeacherBoardDate, parsedConversionDate, Project.ProjectDatesSectionComplete); + + await _repository.SetProjectDates(id, projectDatesModel); + + return RedirectToPage(Links.ProjectDates.ConfirmProjectDates.Page, new { id }); + + } + + return RedirectToPage(Links.ProjectDates.ReasonForConversionDateChange.Page, new { id, conversionDate }); + } + + private void ValidateDate() + { + List missingParts = new(); + + if (string.IsNullOrWhiteSpace(Month)) missingParts.Add("month"); + if (string.IsNullOrWhiteSpace(Year)) missingParts.Add("year"); + + if (missingParts.Count == 2) + { + _errorService.AddError("proposed-conversion-month", "Enter the proposed conversion date"); + return; + } + + if (missingParts.Count > 0) + { + _errorService.AddError("proposed-conversion-month", SomeMissing(missingParts)); + return; + } + + YearIsValid = int.TryParse(Year, out int year); + MonthIsValid = int.TryParse(Month, out int month); + + if (!YearIsValid || !MonthIsValid) + { + _errorService.AddError("proposed-conversion-month", "Enter a date in the correct format"); + return; + } + + if (month < 1 || month > 12) + { + _errorService.AddError("proposed-conversion-month", "Month must be between 1 and 12"); + return; + } + + if (year < 2000 || year > 2050) + { + _errorService.AddError("proposed-conversion-year", "Year must be between 2000 and 2050"); + return; + } + + var existingConversionDate = Project.ProposedConversionDate; + + if (existingConversionDate.HasValue && existingConversionDate.Value.Month == month && existingConversionDate.Value.Year == year) + { + _errorService.AddError("proposed-conversion-month", "New date cannot be the same as the current date"); + return; + } + } + + private string SomeMissing(IEnumerable missingParts) + { + return $"Date must include a {string.Join(" and ", missingParts)}"; + } +} \ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/ProjectDates/ReasonForConversionDateChange.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/ProjectDates/ReasonForConversionDateChange.cshtml new file mode 100644 index 000000000..4542c7996 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/ProjectDates/ReasonForConversionDateChange.cshtml @@ -0,0 +1,106 @@ +@page "/task-list/{id:int}/reason-for-conversion-change" +@using Dfe.PrepareConversions.Data.Models.AcademyConversion +@using Dfe.PrepareConversions.TagHelpers +@using Dfe.Academisation.ExtensionMethods +@model Dfe.PrepareConversions.Pages.TaskList.ProjectDates.ReasonForConversionDateChangePageModel +@{ + Layout = "_QuestionLayout"; + ViewData["Title"] = (ViewData.ModelState.IsValid ? "" : "Error: ") + "Proposed conversion date"; + ViewData["AcademyTypeAndRoute"] = Model.Project.AcademyTypeAndRoute; + var showErrorClass = Model.ShowError ? "govuk-form-group--error" : ""; +} + +@section BeforeMain +{ + +} + +@if (@Model.ShowError) +{ + + Error: @Model.ErrorMessage + +} + +
    +
    + +

    + Reason for date change +

    +
    + +
    + Select all that apply. +
    + +
    + @if (Model.NewDateIsInThePast) + { + @foreach (var changeOption in Model.PastReasonForChangeOptions) + { +
    + + +
    + +
    +
    + + + +
    +
    + } + } + else + { + @foreach (var changeOption in Model.FutureReasonForChangeOptions) + { +
    + + +
    + +
    +
    + + + +
    +
    + } + } +
    +
    +
    \ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/ProjectDates/ReasonForConversionDateChange.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/ProjectDates/ReasonForConversionDateChange.cshtml.cs new file mode 100644 index 000000000..e0336cc7f --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/ProjectDates/ReasonForConversionDateChange.cshtml.cs @@ -0,0 +1,235 @@ +using Dfe.Academisation.ExtensionMethods; +using Dfe.PrepareConversions.Data.Models; +using Dfe.PrepareConversions.Data.Models.AcademyConversion; +using Dfe.PrepareConversions.Data.Services; +using Dfe.PrepareConversions.Models; +using Dfe.PrepareConversions.Services; +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Dfe.PrepareConversions.Pages.TaskList.ProjectDates; + +public class ReasonForConversionDateChangePageModel : BaseAcademyConversionProjectPageModel +{ + private readonly ErrorService _errorService; + + public IEnumerable PastReasonForChangeOptions { get; set; } + public IEnumerable FutureReasonForChangeOptions { get; set; } + + [BindProperty] + public IEnumerable ChangedReasons { get; set; } + + [BindProperty] + public string ChangeIncomingTrustReason { get; set; } + + [BindProperty] + public string ChangeSchoolReason { get; set; } + + [BindProperty] + public string ChangeLAReason { get; set; } + + [BindProperty] + public string ChangeDioceseReason { get; set; } + + [BindProperty] + public string ChangeTuPEReason { get; set; } + + [BindProperty] + public string ChangePensionsReason { get; set; } + + [BindProperty] + public string ChangeUnionReason { get; set; } + + [BindProperty] + public string ChangeNegativePressCoverageReason { get; set; } + + [BindProperty] + public string ChangeGovernanceReason { get; set; } + + [BindProperty] + public string ChangeNotAppliFinancecableReason { get; set; } + + [BindProperty] + public string ChangeFinanceReason { get; set; } + + [BindProperty] + public string ChangeViabilityReason { get; set; } + + [BindProperty] + public string ChangeLandReason { get; set; } + + [BindProperty] + public string ChangeBuildingsReason { get; set; } + + [BindProperty] + public string ChangeLegalDocumentsReason { get; set; } + + [BindProperty] + public string ChangeCorrectingAnErrorReason { get; set; } + + [BindProperty] + public string ChangeVoluntaryDeferralReason { get; set; } + + [BindProperty] + public string ChangeInAFederationReason { get; set; } + + [BindProperty] + public string ChangeProgressingFasterReason { get; set; } + + public UIHelpers UI => new(this); + + public bool ShowError { get; set; } + public string ErrorMessage => _errorService.GetErrors().ToList().Last().Message; + + public DateTime ConversionDate { get; set; } + public bool NewDateIsInThePast { get; set; } + + + public ReasonForConversionDateChangePageModel(IAcademyConversionProjectRepository repository, + ErrorService errorService) + : base(repository) + { + _errorService = errorService; + PastReasonForChangeOptions = Enum.GetValues(typeof(ConversionDateReasonForChangePast)).Cast(); + FutureReasonForChangeOptions = Enum.GetValues(typeof(ConversionDateReasonForChangeFuture)).Cast(); + } + + public override async Task OnGetAsync(int id) + { + await base.OnGetAsync(id); + + ConversionDate = DateTime.Parse(Request.Query["conversionDate"]); + + var previousConversionDate = Project.ProposedConversionDate; + + if (previousConversionDate > ConversionDate) + { + NewDateIsInThePast = true; + } + + return Page(); + } + + public override async Task OnPostAsync(int id) + { + await OnGetAsync(id); + + if (!ChangedReasons.Any()) + { + _errorService.AddError("ChangedReasonSet", "Select at least one reason"); + } + + EnsureExplanationIsProvidedFor(ConversionDateReasonForChangeFuture.IncomingTrust, ChangeIncomingTrustReason); + EnsureExplanationIsProvidedFor(ConversionDateReasonForChangeFuture.School, ChangeSchoolReason); + EnsureExplanationIsProvidedFor(ConversionDateReasonForChangeFuture.LA, ChangeLAReason); + EnsureExplanationIsProvidedFor(ConversionDateReasonForChangeFuture.Diocese, ChangeDioceseReason); + EnsureExplanationIsProvidedFor(ConversionDateReasonForChangeFuture.TuPE, ChangeTuPEReason); + EnsureExplanationIsProvidedFor(ConversionDateReasonForChangeFuture.Pensions, ChangePensionsReason); + EnsureExplanationIsProvidedFor(ConversionDateReasonForChangeFuture.Union, ChangeUnionReason); + EnsureExplanationIsProvidedFor(ConversionDateReasonForChangeFuture.NegativePressCoverage, ChangeNegativePressCoverageReason); + EnsureExplanationIsProvidedFor(ConversionDateReasonForChangeFuture.Governance, ChangeGovernanceReason); + EnsureExplanationIsProvidedFor(ConversionDateReasonForChangeFuture.Finance, ChangeFinanceReason); + EnsureExplanationIsProvidedFor(ConversionDateReasonForChangeFuture.Viability, ChangeViabilityReason); + EnsureExplanationIsProvidedFor(ConversionDateReasonForChangeFuture.Land, ChangeLandReason); + EnsureExplanationIsProvidedFor(ConversionDateReasonForChangeFuture.Buildings, ChangeBuildingsReason); + EnsureExplanationIsProvidedFor(ConversionDateReasonForChangeFuture.LegalDocuments, ChangeLegalDocumentsReason); + EnsureExplanationIsProvidedFor(ConversionDateReasonForChangeFuture.CorrectingAnError, ChangeCorrectingAnErrorReason); + EnsureExplanationIsProvidedFor(ConversionDateReasonForChangeFuture.VoluntaryDeferral, ChangeVoluntaryDeferralReason); + EnsureExplanationIsProvidedFor(ConversionDateReasonForChangeFuture.InAFederation, ChangeInAFederationReason); + + EnsureExplanationIsProvidedFor(ConversionDateReasonForChangePast.ProgressingFaster, ChangeProgressingFasterReason); + + if (_errorService.HasErrors()) + { + ShowError = true; + return await OnGetAsync(id); + } + + var projectDatesModel = new SetProjectDatesModel(id, Project.HeadTeacherBoardDate, Project.PreviousHeadTeacherBoardDate, ConversionDate, Project.ProjectDatesSectionComplete, User.Identity.Name, MapSelectedReasons()); + + await _repository.SetProjectDates(id, projectDatesModel); + + return RedirectToPage(Links.ProjectDates.ConfirmProjectDates.Page, new { id }); + } + + private void EnsureExplanationIsProvidedFor(Enum reason, string explanation) + { + string reasonName = reason.ToString(); + + if (ChangedReasons.Contains(reasonName) && string.IsNullOrWhiteSpace(explanation)) + _errorService.AddError(UI.ReasonFieldFor(reason), $"Enter a reason for selecting {reason.ToDescription()}"); + } + + private IEnumerable MapSelectedReasons() + { + if (NewDateIsInThePast) + { + return ChangedReasons + .Select(reasonText => Enum.Parse(reasonText, true)) + .Select(reason => reason switch + { + ConversionDateReasonForChangePast.ProgressingFaster => new ReasonChange(reason.ToDescription(), ChangeProgressingFasterReason), + ConversionDateReasonForChangePast.CorrectingAnError => new ReasonChange(reason.ToDescription(), ChangeCorrectingAnErrorReason), + _ => throw new ArgumentOutOfRangeException(nameof(reason), reason, "Unexpected value for ReasonChange") + }); + } + else + { + return ChangedReasons + .Select(reasonText => Enum.Parse(reasonText, true)) + .Select(reason => reason switch + { + ConversionDateReasonForChangeFuture.IncomingTrust => new ReasonChange(reason.ToDescription(), ChangeIncomingTrustReason), + ConversionDateReasonForChangeFuture.School => new ReasonChange(reason.ToDescription(), ChangeSchoolReason), + ConversionDateReasonForChangeFuture.LA => new ReasonChange(reason.ToDescription(), ChangeLAReason), + ConversionDateReasonForChangeFuture.Diocese => new ReasonChange(reason.ToDescription(), ChangeDioceseReason), + ConversionDateReasonForChangeFuture.TuPE => new ReasonChange(reason.ToDescription(), ChangeTuPEReason), + ConversionDateReasonForChangeFuture.Pensions => new ReasonChange(reason.ToDescription(), ChangePensionsReason), + ConversionDateReasonForChangeFuture.Union => new ReasonChange(reason.ToDescription(), ChangeUnionReason), + ConversionDateReasonForChangeFuture.NegativePressCoverage => new ReasonChange(reason.ToDescription(), ChangeNegativePressCoverageReason), + ConversionDateReasonForChangeFuture.Finance => new ReasonChange(reason.ToDescription(), ChangeNegativePressCoverageReason), + ConversionDateReasonForChangeFuture.Governance => new ReasonChange(reason.ToDescription(), ChangeFinanceReason), + ConversionDateReasonForChangeFuture.Viability => new ReasonChange(reason.ToDescription(), ChangeViabilityReason), + ConversionDateReasonForChangeFuture.Land => new ReasonChange(reason.ToDescription(), ChangeLandReason), + ConversionDateReasonForChangeFuture.Buildings => new ReasonChange(reason.ToDescription(), ChangeBuildingsReason), + ConversionDateReasonForChangeFuture.LegalDocuments => new ReasonChange(reason.ToDescription(), ChangeLegalDocumentsReason), + ConversionDateReasonForChangeFuture.CorrectingAnError => new ReasonChange(reason.ToDescription(), ChangeCorrectingAnErrorReason), + ConversionDateReasonForChangeFuture.VoluntaryDeferral => new ReasonChange(reason.ToDescription(), ChangeVoluntaryDeferralReason), + ConversionDateReasonForChangeFuture.InAFederation => new ReasonChange(reason.ToDescription(), ChangeInAFederationReason), + _ => throw new ArgumentOutOfRangeException(nameof(reason), reason, "Unexpected value for ReasonChange") + }); + } + + } + + public class UIHelpers + { + private readonly ReasonForConversionDateChangePageModel _model; + + public UIHelpers(ReasonForConversionDateChangePageModel model) + { + _model = model; + } + + public string IdFor(string prefix, object item) + { + string connector = prefix.EndsWith('-') ? string.Empty : "-"; + string suffix = item?.ToString()?.ToLowerInvariant(); + + return $"{prefix}{connector}{suffix}"; + } + + public string ValueFor(object item) + { + return item.ToString(); + } + + public string ReasonFieldFor(object item) + { + return $"Change{item}Reason"; + } + } +} \ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/SchoolAndTrustInformation/PreviousAdvisoryBoard.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/SchoolAndTrustInformation/PreviousAdvisoryBoard.cshtml deleted file mode 100644 index 7f4802f97..000000000 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/SchoolAndTrustInformation/PreviousAdvisoryBoard.cshtml +++ /dev/null @@ -1,19 +0,0 @@ -@page "/task-list/{id:int}/confirm-school-trust-information-project-dates/previous-advisory-board" -@using Dfe.PrepareConversions.TagHelpers -@model Dfe.PrepareConversions.Pages.TaskList.SchoolAndTrustInformation.PreviousHeadTeacherBoardDateQuestion -@{ - Layout = "_QuestionLayout"; - Model.SuccessPage = Links.SchoolAndTrustInformationSection.PreviousHeadTeacherBoardDate.Page; - ViewData["Title"] = "Has this project been to a previous advisory board"; - ViewData["SchoolName"] = Model.Project.SchoolName; - ViewData["ProjectId"] = Model.Project.Id; - ViewData["AcademyTypeAndRoute"] = Model.Project.AcademyTypeAndRoute; - var values = new[] { "Yes", "No" }; -} - -@section BeforeMain -{ - -} - - \ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/SchoolAndTrustInformation/PreviousAdvisoryBoard.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/SchoolAndTrustInformation/PreviousAdvisoryBoard.cshtml.cs deleted file mode 100644 index 2dda1722e..000000000 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/SchoolAndTrustInformation/PreviousAdvisoryBoard.cshtml.cs +++ /dev/null @@ -1,76 +0,0 @@ -using Dfe.PrepareConversions.Data; -using Dfe.PrepareConversions.Data.Models; -using Dfe.PrepareConversions.Data.Services; -using Dfe.PrepareConversions.Models; -using Dfe.PrepareConversions.Services; -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Primitives; -using System.Threading.Tasks; - -namespace Dfe.PrepareConversions.Pages.TaskList.SchoolAndTrustInformation; - -public class PreviousHeadTeacherBoardDateQuestion : UpdateAcademyConversionProjectPageModel -{ - private readonly ErrorService _errorService; - - public PreviousHeadTeacherBoardDateQuestion(IAcademyConversionProjectRepository repository, ErrorService errorService) : base(repository, errorService) - { - _errorService = errorService; - } - - private bool IsNo() - { - return AcademyConversionProject.PreviousHeadTeacherBoardDateQuestion != "Yes"; - } - - public override async Task OnPostAsync(int id) - { - _errorService.AddErrors(Request.Form.Keys, ModelState); - if (_errorService.HasErrors()) - { - await SetProject(id); - return Page(); - } - - ApiResponse response = await _repository.UpdateProject(id, Build()); - - if (!response.Success) - { - _errorService.AddApiError(); - await SetProject(id); - return Page(); - } - - (string returnPage, string fragment, string back) = GetReturnPageAndFragment(); - - if (IsNo()) - { - return ReturnPage(returnPage) - ? RedirectToPage(Links.TaskList.PreviewHTBTemplate.Page, null, new { id }, "previous-head-teacher-board") - : RedirectToPage(Links.SchoolAndTrustInformationSection.ConfirmSchoolAndTrustInformation.Page, new { id }); - } - - if (ReturnPage(returnPage)) - { - fragment ??= "previous-head-teacher-board"; - return !string.IsNullOrEmpty(back) - ? RedirectToPage(returnPage, null, new { id, @return = back, back = Links.SchoolAndTrustInformationSection.PreviousHeadTeacherBoardDateQuestion.Page }, fragment) - : RedirectToPage(returnPage, null, new { id }, fragment); - } - - return RedirectToPage(SuccessPage, new { id }); - } - - private static bool ReturnPage(string returnPage) - { - return !string.IsNullOrWhiteSpace(returnPage); - } - - private (string, string, string) GetReturnPageAndFragment() - { - Request.Query.TryGetValue("return", out StringValues returnQuery); - Request.Query.TryGetValue("fragment", out StringValues fragmentQuery); - Request.Query.TryGetValue("back", out StringValues backQuery); - return (returnQuery, fragmentQuery, backQuery); - } -} diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/SchoolAndTrustInformation/PreviousAdvisoryBoardDate.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/SchoolAndTrustInformation/PreviousAdvisoryBoardDate.cshtml deleted file mode 100644 index 35330b8ba..000000000 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/SchoolAndTrustInformation/PreviousAdvisoryBoardDate.cshtml +++ /dev/null @@ -1,16 +0,0 @@ -@page "/task-list/{id:int}/confirm-school-trust-information-project-dates/previous-advisory-board-date" -@using Dfe.PrepareConversions.TagHelpers -@model Dfe.PrepareConversions.Pages.UpdateAcademyConversionProjectPageModel -@{ - Layout = "_QuestionLayout"; - Model.SuccessPage = Links.SchoolAndTrustInformationSection.ConfirmSchoolAndTrustInformation.Page; - ViewData["Title"] = (ViewData.ModelState.IsValid ? "" : "Error: ") + "Date of previous advisory board"; - ViewData["AcademyTypeAndRoute"] = Model.Project.AcademyTypeAndRoute; -} - -@section BeforeMain -{ - -} - - \ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/AcademyConversionProjectItemsCacheDecorator.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/AcademyConversionProjectItemsCacheDecorator.cs index b989d0762..03e7b52eb 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/AcademyConversionProjectItemsCacheDecorator.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/AcademyConversionProjectItemsCacheDecorator.cs @@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using System.Collections.Generic; +using System.Net.Http; using System.Threading.Tasks; namespace Dfe.PrepareConversions.Services; @@ -153,4 +154,14 @@ public async Task UpdateSchoolImprovementPlan(int id, UpdateSchoolImprovementPla { await _innerRepository.UpdateSchoolImprovementPlan(id, updateSchoolImprovementPlan); } + + public async Task SetProjectDates(int id, SetProjectDatesModel updatedProjectDates) + { + await _innerRepository.SetProjectDates(id, updatedProjectDates); + } + + public async Task>> GetOpeningDateHistoryForConversionProject(int id) + { + return await _innerRepository.GetOpeningDateHistoryForConversionProject(id); + } } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/TagHelpers/DateInputTagHelper.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/TagHelpers/DateInputTagHelper.cs index e801daa47..b85d3eabb 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/TagHelpers/DateInputTagHelper.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/TagHelpers/DateInputTagHelper.cs @@ -1,4 +1,5 @@ -using Dfe.PrepareConversions.Models; +using Dfe.Academisation.ExtensionMethods; +using Dfe.PrepareConversions.Models; using Dfe.PrepareConversions.Services; using Dfe.PrepareConversions.ViewModels; using Microsoft.AspNetCore.Html; @@ -42,8 +43,12 @@ private DateInputViewModel ValidateRequest() Id = Id, Name = Name, Label = Label, + SubLabel = SubLabel, HeadingLabel = HeadingLabel, - Hint = Hint + Hint = Hint, + PreviousInformation = PreviousInformation, + AdditionalInformation = AdditionalInformation, + DateString = date.ToDateString() }; if (date.HasValue) diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/TagHelpers/InputTagHelperBase.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/TagHelpers/InputTagHelperBase.cs index 9bfee0e7a..01ad9c608 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/TagHelpers/InputTagHelperBase.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/TagHelpers/InputTagHelperBase.cs @@ -24,6 +24,15 @@ protected InputTagHelperBase(IHtmlHelper htmlHelper) [HtmlAttributeName("label")] public string Label { get; set; } + [HtmlAttributeName("sub-label")] + public string SubLabel { get; set; } + + [HtmlAttributeName("previous-information")] + public string PreviousInformation { get; set; } + + [HtmlAttributeName("additional-information")] + public string AdditionalInformation { get; set; } + [HtmlAttributeName("suffix")] public string Suffix { get; set; } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/DateInputViewModel.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/DateInputViewModel.cs index 3152a8540..1dbb4b8b7 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/DateInputViewModel.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/DateInputViewModel.cs @@ -8,10 +8,14 @@ public class DateInputViewModel public string Month { get; set; } public string Year { get; set; } public string Label { get; set; } + public string SubLabel { get; set; } public bool HeadingLabel { get; set; } public string Hint { get; set; } public string ErrorMessage { get; set; } public bool DayInvalid { get; set; } public bool MonthInvalid { get; set; } public bool YearInvalid { get; set; } + public string PreviousInformation { get; set; } + public string AdditionalInformation { get; set; } + public string DateString { get; set; } } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/ProjectViewModel.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/ProjectViewModel.cs index e585ac59b..8e55c843b 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/ProjectViewModel.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/ProjectViewModel.cs @@ -128,6 +128,9 @@ public ProjectViewModel(AcademyConversionProject project) NumberOfMedicalPlaces = project.NumberOfMedicalPlaces; NumberOfPost16Places = project.NumberOfPost16Places; NumberOfSENUnitPlaces = project.NumberOfSENUnitPlaces; + + ProposedConversionDate = project.ProposedConversionDate; + ProjectDatesSectionComplete = project.ProjectDatesSectionComplete; } public string Id { get; } @@ -258,6 +261,9 @@ public ProjectViewModel(AcademyConversionProject project) public ICollection Notes { get; } + public bool ProjectDatesSectionComplete { get; set; } + public DateTime? ProposedConversionDate { get; set; } + protected override string TypeAndRouteValue => AcademyTypeAndRoute; public override bool IsExternalSchoolApplication => string.IsNullOrEmpty(this.ApplicationReferenceNumber); diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/TaskListItemViewModel.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/TaskListItemViewModel.cs index d731459e3..8e5affef7 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/TaskListItemViewModel.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/TaskListItemViewModel.cs @@ -160,6 +160,23 @@ public static TaskListItemViewModel GetSchoolBudgetInformationTaskListStatus(Pro return InProgress; } + public static TaskListItemViewModel GetProjectDatesTaskListStatus(ProjectViewModel project) + { + if (project.ProjectDatesSectionComplete) + { + return Completed; + } + + if (!project.HeadTeacherBoardDate.HasValue + && !project.ProposedConversionDate.HasValue + && !project.PreviousHeadTeacherBoardDate.HasValue) + { + return NotStarted; + } + + return InProgress; + } + public override int GetHashCode() { return $"{Status} {CssClass}".GetHashCode(); diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/TaskListViewModel.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/TaskListViewModel.cs index 67da112df..f019a5d7f 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/TaskListViewModel.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/TaskListViewModel.cs @@ -12,6 +12,10 @@ public class TaskListViewModel public TaskListItemViewModel RisksAndIssuesTaskListStatus { get; set; } public TaskListItemViewModel LegalRequirementsTaskListStatus { get; set; } public TaskListItemViewModel SchoolBudgetInformationTaskListStatus { get; set; } + public TaskListItemViewModel ProjectDatesTaskListTaskListStatus { get; set; } + + + public string ProjectStatus { get; set; } public string ProjectStatusColour { get; set; } public bool HasKeyStage2PerformanceTables { get; set; } @@ -33,7 +37,8 @@ public static TaskListViewModel Build(ProjectViewModel project) SchoolBudgetInformationTaskListStatus = TaskListItemViewModel.GetSchoolBudgetInformationTaskListStatus(project), ProjectStatus = ProjectListHelper.MapProjectStatus(project.ProjectStatus).Value, ProjectStatusColour = ProjectListHelper.MapProjectStatus(project.ProjectStatus).Colour, - PerformanceDataHintText = ProjectListHelper.MapPerformanceDataHint(project.SchoolType) + PerformanceDataHintText = ProjectListHelper.MapPerformanceDataHint(project.SchoolType), + ProjectDatesTaskListTaskListStatus = TaskListItemViewModel.GetProjectDatesTaskListStatus(project) }; } }