mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-23 19:20:47 +02:00
modularize addModal in domain requests table
This commit is contained in:
parent
140524fa44
commit
2ffb811b4c
1 changed files with 30 additions and 26 deletions
|
@ -1829,23 +1829,6 @@ class DomainRequestsTable extends BaseTable {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.is_deletable) {
|
if (request.is_deletable) {
|
||||||
// If the request is deletable, create modal body and insert it. This is true for both requests and portfolio requests pages
|
|
||||||
let modalHeading = '';
|
|
||||||
let modalDescription = '';
|
|
||||||
|
|
||||||
if (request.requested_domain) {
|
|
||||||
modalHeading = `Are you sure you want to delete ${request.requested_domain}?`;
|
|
||||||
modalDescription = 'This will remove the domain request from the .gov registrar. This action cannot be undone.';
|
|
||||||
} else {
|
|
||||||
if (request.created_at) {
|
|
||||||
modalHeading = 'Are you sure you want to delete this domain request?';
|
|
||||||
modalDescription = `This will remove the domain request (created ${utcDateString(request.created_at)}) from the .gov registrar. This action cannot be undone`;
|
|
||||||
} else {
|
|
||||||
modalHeading = 'Are you sure you want to delete New domain request?';
|
|
||||||
modalDescription = 'This will remove the domain request from the .gov registrar. This action cannot be undone.';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 1st option: Just a modal trigger in any screen size for non-org users
|
// 1st option: Just a modal trigger in any screen size for non-org users
|
||||||
modalTrigger = `
|
modalTrigger = `
|
||||||
<a
|
<a
|
||||||
|
@ -1861,15 +1844,6 @@ class DomainRequestsTable extends BaseTable {
|
||||||
</svg> Delete <span class="usa-sr-only">${domainName}</span>
|
</svg> Delete <span class="usa-sr-only">${domainName}</span>
|
||||||
</a>`
|
</a>`
|
||||||
|
|
||||||
const modalSubmit = `
|
|
||||||
<button type="button"
|
|
||||||
class="usa-button usa-button--secondary usa-modal__submit"
|
|
||||||
data-pk = ${request.id}
|
|
||||||
name="delete-domain-request">Yes, delete request</button>
|
|
||||||
`
|
|
||||||
|
|
||||||
addModal('toggle-delete-domain', request.id, 'Are you sure you want to continue?', 'Domain will be removed', modalHeading, modalDescription, modalSubmit, tbody, true);
|
|
||||||
|
|
||||||
// Request is deletable, modal and modalTrigger are built. Now check if we are on the portfolio requests page (by seeing if there is a portfolio value) and enhance the modalTrigger accordingly
|
// Request is deletable, modal and modalTrigger are built. Now check if we are on the portfolio requests page (by seeing if there is a portfolio value) and enhance the modalTrigger accordingly
|
||||||
if (this.portfolioValue) {
|
if (this.portfolioValue) {
|
||||||
|
|
||||||
|
@ -1902,6 +1876,7 @@ class DomainRequestsTable extends BaseTable {
|
||||||
${customTableOptions.needsAdditionalColumn ? '<td>'+modalTrigger+'</td>' : ''}
|
${customTableOptions.needsAdditionalColumn ? '<td>'+modalTrigger+'</td>' : ''}
|
||||||
`;
|
`;
|
||||||
tbody.appendChild(row);
|
tbody.appendChild(row);
|
||||||
|
if (request.is_deletable) DomainRequestsTable.addDomainRequestsModal(request.requested_domain, request.id, request.created_at, tbody);
|
||||||
}
|
}
|
||||||
|
|
||||||
initializeModals(page, total, unfiltered_total) {
|
initializeModals(page, total, unfiltered_total) {
|
||||||
|
@ -1959,6 +1934,35 @@ class DomainRequestsTable extends BaseTable {
|
||||||
})
|
})
|
||||||
.catch(error => console.error('Error fetching domain requests:', error));
|
.catch(error => console.error('Error fetching domain requests:', error));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static addDomainRequestsModal(requested_domain, id, created_at, wrapper_element) {
|
||||||
|
// If the request is deletable, create modal body and insert it. This is true for both requests and portfolio requests pages
|
||||||
|
let modalHeading = '';
|
||||||
|
let modalDescription = '';
|
||||||
|
|
||||||
|
if (requested_domain) {
|
||||||
|
modalHeading = `Are you sure you want to delete ${requested_domain}?`;
|
||||||
|
modalDescription = 'This will remove the domain request from the .gov registrar. This action cannot be undone.';
|
||||||
|
} else {
|
||||||
|
if (request.created_at) {
|
||||||
|
modalHeading = 'Are you sure you want to delete this domain request?';
|
||||||
|
modalDescription = `This will remove the domain request (created ${utcDateString(created_at)}) from the .gov registrar. This action cannot be undone`;
|
||||||
|
} else {
|
||||||
|
modalHeading = 'Are you sure you want to delete New domain request?';
|
||||||
|
modalDescription = 'This will remove the domain request from the .gov registrar. This action cannot be undone.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const modalSubmit = `
|
||||||
|
<button type="button"
|
||||||
|
class="usa-button usa-button--secondary usa-modal__submit"
|
||||||
|
data-pk = ${id}
|
||||||
|
name="delete-domain-request">Yes, delete request</button>
|
||||||
|
`
|
||||||
|
|
||||||
|
addModal('toggle-delete-domain', id, 'Are you sure you want to continue?', 'Domain will be removed', modalHeading, modalDescription, modalSubmit, wrapper_element, true);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MembersTable extends BaseTable {
|
class MembersTable extends BaseTable {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue