Skip to content

Commit 38ee2a9

Browse files
Merge branch 'RC' into Develop/Features/TD-6148-Create-a-PoC-mechanism-which-will-allow-us-to-synchronise-user-tables-between-ELFH-and-User-Profile-DBs
2 parents 0029c3b + d33eb31 commit 38ee2a9

File tree

75 files changed

+3651
-246
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+3651
-246
lines changed

AdminUI/LearningHub.Nhs.AdminUI/Controllers/CatalogueController.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using System.Collections.Generic;
2121
using System.Drawing;
2222
using System.Linq;
23+
using System.Net;
2324
using System.Text.RegularExpressions;
2425
using System.Threading.Tasks;
2526

@@ -282,7 +283,10 @@ public async Task<IActionResult> MoodleCategory(int id)
282283

283284
// Build hierarchical select list
284285
var selectList = BuildList(categories, parentId: null, depth: 0);
285-
286+
foreach (var item in selectList)
287+
{
288+
item.Text = WebUtility.HtmlDecode(item.Text);
289+
}
286290
vm.MoodleCategorySelectList = new SelectList(selectList, "Value", "Text");
287291
this.ViewData["CatalogueName"] = vm.Name;
288292
this.ViewData["id"] = id;
@@ -736,6 +740,12 @@ public async Task<IActionResult> AddCategoryToCatalogue(CatalogueViewModel catal
736740
vm.MoodleCategories = categories;
737741
// Build hierarchical select list
738742
var selectList = BuildList(categories, parentId: null, depth: 0);
743+
744+
foreach (var item in selectList)
745+
{
746+
item.Text = WebUtility.HtmlDecode(item.Text);
747+
}
748+
739749
vm.MoodleCategorySelectList = new SelectList(selectList, "Value", "Text");
740750
return this.View("MoodleCategory", vm);
741751
}
@@ -766,6 +776,10 @@ public async Task<IActionResult> RemoveCategoryFromCatalogue(int categoryId, int
766776
vm.SelectedCategoryId = 0;
767777
// Build hierarchical select list
768778
var selectList = BuildList(categories, parentId: null, depth: 0);
779+
foreach (var item in selectList)
780+
{
781+
item.Text = WebUtility.HtmlDecode(item.Text);
782+
}
769783
vm.MoodleCategorySelectList = new SelectList(selectList, "Value", "Text");
770784
return this.View("MoodleCategory", vm);
771785
}

AdminUI/LearningHub.Nhs.AdminUI/Views/Catalogue/MoodleCategory.cshtml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,20 @@
9494
function DisplayCategory() {
9595
// Show the category selection div
9696
document.getElementById('divcategory').style.display = 'block';
97-
document.getElementById('example-error').style.display = 'none'
98-
document.getElementById('errortext').style.display = 'none'
99-
document.getElementById('diverror').classList.remove('nhsuk-form-group--error');
97+
var divexample = document.getElementById('example-error');
98+
if (divexample) {
99+
divexample.style.display = 'none';
100+
}
101+
var diverrortext = document.getElementById('errortext');
102+
if (diverrortext) {
103+
diverrortext.style.display = 'none';
104+
}
105+
var diverror = document.getElementById('diverror');
106+
if (diverror) {
107+
diverror.classList.remove('nhsuk-form-group--error');
108+
}
109+
110+
document.getElementById('selectedCategoryDisplay').style.display = 'none';
100111
101112
// Hide the selected category display div
102113
var selectedCategoryDiv = document.getElementById('selectedCategoryDisplay');

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99

1010
<GenerateDocumentationFile>True</GenerateDocumentationFile>
1111
</PropertyGroup>
12+
1213
<ItemGroup>
1314
<PackageReference Include="elfhHub.Nhs.Models" Version="3.0.14" />
1415
<PackageReference Include="FluentAssertions" Version="6.12.0" />
15-
<PackageReference Include="LearningHub.Nhs.Models" Version="4.0.3" />
16+
<PackageReference Include="LearningHub.Nhs.Models" Version="4.0.10" />
1617
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.1.13" />
1718
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
1819
<PackageReference Include="Selenium.Axe" Version="4.0.19" />

LearningHub.Nhs.WebUI/Configuration/Settings.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,5 +265,10 @@ public Settings()
265265
/// Gets or sets AllCataloguePageSize.
266266
/// </summary>
267267
public int AllCataloguePageSize { get; set; }
268+
269+
/// <summary>
270+
/// Gets or sets the StatMandId.
271+
/// </summary>
272+
public int StatMandId { get; set; } = 12;
268273
}
269274
}

LearningHub.Nhs.WebUI/Controllers/CatalogueController.cs

Lines changed: 50 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -249,62 +249,31 @@ public async Task<IActionResult> IndexAsync(string reference, string tab, int? n
249249
}
250250
}
251251

252-
if (tab == "browse")
252+
if (nodeId.HasValue)
253253
{
254-
if (nodeId.HasValue)
255-
{
256-
// if nodeId has a value it means the user is looking at a subfolder of the catalogue.
257-
// Get the folder name and description, plus folder path data needed for the breadcrumbs.
258-
viewModel.NodeDetails = await this.hierarchyService.GetNodeDetails(nodeId.Value);
259-
viewModel.NodePathNodes = await this.hierarchyService.GetNodePathNodes(viewModel.NodeDetails.NodePathId);
260-
}
261-
else
262-
{
263-
// Otherwise user is looking at catalogue root.
264-
nodeId = catalogue.NodeId;
254+
// if nodeId has a value it means the user is looking at a subfolder of the catalogue.
255+
// Get the folder name and description, plus folder path data needed for the breadcrumbs.
256+
viewModel.NodeDetails = await this.hierarchyService.GetNodeDetails(nodeId.Value);
257+
viewModel.NodePathNodes = await this.hierarchyService.GetNodePathNodes(viewModel.NodeDetails.NodePathId);
258+
}
259+
else
260+
{
261+
// Otherwise user is looking at catalogue root.
262+
nodeId = catalogue.NodeId;
265263

266-
viewModel.NodePathNodes = new List<NodeViewModel>
264+
viewModel.NodePathNodes = new List<NodeViewModel>
267265
{
268266
new NodeViewModel { Name = catalogue.Name },
269267
};
270-
}
271-
272-
bool includeEmptyFolder = viewModel.UserGroups.Any(x => x.RoleId == (int)RoleEnum.LocalAdmin || x.RoleId == (int)RoleEnum.Editor || x.RoleId == (int)RoleEnum.Previewer) || this.User.IsInRole("Administrator");
273-
var nodeContents = await this.hierarchyService.GetNodeContentsForCatalogueBrowse(nodeId.Value, includeEmptyFolder);
274-
viewModel.NodeContents = nodeContents;
275268
}
276-
else if (tab == "search")
277-
{
278-
if (viewModel.SearchResults == null)
279-
{
280-
viewModel.SearchResults = new Models.Search.SearchResultViewModel();
281-
}
282269

283-
if (search.Term != null)
284-
{
285-
search.CatalogueId = catalogue.NodeId;
286-
search.SearchId ??= 0;
287-
search.GroupId = !string.IsNullOrWhiteSpace(search.GroupId) && Guid.TryParse(search.GroupId, out Guid groupId) ? groupId.ToString() : Guid.NewGuid().ToString();
270+
bool includeEmptyFolder = viewModel.UserGroups.Any(x => x.RoleId == (int)RoleEnum.LocalAdmin || x.RoleId == (int)RoleEnum.Editor || x.RoleId == (int)RoleEnum.Previewer) || this.User.IsInRole("Administrator");
271+
var nodeContents = await this.hierarchyService.GetNodeContentsForCatalogueBrowse(nodeId.Value, includeEmptyFolder);
272+
viewModel.NodeContents = nodeContents;
288273

289-
var searchResult = await this.searchService.PerformSearch(this.User, search);
290-
searchResult.CatalogueId = catalogue.NodeId;
291-
searchResult.CatalogueUrl = catalogue.Url;
292-
if (search.SearchId == 0 && searchResult.ResourceSearchResult != null)
293-
{
294-
var searchId = await this.searchService.RegisterSearchEventsAsync(
295-
search,
296-
SearchFormActionTypeEnum.SearchWithinCatalogue,
297-
searchResult.ResourceSearchResult.TotalHits);
298-
299-
searchResult.ResourceSearchResult.SearchId = searchId;
300-
}
301-
302-
viewModel.SearchResults = searchResult;
303-
}
304-
}
305-
else if (tab == "courses")
274+
int categoryId = moodleCategoryId ?? await this.categoryService.GetCatalogueVersionCategoryAsync(catalogue.Id);
275+
if (categoryId > 0)
306276
{
307-
int categoryId = moodleCategoryId ?? await this.categoryService.GetCatalogueVersionCategoryAsync(catalogue.Id);
308277
var response = await this.categoryService.GetCoursesByCategoryIdAsync(categoryId);
309278
viewModel.Courses = response.Courses;
310279

@@ -353,6 +322,40 @@ public async Task<IActionResult> IndexAsync(string reference, string tab, int? n
353322
};
354323
}
355324
}
325+
else
326+
{
327+
viewModel.Catalogue.SelectedCategoryId = 0;
328+
}
329+
330+
if (tab == "search")
331+
{
332+
if (viewModel.SearchResults == null)
333+
{
334+
viewModel.SearchResults = new Models.Search.SearchResultViewModel();
335+
}
336+
337+
if (search.Term != null)
338+
{
339+
search.CatalogueId = catalogue.NodeId;
340+
search.SearchId ??= 0;
341+
search.GroupId = !string.IsNullOrWhiteSpace(search.GroupId) && Guid.TryParse(search.GroupId, out Guid groupId) ? groupId.ToString() : Guid.NewGuid().ToString();
342+
343+
var searchResult = await this.searchService.PerformSearch(this.User, search);
344+
searchResult.CatalogueId = catalogue.NodeId;
345+
searchResult.CatalogueUrl = catalogue.Url;
346+
if (search.SearchId == 0 && searchResult.ResourceSearchResult != null)
347+
{
348+
var searchId = await this.searchService.RegisterSearchEventsAsync(
349+
search,
350+
SearchFormActionTypeEnum.SearchWithinCatalogue,
351+
searchResult.ResourceSearchResult.TotalHits);
352+
353+
searchResult.ResourceSearchResult.SearchId = searchId;
354+
}
355+
356+
viewModel.SearchResults = searchResult;
357+
}
358+
}
356359

357360
return this.View(viewModel);
358361
}

0 commit comments

Comments
 (0)