Skip to content

Commit

Permalink
LG-14959: Cleanup contact form (#1385)
Browse files Browse the repository at this point in the history
* Cleanup contact form
  • Loading branch information
jc-gsa authored Nov 6, 2024
1 parent 1dd89da commit 540cada
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ contact_form_action: 'https://webto.salesforce.com/servlet/servlet.WebToCase?enc
contact_form_orgid: '00DU0000000Leux'
contact_form_agency: '00N3d0000013vIB'
contact_form_integration: '00N3d0000013vIC'
contact_form_topic_id: '00NU0000004z903'

# Contact page phone number enabled (overridden in Cloud.gov Pages)
contact_phone_number_enabled: false
Expand Down
25 changes: 12 additions & 13 deletions _includes/contact_form.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{% comment %} include: - common_applications: array of strings (translation keys) {% endcomment %}
{% comment %}
<!--
This is some slightly modified code provided by the contact center to interact
with their support ticket intake system
-->
{% endcomment %}
<script language="javascript" type="text/javascript">
let topicID = '00NU0000004z903';
let topicId = '{{ site.contact_form_topic_id }}';
let mappedValues = {
'Signing In;New Account': { topic: 'Create Account', sub: 'New Account' },
};
Expand Down Expand Up @@ -306,17 +308,16 @@
),
];

function remapvalues(frm) {
function remapFormValues(frm) {
// Get the current values for topic and subtopic
let topic = document.getElementById('00NU0000004z903');
let topic = document.getElementById(topicId);
let sub = document.getElementById('sub-topic');

let topicValue = topic.value;
let subValue = sub.value;

let key = topicValue + ';' + subValue;

// Do we have a mapping?
if (mappedValues[key]) {
sub.value = mappedValues[key].sub;
topic.value = mappedValues[key].topic;
Expand All @@ -326,7 +327,7 @@
}

function populatetopics() {
let field = document.getElementById(topicID);
let field = document.getElementById(topicId);
field.options.length = 0;
field.options[0] = new Option(
'{{ site.data.[page.lang].settings.contact_page.support_request_form.form_helpers.select_topic }}',
Expand All @@ -351,7 +352,6 @@
}

function dynamicdropdown(listindex) {
console.log(listindex);
let sub = document.getElementById('sub-topic');

let oldvalue = sub.value;
Expand All @@ -360,9 +360,7 @@
let selectedIndex = 0;

for (let i = 0; i < topicMap.length; i++) {
console.log(topicMap[i].key);
if (topicMap[i].key === listindex) {
console.log(topicMap[i]);
options.push(
new Option(
'{{ site.data.[page.lang].settings.contact_page.support_request_form.form_helpers.select_issue }}',
Expand All @@ -387,7 +385,6 @@
sub.options[sub.options.length] = options[i];
}

// sub.options = options;
sub.selectedIndex = selectedIndex;

return true;
Expand All @@ -396,8 +393,10 @@
window.onload = populatetopics;

function doNotAnswer() {
{% comment %}
// this will hide the display of the honeypot Field
// more information found here. https://help.salesforce.com/articleView?id=pardot_forms_add_honeypot.htm
{% endcomment %}
const noAnswer = document.querySelector('#contact-us-form #information');
if (noAnswer) {
noAnswer.removeAttribute('required');
Expand All @@ -416,7 +415,7 @@ <h3>{{ site.data.[page.lang].settings.contact_page.support_request_form.title }}
id="contact-us-form"
action="{{ site.contact_form_action }}"
method="POST"
onSubmit="return remapvalues(this); return true;"
onSubmit="return remapFormValues(this); return true;"
class="usa-form"
>
<input type="hidden" name="00NU0000004z90b" id="00NU0000004z90b" value="{{ site.data.language_map.languages[page.lang] | default: 'English' }}" />
Expand All @@ -440,12 +439,12 @@ <h3>{{ site.data.[page.lang].settings.contact_page.support_request_form.title }}
</strong>

<!-- START: Topic -->
<label class="usa-label" for="00NU0000004z903">
<label class="usa-label" for="{{ site.contact_form_topic_id }}">
{{ site.data.[page.lang].settings.contact_page.support_request_form.labels.topic }}<abbr title="{{ site.data.[page.lang].settings.contact_page.required }}" class="usa-hint usa-hint--required">*</abbr>
</label>
<select
id="00NU0000004z903"
name="00NU0000004z903"
id="{{ site.contact_form_topic_id }}"
name="{{ site.contact_form_topic_id }}"
required
onchange="dynamicdropdown(this.options[this.selectedIndex].value);"
class="usa-select"
Expand Down

0 comments on commit 540cada

Please sign in to comment.