mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-14 21:44:08 +02:00
Catching edge-cases
This commit is contained in:
parent
72fdcfdac0
commit
711c71c114
2 changed files with 31 additions and 26 deletions
|
@ -1,7 +1,7 @@
|
|||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
document.getElementById('copy-summary-btn').addEventListener('click', function() {
|
||||
/// Generate the summary text
|
||||
/// Generate a rich HTML summary text and copy to clipboard
|
||||
|
||||
//------ Organization Type
|
||||
const organizationTypeElement = document.getElementById('id_organization_type');
|
||||
|
@ -20,18 +20,22 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||
//------ Additional Contacts
|
||||
// 1 - Create a hyperlinks map so we can display contact details and also link to the contact
|
||||
const otherContactsDiv = document.querySelector('.form-row.field-other_contacts .readonly');
|
||||
const otherContactLinks = otherContactsDiv.querySelectorAll('a');
|
||||
let otherContactLinks = [];
|
||||
if (otherContactsDiv) {
|
||||
otherContactLinks = otherContactsDiv.querySelectorAll('a');
|
||||
const nameToUrlMap = {};
|
||||
otherContactLinks.forEach(link => {
|
||||
const name = link.textContent.trim();
|
||||
const url = link.href;
|
||||
nameToUrlMap[name] = url;
|
||||
});
|
||||
}
|
||||
|
||||
// 2 - Iterate through contact details and assemble html for summary
|
||||
let otherContactsSummary = ""
|
||||
// Get the table rows of contact details
|
||||
const otherContactsTable = document.querySelector('.form-row.field-other_contacts table tbody');
|
||||
if (otherContactsTable) {
|
||||
const otherContactsRows = otherContactsTable.querySelectorAll('tr');
|
||||
const bulletList = document.createElement('ul');
|
||||
otherContactsRows.forEach(contactRow => {
|
||||
|
@ -47,6 +51,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||
bulletList.appendChild(listItem);
|
||||
});
|
||||
otherContactsSummary += bulletList.outerHTML
|
||||
}
|
||||
|
||||
|
||||
//------ Requested Domains
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
{# Phone #}
|
||||
{% if user.phone %}
|
||||
<span id="contact_info_phone">{{ user.phone.as_national }}</span>
|
||||
<span id="contact_info_phone">{{ user.phone }}</span>
|
||||
<br>
|
||||
{% else %}
|
||||
None<br>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue