Bug fix for PR

This commit is contained in:
zandercymatics 2024-03-08 13:41:40 -07:00
parent 747af88347
commit 454cac951a
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7

View file

@ -61,18 +61,19 @@ function openInNewTab(el, removeAttribute = false){
* This intentionally does not interact with createPhantomModalFormButtons() * This intentionally does not interact with createPhantomModalFormButtons()
*/ */
(function (){ (function (){
function displayModalOnDropdownClick(linkClickedDisplaysModal, statusDropdown, cancelButton, valueToCheck){ function displayModalOnDropdownClick(linkClickedDisplaysModal, statusDropdown, actionButton, valueToCheck){
// If these exist all at the same time, we're on the right page // If these exist all at the same time, we're on the right page
if (linkClickedDisplaysModal && statusDropdown && statusDropdown.value){ if (linkClickedDisplaysModal && statusDropdown && statusDropdown.value){
// Set the previous value in the event the user cancels.
let previousValue = statusDropdown.value;
if (actionButton){
if (cancelButton){ // Otherwise, if the confirmation buttion is pressed, set it to that
// Store the previous value in the event the user cancels. actionButton.addEventListener('click', function() {
// We only need to do this if cancel button is specified.
let previousValue = statusDropdown.value;
cancelButton.addEventListener('click', function() {
// Revert the dropdown to its previous value // Revert the dropdown to its previous value
statusDropdown.value = previousValue; statusDropdown.value = valueToCheck;
}); });
}else { }else {
console.log("displayModalOnDropdownClick() -> Cancel button was null") console.log("displayModalOnDropdownClick() -> Cancel button was null")
@ -82,6 +83,10 @@ function openInNewTab(el, removeAttribute = false){
statusDropdown.addEventListener('change', function() { statusDropdown.addEventListener('change', function() {
// Check if "Ineligible" is selected // Check if "Ineligible" is selected
if (this.value && this.value.toLowerCase() === valueToCheck) { if (this.value && this.value.toLowerCase() === valueToCheck) {
// Set the old value in the event the user cancels,
// or otherwise exists the dropdown.
statusDropdown.value = previousValue
// Display the modal. // Display the modal.
linkClickedDisplaysModal.click() linkClickedDisplaysModal.click()
} }
@ -98,9 +103,9 @@ function openInNewTab(el, removeAttribute = false){
// Because the modal button does not have the class "dja-form-placeholder", // Because the modal button does not have the class "dja-form-placeholder",
// it will not be affected by the createPhantomModalFormButtons() function. // it will not be affected by the createPhantomModalFormButtons() function.
let cancelButton = document.querySelector('button[name="_cancel_application_ineligible"]'); let actionButton = document.querySelector('button[name="_set_application_ineligible"]');
let valueToCheck = "ineligible" let valueToCheck = "ineligible"
displayModalOnDropdownClick(modalButton, statusDropdown, cancelButton, valueToCheck); displayModalOnDropdownClick(modalButton, statusDropdown, actionButton, valueToCheck);
} }
hookModalToIneligibleStatus() hookModalToIneligibleStatus()