mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-22 18:56:15 +02:00
Refactor JS tests for page titles to test against classes instead
This commit is contained in:
parent
c226babfdf
commit
31d80cc91d
4 changed files with 13 additions and 14 deletions
|
@ -358,14 +358,12 @@ function markForm(e, formLabel){
|
||||||
*/
|
*/
|
||||||
function prepareNewDeleteButton(btn, formLabel) {
|
function prepareNewDeleteButton(btn, formLabel) {
|
||||||
let formIdentifier = "form"
|
let formIdentifier = "form"
|
||||||
let isNameserversForm = document.title.includes("DNS name servers |");
|
let isNameserversForm = document.querySelector(".nameservers-form");
|
||||||
let isOtherContactsForm = document.title.includes("Other employees from your organization");
|
let isOtherContactsForm = document.querySelector(".other-contacts-form");
|
||||||
let addButton = document.querySelector("#add-form");
|
let addButton = document.querySelector("#add-form");
|
||||||
|
|
||||||
if (isOtherContactsForm) {
|
if (isOtherContactsForm) {
|
||||||
formIdentifier = "other_contacts";
|
formIdentifier = "other_contacts";
|
||||||
}
|
|
||||||
|
|
||||||
if (isOtherContactsForm) {
|
|
||||||
// We will mark the forms for deletion
|
// We will mark the forms for deletion
|
||||||
btn.addEventListener('click', function(e) {
|
btn.addEventListener('click', function(e) {
|
||||||
markForm(e, formLabel);
|
markForm(e, formLabel);
|
||||||
|
@ -386,8 +384,8 @@ function prepareNewDeleteButton(btn, formLabel) {
|
||||||
function prepareDeleteButtons(formLabel) {
|
function prepareDeleteButtons(formLabel) {
|
||||||
let formIdentifier = "form"
|
let formIdentifier = "form"
|
||||||
let deleteButtons = document.querySelectorAll(".delete-record");
|
let deleteButtons = document.querySelectorAll(".delete-record");
|
||||||
let isNameserversForm = document.title.includes("DNS name servers |");
|
let isNameserversForm = document.querySelector(".nameservers-form");
|
||||||
let isOtherContactsForm = document.title.includes("Other employees from your organization");
|
let isOtherContactsForm = document.querySelector(".other-contacts-form");
|
||||||
let addButton = document.querySelector("#add-form");
|
let addButton = document.querySelector("#add-form");
|
||||||
if (isOtherContactsForm) {
|
if (isOtherContactsForm) {
|
||||||
formIdentifier = "other_contacts";
|
formIdentifier = "other_contacts";
|
||||||
|
@ -443,15 +441,16 @@ function hideDeletedForms() {
|
||||||
let addButton = document.querySelector("#add-form");
|
let addButton = document.querySelector("#add-form");
|
||||||
let cloneIndex = 0;
|
let cloneIndex = 0;
|
||||||
let formLabel = '';
|
let formLabel = '';
|
||||||
let isNameserversForm = document.title.includes("DNS name servers |");
|
let isNameserversForm = document.querySelector(".nameservers-form");
|
||||||
let isOtherContactsForm = document.title.includes("Other employees from your organization");
|
let isOtherContactsForm = document.querySelector(".other-contacts-form");
|
||||||
|
let isDsDataForm = document.querySelector(".ds-data-form");
|
||||||
// The Nameservers formset features 2 required and 11 optionals
|
// The Nameservers formset features 2 required and 11 optionals
|
||||||
if (isNameserversForm) {
|
if (isNameserversForm) {
|
||||||
cloneIndex = 2;
|
cloneIndex = 2;
|
||||||
formLabel = "Name server";
|
formLabel = "Name server";
|
||||||
// DNSSEC: DS Data
|
// DNSSEC: DS Data
|
||||||
} else if (document.title.includes("DS Data |")) {
|
} else if (isDsDataForm) {
|
||||||
formLabel = "DS Data record";
|
formLabel = "DS data record";
|
||||||
// The Other Contacts form
|
// The Other Contacts form
|
||||||
} else if (isOtherContactsForm) {
|
} else if (isOtherContactsForm) {
|
||||||
formLabel = "Organization contact";
|
formLabel = "Organization contact";
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<div id="other-employees">
|
<div id="other-employees" class="other-contacts-form">
|
||||||
{% include "includes/required_fields.html" %}
|
{% include "includes/required_fields.html" %}
|
||||||
{{ forms.1.management_form }}
|
{{ forms.1.management_form }}
|
||||||
{# forms.1 is a formset and this iterates over its forms #}
|
{# forms.1 is a formset and this iterates over its forms #}
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
{% include "includes/required_fields.html" %}
|
{% include "includes/required_fields.html" %}
|
||||||
|
|
||||||
<form class="usa-form usa-form--extra-large" method="post" novalidate id="form-container">
|
<form class="usa-form usa-form--extra-large ds-data-form" method="post" novalidate id="form-container">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ formset.management_form }}
|
{{ formset.management_form }}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
{% include "includes/required_fields.html" %}
|
{% include "includes/required_fields.html" %}
|
||||||
|
|
||||||
<form class="usa-form usa-form--extra-large" method="post" novalidate id="form-container">
|
<form class="usa-form usa-form--extra-large nameservers-form" method="post" novalidate id="form-container">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ formset.management_form }}
|
{{ formset.management_form }}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue