Skip to content

Commit c881bdd

Browse files
Merge pull request #746 from TechnologyEnhancedLearning/Develop/Fixes/TD-4870-Change-in-did-you-mean-suggestion-message
TD-4870: Change in did you mean suggestion message
2 parents 4b32656 + cac9076 commit c881bdd

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

LearningHub.Nhs.WebUI/Models/Search/SearchResultViewModel.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,10 @@ public class SearchResultViewModel
8888
/// Gets or sets Suggested Catalogue name.
8989
/// </summary>
9090
public string SuggestedCatalogue { get; set; }
91+
92+
/// <summary>
93+
/// Gets or sets Suggested Resource name.
94+
/// </summary>
95+
public string SuggestedResource { get; set; }
9196
}
9297
}

LearningHub.Nhs.WebUI/Services/SearchService.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public async Task<SearchResultViewModel> PerformSearch(IPrincipal user, SearchRe
6464
var groupId = Guid.Parse(searchRequest.GroupId);
6565
bool didYouMeanEnabled = false;
6666
var suggestedCatalogue = string.Empty;
67+
var suggestedResource = string.Empty;
6768

6869
var resourceSearchPageSize = this.settings.FindwiseSettings.ResourceSearchPageSize;
6970
var catalogueSearchPageSize = this.settings.FindwiseSettings.CatalogueSearchPageSize;
@@ -125,6 +126,7 @@ public async Task<SearchResultViewModel> PerformSearch(IPrincipal user, SearchRe
125126
if (resourceResult?.Spell?.Suggestions?.Count > 0)
126127
{
127128
resourceSearchRequestModel.SearchText = Regex.Replace(resourceResult?.Spell?.Suggestions?.FirstOrDefault().ToString(), "<.*?>", string.Empty);
129+
suggestedResource = resourceSearchRequestModel.SearchText;
128130

129131
// calling findwise endpoint with new search text - resources
130132
resourceResultTask = this.GetSearchResultAsync(resourceSearchRequestModel);
@@ -233,6 +235,7 @@ public async Task<SearchResultViewModel> PerformSearch(IPrincipal user, SearchRe
233235
},
234236
DidYouMeanEnabled = didYouMeanEnabled,
235237
SuggestedCatalogue = suggestedCatalogue,
238+
SuggestedResource = suggestedResource,
236239
};
237240

238241
return searchResultViewModel;

LearningHub.Nhs.WebUI/Views/Search/Index.cshtml

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,18 @@
99
}
1010

1111
<div class="search-page">
12-
<div class="nhsuk-width-container app-width-container">
13-
<h1 class="nhsuk-u-margin-top-5 nhsuk-u-margin-bottom-6">
14-
Search results @(!string.IsNullOrEmpty(Model.SearchString) ? "for " + Model.SearchString : string.Empty)
15-
</h1>
12+
<div class="nhsuk-width-container app-width-container">
1613
@if (Model.DidYouMeanEnabled)
1714
{
18-
<h6 class="nhsuk-u-margin-top-5 nhsuk-u-margin-bottom-6">
19-
We couldn't find a match for <em>@(Model.SearchString)</em>, try adjusting your search terms or explore the suggestions below.
20-
</h6>
15+
<p class="nhsuk-u-margin-top-5 nhsuk-u-margin-bottom-6 nhsuk-body-l">
16+
No results were found for <b>@(Model.SearchString)</b> please change your search term or explore the suggestions below
17+
</p>
18+
}
19+
else
20+
{
21+
<h1 class="nhsuk-u-margin-top-5 nhsuk-u-margin-bottom-6">
22+
Search results @(!string.IsNullOrEmpty(Model.SearchString) ? "for " + Model.SearchString : string.Empty)
23+
</h1>
2124
}
2225

2326
<div class="nhsuk-grid-row">
@@ -28,6 +31,12 @@
2831

2932
@if (Model.CatalogueSearchResult?.TotalHits > 0)
3033
{
34+
@if (Model.DidYouMeanEnabled)
35+
{
36+
<p class="nhsuk-u-margin-top-5 nhsuk-u-margin-bottom-6">
37+
Showing results for <b>@(Model.SuggestedCatalogue)</b>
38+
</p>
39+
}
3140
<div class="nhsuk-grid-row">
3241
<div class="nhsuk-grid-column-full">
3342
@await Html.PartialAsync("_CatalogueSearchResult", Model)
@@ -37,6 +46,12 @@
3746

3847
@if (Model.ResourceSearchResult?.TotalHits > 0)
3948
{
49+
@if (Model.DidYouMeanEnabled)
50+
{
51+
<p class="nhsuk-u-margin-top-5 nhsuk-u-margin-bottom-6">
52+
Showing results for <b>@(Model.SuggestedResource)</b>
53+
</p>
54+
}
4055
@await Html.PartialAsync("_ResourceFilter", Model)
4156

4257
<div class="nhsuk-grid-row">

0 commit comments

Comments
 (0)