Skip to content

Commit

Permalink
Fix for other schools in MAT regression and fix for searching schools…
Browse files Browse the repository at this point in the history
… with parentheses in the name
  • Loading branch information
paullocknimble committed Jan 31, 2024
1 parent 83feefe commit b33337a
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ public async Task<IActionResult> OnPost(string ukprn, string redirect)
return Page();
}

string expectedUkprn = splitSearch[1];
string expectedUrn = splitSearch[splitSearch.Length - 1]; ;

var expectedEstablishment = await _getEstablishment.GetEstablishmentByUrn(expectedUkprn);
var expectedEstablishment = await _getEstablishment.GetEstablishmentByUrn(expectedUrn);

if (expectedEstablishment.Name == null)
{
Expand All @@ -88,7 +88,7 @@ public async Task<IActionResult> OnPost(string ukprn, string redirect)

redirect = string.IsNullOrEmpty(redirect) ? Links.NewProject.SchoolApply.Page : redirect;

return RedirectToPage(redirect, new { urn = splitSearch[1], ukprn });
return RedirectToPage(redirect, new { urn = expectedUrn, ukprn });
}

private static string HighlightSearchMatch(string input, string toReplace, EstablishmentSearchResponse school)
Expand All @@ -103,6 +103,9 @@ private static string HighlightSearchMatch(string input, string toReplace, Estab

private static string[] SplitOnBrackets(string input)
{
return input.Split(new[] { '(', ')' }, 3, StringSplitOptions.None);
// return array containing one empty string if input string is null or empty
if (string.IsNullOrWhiteSpace(input)) return new string[1] { string.Empty };

return input.Split(new[] { '(', ')' }, StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
@using Dfe.Academisation.ExtensionMethods
@using Dfe.PrepareConversions.TagHelpers
@model ProjectListRowViewModel

<tr class="govuk-table__row form-a-mat" data-cy="select-projectlist-filter-row">
<td class="govuk-table__cell">
<h2 class="govuk-caption-l govuk-!-margin-bottom-0 govuk-!-margin-top-1">
<strong>
<a id="@("school-name-" + Model.Index)" class="govuk-link" asp-page="@Links.FormAMat.Index.Page" asp-route-id="@Model.Item.Id">@Model.Item.SchoolName</a>
</strong>
<span id="@("urn-" + Model.Index)">URN: @Model.Item.SchoolURN</span>
</h2>
<p class="govuk-!-margin-top-3">
<div data-cy="route">Route: @Model.Item.TypeAndRoute.RouteDescription()</div>
<div id="@("application-to-join-trust-" + Model.Index)">Application to join a trust: @Model.Item.NameOfTrust</div>
@if (@Model.Item.LocalAuthority.IsEmpty() is false)
{
<div id="@("local-authority-" + Model.Index)">Local authority: @Model.Item.LocalAuthority</div>
}
</p>
</td>
<td class="govuk-table__cell govuk-table__cell prepare-text-align-right">
<p class="govuk-!-margin-top-0">
<strong class="govuk-tag [email protected]" id="[email protected]">@Model.Item.Status.Value</strong>
</p>
<p class="govuk-hint govuk-!-margin-top-0">
<span id="[email protected]">
Project created date: @Model.Item.CreatedOn.ToDateString()<br>
</span>
<span if="Model.Item.ShowHtbDate" id="@("Advisory-Board-date-" + Model.Index)">
@("Advisory board date: " + Model.Item.HeadTeacherBoardDate)<br>
</span>
<span if="Model.Item.ShowProposedOpeningDate" id="@("opening-date-" + Model.Index)">
Opening date:
<span if="Model.Item.ProposedAcademyOpeningDate.IsPresent()">@Model.Item.ProposedAcademyOpeningDate</span>
</span>
</p>
</td>
</tr>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace Dfe.PrepareConversions.Pages.Shared
{
public class FormAMatProjectListRowModel : PageModel
{
public void OnGet()
{
}
}
}

0 comments on commit b33337a

Please sign in to comment.