Skip to content

Commit d832da0

Browse files
author
Binon
committed
TD-6628 -Update autosuggest panel to improve result limits and update type labels
1 parent ba904c7 commit d832da0

File tree

33 files changed

+138
-48
lines changed

33 files changed

+138
-48
lines changed

AdminUI/LearningHub.Nhs.AdminUI/LearningHub.Nhs.AdminUI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
<PackageReference Include="HtmlSanitizer" Version="6.0.453" />
9090
<PackageReference Include="IdentityModel" Version="4.6.0" />
9191
<PackageReference Include="LearningHub.Nhs.Caching" Version="2.0.2" />
92-
<PackageReference Include="LearningHub.Nhs.Models" Version="4.0.5" />
92+
<PackageReference Include="LearningHub.Nhs.Models" Version="4.0.11" />
9393
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.19.0" />
9494
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="6.0.36" />
9595
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.36" />

LearningHub.Nhs.WebUI.AutomatedUiTests/LearningHub.Nhs.WebUI.AutomatedUiTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<ItemGroup>
1313
<PackageReference Include="elfhHub.Nhs.Models" Version="3.0.14" />
1414
<PackageReference Include="FluentAssertions" Version="6.12.0" />
15-
<PackageReference Include="LearningHub.Nhs.Models" Version="4.0.5" />
15+
<PackageReference Include="LearningHub.Nhs.Models" Version="4.0.11" />
1616
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.1.13" />
1717
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
1818
<PackageReference Include="Selenium.Axe" Version="4.0.19" />

LearningHub.Nhs.WebUI/Controllers/SearchController.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,14 @@ public async Task<IActionResult> GetAutoSuggestion(string term)
338338

339339
var autoSuggestions = await this.searchService.GetAutoSuggestionList(term);
340340

341-
return this.PartialView("_AutoComplete", autoSuggestions);
341+
var azureSearchEnabled = Task.Run(() => this.featureManager.IsEnabledAsync(FeatureFlags.AzureSearch)).Result;
342+
343+
if (!azureSearchEnabled)
344+
{
345+
return this.PartialView("_AutoComplete", autoSuggestions);
346+
}
347+
348+
return this.PartialView("_AutoSuggest", autoSuggestions);
342349
}
343350

344351
/// <summary>

LearningHub.Nhs.WebUI/LearningHub.Nhs.WebUI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
<PackageReference Include="HtmlAgilityPack" Version="1.11.72" />
114114
<PackageReference Include="IdentityModel" Version="4.6.0" />
115115
<PackageReference Include="LearningHub.Nhs.Caching" Version="2.0.0" />
116-
<PackageReference Include="LearningHub.Nhs.Models" Version="4.0.5" />
116+
<PackageReference Include="LearningHub.Nhs.Models" Version="4.0.11" />
117117
<PackageReference Include="linqtotwitter" Version="6.9.0" />
118118
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.19.0" />
119119
<PackageReference Include="Microsoft.ApplicationInsights.EventCounterCollector" Version="2.21.0" />
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
@model LearningHub.Nhs.Models.Search.AutoSuggestionModel;
2+
@inject LearningHub.Nhs.WebUI.Interfaces.IMoodleApiService moodleApiService;
3+
4+
@using LearningHub.Nhs.Models.Search.SearchClick;
5+
@using Microsoft.AspNetCore.WebUtilities
6+
@using System.Web
7+
@{
8+
var counter = 0;
9+
var counter_res = 0;
10+
string GetUrl(string term, string searchType, AutoSuggestionClickPayloadModel payload, string reference, int? resourceReferenceId)
11+
{
12+
13+
var url = string.Empty;
14+
if (!string.IsNullOrEmpty(reference) && searchType == "catalogue")
15+
{
16+
url = "/Catalogue/" + reference;
17+
}
18+
else if ((resourceReferenceId > 0) && searchType == "resource")
19+
{
20+
url = "/Resource/" + resourceReferenceId;
21+
}
22+
else if ((resourceReferenceId > 0) && searchType == "course")
23+
{
24+
if (resourceReferenceId != null)
25+
return moodleApiService.GetCourseUrl(resourceReferenceId.Value);
26+
}
27+
else if (!string.IsNullOrEmpty(term) && searchType == "Concepts")
28+
{
29+
url = "/Search/results?term=" + term;
30+
}
31+
else
32+
{
33+
url = "/Search/results?term=" + term;
34+
}
35+
36+
return $@"/search/record-autosuggestion-click?term={term}&url={url}&clickTargetUrl={payload.ClickTargetUrl}&itemIndex={payload?.HitNumber}&&totalNumberOfHits={payload?.SearchSignal?.Stats?.TotalHits}
37+
&containerId={payload?.ContainerId}&name={payload?.DocumentFields.Name}&query={payload?.SearchSignal?.Query}&userQuery={HttpUtility.UrlEncode(payload?.SearchSignal?.UserQuery)}
38+
&searchId={payload?.SearchSignal?.SearchId}&timeOfSearch={payload?.SearchSignal?.TimeOfSearch}&title={payload?.DocumentFields?.Title}";
39+
}
40+
}
41+
@if (Model != null)
42+
{
43+
@foreach (var item in Model.ConceptDocument.ConceptDocumentList)
44+
{
45+
counter++;
46+
<li class="autosuggestion-option autosugg-concepts" style="@((Model.ConceptDocument.ConceptDocumentList.Count == counter)? "border-bottom: 3px solid #d8dde0;": "" )">
47+
<a tabindex="0" style="text-decoration:none !important" href="@GetUrl(item.Concept,"Concepts", item.Click.Payload, null, null)">
48+
<svg class="nhsuk-icon autosuggestion-icon" width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
49+
<path d="M11.8558 10.5296L15.7218 14.3861C15.8998 14.5627 16 14.8031 16 15.0539C16 15.3047 15.8998 15.5451 15.7218 15.7218C15.5451 15.8998 15.3047 16 15.0539 16C14.8031 16 14.5627 15.8998 14.3861 15.7218L10.5296 11.8558C7.76424 13.9254 3.86973 13.5064 1.60799 10.8959C-0.653748 8.28537 -0.513826 4.37088 1.92852 1.92852C4.37088 -0.513826 8.28537 -0.653748 10.8959 1.60799C13.5064 3.86973 13.9254 7.76424 11.8558 10.5296ZM6.58846 1.88528C3.99101 1.88528 1.88537 3.99093 1.88537 6.58837C1.88537 9.18581 3.99101 11.2915 6.58846 11.2915C9.1859 11.2915 11.2915 9.18581 11.2915 6.58837C11.2915 3.99093 9.1859 1.88528 6.58846 1.88528Z" />
50+
</svg>
51+
<p class="nhsuk-u-font-size-16 autosuggestion-link">@item.Concept</p>
52+
</a>
53+
</li>
54+
}
55+
@foreach (var item in Model.ResourceCollectionDocument.DocumentList)
56+
{
57+
counter_res++;
58+
<li class="autosuggestion-option autosugg-resource" style="@((Model.ResourceCollectionDocument.DocumentList.Count == counter_res)? "border-bottom: 3px solid #d8dde0;": "" )">
59+
<a tabindex="0" style="text-decoration:none !important" href="@GetUrl(item.Title, item.ResourceType, item.Click.Payload, item.URL, item.ResourceReferenceId)">
60+
<p class="nhsuk-u-font-size-16 autosuggestion-link">@item.Title</p>
61+
<p class="nhsuk-u-font-size-14 autosuggestion-subtext" style="padding:0;">
62+
Type: <span style="font-weight:bold; text-transform:capitalize;">
63+
@(item.ResourceType == "resource" ? "Learning resource" : item.ResourceType)
64+
</span>
65+
</p>
66+
67+
</a>
68+
</li>
69+
}
70+
}

OpenAPI/LearningHub.Nhs.OpenApi.Models/LearningHub.Nhs.OpenApi.Models.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
<ItemGroup>
1919
<PackageReference Include="Azure.Search.Documents" Version="11.6.0" />
20-
<PackageReference Include="LearningHub.Nhs.Models" Version="4.0.5" />
20+
<PackageReference Include="LearningHub.Nhs.Models" Version="4.0.11" />
2121
<PackageReference Include="NLog.Web.AspNetCore" Version="4.15.0" />
2222
</ItemGroup>
2323

OpenAPI/LearningHub.Nhs.OpenApi.Models/ServiceModels/AzureSearch/SearchDocument.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@ public string Description
117117
[JsonPropertyName("author")]
118118
public string Author { get; set; } = string.Empty;
119119

120+
/// <summary>
121+
/// Gets or sets the url.
122+
/// </summary>
123+
[JsonPropertyName("url")]
124+
public string Url { get; set; } = string.Empty;
125+
120126
/// <summary>
121127
/// Strips paragraph tags from input string.
122128
/// </summary>

OpenAPI/LearningHub.Nhs.OpenApi.Repositories.Interface/LearningHub.Nhs.OpenApi.Repositories.Interface.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</PropertyGroup>
1818

1919
<ItemGroup>
20-
<PackageReference Include="LearningHub.Nhs.Models" Version="4.0.5" />
20+
<PackageReference Include="LearningHub.Nhs.Models" Version="4.0.11" />
2121
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.7" />
2222
</ItemGroup>
2323

OpenAPI/LearningHub.Nhs.OpenApi.Repositories/LearningHub.Nhs.OpenApi.Repositories.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<PackageReference Include="AutoMapper" Version="10.1.1" />
2525
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.1" />
2626
<PackageReference Include="IdentityModel" Version="4.6.0" />
27-
<PackageReference Include="LearningHub.Nhs.Models" Version="4.0.5" />
27+
<PackageReference Include="LearningHub.Nhs.Models" Version="4.0.11" />
2828
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.20" />
2929
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.20" />
3030
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.20" />

OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/LearningHub.Nhs.OpenApi.Services.Interface.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
<ItemGroup>
1919
<PackageReference Include="elfhHub.Nhs.Models" Version="3.0.14" />
20-
<PackageReference Include="LearningHub.Nhs.Models" Version="4.0.5" />
20+
<PackageReference Include="LearningHub.Nhs.Models" Version="4.0.11" />
2121
</ItemGroup>
2222

2323
<ItemGroup>

0 commit comments

Comments
 (0)