Skip to content

Commit b9a62c8

Browse files
authored
Merge pull request #3231 from TechnologyEnhancedLearning/DLS-Release-v1.2.0
Dls release v1.2.0 to UAT
2 parents ecdb947 + a3bed08 commit b9a62c8

File tree

7 files changed

+54
-23
lines changed

7 files changed

+54
-23
lines changed

DigitalLearningSolutions.Web/Controllers/Support/RequestSupportTicketController.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public IActionResult SetRequestSummary(DlsSubApplication dlsSubApplication, Requ
137137
// Check if RequestDescription is null or contains any default empty tags ("<p><br></p>").
138138
// This ensures that when a user navigates to the submit page and returns to SetRequestSummary,
139139
// removing the description completely results in an actual empty value rather than leftover HTML tags.
140-
if (requestDetailsmodel.RequestDescription == "<p><br></p>")
140+
if (string.IsNullOrEmpty(StringHelper.StripHtmlTags(requestDetailsmodel.RequestDescription)))
141141
{
142142
ModelState.AddModelError("RequestDescription", "Please enter request description");
143143
}
@@ -246,7 +246,7 @@ public IActionResult SupportSummary(DlsSubApplication dlsSubApplication, Support
246246
var data = multiPageFormService.GetMultiPageFormData<RequestSupportTicketData>(
247247
MultiPageFormDataFeature.AddCustomWebForm("RequestSupportTicketCWF"),
248248
TempData
249-
).GetAwaiter().GetResult();
249+
).GetAwaiter().GetResult();
250250
var model = new SupportSummaryViewModel(data);
251251
return View("SupportTicketSummaryPage", model);
252252
}
@@ -262,7 +262,7 @@ public IActionResult SubmitSupportSummary(DlsSubApplication dlsSubApplication, S
262262
var data = multiPageFormService.GetMultiPageFormData<RequestSupportTicketData>(
263263
MultiPageFormDataFeature.AddCustomWebForm("RequestSupportTicketCWF"),
264264
TempData
265-
).GetAwaiter().GetResult();
265+
).GetAwaiter().GetResult();
266266
data.GroupId = configuration.GetFreshdeskCreateTicketGroupId();
267267
data.ProductId = configuration.GetFreshdeskCreateTicketProductId();
268268
List<RequestAttachment> RequestAttachmentList = new List<RequestAttachment>();
@@ -354,7 +354,7 @@ private void setRequestSupportTicketData(RequestSupportTicketData requestSupport
354354
{
355355
foreach (var item in requestAttachmentmodel.RequestAttachment)
356356
{
357-
totalFileSize = totalFileSize + item.SizeMb??0;
357+
totalFileSize = totalFileSize + item.SizeMb ?? 0;
358358
}
359359
}
360360
foreach (var item in requestAttachmentmodel.ImageFiles)

DigitalLearningSolutions.Web/Helpers/StringHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ public static string StripHtmlTags(string input)
2626

2727
// Remove HTML tags
2828
string result = Regex.Replace(input, "<.*?>", string.Empty).Trim();
29-
30-
return string.IsNullOrEmpty(result) ? string.Empty : result;
29+
result = System.Net.WebUtility.HtmlDecode(result);
30+
return string.IsNullOrEmpty(result.Trim()) ? string.Empty : result;
3131
}
3232
}
3333
}

DigitalLearningSolutions.Web/Scripts/frameworks/htmleditor.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Jodit } from 'jodit';
1+
import { Jodit } from 'jodit';
22
import DOMPurify from 'dompurify';
33

44
let jodited = false;
@@ -70,5 +70,31 @@ if (jodited === false) {
7070
const clean = DOMPurify.sanitize(editor.editor.innerHTML);
7171
editor.editor.innerHTML = clean;
7272
});
73+
const textarea = document.querySelector('.nhsuk-textarea.html-editor.nhsuk-input--error') as HTMLTextAreaElement | null;
74+
if (textarea) {
75+
const editorDiv = document.querySelector('.jodit-container.jodit.jodit_theme_default.jodit-wysiwyg_mode') as HTMLDivElement | null;
76+
editorDiv?.classList.add('jodit-container', 'jodit', 'jodit_theme_default', 'jodit-wysiwyg_mode', 'jodit-error');
77+
}
78+
79+
const summary = document.querySelector('.nhsuk-list.nhsuk-error-summary__list') as HTMLDivElement | null;
80+
81+
if (summary) {
82+
summary.addEventListener('click', (e: Event) => {
83+
if (textarea) {
84+
const textareaId = textarea.id.toString();
85+
const target = e.target as HTMLElement;
86+
if (target.tagName.toLowerCase() === 'a') {
87+
const href = (target as HTMLAnchorElement).getAttribute('href');
88+
89+
if (href && href.includes(textareaId)) {
90+
const editorArea = document.querySelector('.jodit-wysiwyg') as HTMLDivElement | null;
91+
editorArea?.focus();
92+
editorArea?.scrollIntoView({ behavior: 'smooth', block: 'center' });
93+
e.preventDefault();
94+
}
95+
}
96+
}
97+
});
98+
}
7399
}
74100
}

DigitalLearningSolutions.Web/Services/ImportCompetenciesFromFileService.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,14 @@ private void PreProcessCompetencyRow(CompetencyTableRow competencyRow, List<int>
7474
else
7575
{
7676
var groupName = (string)(competencyRow?.CompetencyGroup);
77-
originalIndex = existingGroups.IndexOf(groupName);
78-
newIndex = newGroups.IndexOf(groupName);
79-
if (originalIndex != newIndex)
77+
if (!string.IsNullOrWhiteSpace(groupName))
8078
{
81-
competencyRow.Reordered = true;
79+
originalIndex = existingGroups.IndexOf(groupName);
80+
newIndex = newGroups.IndexOf(groupName);
81+
if (originalIndex != newIndex)
82+
{
83+
competencyRow.Reordered = true;
84+
}
8285
}
8386
}
8487
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
11
@use "jodit/build/jodit.min";
2+
3+
.jodit-error {
4+
border: 2px solid red !important;
5+
border-radius: 4px;
6+
}

DigitalLearningSolutions.Web/ViewModels/Support/RequestSupportTicket/RequestSummaryViewModel.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public RequestSummaryViewModel(RequestSupportTicketData data)
2121
[Required(ErrorMessage = "Please enter request summary")]
2222
public string? RequestSubject { get; set; }
2323

24-
[Required(ErrorMessage = "Please enter request description")]
2524
public string? RequestDescription { get; set; }
2625

2726
public int? RequestTypeId { get; set; }

DigitalLearningSolutions.Web/Views/Support/RequestSupportTicket/RequestSummary.cshtml

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,15 @@
4040
autocomplete="given-name"
4141
css-class=""
4242
required="true" />
43-
<nhs-form-group nhs-validation-for="RequestDescription">
44-
<vc:text-area asp-for="RequestDescription"
45-
label="Describe your problem or request"
46-
populate-with-current-value="true"
47-
rows="5"
48-
spell-check="false"
49-
hint-text="If you are reporting a problem, please tell us exactly where it occurs and steps to recreate it. If you need to add screenshots, you will be able to do this in the next step."
50-
css-class=""
51-
character-count="null">
52-
</vc:text-area>
53-
</nhs-form-group>
43+
<vc:text-area asp-for="RequestDescription"
44+
label="Describe your problem or request"
45+
populate-with-current-value="true"
46+
rows="5"
47+
spell-check="false"
48+
hint-text="If you are reporting a problem, please tell us exactly where it occurs and steps to recreate it. If you need to add screenshots, you will be able to do this in the next step."
49+
css-class="html-editor"
50+
character-count="null">
51+
</vc:text-area>
5452
<button class="nhsuk-button" type="submit">Next</button>
5553
</form>
5654

0 commit comments

Comments
 (0)