mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-25 12:08:40 +02:00
Bug fix for PR
This commit is contained in:
parent
747af88347
commit
454cac951a
1 changed files with 14 additions and 9 deletions
|
@ -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()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue