From f3ba5938687b164405844bb2b2973b921ffd7ff0 Mon Sep 17 00:00:00 2001 From: Matt Barton Date: Mon, 8 Jul 2024 14:17:00 +0100 Subject: [PATCH 01/13] feat: Removed free-text entry from feedback component, and implmented GA4 feedback storage --- .../Views/Shared/_Feedback.cshtml | 17 +------- .../wwwroot/javascript/components/feedback.js | 39 +++---------------- 2 files changed, 7 insertions(+), 49 deletions(-) diff --git a/Childrens-Social-Care-CPD/Views/Shared/_Feedback.cshtml b/Childrens-Social-Care-CPD/Views/Shared/_Feedback.cshtml index 74825730..ec8d63e3 100644 --- a/Childrens-Social-Care-CPD/Views/Shared/_Feedback.cshtml +++ b/Childrens-Social-Care-CPD/Views/Shared/_Feedback.cshtml @@ -66,23 +66,8 @@ -
-
- - - -
-
- You can enter up to 400 characters -
-
-
- diff --git a/Childrens-Social-Care-CPD/wwwroot/javascript/components/feedback.js b/Childrens-Social-Care-CPD/wwwroot/javascript/components/feedback.js index 6b607f6d..78b55f22 100644 --- a/Childrens-Social-Care-CPD/wwwroot/javascript/components/feedback.js +++ b/Childrens-Social-Care-CPD/wwwroot/javascript/components/feedback.js @@ -6,8 +6,6 @@ class FeedbackControl { #feedbackForm #cancelLink #isUsefulQuestionGroup - #commentsInput - #commentsFormGroup constructor(root) { this.#root = root @@ -20,8 +18,6 @@ class FeedbackControl { this.#isUsefulNoRadioButton = this.#root.querySelector("[data-module-id=isUsefulNo]") this.#isUsefulQuestionGroup = this.#root.querySelector("[data-module-id=isUsefulQuestionGroup]") this.#pageInput = this.#root.querySelector("[data-module-id=page]") - this.#commentsInput = this.#root.querySelector("[data-module-id=comments]") - this.#commentsFormGroup = this.#root.querySelector("[data-module-id=commentsFormGroup]") // Initialise the event handlers this.#feedbackForm.addEventListener("submit", this.#handleFormSubmit) @@ -40,8 +36,7 @@ class FeedbackControl { if (this.#validateForm()) { const data = { Page: this.#pageInput.value, - IsUseful: this.#isUsefulYesRadioButton.checked, - Comments: this.#commentsInput.value, + IsUseful: this.#isUsefulYesRadioButton.checked } this.#submitFeedback(data) this.#root.querySelector("[data-module-id=submitButton]").disabled = true @@ -56,12 +51,7 @@ class FeedbackControl { // Hide the error messages this.#isUsefulQuestionGroup.classList.remove("govuk-form-group--error") - this.#commentsFormGroup.classList.remove("govuk-form-group--error") this.#hide(this.#root.querySelector("[data-module-id=isUsefulErrorMessage]")) - this.#hide(this.#root.querySelector("[data-module-id=commentsErrorMessage]")) - - // Executes after the form has been reset - resets the character count component - setTimeout((() => this.#commentsInput.dispatchEvent(new KeyboardEvent("keyup"))), 1); } #resetForm = (event) => { @@ -71,18 +61,11 @@ class FeedbackControl { #submitFeedback = async (data) => { try { - await fetch("/api/feedback", { - method: "POST", - mode: "cors", - cache: "no-cache", - credentials: "same-origin", - headers: { - "Content-Type": "application/json", - RequestVerificationToken: this.#root.querySelector("[name=__RequestVerificationToken]").value - }, - redirect: "error", - referrerPolicy: "same-origin", - body: JSON.stringify(data), + console.log('submitting feedback'); + const pageURL = document.location.pathname + document.location.search; + gtag('event', 'page_rating', { + 'page_name': pageURL, + 'is_useful': data.IsUseful ? 'yes' : 'no' }); } catch (e) { console.error(e) @@ -99,16 +82,6 @@ class FeedbackControl { this.#isUsefulQuestionGroup.classList.remove("govuk-form-group--error") this.#hide(this.#root.querySelector("[data-module-id=isUsefulErrorMessage]")) } - - if (this.#commentsInput.value.length > 400) { - isValid = false - this.#commentsFormGroup.classList.add("govuk-form-group--error") - this.#show(this.#root.querySelector("[data-module-id=commentsErrorMessage]")) - } else { - this.#commentsFormGroup.classList.remove("govuk-form-group--error") - this.#hide(this.#root.querySelector("[data-module-id=commentsErrorMessage]")) - } - return isValid } } From da4d96a873b2d9e351b5ad1349c8aa8b15f2ebdd Mon Sep 17 00:00:00 2001 From: Matt Barton Date: Fri, 12 Jul 2024 16:07:56 +0100 Subject: [PATCH 02/13] Change event parameter name and change value to numeric --- .../wwwroot/javascript/components/feedback.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Childrens-Social-Care-CPD/wwwroot/javascript/components/feedback.js b/Childrens-Social-Care-CPD/wwwroot/javascript/components/feedback.js index 78b55f22..e6de9b6c 100644 --- a/Childrens-Social-Care-CPD/wwwroot/javascript/components/feedback.js +++ b/Childrens-Social-Care-CPD/wwwroot/javascript/components/feedback.js @@ -65,7 +65,7 @@ class FeedbackControl { const pageURL = document.location.pathname + document.location.search; gtag('event', 'page_rating', { 'page_name': pageURL, - 'is_useful': data.IsUseful ? 'yes' : 'no' + 'feedback_score': data.IsUseful ? '1' : '0' }); } catch (e) { console.error(e) From 4bc11480063647bfdfc16f348b283fa88dcbc16f Mon Sep 17 00:00:00 2001 From: Matt Barton Date: Mon, 15 Jul 2024 09:57:04 +0100 Subject: [PATCH 03/13] Change page name parameter in gtag event --- .../wwwroot/javascript/components/feedback.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Childrens-Social-Care-CPD/wwwroot/javascript/components/feedback.js b/Childrens-Social-Care-CPD/wwwroot/javascript/components/feedback.js index e6de9b6c..e635b2b6 100644 --- a/Childrens-Social-Care-CPD/wwwroot/javascript/components/feedback.js +++ b/Childrens-Social-Care-CPD/wwwroot/javascript/components/feedback.js @@ -64,7 +64,7 @@ class FeedbackControl { console.log('submitting feedback'); const pageURL = document.location.pathname + document.location.search; gtag('event', 'page_rating', { - 'page_name': pageURL, + 'feedback_page_name': pageURL, 'feedback_score': data.IsUseful ? '1' : '0' }); } catch (e) { From 6dfd0ac7a4b718d41e69a7d678b6a0465f54fae0 Mon Sep 17 00:00:00 2001 From: Matt Barton Date: Tue, 16 Jul 2024 16:04:45 +0100 Subject: [PATCH 04/13] break instruction sentence per designs, and add accessibility labelling info to radios --- .../Views/Shared/_Feedback.cshtml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Childrens-Social-Care-CPD/Views/Shared/_Feedback.cshtml b/Childrens-Social-Care-CPD/Views/Shared/_Feedback.cshtml index ec8d63e3..31b5727c 100644 --- a/Childrens-Social-Care-CPD/Views/Shared/_Feedback.cshtml +++ b/Childrens-Social-Care-CPD/Views/Shared/_Feedback.cshtml @@ -39,7 +39,10 @@
- Use this form to provide feedback about this page. If you have more general feedback about this website, please use this feedback form. + Use this form to provide feedback about this page. +
+
+ If you have more general feedback about this website, please use this feedback form.
@@ -51,14 +54,14 @@

- -
- -
From 7bdb4721fd749993585a8132bd338d6a16302b79 Mon Sep 17 00:00:00 2001 From: Matt Barton Date: Tue, 16 Jul 2024 16:11:29 +0100 Subject: [PATCH 05/13] remove invalid href from link for accessibility --- Childrens-Social-Care-CPD/Views/Shared/_Feedback.cshtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Childrens-Social-Care-CPD/Views/Shared/_Feedback.cshtml b/Childrens-Social-Care-CPD/Views/Shared/_Feedback.cshtml index 31b5727c..8bd1749a 100644 --- a/Childrens-Social-Care-CPD/Views/Shared/_Feedback.cshtml +++ b/Childrens-Social-Care-CPD/Views/Shared/_Feedback.cshtml @@ -74,7 +74,7 @@ Submit Feedback - +
From 90bada9ad12d1f2e80ff1163c85ec489b0a76722 Mon Sep 17 00:00:00 2001 From: Matt Barton Date: Wed, 17 Jul 2024 09:56:30 +0100 Subject: [PATCH 06/13] moved text/link per designs --- Childrens-Social-Care-CPD/Views/Shared/_Feedback.cshtml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Childrens-Social-Care-CPD/Views/Shared/_Feedback.cshtml b/Childrens-Social-Care-CPD/Views/Shared/_Feedback.cshtml index 8bd1749a..9b8b97e6 100644 --- a/Childrens-Social-Care-CPD/Views/Shared/_Feedback.cshtml +++ b/Childrens-Social-Care-CPD/Views/Shared/_Feedback.cshtml @@ -41,9 +41,6 @@
Use this form to provide feedback about this page.
-
- If you have more general feedback about this website, please use this feedback form. -
@@ -68,7 +65,13 @@
+
+
+ If you have more general feedback about this website, please use this feedback form. +
+ +
-
- If you have more general feedback about this website, please use this feedback form. -
-