-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Alsen Aligullu <[email protected]>
- Loading branch information
1 parent
9f47e45
commit ab24615
Showing
9 changed files
with
197 additions
and
12 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Generated by Django 4.2.11 on 2024-05-14 08:14 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("django_feedback_govuk", "0004_alter_basefeedback_id"), | ||
("feedback", "0003_searchfeedbackv2"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="HRFeedback", | ||
fields=[ | ||
( | ||
"basefeedback_ptr", | ||
models.OneToOneField( | ||
auto_created=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
parent_link=True, | ||
primary_key=True, | ||
serialize=False, | ||
to="django_feedback_govuk.basefeedback", | ||
), | ||
), | ||
("page_url", models.CharField(blank=True)), | ||
("useful", models.BooleanField(default=True)), | ||
("contactable", models.BooleanField(default=False)), | ||
("comment", models.TextField(blank=True)), | ||
], | ||
bases=("django_feedback_govuk.basefeedback",), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
{% load feedback_tags %} | ||
|
||
<div id="search-feedback"> | ||
<div class="search-feedback-header govuk-!-padding-1 govuk-!-padding-left-2 govuk-!-margin-bottom-4"> | ||
<div class="govuk-body-s govuk-body--inverse govuk-!-margin-bottom-0 govuk-!-margin-right-2">Is this page useful?</div> | ||
<button class="govuk-button govuk-button--secondary govuk-!-margin-bottom-0 govuk-!-margin-left-1" | ||
onclick="positiveResponse();">Yes</button> | ||
<button class="govuk-button govuk-button--secondary govuk-!-margin-bottom-0 govuk-!-margin-left-1" | ||
onclick="negativeResponse();">No</button> | ||
</div> | ||
</div> | ||
|
||
<dialog id="feedback-dialog"> | ||
{% feedback_submit form_id="hr-v1" %} | ||
<script> | ||
const dialog = document.querySelector("#feedback-dialog"); | ||
const form = dialog.querySelector("form"); | ||
const search_header = document.querySelector("#search-feedback .search-feedback-header"); | ||
|
||
function positiveResponse() { | ||
// Clear all form fields except the hidden ones | ||
clearFeedbackForm(); | ||
// Mark the `useful` hidden field to `true` | ||
form.querySelector("#id_useful").value = "true"; | ||
// Submit the form | ||
submitFeedbackForm(); | ||
} | ||
|
||
function negativeResponse() { | ||
// Clear all form fields except the hidden ones | ||
clearFeedbackForm(); | ||
// Mark the `useful` hidden field to `false` | ||
form.querySelector("#id_useful").value = "false"; | ||
// Show the feedback form | ||
openFeedbackDialog(); | ||
} | ||
|
||
function openFeedbackDialog() { | ||
document.querySelector("#feedback-dialog").showModal(); | ||
} | ||
|
||
function showThankYouMessage() { | ||
// Update text to say thanks. | ||
search_header.innerHTML = '<div class="govuk-body-s govuk-body--inverse govuk-!-margin-bottom-0">Thanks for your feedback.</div>'; | ||
} | ||
|
||
form.addEventListener("submit", (event) => { | ||
if (event.submitter.id == "submit-id-submit") { | ||
event.preventDefault(); | ||
submitFeedbackForm(); | ||
} | ||
}); | ||
|
||
function clearFeedbackForm() { | ||
form.reset(); | ||
} | ||
|
||
function submitFeedbackForm() { | ||
const formData = new FormData(form); | ||
|
||
formData.set('page_url','{{page.url}}'); | ||
|
||
fetch(form.action, { | ||
method: "POST", | ||
body: formData, | ||
}).then((response) => { | ||
if (!response.ok) { | ||
throw new Error("There was an issue submitting your feedback."); | ||
} | ||
|
||
dialog.close(); | ||
showThankYouMessage(); | ||
}).catch((error) => { | ||
alert(error.message); | ||
dialog.close(); | ||
}); | ||
} | ||
</script> | ||
</dialog> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,6 @@ | |
|
||
|
||
class SearchFeedbackV2FormView(FeedbackView): ... | ||
|
||
|
||
class HRFeedbackFormView(FeedbackView): ... |