Cleanup js after merge

This commit is contained in:
zandercymatics 2024-12-20 10:08:00 -07:00
parent cda7316a71
commit 9cb3ecebf4
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
2 changed files with 24 additions and 3 deletions

View file

@ -629,7 +629,18 @@ export function initRejectedEmail() {
});
}
function handleSuborganizationSelection() {
/**
* A function that handles the suborganzation and requested suborganization fields and buttons.
* - Fieldwise: Hooks to the sub_organization, suborganization_city, and suborganization_state_territory fields.
* On change, this function checks if any of these fields are not empty:
* sub_organization, suborganization_city, and suborganization_state_territory.
* If they aren't, then we show the "clear" button. If they are, then we hide it because we don't need it.
*
* - Buttonwise: Hooks to the #clear-requested-suborganization button.
* On click, this will clear the input value of sub_organization, suborganization_city, and suborganization_state_territory.
*/
function handleSuborgFieldsAndButtons() {
const requestedSuborganizationField = document.getElementById("id_requested_suborganization");
const suborganizationCity = document.getElementById("id_suborganization_city");
const suborganizationStateTerritory = document.getElementById("id_suborganization_state_territory");
@ -672,6 +683,6 @@ export function initDynamicDomainRequestFields(){
const domainRequestPage = document.getElementById("domainrequest_form");
if (domainRequestPage) {
handlePortfolioSelection();
handleSuborganizationSelection();
handleSuborgFieldsAndButtons();
}
}

View file

@ -471,6 +471,16 @@ export function handlePortfolioSelection(
if (suborganizationCity) showElement(suborganizationCity);
if (suborganizationStateTerritory) showElement(suborganizationStateTerritory);
// Handle rejectSuborganizationButtonFieldset (display of the clear requested suborg button).
// Basically, this button should only be visible when we have data for suborg, city, and state_territory.
// The function handleSuborgFieldsAndButtons() in domain-request-form.js handles doing this same logic
// but on field input for city, state_territory, and the suborg field.
// If it doesn't exist, don't do anything.
if (!rejectSuborganizationButtonFieldset){
console.warn("updateSuborganizationFieldsDisplay() => Could not update rejectSuborganizationButtonFieldset")
return;
}
// Initially show / hide the clear button only if there is data to clear
let requestedSuborganizationField = document.getElementById("id_requested_suborganization");
let suborganizationCity = document.getElementById("id_suborganization_city");
@ -489,7 +499,7 @@ export function handlePortfolioSelection(
if (requestedSuborganizationField) hideElement(requestedSuborganizationField);
if (suborganizationCity) hideElement(suborganizationCity);
if (suborganizationStateTerritory) hideElement(suborganizationStateTerritory);
hideElement(rejectSuborganizationButtonFieldset);
if (rejectSuborganizationButtonFieldset) hideElement(rejectSuborganizationButtonFieldset);
}
}