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
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class FrameworkCompetency : BaseSearchableItem
public int Ordering { get; set; }
public int AssessmentQuestions { get; set; }
public int CompetencyLearningResourcesCount { get; set; }
public string? FrameworkName { get; set; }

public override string SearchableName
{
Expand Down
12 changes: 8 additions & 4 deletions DigitalLearningSolutions.Data/Services/FrameworkService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -446,10 +446,14 @@ public IEnumerable<BrandedFramework> GetAllFrameworks(int adminId)

public IEnumerable<FrameworkCompetency> GetAllCompetenciesForAdminId(string name, int adminId)
{
return connection.Query<FrameworkCompetency>(
$@"SELECT * FROM Competencies WHERE [Name] = @name AND [UpdatedByAdminID] = @adminId",
new { name, adminId }
);
return connection.Query<FrameworkCompetency>(
$@"SELECT f.FrameworkName,c.Description,c.UpdatedByAdminID,c.Name from Competencies as c
INNER JOIN FrameworkCompetencies AS fc ON c.ID = fc.CompetencyID
INNER JOIN Frameworks AS f ON fc.FrameworkID = f.ID
WHERE fc.FrameworkID = f.ID AND c.Name = @name AND c.UpdatedByAdminID = @adminId",
new { name, adminId }
);

}

public BrandedFramework CreateFramework(DetailFramework detailFramework, int adminId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@ public IActionResult AddEditFrameworkCompetency(int frameworkId, FrameworkCompet
frameworkCompetency.Description = SanitizerHelper.SanitizeHtmlData(frameworkCompetency.Description);
frameworkCompetency.Description?.Trim();
var description = HttpUtility.HtmlDecode(HttpUtility.HtmlDecode(frameworkCompetency.Description));
var detailFramework = frameworkService.GetDetailFrameworkByFrameworkId(frameworkId, GetAdminId());
if (string.IsNullOrWhiteSpace(description)) { frameworkCompetency.Description = null; }
if (!ModelState.IsValid)
{
ModelState.Remove(nameof(FrameworkCompetency.Name));
ModelState.AddModelError(nameof(FrameworkCompetency.Name), "Please enter a valid competency statement (between 3 and 500 characters)");
var detailFramework = frameworkService.GetDetailFrameworkByFrameworkId(frameworkId, GetAdminId());
var competencyFlags = frameworkService.GetCompetencyFlagsByFrameworkId(frameworkId, frameworkCompetency?.CompetencyID).ToList();
if (competencyFlags != null)
competencyFlags.ForEach(f => f.Selected = selectedFlagIds.Contains(f.FlagId));
Expand Down Expand Up @@ -187,6 +187,7 @@ public IActionResult AddEditFrameworkCompetency(int frameworkId, FrameworkCompet
FrameworkId = frameworkId,
FrameworkGroupId = frameworkCompetencyGroupId,
FrameworkCompetencyId = frameworkCompetencyId,
FrameworkConfig = detailFramework?.FrameworkConfig,
Competency = new FrameworkCompetency()
{
Name = frameworkCompetency.Name,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
namespace DigitalLearningSolutions.Web.ViewModels.Frameworks
{
using DigitalLearningSolutions.Data.Models.Frameworks;
using DigitalLearningSolutions.Web.Helpers;
using System.Collections.Generic;
public class SimilarCompetencyViewModel
{
public int MatchingSearchResults { get; set; }
public FrameworkCompetency Competency { get; set; }
public int FrameworkId { get; set; }
public int? FrameworkGroupId { get; set; }
public int FrameworkCompetencyId { get; set; }
public int FrameworkCompetencyId { get; set; }
public string FrameworkConfig { get; set; }
public IEnumerable<FrameworkCompetency> SameCompetency { get; set; }

public string VocabSingular()
{
return FrameworkVocabularyHelper.VocabularySingular(FrameworkConfig);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
@using DigitalLearningSolutions.Web.ViewModels.Frameworks;
@model FrameworkCompetencyViewModel;
@{
ViewData["Title"] = "Competency";
ViewData["Application"] = "Framework Service";
ViewData["Title"] = !string.IsNullOrWhiteSpace(Model.VocabSingular()) ? Model.VocabSingular(): "Competency";
ViewData["Application"] = "Framework Service";
ViewData["HeaderPathName"] = "Framework Service";
}
<link rel="stylesheet" href="@Url.Content("~/css/frameworks/frameworksShared.css")" asp-append-version="true">
Expand All @@ -16,7 +16,7 @@
<ol class="nhsuk-breadcrumb__list">
<li class="nhsuk-breadcrumb__item"><a class="nhsuk-breadcrumb__link trigger-loader" asp-action="ViewFrameworks" asp-route-tabname="Mine">Frameworks</a></li>
<li class="nhsuk-breadcrumb__item"><a class="nhsuk-breadcrumb__link trigger-loader" asp-action="ViewFramework" asp-route-frameworkCompetencyGroupId="@Model.FrameworkCompetencyGroupId" asp-fragment="fc-@Model.FrameworkCompetency.Id" asp-route-frameworkId="@Model.DetailFramework.ID" asp-route-tabname="Structure">Framework Structure</a></li>
<li class="nhsuk-breadcrumb__item">Competency</li>
<li class="nhsuk-breadcrumb__item">@Model.VocabSingular()</li>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This framework vocab needs introducing to the new Views/Frameworks/Developer/SimilarCompetency.cshtml ViewModel so that it can be used to replace the word "competency" in the h1 <h1>Duplicate competency name</h1> in the error message has the same name as an existing competency.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been updated.

</ol>
<p class="nhsuk-breadcrumb__back"><a class="nhsuk-breadcrumb__backlink" asp-route-frameworkCompetencyGroupId="@Model.FrameworkCompetencyGroupId" asp-fragment="fc-@Model.FrameworkCompetency.Id" asp-route-frameworkId="@Model.DetailFramework.ID" asp-route-tabname="Structure">Back to framework structure</a></p>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
@using DigitalLearningSolutions.Web.ViewModels.Frameworks
@model SimilarCompetencyViewModel
@{
ViewData["Title"] = "Similar Competency";
ViewData["Title"] = $"Similar {Model.VocabSingular()}";
ViewData["Application"] = "Framework Service";
ViewData["HeaderPathName"] = "Framework Service";
}

@section NavMenuItems {
<partial name="Shared/_NavMenuItems" />
}
<h1>Duplicate competency name</h1>
<h1>Duplicate @Model.VocabSingular() name</h1>
<div class="nhsuk-form-group nhsuk-form-group--error">
<p class="nhsuk-error-message">
The item you are trying to add "<span class="nhsuk-u-font-weight-bold">@Model.Competency.Name</span>" has the same name as an existing competency.
The item you are trying to add "<span class="nhsuk-u-font-weight-bold">@Model.Competency.Name</span>" has the same name as an existing @Model.VocabSingular().
</p>
<p class="nhsuk-u-margin-top-6">
You can still create this item but we recommend that you give it a distinct name.
Expand All @@ -22,10 +22,13 @@
<h2>Duplicates</h2>
<table role="table" class="nhsuk-table-responsive nhsuk-u-margin-bottom-6">
<caption class="nhsuk-table__caption nhsuk-u-visually-hidden">
Competency
@Model.VocabSingular()
</caption>
<thead role="rowgroup" class="nhsuk-table__head">
<tr role="row">
<th role="columnheader" class="" scope="col">
Framework
</th>
<th role="columnheader" class="" scope="col">
Name
</th>
Expand All @@ -38,6 +41,12 @@
@foreach (var competency in Model.SameCompetency)
{
<tr role="row" class="nhsuk-table__row framework-row">
<td role="cell" class="nhsuk-table__cell nhsuk-u-font-size-19">
<span class="nhsuk-table-responsive__heading">Framework </span>
<span class="framework-brand">
@competency.FrameworkName
</span>
</td>
<td role="cell" class="nhsuk-table__cell nhsuk-u-font-size-19">
<span class="nhsuk-table-responsive__heading">Name </span>
<span class="framework-brand">
Expand Down