From 1b56e713231bd0593e295fb5efbde1427926a68e Mon Sep 17 00:00:00 2001 From: CLAWLOR Date: Wed, 11 Dec 2024 15:21:31 +0000 Subject: [PATCH 01/25] start of induction journey --- .../JourneyNames.cs | 3 ++ .../EditInductionCompletionDateState.cs | 14 ++++++++ .../Induction/DateCompleted/Index.cshtml | 18 ++++++++++ .../Induction/DateCompleted/Index.cshtml.cs | 22 ++++++++++++ .../StartDate/EditInductionStartDateState.cs | 16 +++++++++ .../Pages/Induction/StartDate/Index.cshtml | 18 ++++++++++ .../Pages/Induction/StartDate/Index.cshtml.cs | 26 ++++++++++++++ .../Status/EditInductionStatusState.cs | 10 ++++++ .../Pages/Induction/Status/Index.cshtml | 20 +++++++++++ .../Pages/Induction/Status/Index.cshtml.cs | 26 ++++++++++++++ .../Persons/PersonDetail/Induction.cshtml | 36 ++++++------------- .../TrsLinkGenerator.cs | 9 +++++ .../Persons/PersonDetail/InductionTests.cs | 24 +++++++++++++ 13 files changed, 217 insertions(+), 25 deletions(-) create mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/DateCompleted/EditInductionCompletionDateState.cs create mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/DateCompleted/Index.cshtml create mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/DateCompleted/Index.cshtml.cs create mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/StartDate/EditInductionStartDateState.cs create mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/StartDate/Index.cshtml create mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/StartDate/Index.cshtml.cs create mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/Status/EditInductionStatusState.cs create mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/Status/Index.cshtml create mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/Status/Index.cshtml.cs diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/JourneyNames.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/JourneyNames.cs index 77108efd8..83b7bc92a 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/JourneyNames.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/JourneyNames.cs @@ -18,4 +18,7 @@ public static class JourneyNames public const string CloseAlert = nameof(CloseAlert); public const string ReopenAlert = nameof(ReopenAlert); public const string DeleteAlert = nameof(DeleteAlert); + public const string EditInductionStatus = nameof(EditInductionStatus); + public const string EditInductionStartDate = nameof(EditInductionStartDate); + public const string EditInductionCompletionDate = nameof(EditInductionCompletionDate); } diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/DateCompleted/EditInductionCompletionDateState.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/DateCompleted/EditInductionCompletionDateState.cs new file mode 100644 index 000000000..22790dfd0 --- /dev/null +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/DateCompleted/EditInductionCompletionDateState.cs @@ -0,0 +1,14 @@ +namespace TeachingRecordSystem.SupportUi.Pages.Induction.CompletionDate; + +public class EditInductionCompletionDateState : IRegisterJourney +{ + public static JourneyDescriptor Journey => new( + JourneyNames.EditInductionCompletionDate, + typeof(EditInductionCompletionDateState), + requestDataKeys: ["personId"], + appendUniqueKey: true); + + public Guid? InductionId { get; set; } + + public DateOnly? StartDate { get; set; } +} diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/DateCompleted/Index.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/DateCompleted/Index.cshtml new file mode 100644 index 000000000..b9ace21c6 --- /dev/null +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/DateCompleted/Index.cshtml @@ -0,0 +1,18 @@ +@page +@model TeachingRecordSystem.SupportUi.Pages.Induction.EditInduction.CompletionDate.IndexModel + +@section BeforeContent { + Back +} + +Select completion date +
+
+ @*
+
+ Continue + Cancel and return to record +
+
*@ +
+
diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/DateCompleted/Index.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/DateCompleted/Index.cshtml.cs new file mode 100644 index 000000000..b9903dcac --- /dev/null +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/DateCompleted/Index.cshtml.cs @@ -0,0 +1,22 @@ +using Microsoft.AspNetCore.Mvc.RazorPages; +using TeachingRecordSystem.SupportUi.Pages.Induction.CompletionDate; + +namespace TeachingRecordSystem.SupportUi.Pages.Induction.EditInduction.CompletionDate; + +[Journey(JourneyNames.EditInductionCompletionDate)] +public class IndexModel(TrsLinkGenerator linkGenerator) : PageModel +{ + public JourneyInstance? JourneyInstance { get; set; } + + public Guid PersonId { get; set; } + + public void OnGet(Guid personId) + { + PersonId = personId; + } + + public void OnPost() + { + Redirect(linkGenerator.InductionEditCompletionDate(PersonId, JourneyInstance!.InstanceId)); + } +} diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/StartDate/EditInductionStartDateState.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/StartDate/EditInductionStartDateState.cs new file mode 100644 index 000000000..85ece5bdf --- /dev/null +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/StartDate/EditInductionStartDateState.cs @@ -0,0 +1,16 @@ +namespace TeachingRecordSystem.SupportUi.Pages.Induction.StartDate; + +public class EditInductionStartDateState : IRegisterJourney +{ + public static JourneyDescriptor Journey => new( + JourneyNames.EditInductionStartDate, + typeof(EditInductionStartDateState), + requestDataKeys: ["personId"], + appendUniqueKey: true); + + public Guid? InductionId { get; set; } + + public DateOnly? StartDate { get; set; } + + public bool? IsComplete => StartDate.HasValue; +} diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/StartDate/Index.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/StartDate/Index.cshtml new file mode 100644 index 000000000..3ce97ff6a --- /dev/null +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/StartDate/Index.cshtml @@ -0,0 +1,18 @@ +@page +@model TeachingRecordSystem.SupportUi.Pages.Induction.EditInduction.StartDate.IndexModel + +@section BeforeContent { + Back +} + +Select start date +
+
+
+
+ Continue + Cancel and return to record +
+
+ +
diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/StartDate/Index.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/StartDate/Index.cshtml.cs new file mode 100644 index 000000000..f9a86b30b --- /dev/null +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/StartDate/Index.cshtml.cs @@ -0,0 +1,26 @@ +using Microsoft.AspNetCore.Mvc.RazorPages; +using TeachingRecordSystem.SupportUi.Pages.Induction.StartDate; + +namespace TeachingRecordSystem.SupportUi.Pages.Induction.EditInduction.StartDate; + +[Journey(JourneyNames.EditInductionStartDate)] +public class IndexModel(TrsLinkGenerator linkGenerator) : PageModel +{ + public JourneyInstance? JourneyInstance { get; set; } + + //[FromRoute] + public Guid PersonId { get; set; } + + public void OnGet(Guid personId) + { + PersonId = personId; + } + + public void OnPost() + { + // TODO - store the induction start date + + // TODO - figure out where to go next and redirect to that page + Redirect(linkGenerator.InductionEditCompletionDate(PersonId, JourneyInstance!.InstanceId)); + } +} diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/Status/EditInductionStatusState.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/Status/EditInductionStatusState.cs new file mode 100644 index 000000000..78aab8cb5 --- /dev/null +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/Status/EditInductionStatusState.cs @@ -0,0 +1,10 @@ +namespace TeachingRecordSystem.SupportUi.Pages.Induction.Status; + +public class EditInductionStatusState : IRegisterJourney +{ + public static JourneyDescriptor Journey => new( + JourneyNames.EditInductionStatus, + typeof(EditInductionStatusState), + requestDataKeys: ["personId"], + appendUniqueKey: true); +} diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/Status/Index.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/Status/Index.cshtml new file mode 100644 index 000000000..d490e51c9 --- /dev/null +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/Status/Index.cshtml @@ -0,0 +1,20 @@ +@page +@model TeachingRecordSystem.SupportUi.Pages.Induction.Status.IndexModel +@{ + ViewBag.Title = "Select induction status"; +} + +@section BeforeContent { + Back +} +Select induction status +
+
+
+
+ Continue + Cancel and return to record +
+
+ +
diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/Status/Index.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/Status/Index.cshtml.cs new file mode 100644 index 000000000..64a83dd1b --- /dev/null +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/Status/Index.cshtml.cs @@ -0,0 +1,26 @@ +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace TeachingRecordSystem.SupportUi.Pages.Induction.Status; + + +[Journey(JourneyNames.EditInductionStatus), ActivatesJourney, RequireJourneyInstance] +public class IndexModel(TrsLinkGenerator linkGenerator) : PageModel +{ + public JourneyInstance? JourneyInstance { get; set; } + + //[FromRoute] + public Guid PersonId { get; set; } + + public void OnGet(Guid personId) + { + PersonId = personId; + } + + public void OnPost() + { + // TODO - store the induction status + + // TODO - figure out where to go next and redirect to that page + Redirect(linkGenerator.InductionEditStartDate(PersonId, JourneyInstance!.InstanceId)); + } +} diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/Induction.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/Induction.cshtml index f0db4cf99..c83438a8c 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/Induction.cshtml +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/Induction.cshtml @@ -21,50 +21,36 @@ Induction details - - Induction status - - - @Model.Status.GetTitle() - + Induction status + @Model.Status.GetTitle() + + Change + @if (Model.ExemptionReasons != InductionExemptionReasons.None) // how to enforce that InductionExemptionReasons.None means no other flags are set? { - - Exemption reason - - - @Model.ExemptionReasonsText - + Exemption reason + @Model.ExemptionReasonsText } @if (Model.ShowStartDate) { - - Induction start date - - - @Model.StartDate?.ToString(UiDefaults.DateOnlyDisplayFormat) - + Induction start date + @Model.StartDate?.ToString(UiDefaults.DateOnlyDisplayFormat) } @if (Model.ShowCompletionDate) { - - Induction completion date - - - @Model.CompletionDate?.ToString(UiDefaults.DateOnlyDisplayFormat) - + Induction completion date + @Model.CompletionDate?.ToString(UiDefaults.DateOnlyDisplayFormat) } - } diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/TrsLinkGenerator.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/TrsLinkGenerator.cs index 450fdecf2..fa9e6b6a2 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/TrsLinkGenerator.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/TrsLinkGenerator.cs @@ -169,6 +169,15 @@ public string AlertDeleteCheckAnswers(Guid alertId, JourneyInstanceId journeyIns public string AlertDeleteCheckAnswersCancel(Guid alertId, JourneyInstanceId journeyInstanceId) => GetRequiredPathByPage("/Alerts/DeleteAlert/CheckAnswers", "cancel", routeValues: new { alertId }, journeyInstanceId: journeyInstanceId); + public string InductionEditStatus(Guid personId, JourneyInstanceId? journeyInstanceId, bool? fromCheckAnswers = null) => + GetRequiredPathByPage("/Induction/Status/Index", routeValues: new { personId, fromCheckAnswers }, journeyInstanceId: journeyInstanceId); + + public string InductionEditStartDate(Guid personId, JourneyInstanceId? journeyInstanceId, bool? fromCheckAnswers = null) => + GetRequiredPathByPage("/Induction/StartDate/Index", routeValues: new { personId, fromCheckAnswers }, journeyInstanceId: journeyInstanceId); + + public string InductionEditCompletionDate(Guid personId, JourneyInstanceId? journeyInstanceId, bool? fromCheckAnswers = null) => + GetRequiredPathByPage("/Induction/DateCompleted/Index", routeValues: new { personId, fromCheckAnswers }, journeyInstanceId: journeyInstanceId); + public string EditChangeRequest(string ticketNumber) => GetRequiredPathByPage("/ChangeRequests/EditChangeRequest/Index", routeValues: new { ticketNumber }); public string ChangeRequestDocument(string ticketNumber, Guid documentId) => GetRequiredPathByPage("/ChangeRequests/EditChangeRequest/Index", "documents", routeValues: new { ticketNumber, id = documentId }); diff --git a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/InductionTests.cs b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/InductionTests.cs index 7348b3a65..78b8900ce 100644 --- a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/InductionTests.cs +++ b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/InductionTests.cs @@ -286,4 +286,28 @@ await WithDbContext(async dbContext => var doc = await AssertEx.HtmlResponseAsync(response); Assert.Null(doc.GetElementByTestId("induction-status-warning")); } + + [Fact] + public async Task Get_WithPersonId_ShowsLinkToChangeStatus() + { + // Arrange + var setInductionStatus = InductionStatus.RequiredToComplete; + var person = await TestData.CreatePersonAsync( + builder => builder + .WithQts() + .WithInductionStatus(builder => builder + .WithStatus(setInductionStatus) + ) + ); + + var request = new HttpRequestMessage(HttpMethod.Get, $"/persons/{person.ContactId}/induction"); + + // Act + var response = await HttpClient.SendAsync(request); + + // Assert + var doc = await AssertEx.HtmlResponseAsync(response); + var inductionStatus = doc.GetElementByTestId("induction-status"); + Assert.Contains("Change", inductionStatus!.GetElementsByTagName("a")[0].TextContent); + } } From a2260cfd48b263e77a59a7677ea47f0a2e542693 Mon Sep 17 00:00:00 2001 From: CLAWLOR Date: Wed, 11 Dec 2024 16:29:49 +0000 Subject: [PATCH 02/25] moved folders --- .../Pages/Induction/DateCompleted/Index.cshtml | 5 +++-- .../Pages/Induction/DateCompleted/Index.cshtml.cs | 8 ++++---- .../Pages/Induction/StartDate/Index.cshtml | 4 ++-- .../Pages/Induction/StartDate/Index.cshtml.cs | 11 +++++------ .../Pages/Induction/Status/Index.cshtml | 5 +++-- .../Pages/Induction/Status/Index.cshtml.cs | 6 +++--- 6 files changed, 20 insertions(+), 19 deletions(-) diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/DateCompleted/Index.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/DateCompleted/Index.cshtml index b9ace21c6..fd6f9e44a 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/DateCompleted/Index.cshtml +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/DateCompleted/Index.cshtml @@ -1,5 +1,6 @@ -@page -@model TeachingRecordSystem.SupportUi.Pages.Induction.EditInduction.CompletionDate.IndexModel +@page "{PersondId}" + +@model TeachingRecordSystem.SupportUi.Pages.Induction.CompletionDate.IndexModel @section BeforeContent { Back diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/DateCompleted/Index.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/DateCompleted/Index.cshtml.cs index b9903dcac..e01e1bc7a 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/DateCompleted/Index.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/DateCompleted/Index.cshtml.cs @@ -1,18 +1,18 @@ +using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; -using TeachingRecordSystem.SupportUi.Pages.Induction.CompletionDate; -namespace TeachingRecordSystem.SupportUi.Pages.Induction.EditInduction.CompletionDate; +namespace TeachingRecordSystem.SupportUi.Pages.Induction.CompletionDate; [Journey(JourneyNames.EditInductionCompletionDate)] public class IndexModel(TrsLinkGenerator linkGenerator) : PageModel { public JourneyInstance? JourneyInstance { get; set; } + [FromRoute] public Guid PersonId { get; set; } - public void OnGet(Guid personId) + public void OnGet() { - PersonId = personId; } public void OnPost() diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/StartDate/Index.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/StartDate/Index.cshtml index 3ce97ff6a..d7ba5a6f0 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/StartDate/Index.cshtml +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/StartDate/Index.cshtml @@ -1,5 +1,5 @@ -@page -@model TeachingRecordSystem.SupportUi.Pages.Induction.EditInduction.StartDate.IndexModel +@page "{PersonId}" +@model TeachingRecordSystem.SupportUi.Pages.Induction.StartDate.IndexModel @section BeforeContent { Back diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/StartDate/Index.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/StartDate/Index.cshtml.cs index f9a86b30b..feac703cf 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/StartDate/Index.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/StartDate/Index.cshtml.cs @@ -1,19 +1,18 @@ +using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; -using TeachingRecordSystem.SupportUi.Pages.Induction.StartDate; -namespace TeachingRecordSystem.SupportUi.Pages.Induction.EditInduction.StartDate; +namespace TeachingRecordSystem.SupportUi.Pages.Induction.StartDate; -[Journey(JourneyNames.EditInductionStartDate)] +[Journey(JourneyNames.EditInductionStartDate), RequireJourneyInstance] public class IndexModel(TrsLinkGenerator linkGenerator) : PageModel { public JourneyInstance? JourneyInstance { get; set; } - //[FromRoute] + [FromRoute] public Guid PersonId { get; set; } - public void OnGet(Guid personId) + public void OnGet() { - PersonId = personId; } public void OnPost() diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/Status/Index.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/Status/Index.cshtml index d490e51c9..ddbf6e071 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/Status/Index.cshtml +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/Status/Index.cshtml @@ -1,4 +1,5 @@ -@page +@page "{PersonId}" + @model TeachingRecordSystem.SupportUi.Pages.Induction.Status.IndexModel @{ ViewBag.Title = "Select induction status"; @@ -10,7 +11,7 @@ Select induction status
-
+
Continue Cancel and return to record diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/Status/Index.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/Status/Index.cshtml.cs index 64a83dd1b..b83b7ef0b 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/Status/Index.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/Status/Index.cshtml.cs @@ -1,3 +1,4 @@ +using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; namespace TeachingRecordSystem.SupportUi.Pages.Induction.Status; @@ -8,12 +9,11 @@ public class IndexModel(TrsLinkGenerator linkGenerator) : PageModel { public JourneyInstance? JourneyInstance { get; set; } - //[FromRoute] + [FromRoute] public Guid PersonId { get; set; } - public void OnGet(Guid personId) + public void OnGet() { - PersonId = personId; } public void OnPost() From 593b848782a2a3c317e34f7854e4a21baa7ff16f Mon Sep 17 00:00:00 2001 From: CLAWLOR Date: Thu, 12 Dec 2024 14:10:23 +0000 Subject: [PATCH 03/25] move inductino pages to Persons/PersonDetails --- TeachingRecordSystem/TeachingRecordSystem.sln | 2 +- .../JourneyNames.cs | 4 +-- .../EditInductionCompletionDateState.cs | 14 --------- .../Induction/DateCompleted/Index.cshtml | 19 ------------ .../Induction/DateCompleted/Index.cshtml.cs | 22 -------------- .../StartDate/EditInductionStartDateState.cs | 16 ---------- .../Pages/Induction/StartDate/Index.cshtml | 18 ------------ .../Pages/Induction/StartDate/Index.cshtml.cs | 25 ---------------- .../Status/EditInductionStatusState.cs | 10 ------- .../EditInduction/EditInductionState.cs | 29 +++++++++++++++++++ .../EditInduction/ExemptionReason.cshtml | 20 +++++++++++++ .../EditInduction/ExemptionReason.cshtml.cs} | 8 ++--- .../PersonDetail/EditInduction/Status.cshtml} | 13 +++++---- .../EditInduction/Status.cshtml.cs | 29 +++++++++++++++++++ .../Persons/PersonDetail/Induction.cshtml | 2 +- .../Persons/PersonDetail/Induction.cshtml.cs | 1 + .../TrsLinkGenerator.cs | 10 +++---- 17 files changed, 97 insertions(+), 145 deletions(-) delete mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/DateCompleted/EditInductionCompletionDateState.cs delete mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/DateCompleted/Index.cshtml delete mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/DateCompleted/Index.cshtml.cs delete mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/StartDate/EditInductionStartDateState.cs delete mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/StartDate/Index.cshtml delete mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/StartDate/Index.cshtml.cs delete mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/Status/EditInductionStatusState.cs create mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/EditInductionState.cs create mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml rename TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/{Induction/Status/Index.cshtml.cs => Persons/PersonDetail/EditInduction/ExemptionReason.cshtml.cs} (58%) rename TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/{Induction/Status/Index.cshtml => Persons/PersonDetail/EditInduction/Status.cshtml} (59%) create mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs diff --git a/TeachingRecordSystem/TeachingRecordSystem.sln b/TeachingRecordSystem/TeachingRecordSystem.sln index 2e2b58064..a1bbce22b 100644 --- a/TeachingRecordSystem/TeachingRecordSystem.sln +++ b/TeachingRecordSystem/TeachingRecordSystem.sln @@ -53,7 +53,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeachingRecordSystem.Author EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gen", "gen", "{5E273A79-2EA3-46CD-9049-769F880868FE}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeachingRecordSystem.Api.Generator", "gen\TeachingRecordSystem.Api.Generator\TeachingRecordSystem.Api.Generator.csproj", "{7EA8C0A7-C149-4928-8E37-55D44976D765}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeachingRecordSystem.Api.Generator", "gen\TeachingRecordSystem.Api.Generator\TeachingRecordSystem.Api.Generator.csproj", "{7EA8C0A7-C149-4928-8E37-55D44976D765}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/JourneyNames.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/JourneyNames.cs index 83b7bc92a..34f697f1b 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/JourneyNames.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/JourneyNames.cs @@ -18,7 +18,5 @@ public static class JourneyNames public const string CloseAlert = nameof(CloseAlert); public const string ReopenAlert = nameof(ReopenAlert); public const string DeleteAlert = nameof(DeleteAlert); - public const string EditInductionStatus = nameof(EditInductionStatus); - public const string EditInductionStartDate = nameof(EditInductionStartDate); - public const string EditInductionCompletionDate = nameof(EditInductionCompletionDate); + public const string EditInduction = nameof(EditInduction); } diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/DateCompleted/EditInductionCompletionDateState.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/DateCompleted/EditInductionCompletionDateState.cs deleted file mode 100644 index 22790dfd0..000000000 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/DateCompleted/EditInductionCompletionDateState.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace TeachingRecordSystem.SupportUi.Pages.Induction.CompletionDate; - -public class EditInductionCompletionDateState : IRegisterJourney -{ - public static JourneyDescriptor Journey => new( - JourneyNames.EditInductionCompletionDate, - typeof(EditInductionCompletionDateState), - requestDataKeys: ["personId"], - appendUniqueKey: true); - - public Guid? InductionId { get; set; } - - public DateOnly? StartDate { get; set; } -} diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/DateCompleted/Index.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/DateCompleted/Index.cshtml deleted file mode 100644 index fd6f9e44a..000000000 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/DateCompleted/Index.cshtml +++ /dev/null @@ -1,19 +0,0 @@ -@page "{PersondId}" - -@model TeachingRecordSystem.SupportUi.Pages.Induction.CompletionDate.IndexModel - -@section BeforeContent { - Back -} - -Select completion date -
-
- @* -
- Continue - Cancel and return to record -
- *@ -
-
diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/DateCompleted/Index.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/DateCompleted/Index.cshtml.cs deleted file mode 100644 index e01e1bc7a..000000000 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/DateCompleted/Index.cshtml.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; - -namespace TeachingRecordSystem.SupportUi.Pages.Induction.CompletionDate; - -[Journey(JourneyNames.EditInductionCompletionDate)] -public class IndexModel(TrsLinkGenerator linkGenerator) : PageModel -{ - public JourneyInstance? JourneyInstance { get; set; } - - [FromRoute] - public Guid PersonId { get; set; } - - public void OnGet() - { - } - - public void OnPost() - { - Redirect(linkGenerator.InductionEditCompletionDate(PersonId, JourneyInstance!.InstanceId)); - } -} diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/StartDate/EditInductionStartDateState.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/StartDate/EditInductionStartDateState.cs deleted file mode 100644 index 85ece5bdf..000000000 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/StartDate/EditInductionStartDateState.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace TeachingRecordSystem.SupportUi.Pages.Induction.StartDate; - -public class EditInductionStartDateState : IRegisterJourney -{ - public static JourneyDescriptor Journey => new( - JourneyNames.EditInductionStartDate, - typeof(EditInductionStartDateState), - requestDataKeys: ["personId"], - appendUniqueKey: true); - - public Guid? InductionId { get; set; } - - public DateOnly? StartDate { get; set; } - - public bool? IsComplete => StartDate.HasValue; -} diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/StartDate/Index.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/StartDate/Index.cshtml deleted file mode 100644 index d7ba5a6f0..000000000 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/StartDate/Index.cshtml +++ /dev/null @@ -1,18 +0,0 @@ -@page "{PersonId}" -@model TeachingRecordSystem.SupportUi.Pages.Induction.StartDate.IndexModel - -@section BeforeContent { - Back -} - -Select start date -
-
-
-
- Continue - Cancel and return to record -
-
- -
diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/StartDate/Index.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/StartDate/Index.cshtml.cs deleted file mode 100644 index feac703cf..000000000 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/StartDate/Index.cshtml.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; - -namespace TeachingRecordSystem.SupportUi.Pages.Induction.StartDate; - -[Journey(JourneyNames.EditInductionStartDate), RequireJourneyInstance] -public class IndexModel(TrsLinkGenerator linkGenerator) : PageModel -{ - public JourneyInstance? JourneyInstance { get; set; } - - [FromRoute] - public Guid PersonId { get; set; } - - public void OnGet() - { - } - - public void OnPost() - { - // TODO - store the induction start date - - // TODO - figure out where to go next and redirect to that page - Redirect(linkGenerator.InductionEditCompletionDate(PersonId, JourneyInstance!.InstanceId)); - } -} diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/Status/EditInductionStatusState.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/Status/EditInductionStatusState.cs deleted file mode 100644 index 78aab8cb5..000000000 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/Status/EditInductionStatusState.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace TeachingRecordSystem.SupportUi.Pages.Induction.Status; - -public class EditInductionStatusState : IRegisterJourney -{ - public static JourneyDescriptor Journey => new( - JourneyNames.EditInductionStatus, - typeof(EditInductionStatusState), - requestDataKeys: ["personId"], - appendUniqueKey: true); -} diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/EditInductionState.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/EditInductionState.cs new file mode 100644 index 000000000..353c04e8d --- /dev/null +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/EditInductionState.cs @@ -0,0 +1,29 @@ +namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; + +public class EditInductionState : IRegisterJourney +{ + public static JourneyDescriptor Journey => new( + JourneyNames.EditInduction, + typeof(EditInductionState), + requestDataKeys: ["personId"], + appendUniqueKey: true); + + public InductionStatus InductionStatus { get; set; } + public DateOnly? StartDate { get; set; } + public DateOnly? CompletedDate { get; set; } + public InductionExemptionReasons? ExemptionReasons { get; set; } + public string? ChangeReason { get; set; } + + public bool Initialized { get; set; } + + public void EnsureInitialized(InductionStatus status) + { + if (Initialized) + { + return; + } + + InductionStatus = status; + Initialized = true; + } +} diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml new file mode 100644 index 000000000..25ed210ae --- /dev/null +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml @@ -0,0 +1,20 @@ +@page "/persons/{PersonId}/edit-induction/exemption-reasons" +@model TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction.ExemptionReasonModel +@{ + ViewBag.Title = "Exemption reason"; +} + +@section BeforeContent { + Back +} + +

@ViewBag.Title

+ +
+
+
+ Continue + Cancel and return to record +
+
+
diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/Status/Index.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml.cs similarity index 58% rename from TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/Status/Index.cshtml.cs rename to TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml.cs index b83b7ef0b..0f5117776 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/Status/Index.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml.cs @@ -1,13 +1,11 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; -namespace TeachingRecordSystem.SupportUi.Pages.Induction.Status; +namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; - -[Journey(JourneyNames.EditInductionStatus), ActivatesJourney, RequireJourneyInstance] -public class IndexModel(TrsLinkGenerator linkGenerator) : PageModel +public class ExemptionReasonModel(TrsLinkGenerator linkGenerator) : PageModel { - public JourneyInstance? JourneyInstance { get; set; } + public JourneyInstance? JourneyInstance { get; set; } [FromRoute] public Guid PersonId { get; set; } diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/Status/Index.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml similarity index 59% rename from TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/Status/Index.cshtml rename to TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml index ddbf6e071..17f2e6900 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Induction/Status/Index.cshtml +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml @@ -1,17 +1,18 @@ -@page "{PersonId}" - -@model TeachingRecordSystem.SupportUi.Pages.Induction.Status.IndexModel +@page "/persons/{PersonId}/edit-induction/status" +@model TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction.StatusModel @{ - ViewBag.Title = "Select induction status"; + ViewBag.Title = "Edit status"; } @section BeforeContent { Back } -Select induction status + +

@ViewBag.Title

+
-
+
Continue Cancel and return to record diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs new file mode 100644 index 000000000..6e836f9dd --- /dev/null +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs @@ -0,0 +1,29 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; + +[Journey(JourneyNames.EditInduction), ActivatesJourney, RequireJourneyInstance] +public class StatusModel(TrsLinkGenerator linkGenerator) : PageModel +{ + public JourneyInstance? JourneyInstance { get; set; } + + [FromRoute] + public Guid PersonId { get; set; } + + [BindProperty] + public InductionStatus Status { get; set; } + + + public void OnGet() + { + } + + public void OnPost() + { + // TODO - store the induction status + + // TODO - figure out where to go next and redirect to that page + Redirect(linkGenerator.InductionEditExemptionReason(PersonId, JourneyInstance!.InstanceId)); + } +} diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/Induction.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/Induction.cshtml index c83438a8c..6c60b0601 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/Induction.cshtml +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/Induction.cshtml @@ -24,7 +24,7 @@ Induction status @Model.Status.GetTitle() - Change + Change diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/Induction.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/Induction.cshtml.cs index 541fcec4f..62335778a 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/Induction.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/Induction.cshtml.cs @@ -16,6 +16,7 @@ public class InductionModel(TrsDbContext dbContext, ICrmQueryDispatcher crmQuery [FromRoute] public Guid PersonId { get; set; } + [BindProperty] public InductionStatus Status { get; set; } public DateOnly? StartDate { get; set; } diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/TrsLinkGenerator.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/TrsLinkGenerator.cs index fa9e6b6a2..c5b4f857f 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/TrsLinkGenerator.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/TrsLinkGenerator.cs @@ -170,13 +170,13 @@ public string AlertDeleteCheckAnswersCancel(Guid alertId, JourneyInstanceId jour GetRequiredPathByPage("/Alerts/DeleteAlert/CheckAnswers", "cancel", routeValues: new { alertId }, journeyInstanceId: journeyInstanceId); public string InductionEditStatus(Guid personId, JourneyInstanceId? journeyInstanceId, bool? fromCheckAnswers = null) => - GetRequiredPathByPage("/Induction/Status/Index", routeValues: new { personId, fromCheckAnswers }, journeyInstanceId: journeyInstanceId); + GetRequiredPathByPage("/Persons/PersonDetail/EditInduction/Status", routeValues: new { personId, fromCheckAnswers }, journeyInstanceId: journeyInstanceId); - public string InductionEditStartDate(Guid personId, JourneyInstanceId? journeyInstanceId, bool? fromCheckAnswers = null) => - GetRequiredPathByPage("/Induction/StartDate/Index", routeValues: new { personId, fromCheckAnswers }, journeyInstanceId: journeyInstanceId); + public string InductionEditExemptionReason(Guid personId, JourneyInstanceId? journeyInstanceId, bool? fromCheckAnswers = null) => + GetRequiredPathByPage("/Persons/PersonDetail/EditInduction/ExemptionReason", routeValues: new { personId, fromCheckAnswers }, journeyInstanceId: journeyInstanceId); - public string InductionEditCompletionDate(Guid personId, JourneyInstanceId? journeyInstanceId, bool? fromCheckAnswers = null) => - GetRequiredPathByPage("/Induction/DateCompleted/Index", routeValues: new { personId, fromCheckAnswers }, journeyInstanceId: journeyInstanceId); + public string InductionEditStartDate(Guid personId, JourneyInstanceId? journeyInstanceId, bool? fromCheckAnswers = null) => + GetRequiredPathByPage("/Persons/PersonDetail/EditInduction/StartDate", routeValues: new { personId, fromCheckAnswers }, journeyInstanceId: journeyInstanceId); public string EditChangeRequest(string ticketNumber) => GetRequiredPathByPage("/ChangeRequests/EditChangeRequest/Index", routeValues: new { ticketNumber }); From c39a7a7b9b285530ffc23cceb53781480d4e36ac Mon Sep 17 00:00:00 2001 From: CLAWLOR Date: Thu, 12 Dec 2024 14:36:32 +0000 Subject: [PATCH 04/25] add induction status value to page --- .../Persons/PersonDetail/EditInduction/Status.cshtml | 2 +- .../PersonDetail/EditInduction/Status.cshtml.cs | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml index 17f2e6900..917a948b7 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml @@ -1,7 +1,7 @@ @page "/persons/{PersonId}/edit-induction/status" @model TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction.StatusModel @{ - ViewBag.Title = "Edit status"; + ViewBag.Title = "Edit status: " + Model.Status; } @section BeforeContent { diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs index 6e836f9dd..365b06d6e 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs @@ -1,10 +1,11 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; +using TeachingRecordSystem.Core.DataStore.Postgres; namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; [Journey(JourneyNames.EditInduction), ActivatesJourney, RequireJourneyInstance] -public class StatusModel(TrsLinkGenerator linkGenerator) : PageModel +public class StatusModel(TrsLinkGenerator linkGenerator, TrsDbContext dbContext) : PageModel { public JourneyInstance? JourneyInstance { get; set; } @@ -15,13 +16,18 @@ public class StatusModel(TrsLinkGenerator linkGenerator) : PageModel public InductionStatus Status { get; set; } - public void OnGet() + public async Task OnGetAsync() { + var person = await dbContext.Persons + .SingleAsync(q => q.PersonId == PersonId); + + Status = person!.InductionStatus; } - public void OnPost() + public async Task OnPostAsync() { // TODO - store the induction status + await JourneyInstance!.UpdateStateAsync(state => state.InductionStatus = Status); // TODO - figure out where to go next and redirect to that page Redirect(linkGenerator.InductionEditExemptionReason(PersonId, JourneyInstance!.InstanceId)); From e1c0a34e3d778afb1deb4e7f6143dcfe78e676d5 Mon Sep 17 00:00:00 2001 From: CLAWLOR Date: Thu, 12 Dec 2024 16:27:01 +0000 Subject: [PATCH 05/25] hidden field to store Status for now --- .../Persons/PersonDetail/EditInduction/Status.cshtml | 5 +++-- .../Persons/PersonDetail/EditInduction/Status.cshtml.cs | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml index 917a948b7..03bd0d89d 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml @@ -1,7 +1,7 @@ @page "/persons/{PersonId}/edit-induction/status" @model TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction.StatusModel @{ - ViewBag.Title = "Edit status: " + Model.Status; + ViewBag.Title = "Edit status: " + Model.InductionStatus; } @section BeforeContent { @@ -13,9 +13,10 @@
+
Continue - Cancel and return to record + @* Cancel and return to record *@
diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs index 365b06d6e..05848d46e 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs @@ -13,21 +13,21 @@ public class StatusModel(TrsLinkGenerator linkGenerator, TrsDbContext dbContext) public Guid PersonId { get; set; } [BindProperty] - public InductionStatus Status { get; set; } + public InductionStatus InductionStatus { get; set; } public async Task OnGetAsync() { + InductionStatus = JourneyInstance!.State.InductionStatus; var person = await dbContext.Persons .SingleAsync(q => q.PersonId == PersonId); - - Status = person!.InductionStatus; + InductionStatus = person!.InductionStatus; } public async Task OnPostAsync() { // TODO - store the induction status - await JourneyInstance!.UpdateStateAsync(state => state.InductionStatus = Status); + await JourneyInstance!.UpdateStateAsync(state => state.InductionStatus = InductionStatus); // TODO - figure out where to go next and redirect to that page Redirect(linkGenerator.InductionEditExemptionReason(PersonId, JourneyInstance!.InstanceId)); From a76e19f403b222be44138876c04c17c9b660edd6 Mon Sep 17 00:00:00 2001 From: CLAWLOR Date: Thu, 12 Dec 2024 16:58:53 +0000 Subject: [PATCH 06/25] conditionally set the next page --- .../EditInduction/Status.cshtml.cs | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs index 05848d46e..d542c4ec8 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs @@ -15,7 +15,6 @@ public class StatusModel(TrsLinkGenerator linkGenerator, TrsDbContext dbContext) [BindProperty] public InductionStatus InductionStatus { get; set; } - public async Task OnGetAsync() { InductionStatus = JourneyInstance!.State.InductionStatus; @@ -26,10 +25,25 @@ public async Task OnGetAsync() public async Task OnPostAsync() { - // TODO - store the induction status await JourneyInstance!.UpdateStateAsync(state => state.InductionStatus = InductionStatus); - // TODO - figure out where to go next and redirect to that page - Redirect(linkGenerator.InductionEditExemptionReason(PersonId, JourneyInstance!.InstanceId)); + // Use the delegate to determine where to go next and redirect to that page + Redirect(SetNextPage(InductionStatus)(PersonId, JourneyInstance!.InstanceId)); + } + + private Func SetNextPage(InductionStatus status) + { + if (InductionStatus == InductionStatus.Exempt) + { + return (personId, journeyInstanceId) => linkGenerator.InductionEditExemptionReason(personId, journeyInstanceId); + } + //if (InductionStatus == InductionStatus.RequiredToComplete) + //{ + // return (personId, journeyInstanceId) => linkGenerator.InductionChangeReason(personId, journeyInstanceId); + //} + else + { + return (personId, journeyInstanceId) => linkGenerator.InductionEditStartDate(personId, journeyInstanceId); + } } } From e1f58f69385e01b971026c08c342ca4e85283471 Mon Sep 17 00:00:00 2001 From: CLAWLOR Date: Fri, 13 Dec 2024 10:14:28 +0000 Subject: [PATCH 07/25] some link logic --- .../EditInduction/EditInductionState.cs | 8 ++- .../EditInduction/ExemptionReason.cshtml | 2 +- .../EditInduction/ExemptionReason.cshtml.cs | 17 ++++- .../EditInduction/StartDate.cshtml | 22 ++++++ .../EditInduction/StartDate.cshtml.cs | 52 ++++++++++++++ .../PersonDetail/EditInduction/Status.cshtml | 6 +- .../EditInduction/Status.cshtml.cs | 35 ++++++---- .../TrsLinkGenerator.cs | 6 ++ .../EditInduction/EditInductionStateTests.cs | 67 +++++++++++++++++++ 9 files changed, 196 insertions(+), 19 deletions(-) create mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml create mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs create mode 100644 TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/EditInductionStateTests.cs diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/EditInductionState.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/EditInductionState.cs index 353c04e8d..52a0d2e99 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/EditInductionState.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/EditInductionState.cs @@ -1,3 +1,5 @@ +using TeachingRecordSystem.Core.DataStore.Postgres; + namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; public class EditInductionState : IRegisterJourney @@ -16,14 +18,16 @@ public class EditInductionState : IRegisterJourney public bool Initialized { get; set; } - public void EnsureInitialized(InductionStatus status) + public async Task EnsureInitializedAsync(TrsDbContext dbContext, Guid personId) { if (Initialized) { return; } + var person = await dbContext.Persons + .SingleAsync(q => q.PersonId == personId); + InductionStatus = person!.InductionStatus; - InductionStatus = status; Initialized = true; } } diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml index 25ed210ae..e733e885e 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml @@ -5,7 +5,7 @@ } @section BeforeContent { - Back + Back }

@ViewBag.Title

diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml.cs index 0f5117776..c479426cc 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml.cs @@ -7,11 +7,16 @@ public class ExemptionReasonModel(TrsLinkGenerator linkGenerator) : PageModel { public JourneyInstance? JourneyInstance { get; set; } + public string BackLink => BackPage()(PersonId, JourneyInstance!.InstanceId); + [FromRoute] public Guid PersonId { get; set; } + public InductionStatus InductionStatus { get; set; } + public void OnGet() { + InductionStatus = JourneyInstance!.State.InductionStatus; } public void OnPost() @@ -19,6 +24,16 @@ public void OnPost() // TODO - store the induction status // TODO - figure out where to go next and redirect to that page - Redirect(linkGenerator.InductionEditStartDate(PersonId, JourneyInstance!.InstanceId)); + Redirect(NextPage()(PersonId, JourneyInstance!.InstanceId)); + } + + private Func NextPage() + { + return (Id, journeyInstanceId) => linkGenerator.InductionChangeReason(Id, journeyInstanceId); + } + + private Func BackPage() + { + return (Id, journeyInstanceId) => linkGenerator.InductionEditStatus(Id, journeyInstanceId); } } diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml new file mode 100644 index 000000000..619953f16 --- /dev/null +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml @@ -0,0 +1,22 @@ +@page "/persons/{PersonId}/edit-induction/start-date" +@model TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction.StartDateModel +@{ + ViewBag.Title = "Start date"; +} + +@section BeforeContent { + Back +} + +

@ViewBag.Title

+ +
+
+
+
+ Continue + Cancel and return to record +
+
+ +
diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs new file mode 100644 index 000000000..77741731c --- /dev/null +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs @@ -0,0 +1,52 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; + +[Journey(JourneyNames.EditInduction), ActivatesJourney, RequireJourneyInstance] +public class StartDateModel(TrsLinkGenerator linkGenerator) : PageModel +{ + public JourneyInstance? JourneyInstance { get; set; } + + public InductionStatus InductionStatus { get; set; } + + public string BackLink => BackPage(InductionStatus)(PersonId, JourneyInstance!.InstanceId); + + [FromRoute] + public Guid PersonId { get; set; } + + public void OnGet() + { + InductionStatus = JourneyInstance!.State.InductionStatus; + } + + public void OnPost() + { + // TODO - store the start date + + // TODO - figure out where to go next and redirect to that page + //Redirect(linkGenerator.InductionEditStartDate(PersonId, JourneyInstance!.InstanceId)); + } + + private Func NextPage(InductionStatus status) + { + if (status == InductionStatus.InProgress) + { + return (Id, journeyInstanceId) => linkGenerator.InductionChangeReason(Id, journeyInstanceId); + } + else if (status.RequiresCompletedDate()) + { + return (Id, journeyInstanceId) => linkGenerator.InductionEditCompletedDate(Id, journeyInstanceId); + } + else + { + return (Id, journeyInstanceId) => linkGenerator.InductionEditExemptionReason(Id, journeyInstanceId); + } + } + + private Func BackPage(InductionStatus status) + { + // TODO - determine the correct back link - it's either Change status page, or Induction details + return (Id, journeyInstanceId) => linkGenerator.PersonInduction(Id); + } +} diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml index 03bd0d89d..60b107478 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml @@ -5,18 +5,18 @@ } @section BeforeContent { - Back + Back }

@ViewBag.Title

-
+
Continue - @* Cancel and return to record *@ + Cancel and return to record
diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs index d542c4ec8..8d91d65b0 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.Mvc.RazorPages; using TeachingRecordSystem.Core.DataStore.Postgres; @@ -8,6 +9,7 @@ namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInductio public class StatusModel(TrsLinkGenerator linkGenerator, TrsDbContext dbContext) : PageModel { public JourneyInstance? JourneyInstance { get; set; } + public string BackLink => BackPage()(PersonId, JourneyInstance!.InstanceId); [FromRoute] public Guid PersonId { get; set; } @@ -15,35 +17,44 @@ public class StatusModel(TrsLinkGenerator linkGenerator, TrsDbContext dbContext) [BindProperty] public InductionStatus InductionStatus { get; set; } - public async Task OnGetAsync() + public void OnGet() { InductionStatus = JourneyInstance!.State.InductionStatus; - var person = await dbContext.Persons - .SingleAsync(q => q.PersonId == PersonId); - InductionStatus = person!.InductionStatus; } public async Task OnPostAsync() { await JourneyInstance!.UpdateStateAsync(state => state.InductionStatus = InductionStatus); - // Use the delegate to determine where to go next and redirect to that page - Redirect(SetNextPage(InductionStatus)(PersonId, JourneyInstance!.InstanceId)); + // Determine where to go next and redirect to that page + Redirect(NextPage(InductionStatus)(PersonId, JourneyInstance!.InstanceId)); } - private Func SetNextPage(InductionStatus status) + public override async Task OnPageHandlerExecutionAsync(PageHandlerExecutingContext context, PageHandlerExecutionDelegate next) { - if (InductionStatus == InductionStatus.Exempt) + await JourneyInstance!.State.EnsureInitializedAsync(dbContext, PersonId); + + await next(); + } + + private Func NextPage(InductionStatus status) + { + if (status == InductionStatus.Exempt) { - return (personId, journeyInstanceId) => linkGenerator.InductionEditExemptionReason(personId, journeyInstanceId); + return (Id, journeyInstanceId) => linkGenerator.InductionEditExemptionReason(Id, journeyInstanceId); } - //if (InductionStatus == InductionStatus.RequiredToComplete) + //if (status == InductionStatus.RequiredToComplete) //{ // return (personId, journeyInstanceId) => linkGenerator.InductionChangeReason(personId, journeyInstanceId); //} - else + else { - return (personId, journeyInstanceId) => linkGenerator.InductionEditStartDate(personId, journeyInstanceId); + return (Id, journeyInstanceId) => linkGenerator.InductionEditStartDate(Id, journeyInstanceId); } } + + private Func BackPage() + { + return (Id, journeyInstanceId) => linkGenerator.PersonInduction(Id); + } } diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/TrsLinkGenerator.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/TrsLinkGenerator.cs index c5b4f857f..69ea4f8bb 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/TrsLinkGenerator.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/TrsLinkGenerator.cs @@ -178,6 +178,12 @@ public string InductionEditExemptionReason(Guid personId, JourneyInstanceId? jou public string InductionEditStartDate(Guid personId, JourneyInstanceId? journeyInstanceId, bool? fromCheckAnswers = null) => GetRequiredPathByPage("/Persons/PersonDetail/EditInduction/StartDate", routeValues: new { personId, fromCheckAnswers }, journeyInstanceId: journeyInstanceId); + public string InductionEditCompletedDate(Guid personId, JourneyInstanceId? journeyInstanceId, bool? fromCheckAnswers = null) => + GetRequiredPathByPage("/Persons/PersonDetail/EditInduction/CompletedDate", routeValues: new { personId, fromCheckAnswers }, journeyInstanceId: journeyInstanceId); + + public string InductionChangeReason(Guid personId, JourneyInstanceId? journeyInstanceId, bool? fromCheckAnswers = null) => + GetRequiredPathByPage("/Persons/PersonDetail/EditInduction/ChangeReason", routeValues: new { personId, fromCheckAnswers }, journeyInstanceId: journeyInstanceId); + public string EditChangeRequest(string ticketNumber) => GetRequiredPathByPage("/ChangeRequests/EditChangeRequest/Index", routeValues: new { ticketNumber }); public string ChangeRequestDocument(string ticketNumber, Guid documentId) => GetRequiredPathByPage("/ChangeRequests/EditChangeRequest/Index", "documents", routeValues: new { ticketNumber, id = documentId }); diff --git a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/EditInductionStateTests.cs b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/EditInductionStateTests.cs new file mode 100644 index 000000000..4db83070c --- /dev/null +++ b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/EditInductionStateTests.cs @@ -0,0 +1,67 @@ +using AngleSharp.Html.Dom; +using TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; + +namespace TeachingRecordSystem.SupportUi.Tests.PageTests.Persons.PersonDetail.EditInduction; + + +public class EditInductionStateTests(HostFixture hostFixture) : TestBase(hostFixture) +{ + [Theory] + [InlineData(InductionStatus.Exempt)] + [InlineData(InductionStatus.Passed)] + [InlineData(InductionStatus.RequiredToComplete)] + public async Task Confirm_RedirectsToNextPage(InductionStatus inductionStatus) + { + // Arrange + var person = await TestData.CreatePersonAsync(); + + var journeyInstance = await CreateJourneyInstanceAsync( + person.PersonId, + new EditInductionState() + { + Initialized = true, + InductionStatus = inductionStatus + }); + var request = new HttpRequestMessage(HttpMethod.Get, $"/persons/{person.PersonId}/edit-induction/status?{journeyInstance.GetUniqueIdQueryParameter()}"); + + // Act + var response = await HttpClient.SendAsync(request); + + // Assert + var doc = await AssertEx.HtmlResponseAsync(response); + var form = doc.GetElementByTestId("submit-form") as IHtmlFormElement; + Assert.NotNull(form); + } + + [Theory] + [InlineData(InductionStatus.Exempt)] + [InlineData(InductionStatus.Passed)] + [InlineData(InductionStatus.RequiredToComplete)] + public async Task Post_RedirectsToNextPage(InductionStatus inductionStatus) + { + // Arrange + var person = await TestData.CreatePersonAsync(); + + var journeyInstance = await CreateJourneyInstanceAsync( + person.PersonId, + new EditInductionState() + { + Initialized = true, + InductionStatus = inductionStatus + }); + var request = new HttpRequestMessage(HttpMethod.Post, $"/persons/{person.PersonId}/edit-induction/status?{journeyInstance.GetUniqueIdQueryParameter()}"); + + // Act + var response = await HttpClient.SendAsync(request); + + // Assert + var doc = await AssertEx.HtmlResponseAsync(response); + + } + + private Task> CreateJourneyInstanceAsync(Guid personId, EditInductionState? state = null) => + CreateJourneyInstance( + JourneyNames.EditInduction, + state ?? new EditInductionState(), + new KeyValuePair("personId", personId)); +} From b3b757e04866b1aba7710db066db86de59eb4d4c Mon Sep 17 00:00:00 2001 From: CLAWLOR Date: Fri, 13 Dec 2024 10:58:40 +0000 Subject: [PATCH 08/25] tests --- ...teTests.cs => EditInductionStatusTests.cs} | 42 ++++++------------- .../EditInduction/EditStartDateTests.cs | 42 +++++++++++++++++++ 2 files changed, 55 insertions(+), 29 deletions(-) rename TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/{EditInductionStateTests.cs => EditInductionStatusTests.cs} (50%) create mode 100644 TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/EditStartDateTests.cs diff --git a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/EditInductionStateTests.cs b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/EditInductionStatusTests.cs similarity index 50% rename from TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/EditInductionStateTests.cs rename to TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/EditInductionStatusTests.cs index 4db83070c..141cc072e 100644 --- a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/EditInductionStateTests.cs +++ b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/EditInductionStatusTests.cs @@ -4,13 +4,13 @@ namespace TeachingRecordSystem.SupportUi.Tests.PageTests.Persons.PersonDetail.EditInduction; -public class EditInductionStateTests(HostFixture hostFixture) : TestBase(hostFixture) +public class EditInductionStatusTests(HostFixture hostFixture) : TestBase(hostFixture) { [Theory] [InlineData(InductionStatus.Exempt)] [InlineData(InductionStatus.Passed)] [InlineData(InductionStatus.RequiredToComplete)] - public async Task Confirm_RedirectsToNextPage(InductionStatus inductionStatus) + public async Task Buttons_PostToExpectedPage(InductionStatus inductionStatus) { // Arrange var person = await TestData.CreatePersonAsync(); @@ -31,37 +31,21 @@ public async Task Confirm_RedirectsToNextPage(InductionStatus inductionStatus) var doc = await AssertEx.HtmlResponseAsync(response); var form = doc.GetElementByTestId("submit-form") as IHtmlFormElement; Assert.NotNull(form); + Assert.Contains($"/persons/{person.PersonId}/edit-induction/status", form.Action); + var buttons = form.GetElementsByTagName("button").Select(button => button as IHtmlButtonElement); + Assert.Equal(2, buttons.Count()); + Assert.Equal($"/persons/{person.PersonId}/induction", buttons.ElementAt(1)!.FormAction); } - [Theory] - [InlineData(InductionStatus.Exempt)] - [InlineData(InductionStatus.Passed)] - [InlineData(InductionStatus.RequiredToComplete)] - public async Task Post_RedirectsToNextPage(InductionStatus inductionStatus) + [Fact] + public void BackLink_LinksToExpectedPage() { - // Arrange - var person = await TestData.CreatePersonAsync(); - - var journeyInstance = await CreateJourneyInstanceAsync( - person.PersonId, - new EditInductionState() - { - Initialized = true, - InductionStatus = inductionStatus - }); - var request = new HttpRequestMessage(HttpMethod.Post, $"/persons/{person.PersonId}/edit-induction/status?{journeyInstance.GetUniqueIdQueryParameter()}"); - - // Act - var response = await HttpClient.SendAsync(request); - - // Assert - var doc = await AssertEx.HtmlResponseAsync(response); - + throw new NotImplementedException(); } private Task> CreateJourneyInstanceAsync(Guid personId, EditInductionState? state = null) => - CreateJourneyInstance( - JourneyNames.EditInduction, - state ?? new EditInductionState(), - new KeyValuePair("personId", personId)); + CreateJourneyInstance( + JourneyNames.EditInduction, + state ?? new EditInductionState(), + new KeyValuePair("personId", personId)); } diff --git a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/EditStartDateTests.cs b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/EditStartDateTests.cs new file mode 100644 index 000000000..d361ee5b5 --- /dev/null +++ b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/EditStartDateTests.cs @@ -0,0 +1,42 @@ +using AngleSharp.Html.Dom; +using TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; + +namespace TeachingRecordSystem.SupportUi.Tests.PageTests.Persons.PersonDetail.EditInduction; + +public class EditStartDateTests(HostFixture hostFixture) : TestBase(hostFixture) +{ + [Theory] + [InlineData(InductionStatus.Passed)] + public async Task Buttons_PostToExpectedPage(InductionStatus inductionStatus) + { + // Arrange + var person = await TestData.CreatePersonAsync(); + + var journeyInstance = await CreateJourneyInstanceAsync( + person.PersonId, + new EditInductionState() + { + Initialized = true, + InductionStatus = inductionStatus + }); + var request = new HttpRequestMessage(HttpMethod.Get, $"/persons/{person.PersonId}/edit-induction/start-date?{journeyInstance.GetUniqueIdQueryParameter()}"); + + // Act + var response = await HttpClient.SendAsync(request); + + // Assert + var doc = await AssertEx.HtmlResponseAsync(response); + var form = doc.GetElementByTestId("submit-form") as IHtmlFormElement; + Assert.NotNull(form); + Assert.Contains($"/persons/{person.PersonId}/edit-induction/start-date", form.Action); + var buttons = form.GetElementsByTagName("button").Select(button => button as IHtmlButtonElement); + Assert.Equal(2, buttons.Count()); + Assert.Equal($"/persons/{person.PersonId}/induction", buttons.ElementAt(1)!.FormAction); + } + + private Task> CreateJourneyInstanceAsync(Guid personId, EditInductionState? state = null) => + CreateJourneyInstance( + JourneyNames.EditInduction, + state ?? new EditInductionState(), + new KeyValuePair("personId", personId)); +} From 75d233beb5ad83d1e2fe036bc9fc38240d1fba4a Mon Sep 17 00:00:00 2001 From: CLAWLOR Date: Fri, 13 Dec 2024 12:53:35 +0000 Subject: [PATCH 09/25] share common page logic for journey --- .../EditInduction/CommonJourneyPage.cs | 38 +++++++++++++++++++ .../EditInduction/EditInductionState.cs | 10 +++++ .../EditInduction/ExemptionReason.cshtml | 2 +- .../EditInduction/ExemptionReason.cshtml.cs | 26 +++---------- .../EditInduction/StartDate.cshtml | 2 +- .../EditInduction/StartDate.cshtml.cs | 35 +++++++---------- .../PersonDetail/EditInduction/Status.cshtml | 2 +- .../EditInduction/Status.cshtml.cs | 36 +++++++++--------- .../TrsLinkGenerator.cs | 12 ++++++ 9 files changed, 101 insertions(+), 62 deletions(-) create mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CommonJourneyPage.cs diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CommonJourneyPage.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CommonJourneyPage.cs new file mode 100644 index 000000000..3987b2ebe --- /dev/null +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CommonJourneyPage.cs @@ -0,0 +1,38 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using TeachingRecordSystem.SupportUi; +using TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; + +public abstract class CommonJourneyPage : PageModel +{ + public JourneyInstance? JourneyInstance { get; set; } + + protected TrsLinkGenerator _linkGenerator; + + [FromRoute] + public Guid PersonId { get; set; } + + public string BackLink => BackPage(JourneyInstance!.State.PageBreadcrumb)(PersonId, JourneyInstance!.InstanceId); + + protected CommonJourneyPage(TrsLinkGenerator linkGenerator) + { + _linkGenerator = linkGenerator; + } + + public async Task OnPostCancelAsync() + { + await JourneyInstance!.DeleteAsync(); + return Redirect(_linkGenerator.PersonInduction(PersonId)); + } + + protected Func BackPage(EditInductionState.InductionJourneyPage? backPage) + { + return backPage switch + { + EditInductionState.InductionJourneyPage.Status => (Id, journeyInstanceId) => _linkGenerator.InductionEditStatus(Id, journeyInstanceId), + EditInductionState.InductionJourneyPage.CompletedDate => (Id, journeyInstanceId) => _linkGenerator.InductionEditCompletedDate(Id, journeyInstanceId), + EditInductionState.InductionJourneyPage.ExemptionReason => (Id, journeyInstanceId) => _linkGenerator.InductionEditExemptionReason(Id, journeyInstanceId), + _ => (Id, journeyInstanceId) => _linkGenerator.PersonInduction(Id) + }; + } +} diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/EditInductionState.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/EditInductionState.cs index 52a0d2e99..7a0ff2932 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/EditInductionState.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/EditInductionState.cs @@ -4,6 +4,15 @@ namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInductio public class EditInductionState : IRegisterJourney { + public enum InductionJourneyPage + { + Status, + ExemptionReason, + StartDate, + CompletedDate, + ChangeReason + } + public static JourneyDescriptor Journey => new( JourneyNames.EditInduction, typeof(EditInductionState), @@ -15,6 +24,7 @@ public class EditInductionState : IRegisterJourney public DateOnly? CompletedDate { get; set; } public InductionExemptionReasons? ExemptionReasons { get; set; } public string? ChangeReason { get; set; } + public InductionJourneyPage? PageBreadcrumb { get; set; } public bool Initialized { get; set; } diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml index e733e885e..bbc6bd03a 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml @@ -14,7 +14,7 @@
Continue - Cancel and return to record + Cancel and return to record
diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml.cs index c479426cc..a95990b67 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml.cs @@ -1,39 +1,25 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; - namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; -public class ExemptionReasonModel(TrsLinkGenerator linkGenerator) : PageModel +public class ExemptionReasonModel : CommonJourneyPage { - public JourneyInstance? JourneyInstance { get; set; } - - public string BackLink => BackPage()(PersonId, JourneyInstance!.InstanceId); - - [FromRoute] - public Guid PersonId { get; set; } - - public InductionStatus InductionStatus { get; set; } + public ExemptionReasonModel(TrsLinkGenerator linkGenerator) : base(linkGenerator) + { + } public void OnGet() { - InductionStatus = JourneyInstance!.State.InductionStatus; } public void OnPost() { - // TODO - store the induction status + // TODO - store the exemption reason - // TODO - figure out where to go next and redirect to that page Redirect(NextPage()(PersonId, JourneyInstance!.InstanceId)); } private Func NextPage() { - return (Id, journeyInstanceId) => linkGenerator.InductionChangeReason(Id, journeyInstanceId); + return (Id, journeyInstanceId) => _linkGenerator.InductionChangeReason(Id, journeyInstanceId); } - private Func BackPage() - { - return (Id, journeyInstanceId) => linkGenerator.InductionEditStatus(Id, journeyInstanceId); - } } diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml index 619953f16..66662d87d 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml @@ -15,7 +15,7 @@
Continue - Cancel and return to record + Cancel and return to record
diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs index 77741731c..3cd1fbd36 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs @@ -1,52 +1,45 @@ using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; [Journey(JourneyNames.EditInduction), ActivatesJourney, RequireJourneyInstance] -public class StartDateModel(TrsLinkGenerator linkGenerator) : PageModel +public class StartDateModel : CommonJourneyPage { - public JourneyInstance? JourneyInstance { get; set; } - public InductionStatus InductionStatus { get; set; } - public string BackLink => BackPage(InductionStatus)(PersonId, JourneyInstance!.InstanceId); - - [FromRoute] - public Guid PersonId { get; set; } + public StartDateModel(TrsLinkGenerator linkGenerator) :base(linkGenerator) + { + } public void OnGet() { InductionStatus = JourneyInstance!.State.InductionStatus; } - public void OnPost() + public async Task OnPostAsync() { - // TODO - store the start date + await JourneyInstance!.UpdateStateAsync(state => + { + // TODO - store the start date + state.PageBreadcrumb = EditInductionState.InductionJourneyPage.Status; + }); - // TODO - figure out where to go next and redirect to that page - //Redirect(linkGenerator.InductionEditStartDate(PersonId, JourneyInstance!.InstanceId)); + return Redirect(_linkGenerator.InductionEditStartDate(PersonId, JourneyInstance!.InstanceId)); //TODO add the other pages } private Func NextPage(InductionStatus status) { if (status == InductionStatus.InProgress) { - return (Id, journeyInstanceId) => linkGenerator.InductionChangeReason(Id, journeyInstanceId); + return (Id, journeyInstanceId) => _linkGenerator.InductionChangeReason(Id, journeyInstanceId); } else if (status.RequiresCompletedDate()) { - return (Id, journeyInstanceId) => linkGenerator.InductionEditCompletedDate(Id, journeyInstanceId); + return (Id, journeyInstanceId) => _linkGenerator.InductionEditCompletedDate(Id, journeyInstanceId); } else { - return (Id, journeyInstanceId) => linkGenerator.InductionEditExemptionReason(Id, journeyInstanceId); + return (Id, journeyInstanceId) => _linkGenerator.InductionEditExemptionReason(Id, journeyInstanceId); } } - - private Func BackPage(InductionStatus status) - { - // TODO - determine the correct back link - it's either Change status page, or Induction details - return (Id, journeyInstanceId) => linkGenerator.PersonInduction(Id); - } } diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml index 60b107478..25823bb56 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml @@ -16,7 +16,7 @@
Continue - Cancel and return to record + Cancel and return to record
diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs index 8d91d65b0..6a2a8ae7e 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs @@ -1,38 +1,43 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; -using Microsoft.AspNetCore.Mvc.RazorPages; using TeachingRecordSystem.Core.DataStore.Postgres; namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; [Journey(JourneyNames.EditInduction), ActivatesJourney, RequireJourneyInstance] -public class StatusModel(TrsLinkGenerator linkGenerator, TrsDbContext dbContext) : PageModel +public class StatusModel : CommonJourneyPage { - public JourneyInstance? JourneyInstance { get; set; } - public string BackLink => BackPage()(PersonId, JourneyInstance!.InstanceId); - - [FromRoute] - public Guid PersonId { get; set; } + protected TrsDbContext _dbContext; [BindProperty] public InductionStatus InductionStatus { get; set; } + public StatusModel(TrsLinkGenerator linkGenerator, TrsDbContext dbContext) : base(linkGenerator) + { + _dbContext = dbContext; + } + public void OnGet() { InductionStatus = JourneyInstance!.State.InductionStatus; } - public async Task OnPostAsync() + public async Task OnPostAsync() { - await JourneyInstance!.UpdateStateAsync(state => state.InductionStatus = InductionStatus); + await JourneyInstance!.UpdateStateAsync(state => + { + state.InductionStatus = InductionStatus; + state.PageBreadcrumb = EditInductionState.InductionJourneyPage.Status; + }); // Determine where to go next and redirect to that page - Redirect(NextPage(InductionStatus)(PersonId, JourneyInstance!.InstanceId)); + string url = NextPage(InductionStatus)(PersonId, JourneyInstance!.InstanceId); + return Redirect(url); } public override async Task OnPageHandlerExecutionAsync(PageHandlerExecutingContext context, PageHandlerExecutionDelegate next) { - await JourneyInstance!.State.EnsureInitializedAsync(dbContext, PersonId); + await JourneyInstance!.State.EnsureInitializedAsync(_dbContext, PersonId); await next(); } @@ -41,7 +46,7 @@ private Func NextPage(InductionStatus status) { if (status == InductionStatus.Exempt) { - return (Id, journeyInstanceId) => linkGenerator.InductionEditExemptionReason(Id, journeyInstanceId); + return (Id, journeyInstanceId) => _linkGenerator.InductionEditExemptionReason(Id, journeyInstanceId); } //if (status == InductionStatus.RequiredToComplete) //{ @@ -49,12 +54,7 @@ private Func NextPage(InductionStatus status) //} else { - return (Id, journeyInstanceId) => linkGenerator.InductionEditStartDate(Id, journeyInstanceId); + return (Id, journeyInstanceId) => _linkGenerator.InductionEditStartDate(Id, journeyInstanceId); } } - - private Func BackPage() - { - return (Id, journeyInstanceId) => linkGenerator.PersonInduction(Id); - } } diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/TrsLinkGenerator.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/TrsLinkGenerator.cs index 69ea4f8bb..1c4b1d406 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/TrsLinkGenerator.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/TrsLinkGenerator.cs @@ -172,15 +172,27 @@ public string AlertDeleteCheckAnswersCancel(Guid alertId, JourneyInstanceId jour public string InductionEditStatus(Guid personId, JourneyInstanceId? journeyInstanceId, bool? fromCheckAnswers = null) => GetRequiredPathByPage("/Persons/PersonDetail/EditInduction/Status", routeValues: new { personId, fromCheckAnswers }, journeyInstanceId: journeyInstanceId); + public string InductionEditStatusCancel(Guid personId, JourneyInstanceId? journeyInstanceId, bool? fromCheckAnswers = null) => + GetRequiredPathByPage("/Persons/PersonDetail/EditInduction/Status", "cancel", routeValues: new { personId, fromCheckAnswers }, journeyInstanceId: journeyInstanceId); + public string InductionEditExemptionReason(Guid personId, JourneyInstanceId? journeyInstanceId, bool? fromCheckAnswers = null) => GetRequiredPathByPage("/Persons/PersonDetail/EditInduction/ExemptionReason", routeValues: new { personId, fromCheckAnswers }, journeyInstanceId: journeyInstanceId); + public string InductionEditExemptionReasonCancel(Guid personId, JourneyInstanceId? journeyInstanceId, bool? fromCheckAnswers = null) => + GetRequiredPathByPage("/Persons/PersonDetail/EditInduction/ExemptionReason", "cancel", routeValues: new { personId, fromCheckAnswers }, journeyInstanceId: journeyInstanceId); + public string InductionEditStartDate(Guid personId, JourneyInstanceId? journeyInstanceId, bool? fromCheckAnswers = null) => GetRequiredPathByPage("/Persons/PersonDetail/EditInduction/StartDate", routeValues: new { personId, fromCheckAnswers }, journeyInstanceId: journeyInstanceId); + public string InductionEditStartDateCancel(Guid personId, JourneyInstanceId? journeyInstanceId, bool? fromCheckAnswers = null) => + GetRequiredPathByPage("/Persons/PersonDetail/EditInduction/StartDate", "cancel", routeValues: new { personId, fromCheckAnswers }, journeyInstanceId: journeyInstanceId); + public string InductionEditCompletedDate(Guid personId, JourneyInstanceId? journeyInstanceId, bool? fromCheckAnswers = null) => GetRequiredPathByPage("/Persons/PersonDetail/EditInduction/CompletedDate", routeValues: new { personId, fromCheckAnswers }, journeyInstanceId: journeyInstanceId); + public string InductionEditCompletedDateCancel(Guid personId, JourneyInstanceId? journeyInstanceId, bool? fromCheckAnswers = null) => + GetRequiredPathByPage("/Persons/PersonDetail/EditInduction/CompletedDate", "cancel", routeValues: new { personId, fromCheckAnswers }, journeyInstanceId: journeyInstanceId); + public string InductionChangeReason(Guid personId, JourneyInstanceId? journeyInstanceId, bool? fromCheckAnswers = null) => GetRequiredPathByPage("/Persons/PersonDetail/EditInduction/ChangeReason", routeValues: new { personId, fromCheckAnswers }, journeyInstanceId: journeyInstanceId); From ce8517c82a9b4a054b38e453020d3bcda456bbff Mon Sep 17 00:00:00 2001 From: CLAWLOR Date: Fri, 13 Dec 2024 15:11:11 +0000 Subject: [PATCH 10/25] add pages --- .../EditInduction/CheckYourAnswers.cshtml | 20 ++++++++++++ .../EditInduction/CheckYourAnswers.cshtml.cs | 20 ++++++++++++ .../EditInduction/CompletedDate.cshtml | 22 +++++++++++++ .../EditInduction/CompletedDate.cshtml.cs | 31 ++++++++++++++++++ .../EditInduction/ExemptionReason.cshtml.cs | 13 ++++++-- .../InductionChangeReason.cshtml | 20 ++++++++++++ .../InductionChangeReason.cshtml.cs | 32 +++++++++++++++++++ .../EditInduction/StartDate.cshtml.cs | 5 +-- .../EditInduction/Status.cshtml.cs | 8 ++--- .../TrsLinkGenerator.cs | 11 ++++++- 10 files changed, 172 insertions(+), 10 deletions(-) create mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml create mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml.cs create mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml create mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml.cs create mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml create mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml.cs diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml new file mode 100644 index 000000000..9bd2a4128 --- /dev/null +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml @@ -0,0 +1,20 @@ +@page "/persons/{PersonId}/edit-induction/check-answers" +@model TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction.ExemptionReasonModel +@{ + ViewBag.Title = "Check your answers"; +} + +@section BeforeContent { + Back +} + +

@ViewBag.Title

+ +
+
+
+ Continue + Cancel and return to record +
+
+
diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml.cs new file mode 100644 index 000000000..610586475 --- /dev/null +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml.cs @@ -0,0 +1,20 @@ +namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; + +[Journey(JourneyNames.EditInduction), RequireJourneyInstance] +public class CheckYourAnswersModel : CommonJourneyPage +{ + public CheckYourAnswersModel(TrsLinkGenerator linkGenerator) : base(linkGenerator) + { + } + + public void OnGet() + { + } + + public void OnPost() + { + // TODO - store the exemption reason + + // Final page - do all the special stuff + } +} diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml new file mode 100644 index 000000000..330e3ceef --- /dev/null +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml @@ -0,0 +1,22 @@ +@page "/persons/{PersonId}/edit-induction/date-completed" +@model TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction.CompletedDateModel +@{ + ViewBag.Title = "Date completed"; +} + +@section BeforeContent { + Back +} + +

@ViewBag.Title

+ +
+
+
+
+ Continue + Cancel and return to record +
+
+ +
diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml.cs new file mode 100644 index 000000000..fb317cad0 --- /dev/null +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml.cs @@ -0,0 +1,31 @@ +using Microsoft.AspNetCore.Mvc; + +namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; + +[Journey(JourneyNames.EditInduction), ActivatesJourney, RequireJourneyInstance] +public class CompletedDateModel : CommonJourneyPage +{ + public CompletedDateModel(TrsLinkGenerator linkGenerator) :base(linkGenerator) + { + } + + public void OnGet() + { + } + + public async Task OnPostAsync() + { + await JourneyInstance!.UpdateStateAsync(state => + { + // TODO - store the completed date + state.PageBreadcrumb = EditInductionState.InductionJourneyPage.CompletedDate; + }); + + return Redirect(NextPage()(PersonId, JourneyInstance!.InstanceId)); + } + + private Func NextPage() + { + return (Id, journeyInstanceId) => _linkGenerator.InductionChangeReason(Id, journeyInstanceId); + } +} diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml.cs index a95990b67..8f4c4d9b1 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml.cs @@ -1,5 +1,8 @@ +using Microsoft.AspNetCore.Mvc; + namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; +[Journey(JourneyNames.EditInduction), RequireJourneyInstance] public class ExemptionReasonModel : CommonJourneyPage { public ExemptionReasonModel(TrsLinkGenerator linkGenerator) : base(linkGenerator) @@ -10,11 +13,15 @@ public void OnGet() { } - public void OnPost() + public async Task OnPostAsync() { - // TODO - store the exemption reason + await JourneyInstance!.UpdateStateAsync(state => + { + // TODO - store the exemption reason + state.PageBreadcrumb = EditInductionState.InductionJourneyPage.ExemptionReason; + }); - Redirect(NextPage()(PersonId, JourneyInstance!.InstanceId)); + return Redirect(NextPage()(PersonId, JourneyInstance!.InstanceId)); } private Func NextPage() diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml new file mode 100644 index 000000000..89a795368 --- /dev/null +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml @@ -0,0 +1,20 @@ +@page "/persons/{PersonId}/edit-induction/change-reason" +@model TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction.ExemptionReasonModel +@{ + ViewBag.Title = "Change reason"; +} + +@section BeforeContent { + Back +} + +

@ViewBag.Title

+ +
+
+
+ Continue + Cancel and return to record +
+
+
diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml.cs new file mode 100644 index 000000000..d2e2ba70e --- /dev/null +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml.cs @@ -0,0 +1,32 @@ +using Microsoft.AspNetCore.Mvc; + +namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; + +[Journey(JourneyNames.EditInduction), RequireJourneyInstance] +public class InductionChangeReasonModel : CommonJourneyPage +{ + public InductionChangeReasonModel(TrsLinkGenerator linkGenerator) : base(linkGenerator) + { + } + + public void OnGet() + { + } + + public async Task OnPostAsync() + { + await JourneyInstance!.UpdateStateAsync(state => + { + // TODO - store the change reason + state.PageBreadcrumb = EditInductionState.InductionJourneyPage.ChangeReason; + }); + + return Redirect(NextPage()(PersonId, JourneyInstance!.InstanceId)); + } + + private Func NextPage() + { + return (Id, journeyInstanceId) => _linkGenerator.InductionCheckYourAnswers(Id, journeyInstanceId); + } + +} diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs index 3cd1fbd36..c64d06ebe 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs @@ -18,13 +18,14 @@ public void OnGet() public async Task OnPostAsync() { + InductionStatus = JourneyInstance!.State.InductionStatus; await JourneyInstance!.UpdateStateAsync(state => { // TODO - store the start date - state.PageBreadcrumb = EditInductionState.InductionJourneyPage.Status; + state.PageBreadcrumb = EditInductionState.InductionJourneyPage.StartDate; }); - return Redirect(_linkGenerator.InductionEditStartDate(PersonId, JourneyInstance!.InstanceId)); //TODO add the other pages + return Redirect(NextPage(InductionStatus)(PersonId, JourneyInstance!.InstanceId)); } private Func NextPage(InductionStatus status) diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs index 6a2a8ae7e..66ab4a0e9 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs @@ -48,10 +48,10 @@ private Func NextPage(InductionStatus status) { return (Id, journeyInstanceId) => _linkGenerator.InductionEditExemptionReason(Id, journeyInstanceId); } - //if (status == InductionStatus.RequiredToComplete) - //{ - // return (personId, journeyInstanceId) => linkGenerator.InductionChangeReason(personId, journeyInstanceId); - //} + if (status == InductionStatus.RequiredToComplete) + { + return (personId, journeyInstanceId) => _linkGenerator.InductionChangeReason(personId, journeyInstanceId); + } else { return (Id, journeyInstanceId) => _linkGenerator.InductionEditStartDate(Id, journeyInstanceId); diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/TrsLinkGenerator.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/TrsLinkGenerator.cs index 1c4b1d406..9e57f1c46 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/TrsLinkGenerator.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/TrsLinkGenerator.cs @@ -194,7 +194,16 @@ public string InductionEditCompletedDateCancel(Guid personId, JourneyInstanceId? GetRequiredPathByPage("/Persons/PersonDetail/EditInduction/CompletedDate", "cancel", routeValues: new { personId, fromCheckAnswers }, journeyInstanceId: journeyInstanceId); public string InductionChangeReason(Guid personId, JourneyInstanceId? journeyInstanceId, bool? fromCheckAnswers = null) => - GetRequiredPathByPage("/Persons/PersonDetail/EditInduction/ChangeReason", routeValues: new { personId, fromCheckAnswers }, journeyInstanceId: journeyInstanceId); + GetRequiredPathByPage("/Persons/PersonDetail/EditInduction/InductionChangeReason", routeValues: new { personId, fromCheckAnswers }, journeyInstanceId: journeyInstanceId); + + public string InductionChangeReasonCancel(Guid personId, JourneyInstanceId? journeyInstanceId, bool? fromCheckAnswers = null) => + GetRequiredPathByPage("/Persons/PersonDetail/EditInduction/InductionChangeReason", "cancel", routeValues: new { personId, fromCheckAnswers }, journeyInstanceId: journeyInstanceId); + + public string InductionCheckYourAnswers(Guid personId, JourneyInstanceId? journeyInstanceId, bool? fromCheckAnswers = null) => + GetRequiredPathByPage("/Persons/PersonDetail/EditInduction/CheckYourAnswers", routeValues: new { personId, fromCheckAnswers }, journeyInstanceId: journeyInstanceId); + + public string InductionCheckYourAnswersCancel(Guid personId, JourneyInstanceId? journeyInstanceId, bool? fromCheckAnswers = null) => + GetRequiredPathByPage("/Persons/PersonDetail/EditInduction/CheckYourAnswers", routeValues: new { personId, fromCheckAnswers }, journeyInstanceId: journeyInstanceId); public string EditChangeRequest(string ticketNumber) => GetRequiredPathByPage("/ChangeRequests/EditChangeRequest/Index", routeValues: new { ticketNumber }); From abe3b15078e219e78569f87ebd823f82beb12f6c Mon Sep 17 00:00:00 2001 From: CLAWLOR Date: Fri, 13 Dec 2024 16:36:51 +0000 Subject: [PATCH 11/25] refactor and add State service static class to induction status page --- .../EditInduction/CommonJourneyPage.cs | 32 +++++++++++++++---- .../EditInduction/CompletedDate.cshtml.cs | 3 +- .../EditInduction/EditInductionState.cs | 10 +----- .../EditInduction/ExemptionReason.cshtml.cs | 3 +- .../InductionChangeReason.cshtml.cs | 3 +- .../EditInduction/StartDate.cshtml.cs | 3 +- .../EditInduction/Status.cshtml.cs | 15 +++++---- .../InductionJourneyPage.cs | 11 +++++++ .../InductionWizardPageLogicService.cs | 22 +++++++++++++ 9 files changed, 75 insertions(+), 27 deletions(-) create mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Services/InductionWizardPageLogic/InductionJourneyPage.cs create mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Services/InductionWizardPageLogic/InductionWizardPageLogicService.cs diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CommonJourneyPage.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CommonJourneyPage.cs index 3987b2ebe..953384339 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CommonJourneyPage.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CommonJourneyPage.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Mvc.RazorPages; using TeachingRecordSystem.SupportUi; using TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; +using TeachingRecordSystem.SupportUi.Services.InductionWizardPageLogic; public abstract class CommonJourneyPage : PageModel { @@ -12,7 +13,7 @@ public abstract class CommonJourneyPage : PageModel [FromRoute] public Guid PersonId { get; set; } - public string BackLink => BackPage(JourneyInstance!.State.PageBreadcrumb)(PersonId, JourneyInstance!.InstanceId); + public string BackLink => PageLink(JourneyInstance!.State.PageBreadcrumb); protected CommonJourneyPage(TrsLinkGenerator linkGenerator) { @@ -25,14 +26,31 @@ public async Task OnPostCancelAsync() return Redirect(_linkGenerator.PersonInduction(PersonId)); } - protected Func BackPage(EditInductionState.InductionJourneyPage? backPage) + //protected Func PageLinkFunction(EditInductionState.InductionJourneyPage? pageName) + //{ + // return pageName switch + // { + // EditInductionState.InductionJourneyPage.Status => (Id, journeyInstanceId) => _linkGenerator.InductionEditStatus(Id, journeyInstanceId), + // EditInductionState.InductionJourneyPage.CompletedDate => (Id, journeyInstanceId) => _linkGenerator.InductionEditCompletedDate(Id, journeyInstanceId), + // EditInductionState.InductionJourneyPage.ExemptionReason => (Id, journeyInstanceId) => _linkGenerator.InductionEditExemptionReason(Id, journeyInstanceId), + // EditInductionState.InductionJourneyPage.StartDate => (Id, journeyInstanceId) => _linkGenerator.InductionEditStartDate(Id, journeyInstanceId), + // EditInductionState.InductionJourneyPage.ChangeReason => (Id, journeyInstanceId) => _linkGenerator.InductionChangeReason(Id, journeyInstanceId), + // EditInductionState.InductionJourneyPage.CheckYourAnswers => (Id, journeyInstanceId) => _linkGenerator.InductionCheckYourAnswers(Id, journeyInstanceId), + // _ => throw new NotImplementedException() + // }; + //} + + protected string PageLink(InductionJourneyPage? pageName) { - return backPage switch + return pageName switch { - EditInductionState.InductionJourneyPage.Status => (Id, journeyInstanceId) => _linkGenerator.InductionEditStatus(Id, journeyInstanceId), - EditInductionState.InductionJourneyPage.CompletedDate => (Id, journeyInstanceId) => _linkGenerator.InductionEditCompletedDate(Id, journeyInstanceId), - EditInductionState.InductionJourneyPage.ExemptionReason => (Id, journeyInstanceId) => _linkGenerator.InductionEditExemptionReason(Id, journeyInstanceId), - _ => (Id, journeyInstanceId) => _linkGenerator.PersonInduction(Id) + InductionJourneyPage.Status => _linkGenerator.InductionEditStatus(PersonId, JourneyInstance!.InstanceId), + InductionJourneyPage.CompletedDate => _linkGenerator.InductionEditCompletedDate(PersonId, JourneyInstance!.InstanceId), + InductionJourneyPage.ExemptionReason => _linkGenerator.InductionEditExemptionReason(PersonId, JourneyInstance!.InstanceId), + InductionJourneyPage.StartDate => _linkGenerator.InductionEditStartDate(PersonId, JourneyInstance!.InstanceId), + InductionJourneyPage.ChangeReason => _linkGenerator.InductionChangeReason(PersonId, JourneyInstance!.InstanceId), + InductionJourneyPage.CheckYourAnswers => _linkGenerator.InductionCheckYourAnswers(PersonId, JourneyInstance!.InstanceId), + _ => _linkGenerator.PersonInduction(PersonId) }; } } diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml.cs index fb317cad0..39c917551 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc; +using TeachingRecordSystem.SupportUi.Services.InductionWizardPageLogic; namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; @@ -18,7 +19,7 @@ public async Task OnPostAsync() await JourneyInstance!.UpdateStateAsync(state => { // TODO - store the completed date - state.PageBreadcrumb = EditInductionState.InductionJourneyPage.CompletedDate; + state.PageBreadcrumb = InductionJourneyPage.CompletedDate; }); return Redirect(NextPage()(PersonId, JourneyInstance!.InstanceId)); diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/EditInductionState.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/EditInductionState.cs index 7a0ff2932..2019cd83f 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/EditInductionState.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/EditInductionState.cs @@ -1,18 +1,10 @@ using TeachingRecordSystem.Core.DataStore.Postgres; +using TeachingRecordSystem.SupportUi.Services.InductionWizardPageLogic; namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; public class EditInductionState : IRegisterJourney { - public enum InductionJourneyPage - { - Status, - ExemptionReason, - StartDate, - CompletedDate, - ChangeReason - } - public static JourneyDescriptor Journey => new( JourneyNames.EditInduction, typeof(EditInductionState), diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml.cs index 8f4c4d9b1..1a13a7344 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc; +using TeachingRecordSystem.SupportUi.Services.InductionWizardPageLogic; namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; @@ -18,7 +19,7 @@ public async Task OnPostAsync() await JourneyInstance!.UpdateStateAsync(state => { // TODO - store the exemption reason - state.PageBreadcrumb = EditInductionState.InductionJourneyPage.ExemptionReason; + state.PageBreadcrumb = InductionJourneyPage.ExemptionReason; }); return Redirect(NextPage()(PersonId, JourneyInstance!.InstanceId)); diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml.cs index d2e2ba70e..982007bac 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc; +using TeachingRecordSystem.SupportUi.Services.InductionWizardPageLogic; namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; @@ -18,7 +19,7 @@ public async Task OnPostAsync() await JourneyInstance!.UpdateStateAsync(state => { // TODO - store the change reason - state.PageBreadcrumb = EditInductionState.InductionJourneyPage.ChangeReason; + state.PageBreadcrumb = InductionJourneyPage.ChangeReason; }); return Redirect(NextPage()(PersonId, JourneyInstance!.InstanceId)); diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs index c64d06ebe..ac1dfc2f0 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc; +using TeachingRecordSystem.SupportUi.Services.InductionWizardPageLogic; namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; @@ -22,7 +23,7 @@ public async Task OnPostAsync() await JourneyInstance!.UpdateStateAsync(state => { // TODO - store the start date - state.PageBreadcrumb = EditInductionState.InductionJourneyPage.StartDate; + state.PageBreadcrumb = InductionJourneyPage.StartDate; }); return Redirect(NextPage(InductionStatus)(PersonId, JourneyInstance!.InstanceId)); diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs index 66ab4a0e9..505c1ee86 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs @@ -1,6 +1,8 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; using TeachingRecordSystem.Core.DataStore.Postgres; +using TeachingRecordSystem.SupportUi.Services.InductionRouting; +using TeachingRecordSystem.SupportUi.Services.InductionWizardPageLogic; namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; @@ -27,12 +29,11 @@ public async Task OnPostAsync() await JourneyInstance!.UpdateStateAsync(state => { state.InductionStatus = InductionStatus; - state.PageBreadcrumb = EditInductionState.InductionJourneyPage.Status; + state.PageBreadcrumb = InductionJourneyPage.Status; }); // Determine where to go next and redirect to that page - string url = NextPage(InductionStatus)(PersonId, JourneyInstance!.InstanceId); - return Redirect(url); + return Redirect(PageLink(InductionWizardPageLogicService.NextPageFromStatusPage(InductionStatus))); } public override async Task OnPageHandlerExecutionAsync(PageHandlerExecutingContext context, PageHandlerExecutionDelegate next) @@ -42,19 +43,19 @@ public override async Task OnPageHandlerExecutionAsync(PageHandlerExecutingConte await next(); } - private Func NextPage(InductionStatus status) + private InductionJourneyPage NextJourneyPage(InductionStatus status) { if (status == InductionStatus.Exempt) { - return (Id, journeyInstanceId) => _linkGenerator.InductionEditExemptionReason(Id, journeyInstanceId); + return InductionJourneyPage.ExemptionReason; } if (status == InductionStatus.RequiredToComplete) { - return (personId, journeyInstanceId) => _linkGenerator.InductionChangeReason(personId, journeyInstanceId); + return InductionJourneyPage.ChangeReason; } else { - return (Id, journeyInstanceId) => _linkGenerator.InductionEditStartDate(Id, journeyInstanceId); + return InductionJourneyPage.StartDate; } } } diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Services/InductionWizardPageLogic/InductionJourneyPage.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Services/InductionWizardPageLogic/InductionJourneyPage.cs new file mode 100644 index 000000000..d83bb7f8c --- /dev/null +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Services/InductionWizardPageLogic/InductionJourneyPage.cs @@ -0,0 +1,11 @@ +namespace TeachingRecordSystem.SupportUi.Services.InductionWizardPageLogic; + +public enum InductionJourneyPage +{ + Status, + ExemptionReason, + StartDate, + CompletedDate, + ChangeReason, + CheckYourAnswers +} diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Services/InductionWizardPageLogic/InductionWizardPageLogicService.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Services/InductionWizardPageLogic/InductionWizardPageLogicService.cs new file mode 100644 index 000000000..653f47ab1 --- /dev/null +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Services/InductionWizardPageLogic/InductionWizardPageLogicService.cs @@ -0,0 +1,22 @@ +using TeachingRecordSystem.SupportUi.Services.InductionWizardPageLogic; + +namespace TeachingRecordSystem.SupportUi.Services.InductionRouting; + +public static class InductionWizardPageLogicService +{ + public static InductionJourneyPage NextPageFromStatusPage(InductionStatus status) + { + if (status == InductionStatus.Exempt) + { + return InductionJourneyPage.ExemptionReason; + } + if (status == InductionStatus.RequiredToComplete) + { + return InductionJourneyPage.ChangeReason; + } + else + { + return InductionJourneyPage.StartDate; + } + } +} From 6c459db84ccede99a6d08c95971e34e545dcc3b0 Mon Sep 17 00:00:00 2001 From: CLAWLOR Date: Sun, 15 Dec 2024 16:38:17 +0000 Subject: [PATCH 12/25] button group --- .../EditInduction/CheckYourAnswers.cshtml | 6 ++- .../EditInduction/CommonJourneyPage.cs | 14 ------ .../EditInduction/ExemptionReason.cshtml | 6 ++- .../InductionChangeReason.cshtml | 6 ++- .../EditInduction/StartDate.cshtml | 2 +- .../EditInduction/Status.cshtml.cs | 4 +- .../EditInduction/EditInductionStatusTests.cs | 43 ++++++++++++++++--- 7 files changed, 53 insertions(+), 28 deletions(-) diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml index 9bd2a4128..3df4a34bf 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml @@ -13,8 +13,10 @@
- Continue - Cancel and return to record +
+ Continue + Cancel and return to record +
diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CommonJourneyPage.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CommonJourneyPage.cs index 953384339..c45b64221 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CommonJourneyPage.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CommonJourneyPage.cs @@ -26,20 +26,6 @@ public async Task OnPostCancelAsync() return Redirect(_linkGenerator.PersonInduction(PersonId)); } - //protected Func PageLinkFunction(EditInductionState.InductionJourneyPage? pageName) - //{ - // return pageName switch - // { - // EditInductionState.InductionJourneyPage.Status => (Id, journeyInstanceId) => _linkGenerator.InductionEditStatus(Id, journeyInstanceId), - // EditInductionState.InductionJourneyPage.CompletedDate => (Id, journeyInstanceId) => _linkGenerator.InductionEditCompletedDate(Id, journeyInstanceId), - // EditInductionState.InductionJourneyPage.ExemptionReason => (Id, journeyInstanceId) => _linkGenerator.InductionEditExemptionReason(Id, journeyInstanceId), - // EditInductionState.InductionJourneyPage.StartDate => (Id, journeyInstanceId) => _linkGenerator.InductionEditStartDate(Id, journeyInstanceId), - // EditInductionState.InductionJourneyPage.ChangeReason => (Id, journeyInstanceId) => _linkGenerator.InductionChangeReason(Id, journeyInstanceId), - // EditInductionState.InductionJourneyPage.CheckYourAnswers => (Id, journeyInstanceId) => _linkGenerator.InductionCheckYourAnswers(Id, journeyInstanceId), - // _ => throw new NotImplementedException() - // }; - //} - protected string PageLink(InductionJourneyPage? pageName) { return pageName switch diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml index bbc6bd03a..857acf66b 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml @@ -13,8 +13,10 @@
- Continue - Cancel and return to record +
+ Continue + Cancel and return to record +
diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml index 89a795368..36dc44c05 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml @@ -13,8 +13,10 @@
- Continue - Cancel and return to record +
+ Continue + Cancel and return to record +
diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml index 66662d87d..fb0e82e22 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml @@ -8,7 +8,7 @@ Back } -

@ViewBag.Title

+

@ViewBag.Title

diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs index 505c1ee86..ad21b751a 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs @@ -33,7 +33,7 @@ public async Task OnPostAsync() }); // Determine where to go next and redirect to that page - return Redirect(PageLink(InductionWizardPageLogicService.NextPageFromStatusPage(InductionStatus))); + return Redirect(PageLink(NextPageInJourney(InductionStatus))); } public override async Task OnPageHandlerExecutionAsync(PageHandlerExecutingContext context, PageHandlerExecutionDelegate next) @@ -43,7 +43,7 @@ public override async Task OnPageHandlerExecutionAsync(PageHandlerExecutingConte await next(); } - private InductionJourneyPage NextJourneyPage(InductionStatus status) + private InductionJourneyPage NextPageInJourney(InductionStatus status) { if (status == InductionStatus.Exempt) { diff --git a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/EditInductionStatusTests.cs b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/EditInductionStatusTests.cs index 141cc072e..6500181c5 100644 --- a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/EditInductionStatusTests.cs +++ b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/EditInductionStatusTests.cs @@ -6,13 +6,11 @@ namespace TeachingRecordSystem.SupportUi.Tests.PageTests.Persons.PersonDetail.Ed public class EditInductionStatusTests(HostFixture hostFixture) : TestBase(hostFixture) { - [Theory] - [InlineData(InductionStatus.Exempt)] - [InlineData(InductionStatus.Passed)] - [InlineData(InductionStatus.RequiredToComplete)] - public async Task Buttons_PostToExpectedPage(InductionStatus inductionStatus) + [Fact] + public async Task Buttons_PostToExpectedPage() { // Arrange + InductionStatus inductionStatus = InductionStatus.Passed; var person = await TestData.CreatePersonAsync(); var journeyInstance = await CreateJourneyInstanceAsync( @@ -37,6 +35,41 @@ public async Task Buttons_PostToExpectedPage(InductionStatus inductionStatus) Assert.Equal($"/persons/{person.PersonId}/induction", buttons.ElementAt(1)!.FormAction); } + [Theory] + [InlineData(InductionStatus.Exempt, "Select exemption reason")] + [InlineData(InductionStatus.InProgress, "Start date")] + [InlineData(InductionStatus.Failed, "Start date")] + [InlineData(InductionStatus.FailedInWales, "Start date")] + [InlineData(InductionStatus.Passed, "Start date")] + [InlineData(InductionStatus.RequiredToComplete, "Change reason")] + public async Task Post_RedirectsToExpectedPage(InductionStatus inductionStatus, string expectedNextPage) + { + // Arrange + var person = await TestData.CreatePersonAsync(); + + var journeyInstance = await CreateJourneyInstanceAsync( + person.PersonId, + new EditInductionState() + { + Initialized = true, + InductionStatus = inductionStatus + }); + var request = new HttpRequestMessage(HttpMethod.Post, $"/persons/{person.PersonId}/edit-induction/status?{journeyInstance.GetUniqueIdQueryParameter()}"); + + // Act + var response = await HttpClient.SendAsync(request); + + // Assert + Assert.Equal(StatusCodes.Status302Found, (int)response.StatusCode); + + var redirectResponse = await response.FollowRedirectAsync(HttpClient); + var redirectDoc = await redirectResponse.GetDocumentAsync(); + + // Assert + var title = redirectDoc.GetElementById("page-title")!.TextContent; + Assert.Contains(expectedNextPage, title); + } + [Fact] public void BackLink_LinksToExpectedPage() { From 808370ac81bbc7af71106ff1c383c7cfecfdbc66 Mon Sep 17 00:00:00 2001 From: CLAWLOR Date: Mon, 16 Dec 2024 09:32:07 +0000 Subject: [PATCH 13/25] common tests for journey - buttons --- .../EditInduction/CheckYourAnswers.cshtml | 6 +- .../EditInduction/CompletedDate.cshtml | 6 +- .../EditInduction/ExemptionReason.cshtml | 6 +- .../InductionChangeReason.cshtml | 8 +- .../EditInduction/StartDate.cshtml | 4 +- .../PersonDetail/EditInduction/Status.cshtml | 6 +- .../EditInduction/Status.cshtml.cs | 1 - .../EditInduction/CommonPageTests.cs | 106 ++++++++++++++++++ .../EditInduction/EditInductionStatusTests.cs | 35 ------ 9 files changed, 124 insertions(+), 54 deletions(-) create mode 100644 TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/CommonPageTests.cs diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml index 3df4a34bf..fe5990c81 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml @@ -8,14 +8,14 @@ Back } -

@ViewBag.Title

+

@ViewBag.Title

- Continue - Cancel and return to record + Continue + Cancel and return to record
diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml index 330e3ceef..7c3a36fda 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml @@ -8,14 +8,14 @@ Back } -

@ViewBag.Title

+

@ViewBag.Title

- Continue - Cancel and return to record + Continue + Cancel and return to record
diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml index 857acf66b..acda4c70e 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml @@ -8,14 +8,14 @@ Back } -

@ViewBag.Title

+

@ViewBag.Title

- Continue - Cancel and return to record + Continue + Cancel and return to record
diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml index 36dc44c05..ab1b1ca46 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml @@ -1,5 +1,5 @@ @page "/persons/{PersonId}/edit-induction/change-reason" -@model TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction.ExemptionReasonModel +@model TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction.InductionChangeReasonModel @{ ViewBag.Title = "Change reason"; } @@ -8,14 +8,14 @@ Back } -

@ViewBag.Title

+

@ViewBag.Title

- Continue - Cancel and return to record + Continue + Cancel and return to record
diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml index fb0e82e22..c20366d86 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml @@ -14,8 +14,8 @@
- Continue - Cancel and return to record + Continue + Cancel and return to record
diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml index 25823bb56..6ff16f015 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml @@ -8,15 +8,15 @@ Back } -

@ViewBag.Title

+

@ViewBag.Title

- Continue - Cancel and return to record + Continue + Cancel and return to record
diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs index ad21b751a..b3cd5825b 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs @@ -1,7 +1,6 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; using TeachingRecordSystem.Core.DataStore.Postgres; -using TeachingRecordSystem.SupportUi.Services.InductionRouting; using TeachingRecordSystem.SupportUi.Services.InductionWizardPageLogic; namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; diff --git a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/CommonPageTests.cs b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/CommonPageTests.cs new file mode 100644 index 000000000..6e18d555e --- /dev/null +++ b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/CommonPageTests.cs @@ -0,0 +1,106 @@ +using AngleSharp.Html.Dom; +using TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; + +namespace TeachingRecordSystem.SupportUi.Tests.PageTests.Persons.PersonDetail.EditInduction; + +public class CommonPageTests(HostFixture hostFixture) : TestBase(hostFixture) +{ + [Theory] + [InlineData("edit-induction/status", InductionStatus.Exempt, "exemption-reasons")] + [InlineData("edit-induction/status", InductionStatus.InProgress, "start-date")] + [InlineData("edit-induction/status", InductionStatus.Failed, "start-date")] + [InlineData("edit-induction/status", InductionStatus.FailedInWales, "start-date")] + [InlineData("edit-induction/status", InductionStatus.Passed, "start-date")] + [InlineData("edit-induction/status", InductionStatus.RequiredToComplete, "change-reason")] + [InlineData("edit-induction/exemption-reasons", InductionStatus.Exempt, "change-reason")] + [InlineData("edit-induction/start-date", InductionStatus.InProgress, "change-reason")] + [InlineData("edit-induction/start-date", InductionStatus.Failed, "date-completed")] + [InlineData("edit-induction/start-date", InductionStatus.FailedInWales, "date-completed")] + [InlineData("edit-induction/start-date", InductionStatus.Passed, "date-completed")] + [InlineData("edit-induction/date-completed", InductionStatus.Failed, "change-reason")] + [InlineData("edit-induction/date-completed", InductionStatus.FailedInWales, "change-reason")] + [InlineData("edit-induction/date-completed", InductionStatus.Passed, "change-reason")] + [InlineData("edit-induction/change-reason", InductionStatus.Exempt, "check-answers")] + [InlineData("edit-induction/change-reason", InductionStatus.InProgress, "check-answers")] + [InlineData("edit-induction/change-reason", InductionStatus.Failed, "check-answers")] + [InlineData("edit-induction/change-reason", InductionStatus.FailedInWales, "check-answers")] + [InlineData("edit-induction/change-reason", InductionStatus.Passed, "check-answers")] + [InlineData("edit-induction/change-reason", InductionStatus.RequiredToComplete, "check-answers")] + public async Task Post_RedirectsToExpectedPage(string fromPage, InductionStatus inductionStatus, string expectedNextPageUrl) + { + // Arrange + var person = await TestData.CreatePersonAsync( + personBuilder => personBuilder + .WithInductionStatus(inductionBuilder => inductionBuilder + .WithStatus(inductionStatus))); + + var journeyInstance = await CreateJourneyInstanceAsync( + person.PersonId, + new EditInductionState() + { + Initialized = true, + InductionStatus = inductionStatus + }); + + var request = new HttpRequestMessage(HttpMethod.Post, $"/persons/{person.PersonId}/{fromPage}?{journeyInstance.GetUniqueIdQueryParameter()}"); + if (fromPage == "edit-induction/status") + { + request.Content = new FormUrlEncodedContent(new Dictionary + { + { "InductionStatus", inductionStatus.ToString() } + }); + } + + // Act + var response = await HttpClient.SendAsync(request); + + // Assert + Assert.Equal(StatusCodes.Status302Found, (int)response.StatusCode); + var location = response.Headers.Location?.OriginalString; + Assert.Contains(expectedNextPageUrl, location); + } + + [Theory] + [InlineData("edit-induction/status")] + [InlineData("edit-induction/exemption-reasons")] + [InlineData("edit-induction/start-date")] + [InlineData("edit-induction/date-completed")] + [InlineData("edit-induction/change-reason")] + [InlineData("edit-induction/check-answers")] + public async Task Cancel_RedirectsToExpectedPage(string fromPage) + { + // Arrange + var person = await TestData.CreatePersonAsync(); + + var journeyInstance = await CreateJourneyInstanceAsync( + person.PersonId, + new EditInductionState() + { + Initialized = true, + }); + + var request = new HttpRequestMessage(HttpMethod.Get, $"/persons/{person.PersonId}/{fromPage}?{journeyInstance.GetUniqueIdQueryParameter()}"); + + // Act + var response = await HttpClient.SendAsync(request); + + // Assert + var doc = await AssertEx.HtmlResponseAsync(response); + var cancelButton = doc.GetElementByTestId("cancel-button") as IHtmlButtonElement; + + // Act + var redirectRequest = new HttpRequestMessage(HttpMethod.Post, cancelButton!.FormAction); + var redirectResponse = await HttpClient.SendAsync(redirectRequest); + + // Assert + Assert.Equal(StatusCodes.Status302Found, (int)redirectResponse.StatusCode); + var location = redirectResponse.Headers.Location?.OriginalString; + Assert.Equal($"/persons/{person.PersonId}/induction", location); + } + + private Task> CreateJourneyInstanceAsync(Guid personId, EditInductionState? state = null) => + CreateJourneyInstance( + JourneyNames.EditInduction, + state ?? new EditInductionState(), + new KeyValuePair("personId", personId)); +} diff --git a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/EditInductionStatusTests.cs b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/EditInductionStatusTests.cs index 6500181c5..ddb4998a5 100644 --- a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/EditInductionStatusTests.cs +++ b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/EditInductionStatusTests.cs @@ -35,41 +35,6 @@ public async Task Buttons_PostToExpectedPage() Assert.Equal($"/persons/{person.PersonId}/induction", buttons.ElementAt(1)!.FormAction); } - [Theory] - [InlineData(InductionStatus.Exempt, "Select exemption reason")] - [InlineData(InductionStatus.InProgress, "Start date")] - [InlineData(InductionStatus.Failed, "Start date")] - [InlineData(InductionStatus.FailedInWales, "Start date")] - [InlineData(InductionStatus.Passed, "Start date")] - [InlineData(InductionStatus.RequiredToComplete, "Change reason")] - public async Task Post_RedirectsToExpectedPage(InductionStatus inductionStatus, string expectedNextPage) - { - // Arrange - var person = await TestData.CreatePersonAsync(); - - var journeyInstance = await CreateJourneyInstanceAsync( - person.PersonId, - new EditInductionState() - { - Initialized = true, - InductionStatus = inductionStatus - }); - var request = new HttpRequestMessage(HttpMethod.Post, $"/persons/{person.PersonId}/edit-induction/status?{journeyInstance.GetUniqueIdQueryParameter()}"); - - // Act - var response = await HttpClient.SendAsync(request); - - // Assert - Assert.Equal(StatusCodes.Status302Found, (int)response.StatusCode); - - var redirectResponse = await response.FollowRedirectAsync(HttpClient); - var redirectDoc = await redirectResponse.GetDocumentAsync(); - - // Assert - var title = redirectDoc.GetElementById("page-title")!.TextContent; - Assert.Contains(expectedNextPage, title); - } - [Fact] public void BackLink_LinksToExpectedPage() { From 5d0e8b35f9c609658fca9e36cfe523e21817599e Mon Sep 17 00:00:00 2001 From: CLAWLOR Date: Mon, 16 Dec 2024 09:40:15 +0000 Subject: [PATCH 14/25] page state move --- .../EditInduction/CommonJourneyPage.cs | 1 - .../EditInduction/CompletedDate.cshtml.cs | 1 - .../EditInduction/EditInductionState.cs | 1 - .../EditInduction/ExemptionReason.cshtml.cs | 1 - .../InductionChangeReason.cshtml.cs | 1 - .../EditInduction}/InductionJourneyPage.cs | 2 +- .../EditInduction/StartDate.cshtml.cs | 1 - .../EditInduction/Status.cshtml.cs | 1 - .../InductionWizardPageLogicService.cs | 22 ------------------- 9 files changed, 1 insertion(+), 30 deletions(-) rename TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/{Services/InductionWizardPageLogic => Pages/Persons/PersonDetail/EditInduction}/InductionJourneyPage.cs (63%) delete mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Services/InductionWizardPageLogic/InductionWizardPageLogicService.cs diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CommonJourneyPage.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CommonJourneyPage.cs index c45b64221..07242f9b3 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CommonJourneyPage.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CommonJourneyPage.cs @@ -2,7 +2,6 @@ using Microsoft.AspNetCore.Mvc.RazorPages; using TeachingRecordSystem.SupportUi; using TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; -using TeachingRecordSystem.SupportUi.Services.InductionWizardPageLogic; public abstract class CommonJourneyPage : PageModel { diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml.cs index 39c917551..264f9e0d5 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml.cs @@ -1,5 +1,4 @@ using Microsoft.AspNetCore.Mvc; -using TeachingRecordSystem.SupportUi.Services.InductionWizardPageLogic; namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/EditInductionState.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/EditInductionState.cs index 2019cd83f..defbf6644 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/EditInductionState.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/EditInductionState.cs @@ -1,5 +1,4 @@ using TeachingRecordSystem.Core.DataStore.Postgres; -using TeachingRecordSystem.SupportUi.Services.InductionWizardPageLogic; namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml.cs index 1a13a7344..37d860fd6 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml.cs @@ -1,5 +1,4 @@ using Microsoft.AspNetCore.Mvc; -using TeachingRecordSystem.SupportUi.Services.InductionWizardPageLogic; namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml.cs index 982007bac..a94651e30 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml.cs @@ -1,5 +1,4 @@ using Microsoft.AspNetCore.Mvc; -using TeachingRecordSystem.SupportUi.Services.InductionWizardPageLogic; namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Services/InductionWizardPageLogic/InductionJourneyPage.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionJourneyPage.cs similarity index 63% rename from TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Services/InductionWizardPageLogic/InductionJourneyPage.cs rename to TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionJourneyPage.cs index d83bb7f8c..41662f4a5 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Services/InductionWizardPageLogic/InductionJourneyPage.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionJourneyPage.cs @@ -1,4 +1,4 @@ -namespace TeachingRecordSystem.SupportUi.Services.InductionWizardPageLogic; +namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; public enum InductionJourneyPage { diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs index ac1dfc2f0..56c162ec3 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs @@ -1,5 +1,4 @@ using Microsoft.AspNetCore.Mvc; -using TeachingRecordSystem.SupportUi.Services.InductionWizardPageLogic; namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs index b3cd5825b..82d55c161 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs @@ -1,7 +1,6 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; using TeachingRecordSystem.Core.DataStore.Postgres; -using TeachingRecordSystem.SupportUi.Services.InductionWizardPageLogic; namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Services/InductionWizardPageLogic/InductionWizardPageLogicService.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Services/InductionWizardPageLogic/InductionWizardPageLogicService.cs deleted file mode 100644 index 653f47ab1..000000000 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Services/InductionWizardPageLogic/InductionWizardPageLogicService.cs +++ /dev/null @@ -1,22 +0,0 @@ -using TeachingRecordSystem.SupportUi.Services.InductionWizardPageLogic; - -namespace TeachingRecordSystem.SupportUi.Services.InductionRouting; - -public static class InductionWizardPageLogicService -{ - public static InductionJourneyPage NextPageFromStatusPage(InductionStatus status) - { - if (status == InductionStatus.Exempt) - { - return InductionJourneyPage.ExemptionReason; - } - if (status == InductionStatus.RequiredToComplete) - { - return InductionJourneyPage.ChangeReason; - } - else - { - return InductionJourneyPage.StartDate; - } - } -} From 40f8e3f2ba14b6a39bf33d042332dceeff9ade2a Mon Sep 17 00:00:00 2001 From: CLAWLOR Date: Mon, 16 Dec 2024 11:35:36 +0000 Subject: [PATCH 15/25] backlink id --- .../EditInduction/CheckYourAnswers.cshtml | 6 +-- .../EditInduction/CheckYourAnswers.cshtml.cs | 13 ++++-- .../EditInduction/CompletedDate.cshtml | 2 +- .../EditInduction/ExemptionReason.cshtml | 2 +- .../InductionChangeReason.cshtml | 2 +- .../EditInduction/StartDate.cshtml | 2 +- .../EditInduction/StartDate.cshtml.cs | 8 +--- .../PersonDetail/EditInduction/Status.cshtml | 2 +- .../EditInduction/Status.cshtml.cs | 6 +-- .../EditInduction/CommonPageTests.cs | 46 ++++++++++--------- .../EditInduction/EditInductionStatusTests.cs | 33 +++++++++---- .../EditInduction/EditStartDateTests.cs | 42 ----------------- 12 files changed, 73 insertions(+), 91 deletions(-) delete mode 100644 TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/EditStartDateTests.cs diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml index fe5990c81..5824efdd8 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml @@ -1,11 +1,11 @@ @page "/persons/{PersonId}/edit-induction/check-answers" -@model TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction.ExemptionReasonModel +@model TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction.CheckYourAnswersModel @{ ViewBag.Title = "Check your answers"; } @section BeforeContent { - Back + Back }

@ViewBag.Title

@@ -14,7 +14,7 @@
- Continue + Confirm induction details Cancel and return to record
diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml.cs index 610586475..315d11348 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml.cs @@ -1,3 +1,5 @@ +using Microsoft.AspNetCore.Mvc; + namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; [Journey(JourneyNames.EditInduction), RequireJourneyInstance] @@ -11,10 +13,15 @@ public void OnGet() { } - public void OnPost() + public async Task OnPost() { - // TODO - store the exemption reason + // Final page - complete the journey + + return Redirect(NextPage()(PersonId, JourneyInstance!.InstanceId)); + } - // Final page - do all the special stuff + private Func NextPage() + { + return (Id, journeyInstanceId) => _linkGenerator.PersonInduction(Id); } } diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml index 7c3a36fda..9b9bb4eaf 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml @@ -5,7 +5,7 @@ } @section BeforeContent { - Back + Back }

@ViewBag.Title

diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml index acda4c70e..9b80c7b4d 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml @@ -5,7 +5,7 @@ } @section BeforeContent { - Back + Back }

@ViewBag.Title

diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml index ab1b1ca46..3b79e20d1 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml @@ -5,7 +5,7 @@ } @section BeforeContent { - Back + Back }

@ViewBag.Title

diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml index c20366d86..8ea588a48 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml @@ -5,7 +5,7 @@ } @section BeforeContent { - Back + Back }

@ViewBag.Title

diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs index 56c162ec3..69b881f0c 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs @@ -30,17 +30,13 @@ public async Task OnPostAsync() private Func NextPage(InductionStatus status) { - if (status == InductionStatus.InProgress) - { - return (Id, journeyInstanceId) => _linkGenerator.InductionChangeReason(Id, journeyInstanceId); - } - else if (status.RequiresCompletedDate()) + if (status.RequiresCompletedDate()) { return (Id, journeyInstanceId) => _linkGenerator.InductionEditCompletedDate(Id, journeyInstanceId); } else { - return (Id, journeyInstanceId) => _linkGenerator.InductionEditExemptionReason(Id, journeyInstanceId); + return (Id, journeyInstanceId) => _linkGenerator.InductionChangeReason(Id, journeyInstanceId); } } } diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml index 6ff16f015..76d7f19fc 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml @@ -5,7 +5,7 @@ } @section BeforeContent { - Back + Back }

@ViewBag.Title

diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs index 82d55c161..327158a2b 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs @@ -47,13 +47,13 @@ private InductionJourneyPage NextPageInJourney(InductionStatus status) { return InductionJourneyPage.ExemptionReason; } - if (status == InductionStatus.RequiredToComplete) + else if (status.RequiresStartDate()) { - return InductionJourneyPage.ChangeReason; + return InductionJourneyPage.StartDate; } else { - return InductionJourneyPage.StartDate; + return InductionJourneyPage.ChangeReason; } } } diff --git a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/CommonPageTests.cs b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/CommonPageTests.cs index 6e18d555e..6b0c555ee 100644 --- a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/CommonPageTests.cs +++ b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/CommonPageTests.cs @@ -6,26 +6,27 @@ namespace TeachingRecordSystem.SupportUi.Tests.PageTests.Persons.PersonDetail.Ed public class CommonPageTests(HostFixture hostFixture) : TestBase(hostFixture) { [Theory] - [InlineData("edit-induction/status", InductionStatus.Exempt, "exemption-reasons")] - [InlineData("edit-induction/status", InductionStatus.InProgress, "start-date")] - [InlineData("edit-induction/status", InductionStatus.Failed, "start-date")] - [InlineData("edit-induction/status", InductionStatus.FailedInWales, "start-date")] - [InlineData("edit-induction/status", InductionStatus.Passed, "start-date")] - [InlineData("edit-induction/status", InductionStatus.RequiredToComplete, "change-reason")] - [InlineData("edit-induction/exemption-reasons", InductionStatus.Exempt, "change-reason")] - [InlineData("edit-induction/start-date", InductionStatus.InProgress, "change-reason")] - [InlineData("edit-induction/start-date", InductionStatus.Failed, "date-completed")] - [InlineData("edit-induction/start-date", InductionStatus.FailedInWales, "date-completed")] - [InlineData("edit-induction/start-date", InductionStatus.Passed, "date-completed")] - [InlineData("edit-induction/date-completed", InductionStatus.Failed, "change-reason")] - [InlineData("edit-induction/date-completed", InductionStatus.FailedInWales, "change-reason")] - [InlineData("edit-induction/date-completed", InductionStatus.Passed, "change-reason")] - [InlineData("edit-induction/change-reason", InductionStatus.Exempt, "check-answers")] - [InlineData("edit-induction/change-reason", InductionStatus.InProgress, "check-answers")] - [InlineData("edit-induction/change-reason", InductionStatus.Failed, "check-answers")] - [InlineData("edit-induction/change-reason", InductionStatus.FailedInWales, "check-answers")] - [InlineData("edit-induction/change-reason", InductionStatus.Passed, "check-answers")] - [InlineData("edit-induction/change-reason", InductionStatus.RequiredToComplete, "check-answers")] + [InlineData("edit-induction/status", InductionStatus.Exempt, "edit-induction/exemption-reasons")] + [InlineData("edit-induction/status", InductionStatus.InProgress, "edit-induction/start-date")] + [InlineData("edit-induction/status", InductionStatus.Failed, "edit-induction/start-date")] + [InlineData("edit-induction/status", InductionStatus.FailedInWales, "edit-induction/start-date")] + [InlineData("edit-induction/status", InductionStatus.Passed, "edit-induction/start-date")] + [InlineData("edit-induction/status", InductionStatus.RequiredToComplete, "edit-induction/change-reason")] + [InlineData("edit-induction/exemption-reasons", InductionStatus.Exempt, "edit-induction/change-reason")] + [InlineData("edit-induction/start-date", InductionStatus.InProgress, "edit-induction/change-reason")] + [InlineData("edit-induction/start-date", InductionStatus.Failed, "edit-induction/date-completed")] + [InlineData("edit-induction/start-date", InductionStatus.FailedInWales, "edit-induction/date-completed")] + [InlineData("edit-induction/start-date", InductionStatus.Passed, "edit-induction/date-completed")] + [InlineData("edit-induction/date-completed", InductionStatus.Failed, "edit-induction/change-reason")] + [InlineData("edit-induction/date-completed", InductionStatus.FailedInWales, "edit-induction/change-reason")] + [InlineData("edit-induction/date-completed", InductionStatus.Passed, "edit-induction/change-reason")] + [InlineData("edit-induction/change-reason", InductionStatus.Exempt, "edit-induction/check-answers")] + [InlineData("edit-induction/change-reason", InductionStatus.InProgress, "edit-induction/check-answers")] + [InlineData("edit-induction/change-reason", InductionStatus.Failed, "edit-induction/check-answers")] + [InlineData("edit-induction/change-reason", InductionStatus.FailedInWales, "edit-induction/check-answers")] + [InlineData("edit-induction/change-reason", InductionStatus.Passed, "edit-induction/check-answers")] + [InlineData("edit-induction/change-reason", InductionStatus.RequiredToComplete, "edit-induction/check-answers")] + [InlineData("edit-induction/check-answers", InductionStatus.RequiredToComplete, "induction")] public async Task Post_RedirectsToExpectedPage(string fromPage, InductionStatus inductionStatus, string expectedNextPageUrl) { // Arrange @@ -57,7 +58,10 @@ public async Task Post_RedirectsToExpectedPage(string fromPage, InductionStatus // Assert Assert.Equal(StatusCodes.Status302Found, (int)response.StatusCode); var location = response.Headers.Location?.OriginalString; - Assert.Contains(expectedNextPageUrl, location); + var expectedUrl = expectedNextPageUrl == "induction" + ? $"/persons/{person.PersonId}/{expectedNextPageUrl}" + : $"/persons/{person.PersonId}/{expectedNextPageUrl}?{journeyInstance.GetUniqueIdQueryParameter()}"; + Assert.Equal(expectedUrl, location); } [Theory] diff --git a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/EditInductionStatusTests.cs b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/EditInductionStatusTests.cs index ddb4998a5..4a82e3de6 100644 --- a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/EditInductionStatusTests.cs +++ b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/EditInductionStatusTests.cs @@ -7,7 +7,7 @@ namespace TeachingRecordSystem.SupportUi.Tests.PageTests.Persons.PersonDetail.Ed public class EditInductionStatusTests(HostFixture hostFixture) : TestBase(hostFixture) { [Fact] - public async Task Buttons_PostToExpectedPage() + public async Task ContinueAndCancelButtons_ExistOnPage() { // Arrange InductionStatus inductionStatus = InductionStatus.Passed; @@ -32,18 +32,35 @@ public async Task Buttons_PostToExpectedPage() Assert.Contains($"/persons/{person.PersonId}/edit-induction/status", form.Action); var buttons = form.GetElementsByTagName("button").Select(button => button as IHtmlButtonElement); Assert.Equal(2, buttons.Count()); - Assert.Equal($"/persons/{person.PersonId}/induction", buttons.ElementAt(1)!.FormAction); + Assert.Equal("Continue", buttons.ElementAt(0)!.TextContent); + Assert.Equal("Cancel and return to record", buttons.ElementAt(1)!.TextContent); } [Fact] - public void BackLink_LinksToExpectedPage() + public async Task BackLink_LinksToExpectedPage() { - throw new NotImplementedException(); + // Arrange + InductionStatus inductionStatus = InductionStatus.Passed; + var person = await TestData.CreatePersonAsync(); + + var journeyInstance = await CreateJourneyInstanceAsync( + person.PersonId, + new EditInductionState() + { + Initialized = true, + InductionStatus = inductionStatus + }); + var request = new HttpRequestMessage(HttpMethod.Post, $"/persons/{person.PersonId}/edit-induction/status?{journeyInstance.GetUniqueIdQueryParameter()}"); + + // Act + var response = await HttpClient.SendAsync(request); + + throw new NotImplementedException("Test not implemented"); } private Task> CreateJourneyInstanceAsync(Guid personId, EditInductionState? state = null) => - CreateJourneyInstance( - JourneyNames.EditInduction, - state ?? new EditInductionState(), - new KeyValuePair("personId", personId)); + CreateJourneyInstance( + JourneyNames.EditInduction, + state ?? new EditInductionState(), + new KeyValuePair("personId", personId)); } diff --git a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/EditStartDateTests.cs b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/EditStartDateTests.cs deleted file mode 100644 index d361ee5b5..000000000 --- a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/EditStartDateTests.cs +++ /dev/null @@ -1,42 +0,0 @@ -using AngleSharp.Html.Dom; -using TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; - -namespace TeachingRecordSystem.SupportUi.Tests.PageTests.Persons.PersonDetail.EditInduction; - -public class EditStartDateTests(HostFixture hostFixture) : TestBase(hostFixture) -{ - [Theory] - [InlineData(InductionStatus.Passed)] - public async Task Buttons_PostToExpectedPage(InductionStatus inductionStatus) - { - // Arrange - var person = await TestData.CreatePersonAsync(); - - var journeyInstance = await CreateJourneyInstanceAsync( - person.PersonId, - new EditInductionState() - { - Initialized = true, - InductionStatus = inductionStatus - }); - var request = new HttpRequestMessage(HttpMethod.Get, $"/persons/{person.PersonId}/edit-induction/start-date?{journeyInstance.GetUniqueIdQueryParameter()}"); - - // Act - var response = await HttpClient.SendAsync(request); - - // Assert - var doc = await AssertEx.HtmlResponseAsync(response); - var form = doc.GetElementByTestId("submit-form") as IHtmlFormElement; - Assert.NotNull(form); - Assert.Contains($"/persons/{person.PersonId}/edit-induction/start-date", form.Action); - var buttons = form.GetElementsByTagName("button").Select(button => button as IHtmlButtonElement); - Assert.Equal(2, buttons.Count()); - Assert.Equal($"/persons/{person.PersonId}/induction", buttons.ElementAt(1)!.FormAction); - } - - private Task> CreateJourneyInstanceAsync(Guid personId, EditInductionState? state = null) => - CreateJourneyInstance( - JourneyNames.EditInduction, - state ?? new EditInductionState(), - new KeyValuePair("personId", personId)); -} From 447d1f64296d7c3d59ca8e2738a49264e9ecdc2f Mon Sep 17 00:00:00 2001 From: CLAWLOR Date: Mon, 16 Dec 2024 12:40:48 +0000 Subject: [PATCH 16/25] next page logic --- .../EditInduction/CheckYourAnswers.cshtml.cs | 10 ++++-- .../EditInduction/CompletedDate.cshtml.cs | 9 ++---- .../EditInduction/ExemptionReason.cshtml.cs | 10 ++---- .../InductionChangeReason.cshtml.cs | 10 ++---- .../EditInduction/StartDate.cshtml.cs | 24 +++++++------- .../EditInduction/Status.cshtml.cs | 31 +++++++++---------- .../EditInduction/CommonPageTests.cs | 30 ++++++++++++++++++ .../EditInduction/EditInductionStatusTests.cs | 22 ------------- 8 files changed, 71 insertions(+), 75 deletions(-) diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml.cs index 315d11348..933cfa7c6 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml.cs @@ -13,14 +13,18 @@ public void OnGet() { } - public async Task OnPost() + public async Task OnPostAsync() { - // Final page - complete the journey + await JourneyInstance!.UpdateStateAsync(state => + { + state.PageBreadcrumb = InductionJourneyPage.CheckYourAnswers; + }); + // TODO - end of journey logic return Redirect(NextPage()(PersonId, JourneyInstance!.InstanceId)); } - private Func NextPage() + public Func NextPage() { return (Id, journeyInstanceId) => _linkGenerator.PersonInduction(Id); } diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml.cs index 264f9e0d5..a094f8914 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml.cs @@ -5,6 +5,8 @@ namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInductio [Journey(JourneyNames.EditInduction), ActivatesJourney, RequireJourneyInstance] public class CompletedDateModel : CommonJourneyPage { + public InductionJourneyPage NextPage => InductionJourneyPage.ChangeReason; + public CompletedDateModel(TrsLinkGenerator linkGenerator) :base(linkGenerator) { } @@ -21,11 +23,6 @@ public async Task OnPostAsync() state.PageBreadcrumb = InductionJourneyPage.CompletedDate; }); - return Redirect(NextPage()(PersonId, JourneyInstance!.InstanceId)); - } - - private Func NextPage() - { - return (Id, journeyInstanceId) => _linkGenerator.InductionChangeReason(Id, journeyInstanceId); + return Redirect(PageLink(NextPage)); } } diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml.cs index 37d860fd6..c11e07455 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml.cs @@ -5,6 +5,8 @@ namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInductio [Journey(JourneyNames.EditInduction), RequireJourneyInstance] public class ExemptionReasonModel : CommonJourneyPage { + public InductionJourneyPage NextPage => InductionJourneyPage.ChangeReason; + public ExemptionReasonModel(TrsLinkGenerator linkGenerator) : base(linkGenerator) { } @@ -21,12 +23,6 @@ public async Task OnPostAsync() state.PageBreadcrumb = InductionJourneyPage.ExemptionReason; }); - return Redirect(NextPage()(PersonId, JourneyInstance!.InstanceId)); + return Redirect(PageLink(NextPage)); } - - private Func NextPage() - { - return (Id, journeyInstanceId) => _linkGenerator.InductionChangeReason(Id, journeyInstanceId); - } - } diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml.cs index a94651e30..75abd1a49 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml.cs @@ -5,6 +5,8 @@ namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInductio [Journey(JourneyNames.EditInduction), RequireJourneyInstance] public class InductionChangeReasonModel : CommonJourneyPage { + public InductionJourneyPage NextPage => InductionJourneyPage.CheckYourAnswers; + public InductionChangeReasonModel(TrsLinkGenerator linkGenerator) : base(linkGenerator) { } @@ -21,12 +23,6 @@ public async Task OnPostAsync() state.PageBreadcrumb = InductionJourneyPage.ChangeReason; }); - return Redirect(NextPage()(PersonId, JourneyInstance!.InstanceId)); + return Redirect(PageLink(NextPage)); } - - private Func NextPage() - { - return (Id, journeyInstanceId) => _linkGenerator.InductionCheckYourAnswers(Id, journeyInstanceId); - } - } diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs index 69b881f0c..444507f80 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs @@ -7,6 +7,16 @@ public class StartDateModel : CommonJourneyPage { public InductionStatus InductionStatus { get; set; } + public InductionJourneyPage NextPage + { + get + { + return InductionStatus.RequiresCompletedDate() + ? InductionJourneyPage.CompletedDate + : InductionJourneyPage.ChangeReason; + } + } + public StartDateModel(TrsLinkGenerator linkGenerator) :base(linkGenerator) { } @@ -25,18 +35,6 @@ public async Task OnPostAsync() state.PageBreadcrumb = InductionJourneyPage.StartDate; }); - return Redirect(NextPage(InductionStatus)(PersonId, JourneyInstance!.InstanceId)); - } - - private Func NextPage(InductionStatus status) - { - if (status.RequiresCompletedDate()) - { - return (Id, journeyInstanceId) => _linkGenerator.InductionEditCompletedDate(Id, journeyInstanceId); - } - else - { - return (Id, journeyInstanceId) => _linkGenerator.InductionChangeReason(Id, journeyInstanceId); - } + return Redirect(PageLink(NextPage)); } } diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs index 327158a2b..18be754ad 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs @@ -12,6 +12,19 @@ public class StatusModel : CommonJourneyPage [BindProperty] public InductionStatus InductionStatus { get; set; } + public InductionJourneyPage NextPageInJourney + { + get + { + return InductionStatus switch + { + InductionStatus.Exempt => InductionJourneyPage.ExemptionReason, + _ when InductionStatus.RequiresStartDate() => InductionJourneyPage.StartDate, + _ => InductionJourneyPage.ChangeReason + }; + } + } + public StatusModel(TrsLinkGenerator linkGenerator, TrsDbContext dbContext) : base(linkGenerator) { _dbContext = dbContext; @@ -30,8 +43,7 @@ public async Task OnPostAsync() state.PageBreadcrumb = InductionJourneyPage.Status; }); - // Determine where to go next and redirect to that page - return Redirect(PageLink(NextPageInJourney(InductionStatus))); + return Redirect(PageLink(NextPageInJourney)); } public override async Task OnPageHandlerExecutionAsync(PageHandlerExecutingContext context, PageHandlerExecutionDelegate next) @@ -41,19 +53,4 @@ public override async Task OnPageHandlerExecutionAsync(PageHandlerExecutingConte await next(); } - private InductionJourneyPage NextPageInJourney(InductionStatus status) - { - if (status == InductionStatus.Exempt) - { - return InductionJourneyPage.ExemptionReason; - } - else if (status.RequiresStartDate()) - { - return InductionJourneyPage.StartDate; - } - else - { - return InductionJourneyPage.ChangeReason; - } - } } diff --git a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/CommonPageTests.cs b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/CommonPageTests.cs index 6b0c555ee..b1a6a686e 100644 --- a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/CommonPageTests.cs +++ b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/CommonPageTests.cs @@ -102,6 +102,36 @@ public async Task Cancel_RedirectsToExpectedPage(string fromPage) Assert.Equal($"/persons/{person.PersonId}/induction", location); } + [Theory] + [InlineData("edit-induction/status", InductionJourneyPage.Status)] + [InlineData("edit-induction/exemption-reasons", InductionJourneyPage.ExemptionReason)] + [InlineData("edit-induction/start-date", InductionJourneyPage.StartDate)] + [InlineData("edit-induction/date-completed", InductionJourneyPage.CompletedDate)] + [InlineData("edit-induction/change-reason", InductionJourneyPage.ChangeReason)] + [InlineData("edit-induction/check-answers", InductionJourneyPage.CheckYourAnswers)] + public async Task Post_UpdateJourneyStateBacklinkBreadcrumb(string page, InductionJourneyPage pageName) + { + // Arrange + InductionStatus inductionStatus = InductionStatus.Passed; + var person = await TestData.CreatePersonAsync(); + + var journeyInstance = await CreateJourneyInstanceAsync( + person.PersonId, + new EditInductionState() + { + Initialized = true, + InductionStatus = inductionStatus + }); + var request = new HttpRequestMessage(HttpMethod.Post, $"/persons/{person.PersonId}/{page}?{journeyInstance.GetUniqueIdQueryParameter()}"); + + // Act + var response = await HttpClient.SendAsync(request); + + // Assert + journeyInstance = await ReloadJourneyInstance(journeyInstance); + Assert.Equal(pageName, journeyInstance.State.PageBreadcrumb); + } + private Task> CreateJourneyInstanceAsync(Guid personId, EditInductionState? state = null) => CreateJourneyInstance( JourneyNames.EditInduction, diff --git a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/EditInductionStatusTests.cs b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/EditInductionStatusTests.cs index 4a82e3de6..3053c48f2 100644 --- a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/EditInductionStatusTests.cs +++ b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/EditInductionStatusTests.cs @@ -36,28 +36,6 @@ public async Task ContinueAndCancelButtons_ExistOnPage() Assert.Equal("Cancel and return to record", buttons.ElementAt(1)!.TextContent); } - [Fact] - public async Task BackLink_LinksToExpectedPage() - { - // Arrange - InductionStatus inductionStatus = InductionStatus.Passed; - var person = await TestData.CreatePersonAsync(); - - var journeyInstance = await CreateJourneyInstanceAsync( - person.PersonId, - new EditInductionState() - { - Initialized = true, - InductionStatus = inductionStatus - }); - var request = new HttpRequestMessage(HttpMethod.Post, $"/persons/{person.PersonId}/edit-induction/status?{journeyInstance.GetUniqueIdQueryParameter()}"); - - // Act - var response = await HttpClient.SendAsync(request); - - throw new NotImplementedException("Test not implemented"); - } - private Task> CreateJourneyInstanceAsync(Guid personId, EditInductionState? state = null) => CreateJourneyInstance( JourneyNames.EditInduction, From 2fc36b11b0b101e81f80a435d8f90b5a127dfb57 Mon Sep 17 00:00:00 2001 From: CLAWLOR Date: Mon, 16 Dec 2024 12:56:09 +0000 Subject: [PATCH 17/25] NextPage rename for consistency --- .../Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs index 18be754ad..2c539387b 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs @@ -12,7 +12,7 @@ public class StatusModel : CommonJourneyPage [BindProperty] public InductionStatus InductionStatus { get; set; } - public InductionJourneyPage NextPageInJourney + public InductionJourneyPage NextPage { get { @@ -43,7 +43,7 @@ public async Task OnPostAsync() state.PageBreadcrumb = InductionJourneyPage.Status; }); - return Redirect(PageLink(NextPageInJourney)); + return Redirect(PageLink(NextPage)); } public override async Task OnPageHandlerExecutionAsync(PageHandlerExecutingContext context, PageHandlerExecutionDelegate next) From ddfedc0d6e32286a8b19460e4d9e259cd0db02d4 Mon Sep 17 00:00:00 2001 From: CLAWLOR Date: Mon, 16 Dec 2024 16:39:20 +0000 Subject: [PATCH 18/25] add RequiresExemptionReason to InductionStatus class --- .../DataStore/Postgres/Models/Person.cs | 5 +++-- .../Models/InductionStatus.cs | 11 +++++++---- .../PersonDetail/EditInduction/Status.cshtml.cs | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.Core/DataStore/Postgres/Models/Person.cs b/TeachingRecordSystem/src/TeachingRecordSystem.Core/DataStore/Postgres/Models/Person.cs index 4baa4eb7d..ac8552c02 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.Core/DataStore/Postgres/Models/Person.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.Core/DataStore/Postgres/Models/Person.cs @@ -191,6 +191,7 @@ public static bool ValidateInductionData( { var requiresStartDate = status.RequiresStartDate(); var requiresCompletedDate = status.RequiresCompletedDate(); + var requiresExemptionReason = status.RequiresExemptionReason(); if (requiresStartDate && startDate is null) { @@ -216,13 +217,13 @@ public static bool ValidateInductionData( return false; } - if (status is InductionStatus.Exempt && exemptionReasons == InductionExemptionReasons.None) + if (requiresExemptionReason && exemptionReasons == InductionExemptionReasons.None) { error = $"Exemption reasons cannot be {nameof(InductionExemptionReasons.None)} when the status is: '{status}'."; return false; } - if (status is not InductionStatus.Exempt && exemptionReasons != InductionExemptionReasons.None) + if (!requiresExemptionReason && exemptionReasons != InductionExemptionReasons.None) { error = $"Exemption reasons must be {nameof(InductionExemptionReasons.None)} when the status is: '{status}'."; return false; diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.Core/Models/InductionStatus.cs b/TeachingRecordSystem/src/TeachingRecordSystem.Core/Models/InductionStatus.cs index 12aaf4f84..984105267 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.Core/Models/InductionStatus.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.Core/Models/InductionStatus.cs @@ -8,7 +8,7 @@ public enum InductionStatus None = 0, [InductionStatusInfo("required to complete", requiresStartDate: false, requiresCompletedDate: false)] RequiredToComplete = 1, - [InductionStatusInfo("exempt", requiresStartDate: false, requiresCompletedDate: false)] + [InductionStatusInfo("exempt", requiresStartDate: false, requiresCompletedDate: false, requiresExemptionReason: true)] Exempt = 2, [InductionStatusInfo("in progress", requiresStartDate: true, requiresCompletedDate: false)] InProgress = 3, @@ -35,6 +35,8 @@ public static class InductionStatusRegistry public static bool RequiresCompletedDate(this InductionStatus status) => _info[status].RequiresCompletedDate; + public static bool RequiresExemptionReason(this InductionStatus status) => _info[status].RequiresExemptionReason; + public static InductionStatus ToInductionStatus(this dfeta_InductionStatus status) => ToInductionStatus((dfeta_InductionStatus?)status); @@ -61,19 +63,20 @@ private static InductionStatusInfo GetInfo(InductionStatus status) .GetCustomAttribute() ?? throw new Exception($"{nameof(InductionStatus)}.{status} is missing the {nameof(InductionStatusInfoAttribute)} attribute."); - return new InductionStatusInfo(status, attr.Name, attr.RequiresStartDate, attr.RequiresCompletedDate); + return new InductionStatusInfo(status, attr.Name, attr.RequiresStartDate, attr.RequiresCompletedDate, attr.RequiresExemptionReason); } } -public sealed record InductionStatusInfo(InductionStatus Value, string Name, bool RequiresStartDate, bool RequiresCompletedDate) +public sealed record InductionStatusInfo(InductionStatus Value, string Name, bool RequiresStartDate, bool RequiresCompletedDate, bool RequiresExemptionReason = false) { public string Title => Name[0..1].ToUpper() + Name[1..]; } [AttributeUsage(AttributeTargets.Field, AllowMultiple = false)] -file sealed class InductionStatusInfoAttribute(string name, bool requiresStartDate, bool requiresCompletedDate) : Attribute +file sealed class InductionStatusInfoAttribute(string name, bool requiresStartDate, bool requiresCompletedDate, bool requiresExemptionReason = false) : Attribute { public string Name => name; public bool RequiresStartDate => requiresStartDate; public bool RequiresCompletedDate => requiresCompletedDate; + public bool RequiresExemptionReason => requiresExemptionReason; } diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs index 2c539387b..07d25254c 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs @@ -18,7 +18,7 @@ public InductionJourneyPage NextPage { return InductionStatus switch { - InductionStatus.Exempt => InductionJourneyPage.ExemptionReason, + _ when InductionStatus.RequiresExemptionReason() => InductionJourneyPage.ExemptionReason, _ when InductionStatus.RequiresStartDate() => InductionJourneyPage.StartDate, _ => InductionJourneyPage.ChangeReason }; From f7db66d307280feea24b1e2b29f2731c3073e63e Mon Sep 17 00:00:00 2001 From: CLAWLOR Date: Tue, 17 Dec 2024 07:43:40 +0000 Subject: [PATCH 19/25] space --- .../Persons/PersonDetail/EditInduction/CompletedDate.cshtml.cs | 2 +- .../Persons/PersonDetail/EditInduction/StartDate.cshtml.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml.cs index a094f8914..6264538a9 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml.cs @@ -7,7 +7,7 @@ public class CompletedDateModel : CommonJourneyPage { public InductionJourneyPage NextPage => InductionJourneyPage.ChangeReason; - public CompletedDateModel(TrsLinkGenerator linkGenerator) :base(linkGenerator) + public CompletedDateModel(TrsLinkGenerator linkGenerator) : base(linkGenerator) { } diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs index 444507f80..99f981df8 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs @@ -17,7 +17,7 @@ public InductionJourneyPage NextPage } } - public StartDateModel(TrsLinkGenerator linkGenerator) :base(linkGenerator) + public StartDateModel(TrsLinkGenerator linkGenerator) : base(linkGenerator) { } From d26efecec274e06c4dda8a17ad9d2acd6c1e3906 Mon Sep 17 00:00:00 2001 From: CLAWLOR Date: Tue, 17 Dec 2024 09:47:18 +0000 Subject: [PATCH 20/25] backlink --- .../EditInduction/CheckYourAnswers.cshtml.cs | 9 ++-- .../EditInduction/CommonJourneyPage.cs | 7 ++- .../EditInduction/CompletedDate.cshtml.cs | 10 +++- .../EditInduction/EditInductionState.cs | 2 +- .../EditInduction/ExemptionReason.cshtml.cs | 10 +++- .../InductionChangeReason.cshtml.cs | 14 ++++- .../EditInduction/StartDate.cshtml.cs | 14 +++-- .../EditInduction/Status.cshtml.cs | 8 ++- .../EditInduction/CommonPageTests.cs | 52 +++++++++++++++++-- .../EditInduction/EditInductionStatusTests.cs | 1 - 10 files changed, 106 insertions(+), 21 deletions(-) diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml.cs index 933cfa7c6..47c38d811 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml.cs @@ -9,16 +9,17 @@ public CheckYourAnswersModel(TrsLinkGenerator linkGenerator) : base(linkGenerato { } + public string BackLink + { + get => PageLink(InductionJourneyPage.ChangeReason); + } + public void OnGet() { } public async Task OnPostAsync() { - await JourneyInstance!.UpdateStateAsync(state => - { - state.PageBreadcrumb = InductionJourneyPage.CheckYourAnswers; - }); // TODO - end of journey logic return Redirect(NextPage()(PersonId, JourneyInstance!.InstanceId)); diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CommonJourneyPage.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CommonJourneyPage.cs index 07242f9b3..180ab5f32 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CommonJourneyPage.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CommonJourneyPage.cs @@ -6,14 +6,17 @@ public abstract class CommonJourneyPage : PageModel { public JourneyInstance? JourneyInstance { get; set; } + public virtual InductionStatus InductionStatus + { + get { return JourneyInstance!.State.InductionStatus; } + set { } + } protected TrsLinkGenerator _linkGenerator; [FromRoute] public Guid PersonId { get; set; } - public string BackLink => PageLink(JourneyInstance!.State.PageBreadcrumb); - protected CommonJourneyPage(TrsLinkGenerator linkGenerator) { _linkGenerator = linkGenerator; diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml.cs index 6264538a9..435ee4cc1 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml.cs @@ -6,6 +6,11 @@ namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInductio public class CompletedDateModel : CommonJourneyPage { public InductionJourneyPage NextPage => InductionJourneyPage.ChangeReason; + public string BackLink + { + // TODO - more logic needed when other routes to completed-date are added + get => PageLink(InductionJourneyPage.StartDate); + } public CompletedDateModel(TrsLinkGenerator linkGenerator) : base(linkGenerator) { @@ -20,7 +25,10 @@ public async Task OnPostAsync() await JourneyInstance!.UpdateStateAsync(state => { // TODO - store the completed date - state.PageBreadcrumb = InductionJourneyPage.CompletedDate; + if (state.JourneyStartPage == null) + { + state.JourneyStartPage = InductionJourneyPage.CompletedDate; + } }); return Redirect(PageLink(NextPage)); diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/EditInductionState.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/EditInductionState.cs index defbf6644..a27d2b351 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/EditInductionState.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/EditInductionState.cs @@ -15,7 +15,7 @@ public class EditInductionState : IRegisterJourney public DateOnly? CompletedDate { get; set; } public InductionExemptionReasons? ExemptionReasons { get; set; } public string? ChangeReason { get; set; } - public InductionJourneyPage? PageBreadcrumb { get; set; } + public InductionJourneyPage? JourneyStartPage { get; set; } public bool Initialized { get; set; } diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml.cs index c11e07455..8ca626316 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml.cs @@ -6,6 +6,11 @@ namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInductio public class ExemptionReasonModel : CommonJourneyPage { public InductionJourneyPage NextPage => InductionJourneyPage.ChangeReason; + public string BackLink + { + // TODO - more logic needed when other routes to exemption reason are added + get => PageLink(InductionJourneyPage.Status); + } public ExemptionReasonModel(TrsLinkGenerator linkGenerator) : base(linkGenerator) { @@ -20,7 +25,10 @@ public async Task OnPostAsync() await JourneyInstance!.UpdateStateAsync(state => { // TODO - store the exemption reason - state.PageBreadcrumb = InductionJourneyPage.ExemptionReason; + if (state.JourneyStartPage == null) + { + state.JourneyStartPage = InductionJourneyPage.ExemptionReason; + } }); return Redirect(PageLink(NextPage)); diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml.cs index 75abd1a49..6ad1270b2 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml.cs @@ -6,6 +6,19 @@ namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInductio public class InductionChangeReasonModel : CommonJourneyPage { public InductionJourneyPage NextPage => InductionJourneyPage.CheckYourAnswers; + public string BackLink + { + get + { + return InductionStatus switch + { + _ when InductionStatus.RequiresCompletedDate() => PageLink(InductionJourneyPage.CompletedDate), + _ when InductionStatus.RequiresStartDate() => PageLink(InductionJourneyPage.StartDate), + _ when InductionStatus.RequiresExemptionReason() => PageLink(InductionJourneyPage.ExemptionReason), + _ => PageLink(InductionJourneyPage.Status), + }; + } + } public InductionChangeReasonModel(TrsLinkGenerator linkGenerator) : base(linkGenerator) { @@ -20,7 +33,6 @@ public async Task OnPostAsync() await JourneyInstance!.UpdateStateAsync(state => { // TODO - store the change reason - state.PageBreadcrumb = InductionJourneyPage.ChangeReason; }); return Redirect(PageLink(NextPage)); diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs index 99f981df8..07c9a64de 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs @@ -5,8 +5,6 @@ namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInductio [Journey(JourneyNames.EditInduction), ActivatesJourney, RequireJourneyInstance] public class StartDateModel : CommonJourneyPage { - public InductionStatus InductionStatus { get; set; } - public InductionJourneyPage NextPage { get @@ -17,13 +15,18 @@ public InductionJourneyPage NextPage } } + public string BackLink + { + // TODO - more logic needed when other routes to start-date are added + get => PageLink(InductionJourneyPage.Status); + } + public StartDateModel(TrsLinkGenerator linkGenerator) : base(linkGenerator) { } public void OnGet() { - InductionStatus = JourneyInstance!.State.InductionStatus; } public async Task OnPostAsync() @@ -32,7 +35,10 @@ public async Task OnPostAsync() await JourneyInstance!.UpdateStateAsync(state => { // TODO - store the start date - state.PageBreadcrumb = InductionJourneyPage.StartDate; + if (state.JourneyStartPage == null) + { + state.JourneyStartPage = InductionJourneyPage.StartDate; + } }); return Redirect(PageLink(NextPage)); diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs index 07d25254c..be2b4168e 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs @@ -10,7 +10,7 @@ public class StatusModel : CommonJourneyPage protected TrsDbContext _dbContext; [BindProperty] - public InductionStatus InductionStatus { get; set; } + public override InductionStatus InductionStatus { get; set; } public InductionJourneyPage NextPage { @@ -24,6 +24,7 @@ _ when InductionStatus.RequiresStartDate() => InductionJourneyPage.StartDate, }; } } + public string BackLink => _linkGenerator.PersonInduction(PersonId); public StatusModel(TrsLinkGenerator linkGenerator, TrsDbContext dbContext) : base(linkGenerator) { @@ -40,7 +41,10 @@ public async Task OnPostAsync() await JourneyInstance!.UpdateStateAsync(state => { state.InductionStatus = InductionStatus; - state.PageBreadcrumb = InductionJourneyPage.Status; + if (state.JourneyStartPage == null) + { + state.JourneyStartPage = InductionJourneyPage.Status; + } }); return Redirect(PageLink(NextPage)); diff --git a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/CommonPageTests.cs b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/CommonPageTests.cs index b1a6a686e..1eb198ef6 100644 --- a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/CommonPageTests.cs +++ b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/CommonPageTests.cs @@ -107,9 +107,7 @@ public async Task Cancel_RedirectsToExpectedPage(string fromPage) [InlineData("edit-induction/exemption-reasons", InductionJourneyPage.ExemptionReason)] [InlineData("edit-induction/start-date", InductionJourneyPage.StartDate)] [InlineData("edit-induction/date-completed", InductionJourneyPage.CompletedDate)] - [InlineData("edit-induction/change-reason", InductionJourneyPage.ChangeReason)] - [InlineData("edit-induction/check-answers", InductionJourneyPage.CheckYourAnswers)] - public async Task Post_UpdateJourneyStateBacklinkBreadcrumb(string page, InductionJourneyPage pageName) + public async Task Post_PersistsBacklinkBreadcrumb(string page, InductionJourneyPage pageName) { // Arrange InductionStatus inductionStatus = InductionStatus.Passed; @@ -129,7 +127,53 @@ public async Task Post_UpdateJourneyStateBacklinkBreadcrumb(string page, Inducti // Assert journeyInstance = await ReloadJourneyInstance(journeyInstance); - Assert.Equal(pageName, journeyInstance.State.PageBreadcrumb); + Assert.Equal(pageName, journeyInstance.State.JourneyStartPage); + } + + [Theory] + [InlineData("edit-induction/status", InductionStatus.Exempt)] + [InlineData("edit-induction/status", InductionStatus.InProgress)] + [InlineData("edit-induction/status", InductionStatus.Failed)] + [InlineData("edit-induction/status", InductionStatus.FailedInWales)] + [InlineData("edit-induction/status", InductionStatus.Passed)] + [InlineData("edit-induction/status", InductionStatus.RequiredToComplete)] + [InlineData("edit-induction/exemption-reasons", InductionStatus.Exempt)] + [InlineData("edit-induction/start-date", InductionStatus.InProgress)] + [InlineData("edit-induction/start-date", InductionStatus.Failed)] + [InlineData("edit-induction/start-date", InductionStatus.FailedInWales)] + [InlineData("edit-induction/start-date", InductionStatus.Passed)] + [InlineData("edit-induction/date-completed", InductionStatus.Failed)] + [InlineData("edit-induction/date-completed", InductionStatus.FailedInWales)] + [InlineData("edit-induction/date-completed", InductionStatus.Passed)] + [InlineData("edit-induction/change-reason", InductionStatus.Exempt)] + [InlineData("edit-induction/change-reason", InductionStatus.InProgress)] + [InlineData("edit-induction/change-reason", InductionStatus.Failed)] + [InlineData("edit-induction/change-reason", InductionStatus.FailedInWales)] + [InlineData("edit-induction/change-reason", InductionStatus.Passed)] + [InlineData("edit-induction/change-reason", InductionStatus.RequiredToComplete)] + public async Task FollowingRedirect_BacklinkContainsExpected(string fromPage, InductionStatus inductionStatus) + { + // Arrange + var person = await TestData.CreatePersonAsync(); + + var journeyInstance = await CreateJourneyInstanceAsync( + person.PersonId, + new EditInductionState() + { + Initialized = true, + InductionStatus = inductionStatus + }); + var request = new HttpRequestMessage(HttpMethod.Post, $"/persons/{person.PersonId}/{fromPage}?{journeyInstance.GetUniqueIdQueryParameter()}"); + + // Act + var response = await HttpClient.SendAsync(request); + + // Assert + Assert.Equal(StatusCodes.Status302Found, (int)response.StatusCode); + var redirectResponse = await response.FollowRedirectAsync(HttpClient); + var redirectDoc = await redirectResponse.GetDocumentAsync(); + var backlink = redirectDoc.GetElementByTestId("back-link") as IHtmlAnchorElement; + Assert.Contains(fromPage, backlink!.Href); } private Task> CreateJourneyInstanceAsync(Guid personId, EditInductionState? state = null) => diff --git a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/EditInductionStatusTests.cs b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/EditInductionStatusTests.cs index 3053c48f2..2ee303e71 100644 --- a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/EditInductionStatusTests.cs +++ b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/EditInductionStatusTests.cs @@ -3,7 +3,6 @@ namespace TeachingRecordSystem.SupportUi.Tests.PageTests.Persons.PersonDetail.EditInduction; - public class EditInductionStatusTests(HostFixture hostFixture) : TestBase(hostFixture) { [Fact] From e6efcbad28d7ef2a85ecb9b2bccec6dde353dd15 Mon Sep 17 00:00:00 2001 From: CLAWLOR Date: Tue, 17 Dec 2024 10:04:10 +0000 Subject: [PATCH 21/25] non-async post --- .../PersonDetail/EditInduction/CheckYourAnswers.cshtml.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml.cs index 47c38d811..c60c88bf1 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml.cs @@ -18,7 +18,7 @@ public void OnGet() { } - public async Task OnPostAsync() + public IActionResult OnPost() { // TODO - end of journey logic From 38a193147d9b434ec1d9109b5f22a89e4e3036e2 Mon Sep 17 00:00:00 2001 From: CLAWLOR Date: Tue, 17 Dec 2024 10:25:18 +0000 Subject: [PATCH 22/25] tidy --- .../PersonDetail/EditInduction/CheckYourAnswers.cshtml.cs | 5 +---- .../Persons/PersonDetail/EditInduction/CommonJourneyPage.cs | 3 +-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml.cs index c60c88bf1..1a8be2b47 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml.cs @@ -9,10 +9,7 @@ public CheckYourAnswersModel(TrsLinkGenerator linkGenerator) : base(linkGenerato { } - public string BackLink - { - get => PageLink(InductionJourneyPage.ChangeReason); - } + public string BackLink => PageLink(InductionJourneyPage.ChangeReason); public void OnGet() { diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CommonJourneyPage.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CommonJourneyPage.cs index 180ab5f32..998dc1405 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CommonJourneyPage.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CommonJourneyPage.cs @@ -5,6 +5,7 @@ public abstract class CommonJourneyPage : PageModel { + protected TrsLinkGenerator _linkGenerator; public JourneyInstance? JourneyInstance { get; set; } public virtual InductionStatus InductionStatus { @@ -12,8 +13,6 @@ public virtual InductionStatus InductionStatus set { } } - protected TrsLinkGenerator _linkGenerator; - [FromRoute] public Guid PersonId { get; set; } From cf5ca36a0b7521d6e6e6c8ebea804d11276e20a8 Mon Sep 17 00:00:00 2001 From: CLAWLOR Date: Tue, 17 Dec 2024 13:20:29 +0000 Subject: [PATCH 23/25] PR comments --- TeachingRecordSystem/TeachingRecordSystem.sln | 2 +- .../DataStore/Postgres/Models/Person.cs | 2 +- .../Models/InductionStatus.cs | 10 +++++----- .../EditInduction/CheckYourAnswers.cshtml.cs | 2 +- .../EditInduction/CommonJourneyPage.cs | 14 +++++++------- .../EditInduction/CompletedDate.cshtml.cs | 2 +- .../EditInduction/EditInductionState.cs | 6 +++++- .../EditInduction/ExemptionReason.cshtml.cs | 2 +- .../EditInduction/InductionChangeReason.cshtml.cs | 5 +++-- .../EditInduction/InductionJourneyPage.cs | 4 ++-- .../PersonDetail/EditInduction/StartDate.cshtml.cs | 6 ++++-- .../PersonDetail/EditInduction/Status.cshtml | 2 +- .../PersonDetail/EditInduction/Status.cshtml.cs | 13 ++++--------- .../PersonDetail/EditInduction/CommonPageTests.cs | 11 ++++++----- 14 files changed, 42 insertions(+), 39 deletions(-) diff --git a/TeachingRecordSystem/TeachingRecordSystem.sln b/TeachingRecordSystem/TeachingRecordSystem.sln index a1bbce22b..2e2b58064 100644 --- a/TeachingRecordSystem/TeachingRecordSystem.sln +++ b/TeachingRecordSystem/TeachingRecordSystem.sln @@ -53,7 +53,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeachingRecordSystem.Author EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gen", "gen", "{5E273A79-2EA3-46CD-9049-769F880868FE}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeachingRecordSystem.Api.Generator", "gen\TeachingRecordSystem.Api.Generator\TeachingRecordSystem.Api.Generator.csproj", "{7EA8C0A7-C149-4928-8E37-55D44976D765}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeachingRecordSystem.Api.Generator", "gen\TeachingRecordSystem.Api.Generator\TeachingRecordSystem.Api.Generator.csproj", "{7EA8C0A7-C149-4928-8E37-55D44976D765}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.Core/DataStore/Postgres/Models/Person.cs b/TeachingRecordSystem/src/TeachingRecordSystem.Core/DataStore/Postgres/Models/Person.cs index ac8552c02..ba8544b61 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.Core/DataStore/Postgres/Models/Person.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.Core/DataStore/Postgres/Models/Person.cs @@ -191,7 +191,7 @@ public static bool ValidateInductionData( { var requiresStartDate = status.RequiresStartDate(); var requiresCompletedDate = status.RequiresCompletedDate(); - var requiresExemptionReason = status.RequiresExemptionReason(); + var requiresExemptionReason = status.RequiresExemptionReasons(); if (requiresStartDate && startDate is null) { diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.Core/Models/InductionStatus.cs b/TeachingRecordSystem/src/TeachingRecordSystem.Core/Models/InductionStatus.cs index 984105267..40d3eb519 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.Core/Models/InductionStatus.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.Core/Models/InductionStatus.cs @@ -8,7 +8,7 @@ public enum InductionStatus None = 0, [InductionStatusInfo("required to complete", requiresStartDate: false, requiresCompletedDate: false)] RequiredToComplete = 1, - [InductionStatusInfo("exempt", requiresStartDate: false, requiresCompletedDate: false, requiresExemptionReason: true)] + [InductionStatusInfo("exempt", requiresStartDate: false, requiresCompletedDate: false, requiresExemptionReasons: true)] Exempt = 2, [InductionStatusInfo("in progress", requiresStartDate: true, requiresCompletedDate: false)] InProgress = 3, @@ -35,7 +35,7 @@ public static class InductionStatusRegistry public static bool RequiresCompletedDate(this InductionStatus status) => _info[status].RequiresCompletedDate; - public static bool RequiresExemptionReason(this InductionStatus status) => _info[status].RequiresExemptionReason; + public static bool RequiresExemptionReasons(this InductionStatus status) => _info[status].RequiresExemptionReasons; public static InductionStatus ToInductionStatus(this dfeta_InductionStatus status) => ToInductionStatus((dfeta_InductionStatus?)status); @@ -67,16 +67,16 @@ private static InductionStatusInfo GetInfo(InductionStatus status) } } -public sealed record InductionStatusInfo(InductionStatus Value, string Name, bool RequiresStartDate, bool RequiresCompletedDate, bool RequiresExemptionReason = false) +public sealed record InductionStatusInfo(InductionStatus Value, string Name, bool RequiresStartDate, bool RequiresCompletedDate, bool RequiresExemptionReasons = false) { public string Title => Name[0..1].ToUpper() + Name[1..]; } [AttributeUsage(AttributeTargets.Field, AllowMultiple = false)] -file sealed class InductionStatusInfoAttribute(string name, bool requiresStartDate, bool requiresCompletedDate, bool requiresExemptionReason = false) : Attribute +file sealed class InductionStatusInfoAttribute(string name, bool requiresStartDate, bool requiresCompletedDate, bool requiresExemptionReasons = false) : Attribute { public string Name => name; public bool RequiresStartDate => requiresStartDate; public bool RequiresCompletedDate => requiresCompletedDate; - public bool RequiresExemptionReason => requiresExemptionReason; + public bool RequiresExemptionReason => requiresExemptionReasons; } diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml.cs index 1a8be2b47..4fb10c395 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml.cs @@ -9,7 +9,7 @@ public CheckYourAnswersModel(TrsLinkGenerator linkGenerator) : base(linkGenerato { } - public string BackLink => PageLink(InductionJourneyPage.ChangeReason); + public string BackLink => PageLink(InductionJourneyPage.ChangeReasons); public void OnGet() { diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CommonJourneyPage.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CommonJourneyPage.cs index 998dc1405..bc018d8d6 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CommonJourneyPage.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CommonJourneyPage.cs @@ -7,11 +7,11 @@ public abstract class CommonJourneyPage : PageModel { protected TrsLinkGenerator _linkGenerator; public JourneyInstance? JourneyInstance { get; set; } - public virtual InductionStatus InductionStatus - { - get { return JourneyInstance!.State.InductionStatus; } - set { } - } + //public virtual InductionStatus InductionStatus + //{ + // get { return JourneyInstance!.State.InductionStatus; } + // set { } + //} [FromRoute] public Guid PersonId { get; set; } @@ -35,8 +35,8 @@ protected string PageLink(InductionJourneyPage? pageName) InductionJourneyPage.CompletedDate => _linkGenerator.InductionEditCompletedDate(PersonId, JourneyInstance!.InstanceId), InductionJourneyPage.ExemptionReason => _linkGenerator.InductionEditExemptionReason(PersonId, JourneyInstance!.InstanceId), InductionJourneyPage.StartDate => _linkGenerator.InductionEditStartDate(PersonId, JourneyInstance!.InstanceId), - InductionJourneyPage.ChangeReason => _linkGenerator.InductionChangeReason(PersonId, JourneyInstance!.InstanceId), - InductionJourneyPage.CheckYourAnswers => _linkGenerator.InductionCheckYourAnswers(PersonId, JourneyInstance!.InstanceId), + InductionJourneyPage.ChangeReasons => _linkGenerator.InductionChangeReason(PersonId, JourneyInstance!.InstanceId), + InductionJourneyPage.CheckAnswers => _linkGenerator.InductionCheckYourAnswers(PersonId, JourneyInstance!.InstanceId), _ => _linkGenerator.PersonInduction(PersonId) }; } diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml.cs index 435ee4cc1..8037d2f82 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml.cs @@ -5,7 +5,7 @@ namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInductio [Journey(JourneyNames.EditInduction), ActivatesJourney, RequireJourneyInstance] public class CompletedDateModel : CommonJourneyPage { - public InductionJourneyPage NextPage => InductionJourneyPage.ChangeReason; + public InductionJourneyPage NextPage => InductionJourneyPage.ChangeReasons; public string BackLink { // TODO - more logic needed when other routes to completed-date are added diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/EditInductionState.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/EditInductionState.cs index a27d2b351..a170d5e5e 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/EditInductionState.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/EditInductionState.cs @@ -19,7 +19,7 @@ public class EditInductionState : IRegisterJourney public bool Initialized { get; set; } - public async Task EnsureInitializedAsync(TrsDbContext dbContext, Guid personId) + public async Task EnsureInitializedAsync(TrsDbContext dbContext, Guid personId, InductionJourneyPage startPage) { if (Initialized) { @@ -28,6 +28,10 @@ public async Task EnsureInitializedAsync(TrsDbContext dbContext, Guid personId) var person = await dbContext.Persons .SingleAsync(q => q.PersonId == personId); InductionStatus = person!.InductionStatus; + if (JourneyStartPage == null) + { + JourneyStartPage = startPage; + } Initialized = true; } diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml.cs index 8ca626316..d24de4eee 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml.cs @@ -5,7 +5,7 @@ namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInductio [Journey(JourneyNames.EditInduction), RequireJourneyInstance] public class ExemptionReasonModel : CommonJourneyPage { - public InductionJourneyPage NextPage => InductionJourneyPage.ChangeReason; + public InductionJourneyPage NextPage => InductionJourneyPage.ChangeReasons; public string BackLink { // TODO - more logic needed when other routes to exemption reason are added diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml.cs index 6ad1270b2..fbfbdbe2d 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml.cs @@ -5,7 +5,8 @@ namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInductio [Journey(JourneyNames.EditInduction), RequireJourneyInstance] public class InductionChangeReasonModel : CommonJourneyPage { - public InductionJourneyPage NextPage => InductionJourneyPage.CheckYourAnswers; + public InductionStatus InductionStatus => JourneyInstance!.State.InductionStatus; + public InductionJourneyPage NextPage => InductionJourneyPage.CheckAnswers; public string BackLink { get @@ -14,7 +15,7 @@ public string BackLink { _ when InductionStatus.RequiresCompletedDate() => PageLink(InductionJourneyPage.CompletedDate), _ when InductionStatus.RequiresStartDate() => PageLink(InductionJourneyPage.StartDate), - _ when InductionStatus.RequiresExemptionReason() => PageLink(InductionJourneyPage.ExemptionReason), + _ when InductionStatus.RequiresExemptionReasons() => PageLink(InductionJourneyPage.ExemptionReason), _ => PageLink(InductionJourneyPage.Status), }; } diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionJourneyPage.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionJourneyPage.cs index 41662f4a5..0d7684c05 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionJourneyPage.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionJourneyPage.cs @@ -6,6 +6,6 @@ public enum InductionJourneyPage ExemptionReason, StartDate, CompletedDate, - ChangeReason, - CheckYourAnswers + ChangeReasons, + CheckAnswers } diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs index 07c9a64de..2a2413889 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs @@ -5,13 +5,15 @@ namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInductio [Journey(JourneyNames.EditInduction), ActivatesJourney, RequireJourneyInstance] public class StartDateModel : CommonJourneyPage { + public InductionStatus InductionStatus => JourneyInstance!.State.InductionStatus; + public InductionJourneyPage NextPage { get { return InductionStatus.RequiresCompletedDate() ? InductionJourneyPage.CompletedDate - : InductionJourneyPage.ChangeReason; + : InductionJourneyPage.ChangeReasons; } } @@ -31,7 +33,7 @@ public void OnGet() public async Task OnPostAsync() { - InductionStatus = JourneyInstance!.State.InductionStatus; + //InductionStatus = JourneyInstance!.State.InductionStatus; await JourneyInstance!.UpdateStateAsync(state => { // TODO - store the start date diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml index 76d7f19fc..ecd6a2881 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml @@ -1,7 +1,7 @@ @page "/persons/{PersonId}/edit-induction/status" @model TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction.StatusModel @{ - ViewBag.Title = "Edit status: " + Model.InductionStatus; + ViewBag.Title = "Edit status: " + Model.InductionStatus.GetName(); } @section BeforeContent { diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs index be2b4168e..e21d6faa7 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs @@ -10,7 +10,7 @@ public class StatusModel : CommonJourneyPage protected TrsDbContext _dbContext; [BindProperty] - public override InductionStatus InductionStatus { get; set; } + public InductionStatus InductionStatus { get; set; } public InductionJourneyPage NextPage { @@ -18,9 +18,9 @@ public InductionJourneyPage NextPage { return InductionStatus switch { - _ when InductionStatus.RequiresExemptionReason() => InductionJourneyPage.ExemptionReason, + _ when InductionStatus.RequiresExemptionReasons() => InductionJourneyPage.ExemptionReason, _ when InductionStatus.RequiresStartDate() => InductionJourneyPage.StartDate, - _ => InductionJourneyPage.ChangeReason + _ => InductionJourneyPage.ChangeReasons }; } } @@ -41,10 +41,6 @@ public async Task OnPostAsync() await JourneyInstance!.UpdateStateAsync(state => { state.InductionStatus = InductionStatus; - if (state.JourneyStartPage == null) - { - state.JourneyStartPage = InductionJourneyPage.Status; - } }); return Redirect(PageLink(NextPage)); @@ -52,9 +48,8 @@ public async Task OnPostAsync() public override async Task OnPageHandlerExecutionAsync(PageHandlerExecutingContext context, PageHandlerExecutionDelegate next) { - await JourneyInstance!.State.EnsureInitializedAsync(_dbContext, PersonId); + await JourneyInstance!.State.EnsureInitializedAsync(_dbContext, PersonId, InductionJourneyPage.Status); await next(); } - } diff --git a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/CommonPageTests.cs b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/CommonPageTests.cs index 1eb198ef6..b1a915b1a 100644 --- a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/CommonPageTests.cs +++ b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/CommonPageTests.cs @@ -31,8 +31,9 @@ public async Task Post_RedirectsToExpectedPage(string fromPage, InductionStatus { // Arrange var person = await TestData.CreatePersonAsync( - personBuilder => personBuilder - .WithInductionStatus(inductionBuilder => inductionBuilder + p => p + .WithQts() + .WithInductionStatus(i => i .WithStatus(inductionStatus))); var journeyInstance = await CreateJourneyInstanceAsync( @@ -74,7 +75,7 @@ public async Task Post_RedirectsToExpectedPage(string fromPage, InductionStatus public async Task Cancel_RedirectsToExpectedPage(string fromPage) { // Arrange - var person = await TestData.CreatePersonAsync(); + var person = await TestData.CreatePersonAsync(p => p.WithQts()); var journeyInstance = await CreateJourneyInstanceAsync( person.PersonId, @@ -111,7 +112,7 @@ public async Task Post_PersistsBacklinkBreadcrumb(string page, InductionJourneyP { // Arrange InductionStatus inductionStatus = InductionStatus.Passed; - var person = await TestData.CreatePersonAsync(); + var person = await TestData.CreatePersonAsync(p => p.WithQts()); var journeyInstance = await CreateJourneyInstanceAsync( person.PersonId, @@ -154,7 +155,7 @@ public async Task Post_PersistsBacklinkBreadcrumb(string page, InductionJourneyP public async Task FollowingRedirect_BacklinkContainsExpected(string fromPage, InductionStatus inductionStatus) { // Arrange - var person = await TestData.CreatePersonAsync(); + var person = await TestData.CreatePersonAsync(p => p.WithQts()); var journeyInstance = await CreateJourneyInstanceAsync( person.PersonId, From 2bee478d5ce875632b90cf6676f974ddb2de28be Mon Sep 17 00:00:00 2001 From: CLAWLOR Date: Tue, 17 Dec 2024 13:25:46 +0000 Subject: [PATCH 24/25] more PR comments --- .../EditInduction/CheckYourAnswers.cshtml.cs | 2 +- .../EditInduction/CommonJourneyPage.cs | 25 ++++++++----------- .../EditInduction/Status.cshtml.cs | 2 +- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml.cs index 4fb10c395..0cb48a0dc 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml.cs @@ -24,6 +24,6 @@ public IActionResult OnPost() public Func NextPage() { - return (Id, journeyInstanceId) => _linkGenerator.PersonInduction(Id); + return (Id, journeyInstanceId) => LinkGenerator.PersonInduction(Id); } } diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CommonJourneyPage.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CommonJourneyPage.cs index bc018d8d6..43e154e93 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CommonJourneyPage.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CommonJourneyPage.cs @@ -5,39 +5,34 @@ public abstract class CommonJourneyPage : PageModel { - protected TrsLinkGenerator _linkGenerator; + protected TrsLinkGenerator LinkGenerator { get; set; } public JourneyInstance? JourneyInstance { get; set; } - //public virtual InductionStatus InductionStatus - //{ - // get { return JourneyInstance!.State.InductionStatus; } - // set { } - //} [FromRoute] public Guid PersonId { get; set; } protected CommonJourneyPage(TrsLinkGenerator linkGenerator) { - _linkGenerator = linkGenerator; + LinkGenerator = linkGenerator; } public async Task OnPostCancelAsync() { await JourneyInstance!.DeleteAsync(); - return Redirect(_linkGenerator.PersonInduction(PersonId)); + return Redirect(LinkGenerator.PersonInduction(PersonId)); } protected string PageLink(InductionJourneyPage? pageName) { return pageName switch { - InductionJourneyPage.Status => _linkGenerator.InductionEditStatus(PersonId, JourneyInstance!.InstanceId), - InductionJourneyPage.CompletedDate => _linkGenerator.InductionEditCompletedDate(PersonId, JourneyInstance!.InstanceId), - InductionJourneyPage.ExemptionReason => _linkGenerator.InductionEditExemptionReason(PersonId, JourneyInstance!.InstanceId), - InductionJourneyPage.StartDate => _linkGenerator.InductionEditStartDate(PersonId, JourneyInstance!.InstanceId), - InductionJourneyPage.ChangeReasons => _linkGenerator.InductionChangeReason(PersonId, JourneyInstance!.InstanceId), - InductionJourneyPage.CheckAnswers => _linkGenerator.InductionCheckYourAnswers(PersonId, JourneyInstance!.InstanceId), - _ => _linkGenerator.PersonInduction(PersonId) + InductionJourneyPage.Status => LinkGenerator.InductionEditStatus(PersonId, JourneyInstance!.InstanceId), + InductionJourneyPage.CompletedDate => LinkGenerator.InductionEditCompletedDate(PersonId, JourneyInstance!.InstanceId), + InductionJourneyPage.ExemptionReason => LinkGenerator.InductionEditExemptionReason(PersonId, JourneyInstance!.InstanceId), + InductionJourneyPage.StartDate => LinkGenerator.InductionEditStartDate(PersonId, JourneyInstance!.InstanceId), + InductionJourneyPage.ChangeReasons => LinkGenerator.InductionChangeReason(PersonId, JourneyInstance!.InstanceId), + InductionJourneyPage.CheckAnswers => LinkGenerator.InductionCheckYourAnswers(PersonId, JourneyInstance!.InstanceId), + _ => LinkGenerator.PersonInduction(PersonId) }; } } diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs index e21d6faa7..ef7bb1ced 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs @@ -24,7 +24,7 @@ _ when InductionStatus.RequiresStartDate() => InductionJourneyPage.StartDate, }; } } - public string BackLink => _linkGenerator.PersonInduction(PersonId); + public string BackLink => LinkGenerator.PersonInduction(PersonId); public StatusModel(TrsLinkGenerator linkGenerator, TrsDbContext dbContext) : base(linkGenerator) { From cf222c87690caec06452614d146e7006ed6b6666 Mon Sep 17 00:00:00 2001 From: CLAWLOR Date: Tue, 17 Dec 2024 13:51:17 +0000 Subject: [PATCH 25/25] persist start page --- .../Persons/PersonDetail/EditInduction/StartDate.cshtml.cs | 1 - .../Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs | 4 ++++ .../Persons/PersonDetail/EditInduction/CommonPageTests.cs | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs index 2a2413889..f3f1f6eba 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/StartDate.cshtml.cs @@ -33,7 +33,6 @@ public void OnGet() public async Task OnPostAsync() { - //InductionStatus = JourneyInstance!.State.InductionStatus; await JourneyInstance!.UpdateStateAsync(state => { // TODO - store the start date diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs index ef7bb1ced..9901837d0 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/Status.cshtml.cs @@ -41,6 +41,10 @@ public async Task OnPostAsync() await JourneyInstance!.UpdateStateAsync(state => { state.InductionStatus = InductionStatus; + if (state.JourneyStartPage == null) + { + state.JourneyStartPage = InductionJourneyPage.Status; + } }); return Redirect(PageLink(NextPage)); diff --git a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/CommonPageTests.cs b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/CommonPageTests.cs index b1a915b1a..785d05eb9 100644 --- a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/CommonPageTests.cs +++ b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/EditInduction/CommonPageTests.cs @@ -108,7 +108,7 @@ public async Task Cancel_RedirectsToExpectedPage(string fromPage) [InlineData("edit-induction/exemption-reasons", InductionJourneyPage.ExemptionReason)] [InlineData("edit-induction/start-date", InductionJourneyPage.StartDate)] [InlineData("edit-induction/date-completed", InductionJourneyPage.CompletedDate)] - public async Task Post_PersistsBacklinkBreadcrumb(string page, InductionJourneyPage pageName) + public async Task Post_PersistsStartPage(string page, InductionJourneyPage pageName) { // Arrange InductionStatus inductionStatus = InductionStatus.Passed;