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
21 changes: 21 additions & 0 deletions LearningHub.Nhs.WebUI/Models/SideMenu/SideNavViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace LearningHub.Nhs.WebUI.Models.SideMenu
{
using System.Collections.Generic;
using Microsoft.AspNetCore.Routing;

/// <summary>
/// Defines the <see cref="SideNavViewModel" />.
/// </summary>
public class SideNavViewModel
{
/// <summary>
/// Gets or sets the Groups.
/// </summary>
public List<SideNavigationGroup> Groups { get; set; } = [];

/// <summary>
/// Gets or sets the RouteData.
/// </summary>
public RouteValueDictionary RouteData { get; set; } = [];
}
}
114 changes: 114 additions & 0 deletions LearningHub.Nhs.WebUI/Models/SideMenu/SideNavigationConfiguration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
namespace LearningHub.Nhs.WebUI.Models.SideMenu
{
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Routing;

/// <summary>
/// Defines the <see cref="SideNavigationConfiguration" />.
/// </summary>
public static class SideNavigationConfiguration
{
/// <summary>
/// GetGroupedMenus.
/// </summary>
/// <returns>IEnumerable.</returns>
public static IEnumerable<SideNavigationGroup> GetGroupedMenus()
{
return new List<SideNavigationGroup>
{
new SideNavigationGroup
{
GroupTitle = "Account",
Items = new List<SideNavigationItem>
{
new SideNavigationItem
{
Text = "Personal details",
Controller = "Account",
Action = "PersonalDetails",
IsActive = route => MatchRoute(route, "Account", "PersonalDetails"),
},
new SideNavigationItem
{
Text = "My employment",
Controller = "Account",
Action = "MyEmployment",
IsActive = route => MatchRoute(route, "Account", "MyEmployment"),
},
new SideNavigationItem
{
Text = "Security",
Controller = "Account",
Action = "Security",
IsActive = route => MatchRoute(route, "Account", "Security"),
},
new SideNavigationItem
{
Text = "Notification",
Controller = "Account",
Action = "Notification",
IsActive = route => MatchRoute(route, "Account", "Notification"),
},
},
},
new SideNavigationGroup
{
GroupTitle = "Activity",
Items = new List<SideNavigationItem>
{
new SideNavigationItem
{
Text = "Recent",
Controller = "Activity",
Action = "Recent",
IsActive = route => MatchRoute(route, "Activity", "Recent"),
},
new SideNavigationItem
{
Text = "Bookmark",
Controller = "Activity",
Action = "Bookmark",
IsActive = route => MatchRoute(route, "Activity", "Bookmark"),
},
new SideNavigationItem
{
Text = "Certificates",
Controller = "Activity",
Action = "Certificates",
IsActive = route => MatchRoute(route, "Activity", "Certificates"),
},
new SideNavigationItem
{
Text = "Learning history",
Controller = "Activity",
Action = "Learninghistory",
IsActive = route => MatchRoute(route, "Activity", "Learninghistory"),
},
},
},
};
}

/// <summary>
/// GetMenuGroupByTitle.
/// </summary>
/// <param name="title">title.</param>
/// <returns>string.</returns>
public static SideNavigationGroup? GetMenuGroupByTitle(string title)
{
return GetGroupedMenus().FirstOrDefault(g =>
string.Equals(g.GroupTitle, title, StringComparison.OrdinalIgnoreCase));
}

private static bool MatchRoute(RouteValueDictionary route, string controller, string action)
{
var currentController = route["controller"]?.ToString();
var currentAction = route["action"]?.ToString();

return string.Equals(currentController, controller, StringComparison.OrdinalIgnoreCase) &&
string.Equals(currentAction, action, StringComparison.OrdinalIgnoreCase);
}
}
}
20 changes: 20 additions & 0 deletions LearningHub.Nhs.WebUI/Models/SideMenu/SideNavigationGroup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace LearningHub.Nhs.WebUI.Models.SideMenu
{
using System.Collections.Generic;

/// <summary>
/// Defines the <see cref="SideNavigationGroup" />.
/// </summary>
public class SideNavigationGroup
{
/// <summary>
/// Gets or sets a value indicating GroupTitle.
/// </summary>
public string GroupTitle { get; set; } = string.Empty;

/// <summary>
/// Gets or sets a Items.
/// </summary>
public List<SideNavigationItem> Items { get; set; } = [];
}
}
31 changes: 31 additions & 0 deletions LearningHub.Nhs.WebUI/Models/SideMenu/SideNavigationItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
namespace LearningHub.Nhs.WebUI.Models.SideMenu
{
using System;
using Microsoft.AspNetCore.Routing;

/// <summary>
/// Defines the <see cref="SideNavigationItem" />.
/// </summary>
public class SideNavigationItem
{
/// <summary>
/// Gets or sets a value indicating Text.
/// </summary>
public string Text { get; set; } = string.Empty;

/// <summary>
/// Gets or sets a value indicating Controller.
/// </summary>
public string Controller { get; set; } = string.Empty;

/// <summary>
/// Gets or sets a value indicating Action.
/// </summary>
public string Action { get; set; } = "Index";

/// <summary>
/// Gets or sets a value indicating IsActiven.
/// </summary>
public Func<RouteValueDictionary, bool> IsActive { get; set; }
}
}
Loading
Loading