1+ @using LearningHub .Nhs .Models .Enums
2+ @using LearningHub .Nhs .WebUI .Helpers
3+ @using LearningHub .Nhs .WebUI .Models
4+ @using LearningHub .Nhs .WebUI .Models .Learning
5+ @model MyLearningUserCertificatesViewModel ;
6+ @{
7+ ViewData [" Title" ] = " Certificates" ;
8+ var returnUrl = $" {Context .Request .Path }{Context .Request .QueryString }" ;
9+ var errorHasOccurred = ! ViewData .ModelState .IsValid ;
10+ var distintResourceType = new List <string >();
11+ if (Model .UserCertificates .Any ())
12+ {
13+ var distinctIds = Model .UserCertificates .Select (c => c .ResourceTypeId ).Distinct ();
14+ distintResourceType = distinctIds .Where (id => Enum .IsDefined (typeof (ResourceTypeEnum ), id ))
15+ .Select (id => Enum .GetName (typeof (ResourceTypeEnum ), id )).OrderBy (name => name ).ToList ();
16+ }
17+
18+ }
19+
20+ @functions {
21+ bool IsEntryActive (string entry )
22+ {
23+ var prop = Model .GetType ().GetProperty (entry );
24+ return prop != null && prop .PropertyType == typeof (bool ) && (bool )prop .GetValue (Model );
25+ }
26+ }
27+
28+ @section styles {
29+
30+ <link rel =" stylesheet" type =" text/css" href =" ~/css/nhsuk/pages/mylearning.css" asp-append-version =" true" />
31+
32+ }
33+ @section NavBreadcrumbs {
34+
35+ <section class =" nhsuk-hero" >
36+ <div class =" nhsuk-width-container app-width-container" >
37+ <div class =" nhsuk-grid-row" >
38+ <div class =" nhsuk-grid-column-full" >
39+
40+ <div class =" nhsuk-u-padding-top-3 nhsuk-u-padding-bottom-3" >
41+ <a href =" /" >Home </a >
42+ <i class =" fa-solid fa-chevron-right nhsuk-u-padding-top-1 nhsuk-u-padding-bottom-1 nhsuk-u-padding-left-2 nhsuk-u-padding-right-2" ></i >
43+ </div >
44+ <div class =" nhsuk-u-padding-top-4 nhsuk-u-padding-bottom-7" >
45+ <h1 class =" nhsuk-heading-xl" >My learning activity </h1 >
46+ </div >
47+ </div >
48+ </div >
49+ </div >
50+ </section >
51+ }
52+
53+
54+ <div class =" my-learning" >
55+ <div class =" nhsuk-width-container app-width-container" >
56+ <div class =" nhsuk-grid-row" >
57+ <!-- Left column: SideNav -->
58+ <div class =" nhsuk-grid-column-one-quarter" >
59+ @await Component.InvokeAsync("SideNav", new { groupTitle = " Activity" } )
60+ </div >
61+
62+ <!-- Right column: Main content -->
63+ <div class =" nhsuk-grid-column-three-quarters" >
64+ <div >
65+ <h2 class =" nhsuk-heading-l" >Certificates</h2 >
66+ </div >
67+
68+ <div class =" nhsuk-u-padding-top-3" >
69+ @if (errorHasOccurred )
70+ {
71+ <vc:error-summary order-of-property-names =" @(new[] { nameof(Model) })" />
72+ }
73+
74+ <form asp-controller =" MyLearning" asp-action =" Certificate" method =" post" asp-fragment =" search-results" >
75+
76+ <div class =" nhsuk-form-group search-box-container nhsuk-u-padding-bottom-1" style =" white-space :nowrap " >
77+ <label class =" nhsuk-label nhsuk-u-visually-hidden" for =" SearchText" >Search Text</label >
78+ <input class =" nhsuk-input nhsuk-u-width-one-half search-box" placeholder =" " id =" SearchText" name =" SearchText" value =" @Model.SearchText" type =" text" aria-required =" true" >
79+ <button class =" nhsuk-search__submit" name =" MyLearningFormActionType" value =@MyLearningFormActionTypeEnum.BasicSearch type =" submit" >
80+ <svg class =" nhsuk-icon nhsuk-icon__search" xmlns =" http://www.w3.org/2000/svg" viewBox =" 0 0 24 24" aria-hidden =" true" focusable =" false" >
81+ <path d =" M19.71 18.29l-4.11-4.1a7 7 0 1 0-1.41 1.41l4.1 4.11a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42zM5 10a5 5 0 1 1 5 5 5 5 0 0 1-5-5z" ></path >
82+ </svg >
83+ <span class =" nhsuk-u-visually-hidden" >Search</span >
84+ </button >
85+
86+ </div >
87+ <h3 class =" nhsuk-heading-m" >@Model.TotalCount @( Model .TotalCount > 1 ? " s" : " " ) </h3 >
88+ </form >
89+ </div >
90+
91+ <div class =" search-filters" >
92+
93+ <div >
94+ <span class =" nhsuk-u-padding-right-3 nhsuk-u-primary-text-color nhsuk-u-font-size-16 nhsuk-u-font-weight-bold" >Show</span >
95+
96+
97+
98+ @if (distintResourceType .Any ())
99+ {
100+ <a asp-action =" Certificate"
101+ class =" nhsuk-u-padding-right-3 nhsuk-u-secondary-text-color nhsuk-u-font-size-16 nhsuk-u-font-weight-bold nhsuk-u-text-align-centre"
102+ title =" All" >
103+ <span class =" nhsuk-bg-pale-blue" >All </span >
104+ </a >
105+
106+ @foreach ( var entry in distintResourceType )
107+ {
108+ var routeValues = new Dictionary <string , string >{{ entry , " true" }};
109+
110+ <a asp-action =" Index"
111+ asp-all-route-data =" routeValues"
112+ class =" nhsuk-u-padding-right-3 nhsuk-u-secondary-text-color nhsuk-u-font-size-16 nhsuk-u-font-weight-bold"
113+ title =" @entry" >
114+ @if (IsEntryActive (entry ))
115+ {
116+ <span class =" nhsuk-bg-pale-blue" >@entry </span >
117+ }
118+ else
119+ {
120+ @entry
121+ }
122+ </a >
123+
124+ }
125+
126+ }
127+ else
128+ {
129+ <a asp-action =" Certificate"
130+ class =" nhsuk-u-padding-right-3 nhsuk-u-secondary-text-color nhsuk-u-font-size-16 nhsuk-u-font-weight-bold nhsuk-u-text-align-centre"
131+ title =" All" >
132+ <span class =" nhsuk-bg-pale-blue" >All </span >
133+ </a >
134+ }
135+
136+
137+
138+ </div >
139+ <div class =" nhsuk-u-padding-bottom-5" >
140+ <hr class =" nhsuk-section-break nhsuk-section-break--visible nhsuk-u-padding-bottom-4" >
141+ </div >
142+
143+ </div >
144+
145+ <div class =" nhsuk-u-padding-bottom-4" >
146+ <hr class =" nhsuk-section-break nhsuk-section-break--visible" >
147+ </div >
148+ <div >
149+ <ul class =" nhsuk-grid-row nhsuk-card-group nhsuk-card-group--centred" >
150+ @foreach ( var certificate in Model .UserCertificates )
151+ {
152+
153+ var activityDate = certificate .AwardedDate .Date ;
154+ var today = DateTime .Today ;
155+ var dateTimeText = activityDate == today ? " Today"
156+ : activityDate == today .AddDays (- 1 ) ? " Yesterday"
157+ : activityDate .ToString (" dd MMM yyyy" );
158+
159+
160+
161+ <li class =" nhsuk-grid-column-one-third-small-desktop nhsuk-card-group__item" >
162+ <div class =" nhsuk-card dashboard-card" >
163+
164+ <div class =" nhsuk-card__content dashboard-card-content" >
165+ <div >
166+ <h3 class =" nhsuk-card__heading nhsuk-heading-m line-clamp-2" >
167+ @if ((ResourceTypeEnum )certificate .ResourceTypeId == ResourceTypeEnum .Moodle )
168+ {
169+ <a class =" nhsuk-card__link" href =" @(certificate.CertificatePreviewUrl)" >@UtilityHelper.StripHtmlFromString(certificate.Title) </a >
170+ }
171+ else
172+ {
173+ <a class =" nhsuk-card__link" href =" @(" /Resource /" + certificate.ResourceReferenceId)" >@UtilityHelper.StripHtmlFromString(certificate.Title) </a >
174+ }
175+
176+ </h3 >
177+ </div >
178+ <div class =" nhsuk-card__description dashboard-card-body" >
179+ <div >
180+ <div class =" nhsuk-body-s nhsuk-u-margin-bottom-2point5" >
181+ <span class =" nhsuk-u-font-weight-bold" >Type : </span > @UtilityHelper.GetPrettifiedResourceTypeName((ResourceTypeEnum)certificate.ResourceTypeId)
182+ </div >
183+ <div class =" nhsuk-u-margin-bottom-2point5 line-clamp-3" >
184+ @if ((ResourceTypeEnum )certificate .ResourceTypeId == ResourceTypeEnum .Moodle )
185+ {
186+ <a class =" nhsuk-card__link" target =" _blank" href =" @(certificate.CertificateDownloadUrl)" >Download </a >
187+ }
188+ else
189+ {
190+ <a class =" nhsuk-card__link" target =" _blank" href =" @(" /Resource /" + certificate.ResourceReferenceId)" >Download </a >
191+ }
192+ </div >
193+ <div class =" nhsuk-u-font-size-16 nhsuk-u-margin-bottom-2point5 line-clamp-1" >
194+ <span class =" nhsuk-u-font-weight-bold" >Awarded : </span > @( dateTimeText )
195+ </div >
196+
197+
198+ </div >
199+
200+ </div >
201+ </div >
202+ </div >
203+ </li >
204+ }
205+ </ul >
206+ </div >
207+
208+ <div >
209+ @await Html.PartialAsync("_CertificatePaging", Model)
210+ </div >
211+ </div >
212+ </div >
213+ </div >
214+ </div >
0 commit comments