From 93b86651805cc7974a0f425a967d563b0e17f045 Mon Sep 17 00:00:00 2001 From: killij <51908793+killij@users.noreply.github.com> Date: Fri, 16 Feb 2024 08:32:40 +0000 Subject: [PATCH] feat: Add character count to comment input of the feedback component (#423) * Add character count to feedback control * Refactor javascript * Update feedback.js * Update _BetaBanner.cshtml * Update _Feedback.cshtml --- .../Controllers/FeedbackController.cs | 2 +- .../Views/Shared/_BetaBanner.cshtml | 2 +- .../Views/Shared/_Feedback.cshtml | 56 ++++---- .../wwwroot/javascript/components/feedback.js | 121 ++++++++++++++++++ .../wwwroot/javascript/feedback.js | 72 ----------- 5 files changed, 155 insertions(+), 98 deletions(-) create mode 100644 Childrens-Social-Care-CPD/wwwroot/javascript/components/feedback.js delete mode 100644 Childrens-Social-Care-CPD/wwwroot/javascript/feedback.js diff --git a/Childrens-Social-Care-CPD/Controllers/FeedbackController.cs b/Childrens-Social-Care-CPD/Controllers/FeedbackController.cs index 25a5c271..e3416831 100644 --- a/Childrens-Social-Care-CPD/Controllers/FeedbackController.cs +++ b/Childrens-Social-Care-CPD/Controllers/FeedbackController.cs @@ -45,7 +45,7 @@ private static bool IsModelValid(FeedbackModel model, out string pageId) pageId = pageId.Trim('/'); if (pageId.Length > 512 - || model.Comments?.Length > 500 + || model.Comments?.Length > 400 || !Regex.IsMatch(pageId, @"^[0-9a-z](\/?[0-9a-z\-])*\/?$", RegexOptions.Compiled, TimeSpan.FromSeconds(1))) { return false; diff --git a/Childrens-Social-Care-CPD/Views/Shared/_BetaBanner.cshtml b/Childrens-Social-Care-CPD/Views/Shared/_BetaBanner.cshtml index df7449e6..606a7747 100644 --- a/Childrens-Social-Care-CPD/Views/Shared/_BetaBanner.cshtml +++ b/Childrens-Social-Care-CPD/Views/Shared/_BetaBanner.cshtml @@ -7,7 +7,7 @@ BETA
diff --git a/Childrens-Social-Care-CPD/Views/Shared/_Feedback.cshtml b/Childrens-Social-Care-CPD/Views/Shared/_Feedback.cshtml index 2e2e3871..69304ac8 100644 --- a/Childrens-Social-Care-CPD/Views/Shared/_Feedback.cshtml +++ b/Childrens-Social-Care-CPD/Views/Shared/_Feedback.cshtml @@ -6,9 +6,10 @@ @{ var contextModel = (ContextModel)ViewBag.ContextModel; + var commentsId = $"comments-{Guid.NewGuid()}"; } -