-
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.
Include alert events in Change history (#1624)
Co-authored-by: Andrew Horth <[email protected]>
- Loading branch information
Showing
11 changed files
with
607 additions
and
3 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
TeachingRecordSystem/src/TeachingRecordSystem.Core/TaskEnumerableExtensions.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,14 @@ | ||
namespace TeachingRecordSystem.Core; | ||
|
||
public static class TaskEnumerableExtensions | ||
{ | ||
public static async IAsyncEnumerable<T> ToAsyncEnumerable<T>(this Task<T[]> task) | ||
{ | ||
var result = await task; | ||
|
||
foreach (var r in result) | ||
{ | ||
yield return r; | ||
} | ||
} | ||
} |
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
85 changes: 85 additions & 0 deletions
85
...ecordSystem.SupportUi/Pages/Persons/PersonDetail/Timeline/Events/AlertCreatedEvent.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,85 @@ | ||
@using TeachingRecordSystem.Core.Events | ||
@using TeachingRecordSystem.Core.Services.Files | ||
@inject IFileService FileService | ||
@inject ReferenceDataCache ReferenceDataCache | ||
@model TimelineItem<TimelineEvent<AlertCreatedEvent>> | ||
@{ | ||
var createdEvent = Model.ItemModel.Event; | ||
var alert = createdEvent.Alert; | ||
var alertType = alert.AlertTypeId is not null ? await ReferenceDataCache.GetAlertTypeById(alert.AlertTypeId.Value) : null; | ||
var evidenceFileUrl = createdEvent.EvidenceFile is not null ? await FileService.GetFileUrl(createdEvent.EvidenceFile!.FileId, TimeSpan.FromMinutes(15)) : null; | ||
} | ||
|
||
<div class="moj-timeline__item govuk-!-padding-bottom-2" data-testid="timeline-item-alert-created-event"> | ||
<div class="moj-timeline__header"> | ||
<h2 class="moj-timeline__title">Alert added</h2> | ||
</div> | ||
<p class="moj-timeline__date"> | ||
<span data-testid="raised-by">By @Model.ItemModel.RaisedByUser.Name on</span> | ||
<time datetime="@Model.Timestamp.ToString("O")" data-testid="timeline-item-time">@Model.FormattedTimestamp</time> | ||
</p> | ||
<div class="moj-timeline__description"> | ||
<govuk-summary-list> | ||
@if (alertType is not null) | ||
{ | ||
<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" use-empty-fallback>@alertType?.Name</govuk-summary-list-row-value> | ||
</govuk-summary-list-row> | ||
} | ||
else | ||
{ | ||
<govuk-summary-list-row> | ||
<govuk-summary-list-row-key>DQT sanction code</govuk-summary-list-row-key> | ||
<govuk-summary-list-row-value data-testid="sanction-code" use-empty-fallback>@alert.DqtSanctionCode?.Value</govuk-summary-list-row-value> | ||
</govuk-summary-list-row> | ||
<govuk-summary-list-row> | ||
<govuk-summary-list-row-key>DQT sanction name</govuk-summary-list-row-key> | ||
<govuk-summary-list-row-value data-testid="sanction-name" use-empty-fallback>@alert.DqtSanctionCode?.Name</govuk-summary-list-row-value> | ||
</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">@alert.StartDate?.ToString("d MMMM yyyy")</govuk-summary-list-row-value> | ||
</govuk-summary-list-row> | ||
</govuk-summary-list> | ||
|
||
<govuk-details class="govuk-!-margin-bottom-2"> | ||
<govuk-details-summary>Reason for adding alert</govuk-details-summary> | ||
<govuk-details-text> | ||
<govuk-summary-list> | ||
<govuk-summary-list-row> | ||
<govuk-summary-list-row-key>Reason</govuk-summary-list-row-key> | ||
<govuk-summary-list-row-value data-testid="reason" use-empty-fallback>@createdEvent.AddReason</govuk-summary-list-row-value> | ||
</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 (createdEvent.AddReasonDetail is not null) | ||
{ | ||
<multi-line-text text="@createdEvent.AddReasonDetail" /> | ||
} | ||
else | ||
{ | ||
<span use-empty-fallback></span> | ||
} | ||
</govuk-summary-list-row-value> | ||
</govuk-summary-list-row> | ||
<govuk-summary-list-row> | ||
<govuk-summary-list-row-key>Evidence</govuk-summary-list-row-key> | ||
<govuk-summary-list-row-value> | ||
@if (evidenceFileUrl is not null) | ||
{ | ||
<a href="@evidenceFileUrl" class="govuk-link" rel="noreferrer noopener" target="_blank" data-testid="uploaded-evidence-link">@($"{createdEvent.EvidenceFile!.Name} (opens in new tab)")</a> | ||
} | ||
else | ||
{ | ||
<span use-empty-fallback></span> | ||
} | ||
</govuk-summary-list-row-value> | ||
</govuk-summary-list-row> | ||
</govuk-summary-list> | ||
</govuk-details-text> | ||
</govuk-details> | ||
</div> | ||
</div> |
67 changes: 67 additions & 0 deletions
67
...ecordSystem.SupportUi/Pages/Persons/PersonDetail/Timeline/Events/AlertDeletedEvent.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,67 @@ | ||
@using TeachingRecordSystem.Core.Events | ||
@using TeachingRecordSystem.Core.Services.Files | ||
@inject IFileService FileService | ||
@inject ReferenceDataCache ReferenceDataCache | ||
@model TimelineItem<TimelineEvent<AlertDeletedEvent>> | ||
@{ | ||
var deletedEvent = Model.ItemModel.Event; | ||
var alert = deletedEvent.Alert; | ||
var alertType = alert.AlertTypeId is not null ? await ReferenceDataCache.GetAlertTypeById(alert.AlertTypeId.Value) : null; | ||
var evidenceFileUrl = deletedEvent.EvidenceFile is not null ? await FileService.GetFileUrl(deletedEvent.EvidenceFile!.FileId, TimeSpan.FromMinutes(15)) : null; | ||
} | ||
|
||
<div class="moj-timeline__item govuk-!-padding-bottom-2" data-testid="timeline-item-alert-deleted-event"> | ||
<div class="moj-timeline__header"> | ||
<h2 class="moj-timeline__title">Alert deleted</h2> | ||
</div> | ||
<p class="moj-timeline__date"> | ||
<span data-testid="raised-by">By @Model.ItemModel.RaisedByUser.Name on</span> | ||
<time datetime="@Model.Timestamp.ToString("O")" data-testid="timeline-item-time">@Model.FormattedTimestamp</time> | ||
</p> | ||
<div class="moj-timeline__description"> | ||
<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" use-empty-fallback>@alertType?.Name</govuk-summary-list-row-value> | ||
</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">@alert.StartDate?.ToString("d MMMM yyyy")</govuk-summary-list-row-value> | ||
</govuk-summary-list-row> | ||
</govuk-summary-list> | ||
|
||
<govuk-details class="govuk-!-margin-bottom-2"> | ||
<govuk-details-summary>Reason for deletion</govuk-details-summary> | ||
<govuk-details-text> | ||
<govuk-summary-list> | ||
<govuk-summary-list-row> | ||
<govuk-summary-list-row-key>Deletion details</govuk-summary-list-row-key> | ||
<govuk-summary-list-row-value> | ||
@if (deletedEvent.DeletionReasonDetail is not null) | ||
{ | ||
<multi-line-text text="@deletedEvent.DeletionReasonDetail" /> | ||
} | ||
else | ||
{ | ||
<span use-empty-fallback></span> | ||
} | ||
</govuk-summary-list-row-value> | ||
</govuk-summary-list-row> | ||
<govuk-summary-list-row> | ||
<govuk-summary-list-row-key>Evidence</govuk-summary-list-row-key> | ||
<govuk-summary-list-row-value> | ||
@if (evidenceFileUrl is not null) | ||
{ | ||
<a href="@evidenceFileUrl" class="govuk-link" rel="noreferrer noopener" target="_blank" data-testid="uploaded-evidence-link">@($"{deletedEvent.EvidenceFile!.Name} (opens in new tab)")</a> | ||
} | ||
else | ||
{ | ||
<span use-empty-fallback></span> | ||
} | ||
</govuk-summary-list-row-value> | ||
</govuk-summary-list-row> | ||
</govuk-summary-list> | ||
</govuk-details-text> | ||
</govuk-details> | ||
</div> | ||
</div> |
56 changes: 56 additions & 0 deletions
56
...stem.SupportUi/Pages/Persons/PersonDetail/Timeline/Events/AlertDqtDeactivatedEvent.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,56 @@ | ||
@using TeachingRecordSystem.Core.Events | ||
@using TeachingRecordSystem.Core.Services.Files | ||
@inject IFileService FileService | ||
@inject ReferenceDataCache ReferenceDataCache | ||
@model TimelineItem<TimelineEvent<AlertDqtDeactivatedEvent>> | ||
@{ | ||
var dqtDeactivatedEvent = Model.ItemModel.Event; | ||
var alert = dqtDeactivatedEvent.Alert; | ||
} | ||
|
||
<div class="moj-timeline__item govuk-!-padding-bottom-2" data-testid="timeline-item-alert-deleted-event"> | ||
<div class="moj-timeline__header"> | ||
<h2 class="moj-timeline__title">Alert deactivated</h2> | ||
</div> | ||
<p class="moj-timeline__date"> | ||
<span data-testid="raised-by">By @Model.ItemModel.RaisedByUser.Name on</span> | ||
<time datetime="@Model.Timestamp.ToString("O")" data-testid="timeline-item-time">@Model.FormattedTimestamp</time> | ||
</p> | ||
<div class="moj-timeline__description"> | ||
<govuk-details class="govuk-!-margin-bottom-2"> | ||
<govuk-details-summary>Deactivated data</govuk-details-summary> | ||
<govuk-details-text> | ||
<govuk-summary-list> | ||
<govuk-summary-list-row> | ||
<govuk-summary-list-row-key>DQT sanction code</govuk-summary-list-row-key> | ||
<govuk-summary-list-row-value data-testid="sanction-code" use-empty-fallback>@alert.DqtSanctionCode?.Value</govuk-summary-list-row-value> | ||
</govuk-summary-list-row> | ||
<govuk-summary-list-row> | ||
<govuk-summary-list-row-key>DQT sanction name</govuk-summary-list-row-key> | ||
<govuk-summary-list-row-value data-testid="sanction-name" use-empty-fallback>@alert.DqtSanctionCode?.Name</govuk-summary-list-row-value> | ||
</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" use-empty-fallback>@alert.StartDate?.ToString("d MMMM yyyy")</govuk-summary-list-row-value> | ||
</govuk-summary-list-row> | ||
<govuk-summary-list-row> | ||
<govuk-summary-list-row-key>Details</govuk-summary-list-row-key> | ||
<govuk-summary-list-row-value data-testid="details" use-empty-fallback>@alert.Details</govuk-summary-list-row-value> | ||
</govuk-summary-list-row> | ||
<govuk-summary-list-row> | ||
<govuk-summary-list-row-key>External link</govuk-summary-list-row-key> | ||
<govuk-summary-list-row-value data-testid="external-link" use-empty-fallback>@alert.ExternalLink</govuk-summary-list-row-value> | ||
</govuk-summary-list-row> | ||
<govuk-summary-list-row> | ||
<govuk-summary-list-row-key>End date</govuk-summary-list-row-key> | ||
<govuk-summary-list-row-value data-testid="end-date" use-empty-fallback>@alert.EndDate?.ToString("d MMMM yyyy")</govuk-summary-list-row-value> | ||
</govuk-summary-list-row> | ||
<govuk-summary-list-row> | ||
<govuk-summary-list-row-key>DQT spent</govuk-summary-list-row-key> | ||
<govuk-summary-list-row-value data-testid="dqt-spent" use-empty-fallback>@alert.DqtSpent</govuk-summary-list-row-value> | ||
</govuk-summary-list-row> | ||
</govuk-summary-list> | ||
</govuk-details-text> | ||
</govuk-details> | ||
</div> | ||
</div> |
35 changes: 35 additions & 0 deletions
35
...dSystem.SupportUi/Pages/Persons/PersonDetail/Timeline/Events/AlertDqtImportedEvent.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,35 @@ | ||
@using TeachingRecordSystem.Core.Events | ||
@using TeachingRecordSystem.Core.Services.Files | ||
@inject IFileService FileService | ||
@inject ReferenceDataCache ReferenceDataCache | ||
@model TimelineItem<TimelineEvent<AlertDqtImportedEvent>> | ||
@{ | ||
var dqtImportedEvent = Model.ItemModel.Event; | ||
var alert = dqtImportedEvent.Alert; | ||
} | ||
|
||
<div class="moj-timeline__item govuk-!-padding-bottom-2" data-testid="timeline-item-alert-deleted-event"> | ||
<div class="moj-timeline__header"> | ||
<h2 class="moj-timeline__title">Alert imported</h2> | ||
</div> | ||
<p class="moj-timeline__date"> | ||
<span data-testid="raised-by">By @Model.ItemModel.RaisedByUser.Name on</span> | ||
<time datetime="@Model.Timestamp.ToString("O")" data-testid="timeline-item-time">@Model.FormattedTimestamp</time> | ||
</p> | ||
<div class="moj-timeline__description"> | ||
<govuk-summary-list> | ||
<govuk-summary-list-row> | ||
<govuk-summary-list-row-key>DQT sanction code</govuk-summary-list-row-key> | ||
<govuk-summary-list-row-value data-testid="sanction-code" use-empty-fallback>@alert.DqtSanctionCode?.Value</govuk-summary-list-row-value> | ||
</govuk-summary-list-row> | ||
<govuk-summary-list-row> | ||
<govuk-summary-list-row-key>DQT sanction name</govuk-summary-list-row-key> | ||
<govuk-summary-list-row-value data-testid="sanction-name" use-empty-fallback>@alert.DqtSanctionCode?.Name</govuk-summary-list-row-value> | ||
</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" use-empty-fallback>@alert.StartDate?.ToString("d MMMM yyyy")</govuk-summary-list-row-value> | ||
</govuk-summary-list-row> | ||
</govuk-summary-list> | ||
</div> | ||
</div> |
35 changes: 35 additions & 0 deletions
35
...stem.SupportUi/Pages/Persons/PersonDetail/Timeline/Events/AlertDqtReactivatedEvent.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,35 @@ | ||
@using TeachingRecordSystem.Core.Events | ||
@using TeachingRecordSystem.Core.Services.Files | ||
@inject IFileService FileService | ||
@inject ReferenceDataCache ReferenceDataCache | ||
@model TimelineItem<TimelineEvent<AlertDqtReactivatedEvent>> | ||
@{ | ||
var dqtReactivatedEvent = Model.ItemModel.Event; | ||
var alert = dqtReactivatedEvent.Alert; | ||
} | ||
|
||
<div class="moj-timeline__item govuk-!-padding-bottom-2" data-testid="timeline-item-alert-deleted-event"> | ||
<div class="moj-timeline__header"> | ||
<h2 class="moj-timeline__title">Alert reactivated</h2> | ||
</div> | ||
<p class="moj-timeline__date"> | ||
<span data-testid="raised-by">By @Model.ItemModel.RaisedByUser.Name on</span> | ||
<time datetime="@Model.Timestamp.ToString("O")" data-testid="timeline-item-time">@Model.FormattedTimestamp</time> | ||
</p> | ||
<div class="moj-timeline__description"> | ||
<govuk-summary-list> | ||
<govuk-summary-list-row> | ||
<govuk-summary-list-row-key>DQT sanction code</govuk-summary-list-row-key> | ||
<govuk-summary-list-row-value data-testid="sanction-code" use-empty-fallback>@alert.DqtSanctionCode?.Value</govuk-summary-list-row-value> | ||
</govuk-summary-list-row> | ||
<govuk-summary-list-row> | ||
<govuk-summary-list-row-key>DQT sanction name</govuk-summary-list-row-key> | ||
<govuk-summary-list-row-value data-testid="sanction-name" use-empty-fallback>@alert.DqtSanctionCode?.Name</govuk-summary-list-row-value> | ||
</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" use-empty-fallback>@alert.StartDate?.ToString("d MMMM yyyy")</govuk-summary-list-row-value> | ||
</govuk-summary-list-row> | ||
</govuk-summary-list> | ||
</div> | ||
</div> |
Oops, something went wrong.