diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index d705a4791..b276131f7 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,25 +1,25 @@ ### JIRA link -_TD-###_ +[TD-####](https://hee-tis.atlassian.net/browse/TD-####) ### Description -_Describe what has changed and how that will affect the app. If relevant, add references to the resources you used. Use this as your opportunity to highlight anything odd and give people context around particular decisions._ +_Describe what has changed and how that will affect the app. If relevant, add links to any sources/documentation you used. Highlight anything unusual and give people context around particular decisions._ ### Screenshots -_Attach screenshots on mobile, tablet and desktop._ +_Paste screenshots for all views created or changed: mobile, tablet and desktop, wave analyser showing no errors._ ----- ### Developer checks (Leave tasks unticked if they haven't been appropriate for your ticket.) I have: -- [ ] Run the formatter and made sure there are no IDE errors -- [ ] Written appropriate unit tests for the changes, including: - - accessibility tests for new views - - tests for new controller methods - - tests for new or modified API endpoints -- [ ] Manually tested my work with and without JavaScript -- [ ] Tested any Views or partials created or changed with [Wave Chrome plugin](https://chrome.google.com/webstore/detail/wave-evaluation-tool/jbbplnpkjmmeebjpijfedlgcdilocofh/related) and addressed any valid accessibility issues -- [ ] Updated/added documentation in [Confluence](https://hee-tis.atlassian.net/wiki/spaces/TP/pages/3477930003/Learning+Hub) and/or [GitHub Readme](https://github.com/TechnologyEnhancedLearning/LearningHub.Nhs.UserApi/blob/master/README.md). List of documentation links added/changed: +- [ ] Run the IDE auto formatter on all files I’ve worked on and made sure there are no IDE errors relating to them +- [ ] Written or updated tests for the changes (accessibility ui tests for views, tests for controller, data services, services, view models created or modified) and made sure all tests are passing +- [ ] Manually tested my work with and without JavaScript (adding notes where functionality requires JavaScript) +- [ ] Tested any Views or partials created or changed with [Wave Chrome plugin](https://chrome.google.com/webstore/detail/wave-evaluation-tool/jbbplnpkjmmeebjpijfedlgcdilocofh/related). Addressed any valid accessibility issues and documented any invalid errors +- [ ] Updated my Jira ticket with testing notes, including information about other parts of the system that were touched as part of the MR and need to be tested to ensure nothing is broken +- [ ] Scanned over my pull request in GitHub and addressed any warnings from the GitHub Build and Test checks in the GitHub PR ‘Files Changed’ tab +Either: +- [ ] Documented my work in [Confluence](https://hee-tis.atlassian.net/wiki/spaces/TP/pages/3461087233/Development), updating any business rules applied or modified. Updated GitHub readme/documentation for the repository if appropriate. List of documentation links added/changed: - [doc_1_here](link_1_here) -- [ ] Updated my Jira ticket with information about other parts of the system that were touched as part of the MR and have to be sanity tested to ensure nothing is broken -- [ ] Scanned over my pull request in GitHub and addressed any warnings from the GitHub Build and Test checks. +Or: +- [ ] Confirmed that none of the work that I have undertaken requires any updates to documentation \ No newline at end of file diff --git a/AdminUI/LearningHub.Nhs.AdminUI/Controllers/ResourceController.cs b/AdminUI/LearningHub.Nhs.AdminUI/Controllers/ResourceController.cs index 2338e457c..1a662d524 100644 --- a/AdminUI/LearningHub.Nhs.AdminUI/Controllers/ResourceController.cs +++ b/AdminUI/LearningHub.Nhs.AdminUI/Controllers/ResourceController.cs @@ -91,11 +91,15 @@ public ResourceController( /// The Details. /// /// The id. + /// The activeTab. + /// The status. /// The . [HttpGet] - public async Task Details(int id) + public async Task Details(int id, string activeTab = "details", string status = "") { var resource = await this.resourceService.GetResourceVersionExtendedViewModelAsync(id); + this.ViewBag.ActiveTab = activeTab; + this.ViewBag.Status = status; return this.View(resource); } @@ -138,6 +142,41 @@ public async Task GetValidationResults(int resourceVersionId) return this.PartialView("_ValidationResults", vm); } + /// + /// The GetDevIdDetails. + /// + /// The resourceVersionId. + /// The . + [HttpPost] + public async Task GetDevIdDetails(int resourceVersionId) + { + var vm = await this.resourceService.GetResourceVersionDevIdDetailsAsync(resourceVersionId); + + return this.PartialView("_DevIdDetails", vm); + } + + /// + /// The update the dev Id details. + /// + /// The model. + /// The . + [HttpPost] + public async Task UpdateDevIdDetails(ResourceVersionDevIdViewModel model) + { + var message = string.Empty; + if (await this.resourceService.DoesDevIdExistsAsync(model.DevId)) + { + message = "Duplicate"; + } + else + { + await this.resourceService.UpdateDevIdDetailsAsync(model); + message = "Success"; + } + + return this.RedirectToAction("Details", new { id = model.ResourceVersionId, activeTab = "devId", status = message }); + } + /// /// The Index. /// diff --git a/AdminUI/LearningHub.Nhs.AdminUI/Interfaces/IResourceService.cs b/AdminUI/LearningHub.Nhs.AdminUI/Interfaces/IResourceService.cs index 826c98b55..703be694e 100644 --- a/AdminUI/LearningHub.Nhs.AdminUI/Interfaces/IResourceService.cs +++ b/AdminUI/LearningHub.Nhs.AdminUI/Interfaces/IResourceService.cs @@ -32,9 +32,30 @@ public interface IResourceService /// The GetResourceVersionValidationResultAsync. /// /// The resourceVersionId. - /// The . + /// The . Task GetResourceVersionValidationResultAsync(int resourceVersionId); + /// + /// The GetResourceVersionDevIdDetailsAsync. + /// + /// The resourceVersionId. + /// The . + Task GetResourceVersionDevIdDetailsAsync(int resourceVersionId); + + /// + /// Check dev id already exist against a resource. + /// + /// string devId. + /// The . + Task DoesDevIdExistsAsync(string devId); + + /// + /// To update dev id details for a resource. + /// + /// the ResourceVersionDevIdViewModel. + /// The . + Task UpdateDevIdDetailsAsync(ResourceVersionDevIdViewModel model); + /// /// The GetResourceVersionExtendedViewModelAsync. /// diff --git a/AdminUI/LearningHub.Nhs.AdminUI/LearningHub.Nhs.AdminUI.csproj b/AdminUI/LearningHub.Nhs.AdminUI/LearningHub.Nhs.AdminUI.csproj index 0b26b9cd7..3eb1d8323 100644 --- a/AdminUI/LearningHub.Nhs.AdminUI/LearningHub.Nhs.AdminUI.csproj +++ b/AdminUI/LearningHub.Nhs.AdminUI/LearningHub.Nhs.AdminUI.csproj @@ -89,7 +89,7 @@ - + diff --git a/AdminUI/LearningHub.Nhs.AdminUI/Services/ResourceService.cs b/AdminUI/LearningHub.Nhs.AdminUI/Services/ResourceService.cs index d0d595b52..4c6e3fe46 100644 --- a/AdminUI/LearningHub.Nhs.AdminUI/Services/ResourceService.cs +++ b/AdminUI/LearningHub.Nhs.AdminUI/Services/ResourceService.cs @@ -2,6 +2,7 @@ { using System; using System.Collections.Generic; + using System.Net; using System.Net.Http; using System.Text; using System.Threading.Tasks; @@ -130,6 +131,89 @@ public async Task GetResourceVersionVa return viewmodel; } + /// + /// The GetResourceVersionDevIdDetailsAsync. + /// + /// The resourceVersionId. + /// The . + public async Task GetResourceVersionDevIdDetailsAsync(int resourceVersionId) + { + ResourceVersionDevIdViewModel viewmodel = null; + + var client = await this.LearningHubHttpClient.GetClientAsync(); + + var request = $"Resource/GetResourceVersionDevIdDetails/{resourceVersionId.ToString()}"; + var response = await client.GetAsync(request).ConfigureAwait(false); + + if (response.IsSuccessStatusCode) + { + var result = response.Content.ReadAsStringAsync().Result; + viewmodel = JsonConvert.DeserializeObject(result); + } + else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized + || + response.StatusCode == System.Net.HttpStatusCode.Forbidden) + { + throw new Exception("AccessDenied"); + } + + return viewmodel; + } + + /// + /// The GetResourceVersionDevIdDetailsAsync. + /// + /// The devId. + /// The . + public async Task DoesDevIdExistsAsync(string devId) + { + var client = await this.LearningHubHttpClient.GetClientAsync(); + + var request = $"Resource/DoesDevIdExists/{devId}"; + var response = await client.GetAsync(request).ConfigureAwait(false); + var doesDevIdExist = false; + if (response.IsSuccessStatusCode) + { + var result = response.Content.ReadAsStringAsync().Result; + doesDevIdExist = JsonConvert.DeserializeObject(result); + } + else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized + || + response.StatusCode == System.Net.HttpStatusCode.Forbidden) + { + throw new Exception("AccessDenied"); + } + + return doesDevIdExist; + } + + /// + /// Update dev id details for a resource. + /// + /// The model. + /// The . + /// the exception. + public async Task UpdateDevIdDetailsAsync(ResourceVersionDevIdViewModel model) + { + var json = JsonConvert.SerializeObject(model); + var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json"); + + var client = await this.LearningHubHttpClient.GetClientAsync(); + + var request = $"Resource/UpdateDevId"; + var response = await client.PutAsync(request, stringContent).ConfigureAwait(false); + + if (response.StatusCode == HttpStatusCode.Unauthorized || response.StatusCode == HttpStatusCode.Forbidden) + { + throw new Exception("AccessDenied"); + } + + if (!response.IsSuccessStatusCode) + { + throw new Exception("Update first name failed!"); + } + } + /// /// The GetResourceVersionExtendedViewModelAsync. /// diff --git a/AdminUI/LearningHub.Nhs.AdminUI/Views/Resource/Details.cshtml b/AdminUI/LearningHub.Nhs.AdminUI/Views/Resource/Details.cshtml index a2df6a2c6..44b2f9b11 100644 --- a/AdminUI/LearningHub.Nhs.AdminUI/Views/Resource/Details.cshtml +++ b/AdminUI/LearningHub.Nhs.AdminUI/Views/Resource/Details.cshtml @@ -5,862 +5,913 @@ @inject IOptions webSettings @{ - ViewData["Title"] = "Details"; + ViewData["Title"] = "Details"; + var activetab = this.ViewBag.ActiveTab; } @section Styles{ - + }
- -
-
+ +
+
+
+ + @if (Model.ResourceVersionId == 0) + { +
Resource Version not found
+ } + else + { +
+
@Model.Title (@Model.VersionStatusDescription)
+
+ @if (Model.VersionStatusEnum == VersionStatusEnum.Published) + { + + } + @if (Model.VersionStatusEnum == VersionStatusEnum.Publishing || Model.VersionStatusEnum == VersionStatusEnum.FailedToPublish) + { + + } + +
- - @if (Model.ResourceVersionId == 0) - { -
Resource Version not found
- } - else - { -
-
@Model.Title (@Model.VersionStatusDescription)
-
- @if (Model.VersionStatusEnum == VersionStatusEnum.Published) - { - - } - @if (Model.VersionStatusEnum == VersionStatusEnum.Publishing || Model.VersionStatusEnum == VersionStatusEnum.FailedToPublish) - { - - } - -
-
-