fix fed agency bug

This commit is contained in:
zandercymatics 2024-09-26 14:49:19 -06:00
parent 2260269e3d
commit 81e76fe04a
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7

View file

@ -860,10 +860,13 @@ function initializeWidgetOnList(list, parentId) {
let organizationType = document.getElementById("id_organization_type"); let organizationType = document.getElementById("id_organization_type");
let readonlyOrganizationType = document.querySelector(".field-organization_type .readonly"); let readonlyOrganizationType = document.querySelector(".field-organization_type .readonly");
let organizationNameContainer = document.querySelector(".field-organization_name");
let federalType = document.querySelector(".field-federal_type");
if ($federalAgency && (organizationType || readonlyOrganizationType)) { if ($federalAgency && (organizationType || readonlyOrganizationType)) {
// Attach the change event listener // Attach the change event listener
$federalAgency.on("change", function() { $federalAgency.on("change", function() {
handleFederalAgencyChange($federalAgency, organizationType, readonlyOrganizationType); handleFederalAgencyChange($federalAgency, organizationType, readonlyOrganizationType, organizationNameContainer, federalType);
}); });
} }
@ -882,8 +885,6 @@ function initializeWidgetOnList(list, parentId) {
// Handle hiding the organization name field when the organization_type is federal. // Handle hiding the organization name field when the organization_type is federal.
// Run this first one page load, then secondly on a change event. // Run this first one page load, then secondly on a change event.
let organizationNameContainer = document.querySelector(".field-organization_name");
let federalType = document.querySelector(".field-federal_type");
handleOrganizationTypeChange(organizationType, organizationNameContainer, federalType); handleOrganizationTypeChange(organizationType, organizationNameContainer, federalType);
organizationType.addEventListener("change", function() { organizationType.addEventListener("change", function() {
handleOrganizationTypeChange(organizationType, organizationNameContainer, federalType); handleOrganizationTypeChange(organizationType, organizationNameContainer, federalType);
@ -907,7 +908,7 @@ function initializeWidgetOnList(list, parentId) {
} }
} }
function handleFederalAgencyChange(federalAgency, organizationType, readonlyOrganizationType) { function handleFederalAgencyChange(federalAgency, organizationType, readonlyOrganizationType, organizationNameContainer, federalType) {
// Don't do anything on page load // Don't do anything on page load
if (isInitialPageLoad) { if (isInitialPageLoad) {
isInitialPageLoad = false; isInitialPageLoad = false;
@ -941,6 +942,8 @@ function initializeWidgetOnList(list, parentId) {
} }
} }
handleOrganizationTypeChange(organizationType, organizationNameContainer, federalType);
// Determine if any changes are necessary to the display of portfolio type or federal type // Determine if any changes are necessary to the display of portfolio type or federal type
// based on changes to the Federal Agency // based on changes to the Federal Agency
let federalPortfolioApi = document.getElementById("federal_and_portfolio_types_from_agency_json_url").value; let federalPortfolioApi = document.getElementById("federal_and_portfolio_types_from_agency_json_url").value;