Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add details link to alert detail page #853

Merged
merged 4 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8910,6 +8910,7 @@ public partial class dfeta_sanction : Microsoft.Xrm.Sdk.Entity, System.Component
/// </summary>
public static class Fields
{
public const string dfeta_DetailsLink = "dfeta_detailslink";
public const string dfeta_EndDate = "dfeta_enddate";
public const string dfeta_NoReAppuntildate = "dfeta_noreappuntildate";
public const string dfeta_PersonId = "dfeta_personid";
Expand Down Expand Up @@ -8973,6 +8974,26 @@ private void OnPropertyChanging(string propertyName)
}
}

/// <summary>
///
/// </summary>
[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("dfeta_detailslink")]
public string dfeta_DetailsLink
{
[System.Diagnostics.DebuggerNonUserCode()]
get
{
return this.GetAttributeValue<string>("dfeta_detailslink");
}
[System.Diagnostics.DebuggerNonUserCode()]
set
{
this.OnPropertyChanging("dfeta_DetailsLink");
this.SetAttributeValue("dfeta_detailslink", value);
this.OnPropertyChanged("dfeta_DetailsLink");
}
}

/// <summary>
///
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public async Task<SanctionDetailResult[]> Execute(GetSanctionDetailsByContactIdQ
dfeta_sanction.Fields.dfeta_StartDate,
dfeta_sanction.Fields.dfeta_EndDate,
dfeta_sanction.Fields.dfeta_Spent,
dfeta_sanction.Fields.dfeta_DetailsLink,
dfeta_sanction.Fields.StateCode),
Criteria = filter
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class GetSanctionDetailsBySanctionIdHandler : ICrmQueryHandler<GetSanctio
dfeta_sanction.Fields.dfeta_StartDate,
dfeta_sanction.Fields.dfeta_EndDate,
dfeta_sanction.Fields.dfeta_Spent,
dfeta_sanction.Fields.dfeta_DetailsLink,
dfeta_sanction.Fields.StateCode),
Criteria = filter
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,27 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds-from-desktop">
<h3 class="govuk-heading-s">Details</h3>
@if (!string.IsNullOrEmpty(@Model.Alert.Details))
@if (!string.IsNullOrEmpty(Model.Alert.Details))
{
<multi-line-text data-testid="alert-details" text="@Model.Alert.Details"/>
}
@if (Model.IsActive)
{
<form asp-page-handler="SetInactive" method="post">
<govuk-button type="submit" class="govuk-!-margin-top-9" data-testid="deactivate-button">Mark alert as inactive</govuk-button>
</form>
}
else
{
<form asp-page-handler="SetActive" method="post">
<govuk-button type="submit" class="govuk-button--warning govuk-!-margin-top-9" data-testid="reactivate-button">Remove inactive status</govuk-button>
</form>
}
}

@if (!string.IsNullOrEmpty(Model.Alert.DetailsLink))
{
<a href="@Model.Alert.DetailsLink" class="govuk-link" rel="noreferrer noopener" target="_blank" data-testid="full-case-details-link">See full case details (opens in new tab)</a>
}

@if (Model.IsActive)
{
<form asp-page-handler="SetInactive" method="post">
<govuk-button type="submit" class="govuk-!-margin-top-9" data-testid="deactivate-button">Mark alert as inactive</govuk-button>
</form>
}
else
{
<form asp-page-handler="SetActive" method="post">
<govuk-button type="submit" class="govuk-button--warning govuk-!-margin-top-9" data-testid="reactivate-button">Remove inactive status</govuk-button>
</form>
}
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ private AlertInfo MapSanction(SanctionDetailResult sanction)
AlertId = sanction.Sanction.Id,
Description = sanction.Description,
Details = sanction.Sanction.dfeta_SanctionDetails,
DetailsLink = sanction.Sanction.dfeta_DetailsLink,
StartDate = sanction.Sanction.dfeta_StartDate.ToDateOnlyWithDqtBstFix(isLocalTime: true),
EndDate = sanction.Sanction.dfeta_EndDate.ToDateOnlyWithDqtBstFix(isLocalTime: true),
Status = alertStatus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
}

@section BeforeContent {
<govuk-back-link href="@LinkGenerator.PersonDetail(Model.PersonId!.Value)">Back</govuk-back-link>
<govuk-back-link href="@LinkGenerator.PersonAlerts(Model.PersonId!.Value)">Back</govuk-back-link>
}

<h1 class="govuk-heading-l">@ViewBag.Title</h1>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public record AlertInfo
public required Guid AlertId { get; init; }
public required string Description { get; init; }
public required string Details { get; init; }
public required string DetailsLink { get; init; }
public required DateOnly? StartDate { get; init; }
public required DateOnly? EndDate { get; init; }
public required AlertStatus Status { get; init; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ private AlertInfo MapSanction(SanctionDetailResult sanction)
AlertId = sanction.Sanction.Id,
Description = sanction.Description,
Details = sanction.Sanction.dfeta_SanctionDetails,
DetailsLink = sanction.Sanction.dfeta_DetailsLink,
StartDate = sanction.Sanction.dfeta_StartDate.ToDateOnlyWithDqtBstFix(isLocalTime: true),
EndDate = sanction.Sanction.dfeta_EndDate.ToDateOnlyWithDqtBstFix(isLocalTime: true),
Status = alertStatus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ public async Task Get_WithAlertIdForNonExistentAlert_ReturnsNotFound()
}

[Theory]
[InlineData("2021-01-01", "2022-03-05", true, true, AlertStatus.Closed)]
[InlineData("2021-01-01", null, false, true, AlertStatus.Active)]
[InlineData("2021-01-01", null, false, false, AlertStatus.Inactive)]
[InlineData("2021-01-01", "2022-03-05", true, false, AlertStatus.Inactive)]
public async Task Get_ValidRequest_RendersExpectedContent(string startDateString, string? endDateString, bool isSpent, bool isActive, AlertStatus expectedAlertStatus)
[InlineData("2021-01-01", "2022-03-05", "http://www.gov.uk", true, true, AlertStatus.Closed)]
[InlineData("2021-01-01", null, null, false, true, AlertStatus.Active)]
[InlineData("2021-01-01", null, "http://www.gov.uk", false, false, AlertStatus.Inactive)]
[InlineData("2021-01-01", "2022-03-05", null, true, false, AlertStatus.Inactive)]
public async Task Get_ValidRequest_RendersExpectedContent(string startDateString, string? endDateString, string? detailsLink, bool isSpent, bool isActive, AlertStatus expectedAlertStatus)
{
// Arrange
var sanctionCode = "G1";
var sanctionCodeName = (await TestData.ReferenceDataCache.GetSanctionCodeByValue(sanctionCode)).dfeta_name;
var startDate = DateOnly.Parse(startDateString);
DateOnly? endDate = endDateString is not null ? DateOnly.Parse(endDateString) : null;
var person = await TestData.CreatePerson(x => x.WithSanction(sanctionCode, startDate: startDate, endDate: endDate, spent: isSpent, isActive: isActive));
var person = await TestData.CreatePerson(x => x.WithSanction(sanctionCode, startDate: startDate, endDate: endDate, spent: isSpent, detailsLink: detailsLink, isActive: isActive));

var request = new HttpRequestMessage(HttpMethod.Get, $"/alerts/{person.Sanctions.Single().SanctionId}");

Expand All @@ -56,6 +56,14 @@ public async Task Get_ValidRequest_RendersExpectedContent(string startDateString
Assert.Equal(endDate is not null ? endDate.Value.ToString("dd/MM/yyyy") : "-", alertHeader.GetElementByTestId("end-date")!.TextContent);
Assert.Equal(expectedAlertStatus.ToString(), alertHeader.GetElementByTestId("status")!.TextContent);
Assert.NotNull(doc.GetElementByTestId("alert-details"));
if (detailsLink is not null)
{
Assert.Equal(detailsLink, doc.GetElementByTestId("full-case-details-link")!.GetAttribute("href"));
}
else
{
Assert.Null(doc.GetElementByTestId("full-case-details-link"));
}
if (isActive)
{
Assert.NotNull(doc.GetElementByTestId("deactivate-button"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,10 @@ public CreatePersonBuilder WithSanction(
DateOnly? reviewDate = null,
bool spent = false,
string details = "lorem ipsum",
string? detailsLink = null,
bool isActive = true)
{
_sanctions.Add(new(Guid.NewGuid(), sanctionCode, startDate, endDate, reviewDate, spent, details, isActive));
_sanctions.Add(new(Guid.NewGuid(), sanctionCode, startDate, endDate, reviewDate, spent, details, detailsLink, isActive));
return this;
}

Expand Down Expand Up @@ -184,20 +185,26 @@ public async Task<CreatePersonResult> Execute(CrmTestData testData)
foreach (var sanction in _sanctions)
{
var sanctionCode = await testData.ReferenceDataCache.GetSanctionCodeByValue(sanction.SanctionCode);
var crmSanction = new dfeta_sanction()
{
Id = sanction.SanctionId,
dfeta_PersonId = personId.ToEntityReference(Contact.EntityLogicalName),
dfeta_SanctionCodeId = sanctionCode.Id.ToEntityReference(dfeta_sanctioncode.EntityLogicalName),
dfeta_StartDate = sanction.StartDate?.FromDateOnlyWithDqtBstFix(isLocalTime: true),
dfeta_EndDate = sanction.EndDate?.FromDateOnlyWithDqtBstFix(isLocalTime: true),
dfeta_NoReAppuntildate = sanction.ReviewDate?.FromDateOnlyWithDqtBstFix(isLocalTime: true),
dfeta_Spent = sanction.Spent,
dfeta_SanctionDetails = sanction.Details
};

if (!string.IsNullOrWhiteSpace(sanction.DetailsLink))
{
crmSanction.dfeta_DetailsLink = sanction.DetailsLink;
}

txnRequestBuilder.AddRequest(new CreateRequest()
{
Target = new dfeta_sanction()
{
Id = sanction.SanctionId,
dfeta_PersonId = personId.ToEntityReference(Contact.EntityLogicalName),
dfeta_SanctionCodeId = sanctionCode.Id.ToEntityReference(dfeta_sanctioncode.EntityLogicalName),
dfeta_StartDate = sanction.StartDate?.FromDateOnlyWithDqtBstFix(isLocalTime: true),
dfeta_EndDate = sanction.EndDate?.FromDateOnlyWithDqtBstFix(isLocalTime: true),
dfeta_NoReAppuntildate = sanction.ReviewDate?.FromDateOnlyWithDqtBstFix(isLocalTime: true),
dfeta_Spent = sanction.Spent,
dfeta_SanctionDetails = sanction.Details
}
Target = crmSanction
});

if (!sanction.IsActive)
Expand Down Expand Up @@ -265,5 +272,5 @@ public record CreatePersonResult
};
}

public record Sanction(Guid SanctionId, string SanctionCode, DateOnly? StartDate, DateOnly? EndDate, DateOnly? ReviewDate, bool Spent, string Details, bool IsActive);
public record Sanction(Guid SanctionId, string SanctionCode, DateOnly? StartDate, DateOnly? EndDate, DateOnly? ReviewDate, bool Spent, string Details, string? DetailsLink, bool IsActive);
}
1 change: 1 addition & 0 deletions crm_attributes.json
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@
"statecode"
],
"dfeta_sanction": [
"dfeta_detailslink",
"dfeta_enddate",
"dfeta_noreappuntildate",
"dfeta_personid",
Expand Down
2 changes: 1 addition & 1 deletion tools/coretools/CrmSvcUtil.exe.config
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<add key="EntityCommandLineText" />
<add key="EntitiesToSkip" />
<add key="EntitiesWhitelist" value="account|annotation|contact|dfeta_businesseventaudit|dfeta_country|dfeta_document|dfeta_earlyyearsstatus|dfeta_hequalification|dfeta_hesubject|dfeta_induction|dfeta_inductionperiod|dfeta_initialteachertraining|dfeta_ittqualification|dfeta_ittsubject|dfeta_previousname|dfeta_qtsregistration|dfeta_qualification|dfeta_sanction|dfeta_sanctioncode|dfeta_specialism|dfeta_teacherstatus|incident|incidentresolution|plugintype|sdkmessage|sdkmessagefilter|sdkmessageprocessingstep|sdkmessageprocessingstepimage|subject|systemuser|task" />
<add key="AttributesWhitelist" value="account:dfeta_trainingprovider,dfeta_ukprn,name,statecode|annotation:documentbody,filename,mimetype,notetext,objectid,objecttypecode,statecode,subject|contact:address1_city,address1_country,address1_line1,address1_line2,address1_line3,address1_postalcode,birthdate,contactid,createdon,dfeta_activesanctions,dfeta_allowpiiupdatesfromregister,dfeta_eytsdate,dfeta_husid,dfeta_inductionStatus,dfeta_lastidentityupdate,dfeta_loginfailedcounter,dfeta_ninumber,dfeta_previouslastname,dfeta_qtsdate,dfeta_slugid,dfeta_statedfirstname,dfeta_statedlastname,dfeta_statedmiddlename,dfeta_trn,dfeta_trnallocaterequest,dfeta_trnrequired,dfeta_tspersonid,emailaddress1,emailaddress2,firstname,fullname,gendercode,lastname,masterid,merged,middlename,mobilephone,statecode,telephone1|dfeta_businesseventaudit:createdon,dfeta_changedfield,dfeta_newvalue,dfeta_oldvalue,dfeta_person,statecode|dfeta_country:dfeta_name,dfeta_value,statecode|dfeta_document:dfeta_caseid,dfeta_documentid,dfeta_name,dfeta_personid,dfeta_type,statecode,statuscode|dfeta_earlyyearsstatus:dfeta_name,dfeta_value,statecode|dfeta_hequalification:dfeta_hequalificationid,dfeta_name,dfeta_value,statecode|dfeta_hesubject:dfeta_name,dfeta_value,statecode|dfeta_induction:CreatedOn,dfeta_completiondate,dfeta_inductionexemptionreason,dfeta_inductionstatus,dfeta_personid,dfeta_startdate,statecode|dfeta_inductionperiod:dfeta_appropriatebodyid,dfeta_enddate,dfeta_inductionid,dfeta_numberofterms,dfeta_startdate,statecode|dfeta_initialteachertraining:dfeta_agerangefrom,dfeta_agerangeto,dfeta_cohortyear,dfeta_countryid,dfeta_establishmentid,dfeta_ittqualificationaim,dfeta_ittqualificationid,dfeta_personid,dfeta_programmeenddate,dfeta_programmestartdate,dfeta_programmetype,dfeta_result,dfeta_slugid,dfeta_subject1id,dfeta_subject2id,dfeta_subject3id,dfeta_traineeid,statecode|dfeta_ittqualification:dfeta_name,dfeta_value,statecode|dfeta_ittsubject:dfeta_name,dfeta_value,statecode|dfeta_previousname:createdon,dfeta_changedon,dfeta_name,dfeta_personid,dfeta_previousnameid,dfeta_type,statecode|dfeta_qtsregistration:dfeta_earlyyearsstatusid,dfeta_eytsdate,dfeta_inductionid,dfeta_name,dfeta_personid,dfeta_qtsdate,dfeta_teacherstatusid,statecode|dfeta_qualification:CreatedOn,dfeta_completionorawarddate,dfeta_createdbyapi,dfeta_he_classdivision,dfeta_he_completiondate,dfeta_he_countryid,dfeta_he_establishmentid,dfeta_he_hequalificationid,dfeta_he_hesubject1id,dfeta_he_hesubject2id,dfeta_he_hesubject3id,dfeta_mq_date,dfeta_mq_specialismid,dfeta_npqel_awarded,dfeta_npqel_date,dfeta_npqeyl_awarded,dfeta_npqeyl_date,dfeta_NPQH_Awarded,dfeta_NPQH_Date,dfeta_npqlbc_awarded,dfeta_npqlbc_date,dfeta_npqll_awarded,dfeta_npqll_date,dfeta_npqlt_awarded,dfeta_npqlt_date,dfeta_npqltd_awarded,dfeta_npqltd_date,dfeta_npqml_awarded,dfeta_npqml_date,dfeta_npqsl_awarded,dfeta_npqsl_date,dfeta_personid,dfeta_type,statecode|dfeta_sanction:dfeta_enddate,dfeta_noreappuntildate,dfeta_personid,dfeta_sanctioncodeid,dfeta_sanctiondetails,dfeta_sanctionid,dfeta_spent,dfeta_startdate,statecode|dfeta_sanctioncode:dfeta_name,dfeta_sanctioncodeid,dfeta_value,statecode|dfeta_specialism:dfeta_name,dfeta_value,statecode|dfeta_teacherstatus:dfeta_name,dfeta_qtsdaterequired,dfeta_value,statecode|incident:createdon,customerid,description,dfeta_fromidentity,dfeta_newdateofbirth,dfeta_newfirstname,dfeta_newlastname,dfeta_newmiddlename,dfeta_statedfirstname,dfeta_statedlastname,dfeta_statedmiddlename,statecode,statuscode,subjectid,ticketnumber,title|incidentresolution:activityid,incidentid,statecode,subject|plugintype:|sdkmessage:|sdkmessagefilter:|sdkmessageprocessingstep:|sdkmessageprocessingstepimage:|subject:description,statecode,subjectid,title|systemuser:azureactivedirectoryobjectid,firstname,lastname|task:category,description,dfeta_potentialduplicateid,regardingobjectid,scheduledend,statecode,subject" />
<add key="AttributesWhitelist" value="account:dfeta_trainingprovider,dfeta_ukprn,name,statecode|annotation:documentbody,filename,mimetype,notetext,objectid,objecttypecode,statecode,subject|contact:address1_city,address1_country,address1_line1,address1_line2,address1_line3,address1_postalcode,birthdate,contactid,createdon,dfeta_activesanctions,dfeta_allowpiiupdatesfromregister,dfeta_eytsdate,dfeta_husid,dfeta_inductionStatus,dfeta_lastidentityupdate,dfeta_loginfailedcounter,dfeta_ninumber,dfeta_previouslastname,dfeta_qtsdate,dfeta_slugid,dfeta_statedfirstname,dfeta_statedlastname,dfeta_statedmiddlename,dfeta_trn,dfeta_trnallocaterequest,dfeta_trnrequired,dfeta_tspersonid,emailaddress1,emailaddress2,firstname,fullname,gendercode,lastname,masterid,merged,middlename,mobilephone,statecode,telephone1|dfeta_businesseventaudit:createdon,dfeta_changedfield,dfeta_newvalue,dfeta_oldvalue,dfeta_person,statecode|dfeta_country:dfeta_name,dfeta_value,statecode|dfeta_document:dfeta_caseid,dfeta_documentid,dfeta_name,dfeta_personid,dfeta_type,statecode,statuscode|dfeta_earlyyearsstatus:dfeta_name,dfeta_value,statecode|dfeta_hequalification:dfeta_hequalificationid,dfeta_name,dfeta_value,statecode|dfeta_hesubject:dfeta_name,dfeta_value,statecode|dfeta_induction:CreatedOn,dfeta_completiondate,dfeta_inductionexemptionreason,dfeta_inductionstatus,dfeta_personid,dfeta_startdate,statecode|dfeta_inductionperiod:dfeta_appropriatebodyid,dfeta_enddate,dfeta_inductionid,dfeta_numberofterms,dfeta_startdate,statecode|dfeta_initialteachertraining:dfeta_agerangefrom,dfeta_agerangeto,dfeta_cohortyear,dfeta_countryid,dfeta_establishmentid,dfeta_ittqualificationaim,dfeta_ittqualificationid,dfeta_personid,dfeta_programmeenddate,dfeta_programmestartdate,dfeta_programmetype,dfeta_result,dfeta_slugid,dfeta_subject1id,dfeta_subject2id,dfeta_subject3id,dfeta_traineeid,statecode|dfeta_ittqualification:dfeta_name,dfeta_value,statecode|dfeta_ittsubject:dfeta_name,dfeta_value,statecode|dfeta_previousname:createdon,dfeta_changedon,dfeta_name,dfeta_personid,dfeta_previousnameid,dfeta_type,statecode|dfeta_qtsregistration:dfeta_earlyyearsstatusid,dfeta_eytsdate,dfeta_inductionid,dfeta_name,dfeta_personid,dfeta_qtsdate,dfeta_teacherstatusid,statecode|dfeta_qualification:CreatedOn,dfeta_completionorawarddate,dfeta_createdbyapi,dfeta_he_classdivision,dfeta_he_completiondate,dfeta_he_countryid,dfeta_he_establishmentid,dfeta_he_hequalificationid,dfeta_he_hesubject1id,dfeta_he_hesubject2id,dfeta_he_hesubject3id,dfeta_mq_date,dfeta_mq_specialismid,dfeta_npqel_awarded,dfeta_npqel_date,dfeta_npqeyl_awarded,dfeta_npqeyl_date,dfeta_NPQH_Awarded,dfeta_NPQH_Date,dfeta_npqlbc_awarded,dfeta_npqlbc_date,dfeta_npqll_awarded,dfeta_npqll_date,dfeta_npqlt_awarded,dfeta_npqlt_date,dfeta_npqltd_awarded,dfeta_npqltd_date,dfeta_npqml_awarded,dfeta_npqml_date,dfeta_npqsl_awarded,dfeta_npqsl_date,dfeta_personid,dfeta_type,statecode|dfeta_sanction:dfeta_detailslink,dfeta_enddate,dfeta_noreappuntildate,dfeta_personid,dfeta_sanctioncodeid,dfeta_sanctiondetails,dfeta_sanctionid,dfeta_spent,dfeta_startdate,statecode|dfeta_sanctioncode:dfeta_name,dfeta_sanctioncodeid,dfeta_value,statecode|dfeta_specialism:dfeta_name,dfeta_value,statecode|dfeta_teacherstatus:dfeta_name,dfeta_qtsdaterequired,dfeta_value,statecode|incident:createdon,customerid,description,dfeta_fromidentity,dfeta_newdateofbirth,dfeta_newfirstname,dfeta_newlastname,dfeta_newmiddlename,dfeta_statedfirstname,dfeta_statedlastname,dfeta_statedmiddlename,statecode,statuscode,subjectid,ticketnumber,title|incidentresolution:activityid,incidentid,statecode,subject|plugintype:|sdkmessage:|sdkmessagefilter:|sdkmessageprocessingstep:|sdkmessageprocessingstepimage:|subject:description,statecode,subjectid,title|systemuser:azureactivedirectoryobjectid,firstname,lastname|task:category,description,dfeta_potentialduplicateid,regardingobjectid,scheduledend,statecode,subject" />
<add key="EntityPrefixesToSkip" />
<add key="EntityPrefixesWhitelist" />
<add key="FilePrefixText" />
Expand Down