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.addEventListener('DOMContentLoaded', function() {
|
||||||
document.getElementById('copy-summary-btn').addEventListener('click', 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
|
//------ Organization Type
|
||||||
const organizationTypeElement = document.getElementById('id_organization_type');
|
const organizationTypeElement = document.getElementById('id_organization_type');
|
||||||
|
@ -20,18 +20,22 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||||
//------ Additional Contacts
|
//------ Additional Contacts
|
||||||
// 1 - Create a hyperlinks map so we can display contact details and also link to the contact
|
// 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 otherContactsDiv = document.querySelector('.form-row.field-other_contacts .readonly');
|
||||||
const otherContactLinks = otherContactsDiv.querySelectorAll('a');
|
let otherContactLinks = [];
|
||||||
|
if (otherContactsDiv) {
|
||||||
|
otherContactLinks = otherContactsDiv.querySelectorAll('a');
|
||||||
const nameToUrlMap = {};
|
const nameToUrlMap = {};
|
||||||
otherContactLinks.forEach(link => {
|
otherContactLinks.forEach(link => {
|
||||||
const name = link.textContent.trim();
|
const name = link.textContent.trim();
|
||||||
const url = link.href;
|
const url = link.href;
|
||||||
nameToUrlMap[name] = url;
|
nameToUrlMap[name] = url;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// 2 - Iterate through contact details and assemble html for summary
|
// 2 - Iterate through contact details and assemble html for summary
|
||||||
let otherContactsSummary = ""
|
let otherContactsSummary = ""
|
||||||
// Get the table rows of contact details
|
// Get the table rows of contact details
|
||||||
const otherContactsTable = document.querySelector('.form-row.field-other_contacts table tbody');
|
const otherContactsTable = document.querySelector('.form-row.field-other_contacts table tbody');
|
||||||
|
if (otherContactsTable) {
|
||||||
const otherContactsRows = otherContactsTable.querySelectorAll('tr');
|
const otherContactsRows = otherContactsTable.querySelectorAll('tr');
|
||||||
const bulletList = document.createElement('ul');
|
const bulletList = document.createElement('ul');
|
||||||
otherContactsRows.forEach(contactRow => {
|
otherContactsRows.forEach(contactRow => {
|
||||||
|
@ -47,6 +51,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||||
bulletList.appendChild(listItem);
|
bulletList.appendChild(listItem);
|
||||||
});
|
});
|
||||||
otherContactsSummary += bulletList.outerHTML
|
otherContactsSummary += bulletList.outerHTML
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//------ Requested Domains
|
//------ Requested Domains
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
{# Phone #}
|
{# Phone #}
|
||||||
{% if user.phone %}
|
{% if user.phone %}
|
||||||
<span id="contact_info_phone">{{ user.phone.as_national }}</span>
|
<span id="contact_info_phone">{{ user.phone }}</span>
|
||||||
<br>
|
<br>
|
||||||
{% else %}
|
{% else %}
|
||||||
None<br>
|
None<br>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue