-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Journey through induction edit pages with skeleton pages
- Loading branch information
Showing
24 changed files
with
779 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...ngRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
@page "/persons/{PersonId}/edit-induction/check-answers" | ||
@model TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction.CheckYourAnswersModel | ||
@{ | ||
ViewBag.Title = "Check your answers"; | ||
} | ||
|
||
@section BeforeContent { | ||
<govuk-back-link data-testid="back-link" href="@Model.BackLink">Back</govuk-back-link> | ||
} | ||
|
||
<h1 data-testid="page-title" class="govuk-heading-l">@ViewBag.Title</h1> | ||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds-from-desktop"> | ||
<form action="@LinkGenerator.InductionCheckYourAnswers(Model.PersonId, Model.JourneyInstance!.InstanceId)" method="post"> | ||
<div class="govuk-button-group"> | ||
<govuk-button type="submit" data-testid="continue-button">Confirm induction details</govuk-button> | ||
<govuk-button data-testid="cancel-button" formaction="@LinkGenerator.InductionCheckYourAnswersCancel(Model.PersonId, Model.JourneyInstance!.InstanceId)" class="govuk-button--secondary" type="submit">Cancel and return to record</govuk-button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> |
29 changes: 29 additions & 0 deletions
29
...ecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CheckYourAnswers.cshtml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; | ||
|
||
[Journey(JourneyNames.EditInduction), RequireJourneyInstance] | ||
public class CheckYourAnswersModel : CommonJourneyPage | ||
{ | ||
public CheckYourAnswersModel(TrsLinkGenerator linkGenerator) : base(linkGenerator) | ||
{ | ||
} | ||
|
||
public string BackLink => PageLink(InductionJourneyPage.ChangeReasons); | ||
|
||
public void OnGet() | ||
{ | ||
} | ||
|
||
public IActionResult OnPost() | ||
{ | ||
// TODO - end of journey logic | ||
|
||
return Redirect(NextPage()(PersonId, JourneyInstance!.InstanceId)); | ||
} | ||
|
||
public Func<Guid, JourneyInstanceId, string> NextPage() | ||
{ | ||
return (Id, journeyInstanceId) => LinkGenerator.PersonInduction(Id); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...chingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CommonJourneyPage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 | ||
{ | ||
protected TrsLinkGenerator LinkGenerator { get; set; } | ||
public JourneyInstance<EditInductionState>? JourneyInstance { get; set; } | ||
|
||
[FromRoute] | ||
public Guid PersonId { get; set; } | ||
|
||
protected CommonJourneyPage(TrsLinkGenerator linkGenerator) | ||
{ | ||
LinkGenerator = linkGenerator; | ||
} | ||
|
||
public async Task<IActionResult> OnPostCancelAsync() | ||
{ | ||
await JourneyInstance!.DeleteAsync(); | ||
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) | ||
}; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...chingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
@page "/persons/{PersonId}/edit-induction/date-completed" | ||
@model TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction.CompletedDateModel | ||
@{ | ||
ViewBag.Title = "Date completed"; | ||
} | ||
|
||
@section BeforeContent { | ||
<govuk-back-link data-testid="back-link" href="@Model.BackLink">Back</govuk-back-link> | ||
} | ||
|
||
<h1 data-testid="page-title" class="govuk-heading-l">@ViewBag.Title</h1> | ||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds-from-desktop"> | ||
<form data-testid="submit-form" action="@LinkGenerator.InductionEditCompletedDate(Model.PersonId, Model.JourneyInstance!.InstanceId)" method="post"> | ||
<div class="govuk-button-group"> | ||
<govuk-button type="submit" data-testid="continue-button">Continue</govuk-button> | ||
<govuk-button data-testid="cancel-button" formaction="@LinkGenerator.InductionEditCompletedDateCancel(Model.PersonId, Model.JourneyInstance!.InstanceId)" class="govuk-button--secondary" type="submit">Cancel and return to record</govuk-button> | ||
</div> | ||
</form> | ||
</<div> | ||
</div> |
36 changes: 36 additions & 0 deletions
36
...ngRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/CompletedDate.cshtml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; | ||
|
||
[Journey(JourneyNames.EditInduction), ActivatesJourney, RequireJourneyInstance] | ||
public class CompletedDateModel : CommonJourneyPage | ||
{ | ||
public InductionJourneyPage NextPage => InductionJourneyPage.ChangeReasons; | ||
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) | ||
{ | ||
} | ||
|
||
public void OnGet() | ||
{ | ||
} | ||
|
||
public async Task<IActionResult> OnPostAsync() | ||
{ | ||
await JourneyInstance!.UpdateStateAsync(state => | ||
{ | ||
// TODO - store the completed date | ||
if (state.JourneyStartPage == null) | ||
{ | ||
state.JourneyStartPage = InductionJourneyPage.CompletedDate; | ||
} | ||
}); | ||
|
||
return Redirect(PageLink(NextPage)); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...hingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/EditInductionState.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using TeachingRecordSystem.Core.DataStore.Postgres; | ||
|
||
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 InductionJourneyPage? JourneyStartPage { get; set; } | ||
|
||
public bool Initialized { get; set; } | ||
|
||
public async Task EnsureInitializedAsync(TrsDbContext dbContext, Guid personId, InductionJourneyPage startPage) | ||
{ | ||
if (Initialized) | ||
{ | ||
return; | ||
} | ||
var person = await dbContext.Persons | ||
.SingleAsync(q => q.PersonId == personId); | ||
InductionStatus = person!.InductionStatus; | ||
if (JourneyStartPage == null) | ||
{ | ||
JourneyStartPage = startPage; | ||
} | ||
|
||
Initialized = true; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...ingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
@page "/persons/{PersonId}/edit-induction/exemption-reasons" | ||
@model TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction.ExemptionReasonModel | ||
@{ | ||
ViewBag.Title = "Exemption reason"; | ||
} | ||
|
||
@section BeforeContent { | ||
<govuk-back-link data-testid="back-link" href="@Model.BackLink">Back</govuk-back-link> | ||
} | ||
|
||
<h1 data-testid="page-title" class="govuk-heading-l">@ViewBag.Title</h1> | ||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds-from-desktop"> | ||
<form action="@LinkGenerator.InductionEditExemptionReason(Model.PersonId, Model.JourneyInstance!.InstanceId)" method="post"> | ||
<div class="govuk-button-group"> | ||
<govuk-button type="submit" data-testid="continue-button">Continue</govuk-button> | ||
<govuk-button data-testid="cancel-button" formaction="@LinkGenerator.InductionEditExemptionReasonCancel(Model.PersonId, Model.JourneyInstance!.InstanceId)" class="govuk-button--secondary" type="submit">Cancel and return to record</govuk-button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> |
36 changes: 36 additions & 0 deletions
36
...RecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/ExemptionReason.cshtml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; | ||
|
||
[Journey(JourneyNames.EditInduction), RequireJourneyInstance] | ||
public class ExemptionReasonModel : CommonJourneyPage | ||
{ | ||
public InductionJourneyPage NextPage => InductionJourneyPage.ChangeReasons; | ||
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) | ||
{ | ||
} | ||
|
||
public void OnGet() | ||
{ | ||
} | ||
|
||
public async Task<IActionResult> OnPostAsync() | ||
{ | ||
await JourneyInstance!.UpdateStateAsync(state => | ||
{ | ||
// TODO - store the exemption reason | ||
if (state.JourneyStartPage == null) | ||
{ | ||
state.JourneyStartPage = InductionJourneyPage.ExemptionReason; | ||
} | ||
}); | ||
|
||
return Redirect(PageLink(NextPage)); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...ordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
@page "/persons/{PersonId}/edit-induction/change-reason" | ||
@model TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction.InductionChangeReasonModel | ||
@{ | ||
ViewBag.Title = "Change reason"; | ||
} | ||
|
||
@section BeforeContent { | ||
<govuk-back-link data-testid="back-link" href="@Model.BackLink">Back</govuk-back-link> | ||
} | ||
|
||
<h1 data-testid="page-title" class="govuk-heading-l">@ViewBag.Title</h1> | ||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds-from-desktop"> | ||
<form action="@LinkGenerator.InductionChangeReason(Model.PersonId, Model.JourneyInstance!.InstanceId)" method="post"> | ||
<div class="govuk-button-group"> | ||
<govuk-button type="submit" data-testid="continue-button">Continue</govuk-button> | ||
<govuk-button data-testid="cancel-button" formaction="@LinkGenerator.InductionChangeReasonCancel(Model.PersonId, Model.JourneyInstance!.InstanceId)" class="govuk-button--secondary" type="submit">Cancel and return to record</govuk-button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> |
41 changes: 41 additions & 0 deletions
41
...System.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionChangeReason.cshtml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; | ||
|
||
[Journey(JourneyNames.EditInduction), RequireJourneyInstance] | ||
public class InductionChangeReasonModel : CommonJourneyPage | ||
{ | ||
public InductionStatus InductionStatus => JourneyInstance!.State.InductionStatus; | ||
public InductionJourneyPage NextPage => InductionJourneyPage.CheckAnswers; | ||
public string BackLink | ||
{ | ||
get | ||
{ | ||
return InductionStatus switch | ||
{ | ||
_ when InductionStatus.RequiresCompletedDate() => PageLink(InductionJourneyPage.CompletedDate), | ||
_ when InductionStatus.RequiresStartDate() => PageLink(InductionJourneyPage.StartDate), | ||
_ when InductionStatus.RequiresExemptionReasons() => PageLink(InductionJourneyPage.ExemptionReason), | ||
_ => PageLink(InductionJourneyPage.Status), | ||
}; | ||
} | ||
} | ||
|
||
public InductionChangeReasonModel(TrsLinkGenerator linkGenerator) : base(linkGenerator) | ||
{ | ||
} | ||
|
||
public void OnGet() | ||
{ | ||
} | ||
|
||
public async Task<IActionResult> OnPostAsync() | ||
{ | ||
await JourneyInstance!.UpdateStateAsync(state => | ||
{ | ||
// TODO - store the change reason | ||
}); | ||
|
||
return Redirect(PageLink(NextPage)); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...ngRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditInduction/InductionJourneyPage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditInduction; | ||
|
||
public enum InductionJourneyPage | ||
{ | ||
Status, | ||
ExemptionReason, | ||
StartDate, | ||
CompletedDate, | ||
ChangeReasons, | ||
CheckAnswers | ||
} |
Oops, something went wrong.