Skip to content

Commit

Permalink
Align Add Alert journey with updated designs (#1573)
Browse files Browse the repository at this point in the history
  • Loading branch information
gunndabad authored Oct 11, 2024
1 parent f8c6751 commit 8ea3546
Show file tree
Hide file tree
Showing 25 changed files with 759 additions and 269 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public record class AlertCreatedEvent : EventBase, IEventWithPersonId, IEventWit
public string? Key { get; init; }
public required Guid PersonId { get; init; }
public required Alert Alert { get; init; }
public required string? AddReason { get; init; }
public required string? AddReasonDetail { get; init; }
public required File? EvidenceFile { get; init; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,7 @@ EventBase MapCreatedEvent(EntityVersionInfo<dfeta_sanction> snapshot)
RaisedBy = EventModels.RaisedByUserInfo.FromDqtUser(snapshot.UserId, snapshot.UserName),
PersonId = snapshot.Entity.dfeta_PersonId.Id,
Alert = GetEventAlert(snapshot.Entity, applyMigrationMappings: false),
AddReason = null,
AddReasonDetail = null,
EvidenceFile = null,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.ComponentModel.DataAnnotations;

namespace TeachingRecordSystem.SupportUi.Pages.Alerts.AddAlert;

public enum AddAlertReasonOption
{
[Display(Name = "Routine notification from stakeholder")]
RoutineNotificationFromStakeholder,
[Display(Name = "Identified during data reconciliation with stakeholder")]
IdentifiedDuringDataReconciliationWithStakeholder,
[Display(Name = "Another reason")]
AnotherReason
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,17 @@ public class AddAlertState : IRegisterJourney

public string? Details { get; set; }

public bool? AddLink { get; set; }

public string? Link { get; set; }

public DateOnly? StartDate { get; set; }

public string? Reason { get; set; }
public AddAlertReasonOption? AddReason { get; set; }

public bool? HaveAdditionalReasonDetail { get; set; }

public string? AddReasonDetail { get; set; }

public bool? UploadEvidence { get; set; }

Expand All @@ -36,7 +42,10 @@ public class AddAlertState : IRegisterJourney
public bool IsComplete =>
AlertTypeId.HasValue &&
!string.IsNullOrWhiteSpace(Details) &&
AddLink.HasValue &&
StartDate.HasValue &&
AddReason.HasValue &&
HaveAdditionalReasonDetail.HasValue &&
UploadEvidence.HasValue &&
(!UploadEvidence.Value || (UploadEvidence.Value && EvidenceFileId.HasValue));
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@
<div class="govuk-grid-column-full-from-desktop">
<form action="@LinkGenerator.AlertAddCheckAnswers(Model.PersonId, Model.JourneyInstance!.InstanceId)" method="post">
<span class="govuk-caption-l">Add an alert - @Model.PersonName</span>
<h1 class="govuk-heading-l" data-testid="title">@ViewBag.Title</h1>
<h1 class="govuk-heading-l">@ViewBag.Title</h1>

<govuk-summary-list>
<govuk-summary-list-row>
<govuk-summary-list-row-key>Alert type</govuk-summary-list-row-key>
<govuk-summary-list-row-value data-testid="alert-type">@Model.AlertTypeName</govuk-summary-list-row-value>
<govuk-summary-list-row-value>@Model.AlertTypeName</govuk-summary-list-row-value>
<govuk-summary-list-row-actions>
<govuk-summary-list-row-action href="@LinkGenerator.AlertAddType(Model.PersonId, Model.JourneyInstance!.InstanceId, fromCheckAnswers: true)">Change</govuk-summary-list-row-action>
</govuk-summary-list-row-actions>
</govuk-summary-list-row>
<govuk-summary-list-row>
<govuk-summary-list-row-key>Details</govuk-summary-list-row-key>
<govuk-summary-list-row-value><multi-line-text text="@Model.Details" data-testid="details" /></govuk-summary-list-row-value>
<govuk-summary-list-row-value><multi-line-text text="@Model.Details" /></govuk-summary-list-row-value>
<govuk-summary-list-row-actions>
<govuk-summary-list-row-action href="@LinkGenerator.AlertAddDetails(Model.PersonId, Model.JourneyInstance!.InstanceId, fromCheckAnswers: true)">Change</govuk-summary-list-row-action>
</govuk-summary-list-row-actions>
Expand All @@ -34,11 +34,11 @@
<govuk-summary-list-row-value>
@if (Model.Link is not null)
{
<a href="@Model.Link" class="govuk-link" rel="noreferrer noopener" target="_blank" data-testid="link">@($"{Model.Link} (opens in new tab)")</a>
<a href="@Model.Link" class="govuk-link" rel="noreferrer noopener" target="_blank">@($"{Model.Link} (opens in new tab)")</a>
}
else
{
<span data-testid="link" use-empty-fallback></span>
<span use-empty-fallback></span>
}
</govuk-summary-list-row-value>
<govuk-summary-list-row-actions>
Expand All @@ -47,21 +47,28 @@
</govuk-summary-list-row>
<govuk-summary-list-row>
<govuk-summary-list-row-key>Start date</govuk-summary-list-row-key>
<govuk-summary-list-row-value data-testid="start-date">@Model.StartDate?.ToString("d MMMM yyyy")</govuk-summary-list-row-value>
<govuk-summary-list-row-value>@Model.StartDate.ToString("d MMMM yyyy")</govuk-summary-list-row-value>
<govuk-summary-list-row-actions>
<govuk-summary-list-row-action href="@LinkGenerator.AlertAddStartDate(Model.PersonId, Model.JourneyInstance!.InstanceId, fromCheckAnswers: true)">Change</govuk-summary-list-row-action>
</govuk-summary-list-row-actions>
</govuk-summary-list-row>
<govuk-summary-list-row>
<govuk-summary-list-row-key>Reason for adding</govuk-summary-list-row-key>
<govuk-summary-list-row-value>@Model.AddReason.GetDisplayName()</govuk-summary-list-row-value>
<govuk-summary-list-row-actions>
<govuk-summary-list-row-action href="@LinkGenerator.AlertAddReason(Model.PersonId, Model.JourneyInstance!.InstanceId, fromCheckAnswers: true)">Change</govuk-summary-list-row-action>
</govuk-summary-list-row-actions>
</govuk-summary-list-row>
<govuk-summary-list-row>
<govuk-summary-list-row-key>Reason details</govuk-summary-list-row-key>
<govuk-summary-list-row-value>
@if(!string.IsNullOrEmpty(Model.Reason))
@if (Model.AddReasonDetail is not null)
{
<multi-line-text text="@Model.Reason" data-testid="reason" />
<multi-line-text text="@Model.AddReasonDetail" />
}
else
{
<span data-testid="reason" use-empty-fallback></span>
<span use-empty-fallback></span>
}
</govuk-summary-list-row-value>
<govuk-summary-list-row-actions>
Expand All @@ -73,11 +80,11 @@
<govuk-summary-list-row-value>
@if (Model.UploadedEvidenceFileUrl is not null)
{
<a href="@Model.UploadedEvidenceFileUrl" class="govuk-link" rel="noreferrer noopener" target="_blank" data-testid="uploaded-evidence-link">@($"{Model.EvidenceFileName} (opens in new tab)")</a>
<a href="@Model.UploadedEvidenceFileUrl" class="govuk-link" rel="noreferrer noopener" target="_blank">@($"{Model.EvidenceFileName} (opens in new tab)")</a>
}
else
{
<span data-testid="uploaded-evidence-link" use-empty-fallback></span>
<span use-empty-fallback></span>
}
</govuk-summary-list-row-value>
<govuk-summary-list-row-actions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,19 @@ public class CheckAnswersModel(

public string? PersonName { get; set; }

public Guid? AlertTypeId { get; set; }
public Guid AlertTypeId { get; set; }

public string? AlertTypeName { get; set; }

public string? Details { get; set; }

public string? Link { get; set; }

public DateOnly? StartDate { get; set; }
public DateOnly StartDate { get; set; }

public string? Reason { get; set; }
public AddAlertReasonOption AddReason { get; set; }

public string? AddReasonDetail { get; set; }

public string? EvidenceFileName { get; set; }

Expand All @@ -53,7 +55,7 @@ public async Task<IActionResult> OnPost()
CreatedOn = now,
UpdatedOn = now,
PersonId = PersonId,
AlertTypeId = AlertTypeId!.Value,
AlertTypeId = AlertTypeId,
Details = Details,
ExternalLink = Link,
StartDate = StartDate,
Expand All @@ -68,7 +70,8 @@ public async Task<IActionResult> OnPost()
RaisedBy = User.GetUserId(),
PersonId = PersonId,
Alert = EventModels.Alert.FromModel(alert),
AddReasonDetail = Reason,
AddReason = AddReason.GetDisplayName(),
AddReasonDetail = AddReasonDetail,
EvidenceFile = JourneyInstance!.State.EvidenceFileId is Guid fileId ?
new EventModels.File()
{
Expand Down Expand Up @@ -97,19 +100,20 @@ public override async Task OnPageHandlerExecutionAsync(PageHandlerExecutingConte
{
if (!JourneyInstance!.State.IsComplete)
{
context.Result = Redirect(linkGenerator.AlertAddType(PersonId, JourneyInstance.InstanceId));
context.Result = Redirect(linkGenerator.AlertAddReason(PersonId, JourneyInstance.InstanceId));
return;
}

var personInfo = context.HttpContext.GetCurrentPersonFeature();

PersonName = personInfo.Name;
AlertTypeId = JourneyInstance!.State.AlertTypeId;
AlertTypeId = JourneyInstance!.State.AlertTypeId!.Value;
AlertTypeName = JourneyInstance!.State.AlertTypeName;
Details = JourneyInstance!.State.Details;
Link = JourneyInstance!.State.Link;
StartDate = JourneyInstance!.State.StartDate;
Reason = JourneyInstance!.State.Reason;
StartDate = JourneyInstance!.State.StartDate!.Value;
AddReason = JourneyInstance!.State.AddReason!.Value;
AddReasonDetail = JourneyInstance!.State.AddReasonDetail;
EvidenceFileName = JourneyInstance.State.EvidenceFileName;
UploadedEvidenceFileUrl = JourneyInstance!.State.EvidenceFileId is not null ?
await fileService.GetFileUrl(JourneyInstance!.State.EvidenceFileId!.Value, _fileUrlExpiresAfter) :
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
@page "/alerts/add/details/{handler?}"
@model TeachingRecordSystem.SupportUi.Pages.Alerts.AddAlert.DetailsModel
@{
ViewBag.Title = "Details";
ViewBag.Title = $"Enter details about the alert type: {Model.AlertTypeName}";
}

@section BeforeContent {
<govuk-back-link href="@(Model.FromCheckAnswers == true ? LinkGenerator.AlertAddCheckAnswers(Model.PersonId, Model.JourneyInstance!.InstanceId) : LinkGenerator.AlertAddType(Model.PersonId, Model.JourneyInstance!.InstanceId))">Back</govuk-back-link>
<govuk-back-link href="@(Model.FromCheckAnswers == true ? LinkGenerator.AlertAddCheckAnswers(Model.PersonId, Model.JourneyInstance!.InstanceId) : LinkGenerator.AlertAddType(Model.PersonId, Model.JourneyInstance!.InstanceId))" />
}

<div class="govuk-grid-row">
Expand All @@ -14,7 +14,9 @@
<span class="govuk-caption-l">Add an alert - @Model.PersonName</span>

<govuk-character-count asp-for="Details" max-length="4000" data-testid="details">
<govuk-character-count-label class="govuk-label--l" is-page-heading="true" />
<govuk-character-count-label class="govuk-label--l" is-page-heading="true">
@ViewBag.Title
</govuk-character-count-label>
</govuk-character-count>

<div class="govuk-button-group">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ public class DetailsModel(TrsLinkGenerator linkGenerator) : PageModel

public string? PersonName { get; set; }

public string? AlertTypeName { get; set; }

[BindProperty]
[Required(ErrorMessage = "Enter details")]
[Display(Name = "Enter details")]
[Display(Description = "For example, include any restrictions it places on a teacher.")]
public string? Details { get; set; }

public void OnGet()
Expand Down Expand Up @@ -62,5 +64,6 @@ public override void OnPageHandlerExecuting(PageHandlerExecutingContext context)
var personInfo = context.HttpContext.GetCurrentPersonFeature();

PersonName = personInfo.Name;
AlertTypeName = JourneyInstance.State.AlertTypeName;
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,36 @@
@page "/alerts/add/link/{handler?}"
@model TeachingRecordSystem.SupportUi.Pages.Alerts.AddAlert.LinkModel
@{
ViewBag.Title = "Link";
ViewBag.Title = Html.DisplayNameFor(m => m.AddLink);
}

@section BeforeContent {
<govuk-back-link href="@(Model.FromCheckAnswers == true ? LinkGenerator.AlertAddCheckAnswers(Model.PersonId, Model.JourneyInstance!.InstanceId) : LinkGenerator.AlertAddDetails(Model.PersonId, Model.JourneyInstance!.InstanceId))">Back</govuk-back-link>
<govuk-back-link href="@(Model.FromCheckAnswers == true ? LinkGenerator.AlertAddCheckAnswers(Model.PersonId, Model.JourneyInstance!.InstanceId) : LinkGenerator.AlertAddDetails(Model.PersonId, Model.JourneyInstance!.InstanceId))" />
}

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds-from-desktop">
<form action="@LinkGenerator.AlertAddLink(Model.PersonId, Model.JourneyInstance!.InstanceId, Model.FromCheckAnswers)" method="post">
<span class="govuk-caption-l">Add an alert - @Model.PersonName</span>

<govuk-input asp-for="Link" label-class="govuk-label--l">
<govuk-input-hint>Optional</govuk-input-hint>
</govuk-input>
<govuk-radios asp-for="AddLink">
<govuk-radios-fieldset>
<govuk-radios-fieldset-legend class="govuk-fieldset__legend--l" />
<govuk-radios-hint>
<a href="https://www.gov.uk/government/collections/teacher-misconduct" class="govuk-link" target="_blank" rel="noopener noreferrer">Panel outcomes (opens in a new tab)</a>
include details about the allegation, the panel’s decision and reasons for it. The link will be seen internally.
</govuk-radios-hint>
<govuk-radios-item value="@true">
Yes
<govuk-radios-item-conditional>
<govuk-input asp-for="Link" />
</govuk-radios-item-conditional>
</govuk-radios-item>
<govuk-radios-item value="@false">
No
</govuk-radios-item>
</govuk-radios-fieldset>
</govuk-radios>

<div class="govuk-button-group">
<govuk-button type="submit">Continue</govuk-button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,23 @@ public class LinkModel(TrsLinkGenerator linkGenerator) : PageModel
public string? PersonName { get; set; }

[BindProperty]
[Display(Name = "Enter link")]
[Display(Name = "Do you want to add a link to a panel outcome?")]
[Required(ErrorMessage = "Select yes if you want to add a link to a panel outcome")]
public bool? AddLink { get; set; }

[BindProperty]
[Display(Name = "Enter link to panel outcome")]
public string? Link { get; set; }

public void OnGet()
{
AddLink = JourneyInstance!.State.AddLink;
Link = JourneyInstance!.State.Link;
}

public async Task<IActionResult> OnPost()
{
if (!string.IsNullOrEmpty(Link) &&
if (AddLink == true &&
(!Uri.TryCreate(Link, UriKind.Absolute, out var uri) ||
(uri.Scheme != "http" && uri.Scheme != "https")))
{
Expand All @@ -43,7 +49,8 @@ public async Task<IActionResult> OnPost()

await JourneyInstance!.UpdateStateAsync(state =>
{
state.Link = Link;
state.AddLink = AddLink;
state.Link = AddLink == true ? Link : null;
});

return Redirect(FromCheckAnswers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@page "/alerts/add/reason/{handler?}"
@model TeachingRecordSystem.SupportUi.Pages.Alerts.AddAlert.ReasonModel
@{
ViewBag.Title = "Reason";
ViewBag.Title = "Why are you adding this alert?";
}

@section BeforeContent {
Expand All @@ -12,11 +12,37 @@
<div class="govuk-grid-column-two-thirds-from-desktop">
<form action="@LinkGenerator.AlertAddReason(Model.PersonId, Model.JourneyInstance!.InstanceId, Model.FromCheckAnswers)" method="post" enctype="multipart/form-data">
<span class="govuk-caption-l">Add an alert - @Model.PersonName</span>
<h1 class="govuk-heading-l">@ViewBag.Title</h1>

<govuk-character-count asp-for="Detail" max-length="4000">
<govuk-character-count-label class="govuk-label--l" is-page-heading="true" />
<govuk-character-count-hint>Optional</govuk-character-count-hint>
</govuk-character-count>
<govuk-radios asp-for="AddReason">
<govuk-radios-fieldset>
<govuk-radios-fieldset-legend class="govuk-fieldset__legend--m" />
<govuk-radios-item value="@AddAlertReasonOption.RoutineNotificationFromStakeholder">
@AddAlertReasonOption.RoutineNotificationFromStakeholder.GetDisplayName()
</govuk-radios-item>
<govuk-radios-item value="@AddAlertReasonOption.IdentifiedDuringDataReconciliationWithStakeholder">
@AddAlertReasonOption.IdentifiedDuringDataReconciliationWithStakeholder.GetDisplayName()
</govuk-radios-item>
<govuk-radios-item value="@AddAlertReasonOption.AnotherReason">
@AddAlertReasonOption.AnotherReason.GetDisplayName()
</govuk-radios-item>
</govuk-radios-fieldset>
</govuk-radios>

<govuk-radios asp-for="HaveAdditionalReasonDetail">
<govuk-radios-fieldset>
<govuk-radios-fieldset-legend class="govuk-fieldset__legend--m" />
<govuk-radios-item value="@true">
Yes
<govuk-radios-item-conditional>
<govuk-character-count asp-for="AddReasonDetail" max-length="4000" />
</govuk-radios-item-conditional>
</govuk-radios-item>
<govuk-radios-item value="@false">
No
</govuk-radios-item>
</govuk-radios-fieldset>
</govuk-radios>

<govuk-radios asp-for="UploadEvidence" data-testid="upload-evidence-options">
<govuk-radios-fieldset>
Expand Down
Loading

0 comments on commit 8ea3546

Please sign in to comment.