mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-04 17:01:56 +02:00
Add conditional "confirm" logic
This commit is contained in:
parent
612f967c6f
commit
df70a179e8
3 changed files with 25 additions and 19 deletions
|
@ -44,27 +44,24 @@ function openInNewTab(el, removeAttribute = false){
|
|||
domainSubmitButton.addEventListener("mouseover", () => openInNewTab(domainFormElement, true));
|
||||
domainSubmitButton.addEventListener("mouseout", () => openInNewTab(domainFormElement, false));
|
||||
}
|
||||
|
||||
let extendExpirationDateButton = document.getElementById("extend-expiration-button")
|
||||
let confirmationButtons = document.querySelector(".admin-confirmation-buttons")
|
||||
let cancelExpirationButton = document.getElementById("cancel-extend-button")
|
||||
if (extendExpirationDateButton && confirmationButtons && cancelExpirationButton){
|
||||
|
||||
let extendExpirationDateButton = document.getElementById("extend_expiration_date_button")
|
||||
if (extendExpirationDateButton){
|
||||
// Tie logic to the extend button to show confirmation options
|
||||
extendExpirationDateButton.addEventListener("click", () => {
|
||||
form = document.getElementById("domain_form")
|
||||
/*
|
||||
For some reason, Django admin has the propensity to ignore nested
|
||||
inputs and delete nested form objects.
|
||||
The workaround is to manually create an element as so, after the DOM
|
||||
has been generated.
|
||||
extendExpirationDateButton.hidden = true
|
||||
console.log("these are the buttons: ")
|
||||
console.log(confirmationButtons)
|
||||
confirmationButtons.hidden = false
|
||||
})
|
||||
|
||||
Its not the most beautiful thing every, but it works.
|
||||
*/
|
||||
var input = document.createElement("input");
|
||||
input.type = "hidden";
|
||||
input.name = "_extend_expiration_date";
|
||||
// The value doesn't matter, just needs to be present
|
||||
input.value = "1";
|
||||
// Add the hidden input to the form
|
||||
form.appendChild(input);
|
||||
form.submit();
|
||||
// Tie logic to the cancel button to hide the confirmation options
|
||||
cancelExpirationButton.addEventListener("click", () => {
|
||||
confirmationButtons.hidden = true
|
||||
extendExpirationDateButton.hidden = false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -283,6 +283,11 @@ h1, h2, h3,
|
|||
}
|
||||
}
|
||||
|
||||
.usa-button{
|
||||
font-size: 14px;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
// Button groups in /admin incorrectly have bullets.
|
||||
// Remove that!
|
||||
.usa-button-group .usa-button-group__item {
|
||||
|
|
|
@ -11,7 +11,11 @@
|
|||
</div>
|
||||
<div class="desktop:flex-align-self-end">
|
||||
{% if original.state != original.State.DELETED %}
|
||||
<input type="submit" value="Extend expiration date" name="_extend_expiration_date" class="custom-link-button">
|
||||
<span class="admin-confirmation-buttons" hidden>
|
||||
<button type="submit" class="usa-button" name="_extend_expiration_date">Confirm extension</button>
|
||||
<button type="button" id="cancel-extend-button" class="usa-button usa-button--secondary">Cancel</button>
|
||||
</span>
|
||||
<input id="extend-expiration-button" type="button" value="Extend expiration date" class="custom-link-button">
|
||||
{% endif %}
|
||||
<span class="margin-left-05 margin-right-05 text-middle"> | </span>
|
||||
{% if original.state == original.State.READY %}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue