Skip to content

Commit d73ad90

Browse files
Merge pull request #1293 from TechnologyEnhancedLearning/Merge-Unfiied-platform-change-to-My-Leraningpage
Merge unified platform change to my learning page
2 parents 69fe7e3 + 22a4ece commit d73ad90

File tree

7 files changed

+481
-1
lines changed

7 files changed

+481
-1
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
namespace LearningHub.Nhs.WebUI.Models.SideMenu
2+
{
3+
using System.Collections.Generic;
4+
using Microsoft.AspNetCore.Routing;
5+
6+
/// <summary>
7+
/// Defines the <see cref="SideNavViewModel" />.
8+
/// </summary>
9+
public class SideNavViewModel
10+
{
11+
/// <summary>
12+
/// Gets or sets the Groups.
13+
/// </summary>
14+
public List<SideNavigationGroup> Groups { get; set; } = [];
15+
16+
/// <summary>
17+
/// Gets or sets the RouteData.
18+
/// </summary>
19+
public RouteValueDictionary RouteData { get; set; } = [];
20+
}
21+
}
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
namespace LearningHub.Nhs.WebUI.Models.SideMenu
2+
{
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using Microsoft.AspNetCore.Routing;
7+
8+
/// <summary>
9+
/// Defines the <see cref="SideNavigationConfiguration" />.
10+
/// </summary>
11+
public static class SideNavigationConfiguration
12+
{
13+
/// <summary>
14+
/// GetGroupedMenus.
15+
/// </summary>
16+
/// <returns>IEnumerable.</returns>
17+
public static IEnumerable<SideNavigationGroup> GetGroupedMenus()
18+
{
19+
return new List<SideNavigationGroup>
20+
{
21+
new SideNavigationGroup
22+
{
23+
GroupTitle = "Account",
24+
Items = new List<SideNavigationItem>
25+
{
26+
new SideNavigationItem
27+
{
28+
Text = "Personal details",
29+
Controller = "Account",
30+
Action = "PersonalDetails",
31+
IsActive = route => MatchRoute(route, "Account", "PersonalDetails"),
32+
},
33+
new SideNavigationItem
34+
{
35+
Text = "My employment",
36+
Controller = "Account",
37+
Action = "MyEmployment",
38+
IsActive = route => MatchRoute(route, "Account", "MyEmployment"),
39+
},
40+
new SideNavigationItem
41+
{
42+
Text = "Security",
43+
Controller = "Account",
44+
Action = "Security",
45+
IsActive = route => MatchRoute(route, "Account", "Security"),
46+
},
47+
new SideNavigationItem
48+
{
49+
Text = "Notification",
50+
Controller = "Account",
51+
Action = "Notification",
52+
IsActive = route => MatchRoute(route, "Account", "Notification"),
53+
},
54+
},
55+
},
56+
new SideNavigationGroup
57+
{
58+
GroupTitle = "Activity",
59+
Items = new List<SideNavigationItem>
60+
{
61+
new SideNavigationItem
62+
{
63+
Text = "Recent",
64+
Controller = "Activity",
65+
Action = "Recent",
66+
IsActive = route => MatchRoute(route, "Activity", "Recent"),
67+
},
68+
new SideNavigationItem
69+
{
70+
Text = "Bookmark",
71+
Controller = "Activity",
72+
Action = "Bookmark",
73+
IsActive = route => MatchRoute(route, "Activity", "Bookmark"),
74+
},
75+
new SideNavigationItem
76+
{
77+
Text = "Certificates",
78+
Controller = "Activity",
79+
Action = "Certificates",
80+
IsActive = route => MatchRoute(route, "Activity", "Certificates"),
81+
},
82+
new SideNavigationItem
83+
{
84+
Text = "Learning history",
85+
Controller = "Activity",
86+
Action = "Learninghistory",
87+
IsActive = route => MatchRoute(route, "Activity", "Learninghistory"),
88+
},
89+
},
90+
},
91+
};
92+
}
93+
94+
/// <summary>
95+
/// GetMenuGroupByTitle.
96+
/// </summary>
97+
/// <param name="title">title.</param>
98+
/// <returns>string.</returns>
99+
public static SideNavigationGroup? GetMenuGroupByTitle(string title)
100+
{
101+
return GetGroupedMenus().FirstOrDefault(g =>
102+
string.Equals(g.GroupTitle, title, StringComparison.OrdinalIgnoreCase));
103+
}
104+
105+
private static bool MatchRoute(RouteValueDictionary route, string controller, string action)
106+
{
107+
var currentController = route["controller"]?.ToString();
108+
var currentAction = route["action"]?.ToString();
109+
110+
return string.Equals(currentController, controller, StringComparison.OrdinalIgnoreCase) &&
111+
string.Equals(currentAction, action, StringComparison.OrdinalIgnoreCase);
112+
}
113+
}
114+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
namespace LearningHub.Nhs.WebUI.Models.SideMenu
2+
{
3+
using System.Collections.Generic;
4+
5+
/// <summary>
6+
/// Defines the <see cref="SideNavigationGroup" />.
7+
/// </summary>
8+
public class SideNavigationGroup
9+
{
10+
/// <summary>
11+
/// Gets or sets a value indicating GroupTitle.
12+
/// </summary>
13+
public string GroupTitle { get; set; } = string.Empty;
14+
15+
/// <summary>
16+
/// Gets or sets a Items.
17+
/// </summary>
18+
public List<SideNavigationItem> Items { get; set; } = [];
19+
}
20+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
namespace LearningHub.Nhs.WebUI.Models.SideMenu
2+
{
3+
using System;
4+
using Microsoft.AspNetCore.Routing;
5+
6+
/// <summary>
7+
/// Defines the <see cref="SideNavigationItem" />.
8+
/// </summary>
9+
public class SideNavigationItem
10+
{
11+
/// <summary>
12+
/// Gets or sets a value indicating Text.
13+
/// </summary>
14+
public string Text { get; set; } = string.Empty;
15+
16+
/// <summary>
17+
/// Gets or sets a value indicating Controller.
18+
/// </summary>
19+
public string Controller { get; set; } = string.Empty;
20+
21+
/// <summary>
22+
/// Gets or sets a value indicating Action.
23+
/// </summary>
24+
public string Action { get; set; } = "Index";
25+
26+
/// <summary>
27+
/// Gets or sets a value indicating IsActiven.
28+
/// </summary>
29+
public Func<RouteValueDictionary, bool> IsActive { get; set; }
30+
}
31+
}

0 commit comments

Comments
 (0)