Skip to content
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
5 changes: 5 additions & 0 deletions LearningHub.Nhs.WebUI/Models/Search/SearchResultViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,10 @@ public class SearchResultViewModel
/// Gets or sets Suggested Catalogue name.
/// </summary>
public string SuggestedCatalogue { get; set; }

/// <summary>
/// Gets or sets Suggested Resource name.
/// </summary>
public string SuggestedResource { get; set; }
}
}
3 changes: 3 additions & 0 deletions LearningHub.Nhs.WebUI/Services/SearchService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public async Task<SearchResultViewModel> PerformSearch(IPrincipal user, SearchRe
var groupId = Guid.Parse(searchRequest.GroupId);
bool didYouMeanEnabled = false;
var suggestedCatalogue = string.Empty;
var suggestedResource = string.Empty;

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

// calling findwise endpoint with new search text - resources
resourceResultTask = this.GetSearchResultAsync(resourceSearchRequestModel);
Expand Down Expand Up @@ -233,6 +235,7 @@ public async Task<SearchResultViewModel> PerformSearch(IPrincipal user, SearchRe
},
DidYouMeanEnabled = didYouMeanEnabled,
SuggestedCatalogue = suggestedCatalogue,
SuggestedResource = suggestedResource,
};

return searchResultViewModel;
Expand Down
29 changes: 22 additions & 7 deletions LearningHub.Nhs.WebUI/Views/Search/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@
}

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

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

@if (Model.CatalogueSearchResult?.TotalHits > 0)
{
@if (Model.DidYouMeanEnabled)
{
<p class="nhsuk-u-margin-top-5 nhsuk-u-margin-bottom-6">
Showing results for <b>@(Model.SuggestedCatalogue)</b>
</p>
}
<div class="nhsuk-grid-row">
<div class="nhsuk-grid-column-full">
@await Html.PartialAsync("_CatalogueSearchResult", Model)
Expand All @@ -37,6 +46,12 @@

@if (Model.ResourceSearchResult?.TotalHits > 0)
{
@if (Model.DidYouMeanEnabled)
{
<p class="nhsuk-u-margin-top-5 nhsuk-u-margin-bottom-6">
Showing results for <b>@(Model.SuggestedResource)</b>
</p>
}
@await Html.PartialAsync("_ResourceFilter", Model)

<div class="nhsuk-grid-row">
Expand Down
Loading