mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-25 20:18:38 +02:00
Fix bugs with the copy email button UI plus code cleanup
This commit is contained in:
parent
d73d611cab
commit
dd29081fff
7 changed files with 63 additions and 93 deletions
|
@ -3112,7 +3112,7 @@ class PortfolioAdmin(ListHeaderAdmin):
|
||||||
admin_details += f'<a href="{change_url}">{escape(portfolio_admin)}</a><br>'
|
admin_details += f'<a href="{change_url}">{escape(portfolio_admin)}</a><br>'
|
||||||
admin_details += f"{escape(portfolio_admin.title)}<br>"
|
admin_details += f"{escape(portfolio_admin.title)}<br>"
|
||||||
admin_details += f"{escape(portfolio_admin.email)}"
|
admin_details += f"{escape(portfolio_admin.email)}"
|
||||||
admin_details += "<div class='admin-icon-group admin-icon-group__clipboard-link'>"
|
admin_details += "<div class='admin-icon-group'>"
|
||||||
admin_details += f"<input aria-hidden='true' class='display-none' value='{escape(portfolio_admin.email)}'>"
|
admin_details += f"<input aria-hidden='true' class='display-none' value='{escape(portfolio_admin.email)}'>"
|
||||||
admin_details += (
|
admin_details += (
|
||||||
"<button class='usa-button usa-button--unstyled padding-right-1 usa-button--icon padding-left-05"
|
"<button class='usa-button usa-button--unstyled padding-right-1 usa-button--icon padding-left-05"
|
||||||
|
|
|
@ -515,10 +515,14 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||||
const formLabel = document.querySelector('label[for="id_action_needed_reason_email"]');
|
const formLabel = document.querySelector('label[for="id_action_needed_reason_email"]');
|
||||||
let lastSentEmailContent = document.getElementById("last-sent-email-content");
|
let lastSentEmailContent = document.getElementById("last-sent-email-content");
|
||||||
const initialDropdownValue = dropdown ? dropdown.value : null;
|
const initialDropdownValue = dropdown ? dropdown.value : null;
|
||||||
const initialEmailValue = textarea.value;
|
let initialEmailValue;
|
||||||
|
if (textarea)
|
||||||
|
initialEmailValue = textarea.value
|
||||||
|
|
||||||
// We will use the const to control the modal
|
// We will use the const to control the modal
|
||||||
let isEmailAlreadySentConst = lastSentEmailContent.value.replace(/\s+/g, '') === textarea.value.replace(/\s+/g, '');
|
let isEmailAlreadySentConst;
|
||||||
|
if (lastSentEmailContent)
|
||||||
|
isEmailAlreadySentConst = lastSentEmailContent.value.replace(/\s+/g, '') === textarea.value.replace(/\s+/g, '');
|
||||||
// We will use the function to control the label and help
|
// We will use the function to control the label and help
|
||||||
function isEmailAlreadySent() {
|
function isEmailAlreadySent() {
|
||||||
return lastSentEmailContent.value.replace(/\s+/g, '') === textarea.value.replace(/\s+/g, '');
|
return lastSentEmailContent.value.replace(/\s+/g, '') === textarea.value.replace(/\s+/g, '');
|
||||||
|
@ -706,18 +710,6 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
// Extract the submitter name, title, email, and phone number
|
|
||||||
const submitterDiv = document.querySelector('.form-row.field-submitter');
|
|
||||||
const submitterNameElement = document.getElementById('id_submitter');
|
|
||||||
// We have to account for different superuser and analyst markups
|
|
||||||
const submitterName = submitterNameElement
|
|
||||||
? submitterNameElement.options[submitterNameElement.selectedIndex].text
|
|
||||||
: submitterDiv.querySelector('a').text;
|
|
||||||
const submitterTitle = extractTextById('contact_info_title', submitterDiv);
|
|
||||||
const submitterEmail = extractTextById('contact_info_email', submitterDiv);
|
|
||||||
const submitterPhone = extractTextById('contact_info_phone', submitterDiv);
|
|
||||||
let submitterInfo = `${submitterName}${submitterTitle}${submitterEmail}${submitterPhone}`;
|
|
||||||
|
|
||||||
|
|
||||||
//------ Senior Official
|
//------ Senior Official
|
||||||
const seniorOfficialDiv = document.querySelector('.form-row.field-senior_official');
|
const seniorOfficialDiv = document.querySelector('.form-row.field-senior_official');
|
||||||
|
@ -734,7 +726,6 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||||
`<strong>Current Websites:</strong> ${existingWebsites.join(', ')}</br>` +
|
`<strong>Current Websites:</strong> ${existingWebsites.join(', ')}</br>` +
|
||||||
`<strong>Rationale:</strong></br>` +
|
`<strong>Rationale:</strong></br>` +
|
||||||
`<strong>Alternative Domains:</strong> ${alternativeDomains.join(', ')}</br>` +
|
`<strong>Alternative Domains:</strong> ${alternativeDomains.join(', ')}</br>` +
|
||||||
`<strong>Submitter:</strong> ${submitterInfo}</br>` +
|
|
||||||
`<strong>Senior Official:</strong> ${seniorOfficialInfo}</br>` +
|
`<strong>Senior Official:</strong> ${seniorOfficialInfo}</br>` +
|
||||||
`<strong>Other Employees:</strong> ${otherContactsSummary}</br>`;
|
`<strong>Other Employees:</strong> ${otherContactsSummary}</br>`;
|
||||||
|
|
||||||
|
|
|
@ -390,6 +390,9 @@ a.button,
|
||||||
.usa-button--dja span {
|
.usa-button--dja span {
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
.usa-button--dja.usa-button--unstyled {
|
||||||
|
color: var(--link-fg);
|
||||||
|
}
|
||||||
.usa-button--dja:not(.usa-button--unstyled, .usa-button--outline, .usa-modal__close, .usa-button--secondary) {
|
.usa-button--dja:not(.usa-button--unstyled, .usa-button--outline, .usa-modal__close, .usa-button--secondary) {
|
||||||
background: var(--button-bg);
|
background: var(--button-bg);
|
||||||
}
|
}
|
||||||
|
@ -425,6 +428,37 @@ button .usa-icon,
|
||||||
.button--clipboard .usa-icon {
|
.button--clipboard .usa-icon {
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
// Make the clipboard button "float" inside of the input box
|
||||||
|
.admin-icon-group {
|
||||||
|
position: relative;
|
||||||
|
display: inline;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
input {
|
||||||
|
// Allow for padding around the copy button
|
||||||
|
padding-right: 35px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
width: max-content;
|
||||||
|
text-decoration: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 1000px) {
|
||||||
|
button {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
span {
|
||||||
|
padding-left: 0.05rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
.usa-button__small-text,
|
||||||
|
.usa-button__small-text span {
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
.module--custom {
|
.module--custom {
|
||||||
a {
|
a {
|
||||||
|
@ -670,71 +704,10 @@ address.dja-address-contact-list {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make the clipboard button "float" inside of the input box
|
|
||||||
.admin-icon-group {
|
|
||||||
position: relative;
|
|
||||||
display: inline;
|
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
input {
|
|
||||||
// Allow for padding around the copy button
|
|
||||||
padding-right: 35px !important;
|
|
||||||
// Match the height of other inputs
|
|
||||||
min-height: 2.25rem !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
button {
|
|
||||||
line-height: 14px;
|
|
||||||
width: max-content;
|
|
||||||
font-size: unset;
|
|
||||||
text-decoration: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 1000px) {
|
|
||||||
button {
|
|
||||||
display: block;
|
|
||||||
padding-top: 8px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
span {
|
|
||||||
padding-left: 0.1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
.admin-icon-group.admin-icon-group__clipboard-link {
|
|
||||||
position: relative;
|
|
||||||
display: inline;
|
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
|
|
||||||
.usa-button--icon {
|
|
||||||
position: absolute;
|
|
||||||
right: auto;
|
|
||||||
left: 4px;
|
|
||||||
height: 100%;
|
|
||||||
top: -1px;
|
|
||||||
}
|
|
||||||
button {
|
|
||||||
font-size: unset !important;
|
|
||||||
display: inline-flex;
|
|
||||||
padding-top: 4px;
|
|
||||||
line-height: 14px;
|
|
||||||
width: max-content;
|
|
||||||
font-size: unset;
|
|
||||||
text-decoration: none !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.no-outline-on-click:focus {
|
.no-outline-on-click:focus {
|
||||||
outline: none !important;
|
outline: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.usa-button__small-text {
|
|
||||||
font-size: small;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get rid of padding on all help texts
|
// Get rid of padding on all help texts
|
||||||
form .aligned p.help, form .aligned div.help {
|
form .aligned p.help, form .aligned div.help {
|
||||||
padding-left: 0px !important;
|
padding-left: 0px !important;
|
||||||
|
|
|
@ -20,10 +20,11 @@
|
||||||
</li>
|
</li>
|
||||||
{% if opts.model_name == 'domainrequest' %}
|
{% if opts.model_name == 'domainrequest' %}
|
||||||
<li>
|
<li>
|
||||||
<a id="id-copy-to-clipboard-summary" class="button--clipboard" type="button" href="#">
|
<a id="id-copy-to-clipboard-summary" class="usa-button--dja button--clipboard" type="button" href="#">
|
||||||
<svg class="usa-icon" >
|
<svg class="usa-icon" >
|
||||||
<use xlink:href="{%static 'img/sprite.svg'%}#content_copy"></use>
|
<use xlink:href="{%static 'img/sprite.svg'%}#content_copy"></use>
|
||||||
</svg>
|
</svg>
|
||||||
|
<!-- the span is targeted in JS, do not remove -->
|
||||||
<span>{% translate "Copy request summary" %}</span>
|
<span>{% translate "Copy request summary" %}</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -8,7 +8,7 @@ Template for an input field with a clipboard
|
||||||
<div class="admin-icon-group">
|
<div class="admin-icon-group">
|
||||||
{{ field }}
|
{{ field }}
|
||||||
<button
|
<button
|
||||||
class="usa-button usa-button--unstyled padding-left-1 usa-button--icon button--clipboard copy-to-clipboard"
|
class="usa-button--dja usa-button usa-button__small-text usa-button--unstyled padding-left-1 usa-button--icon button--clipboard copy-to-clipboard"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<div class="no-outline-on-click">
|
<div class="no-outline-on-click">
|
||||||
|
@ -17,23 +17,27 @@ Template for an input field with a clipboard
|
||||||
>
|
>
|
||||||
<use aria-hidden="true" xlink:href="{%static 'img/sprite.svg'%}#content_copy"></use>
|
<use aria-hidden="true" xlink:href="{%static 'img/sprite.svg'%}#content_copy"></use>
|
||||||
</svg>
|
</svg>
|
||||||
Copy
|
<!-- the span is targeted in JS, do not remove -->
|
||||||
|
<span>Copy</span>
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="admin-icon-group admin-icon-group__clipboard-link">
|
<div class="admin-icon-group">
|
||||||
<input aria-hidden="true" class="display-none" value="{{ field.email }}" />
|
<input aria-hidden="true" class="display-none" value="{{ field.email }}" />
|
||||||
<button
|
{% if field.email is not None %}
|
||||||
class="usa-button usa-button--unstyled padding-right-1 usa-button--icon button--clipboard copy-to-clipboard text-no-underline padding-left-05"
|
<button
|
||||||
type="button"
|
class="usa-button--dja usa-button usa-button__small-text usa-button--unstyled padding-right-1 usa-button--icon button--clipboard copy-to-clipboard text-no-underline padding-left-05"
|
||||||
>
|
type="button"
|
||||||
<svg
|
|
||||||
class="usa-icon"
|
|
||||||
>
|
>
|
||||||
<use aria-hidden="true" xlink:href="{%static 'img/sprite.svg'%}#content_copy"></use>
|
<svg
|
||||||
</svg>
|
class="usa-icon"
|
||||||
Copy
|
>
|
||||||
</button>
|
<use aria-hidden="true" xlink:href="{%static 'img/sprite.svg'%}#content_copy"></use>
|
||||||
|
</svg>
|
||||||
|
<!-- the span is targeted in JS, do not remove -->
|
||||||
|
<span>Copy</span>
|
||||||
|
</button>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
|
@ -26,7 +26,7 @@
|
||||||
{% if user.email %}
|
{% if user.email %}
|
||||||
<span id="contact_info_email">{{ user.email }}</span>
|
<span id="contact_info_email">{{ user.email }}</span>
|
||||||
{% include "admin/input_with_clipboard.html" with field=user invisible_input_field=True %}
|
{% include "admin/input_with_clipboard.html" with field=user invisible_input_field=True %}
|
||||||
<br class="admin-icon-group__br">
|
<br>
|
||||||
{% else %}
|
{% else %}
|
||||||
None<br>
|
None<br>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -269,7 +269,7 @@ This is using a custom implementation fieldset.html (see admin/fieldset.html)
|
||||||
<td class="padding-left-1 text-size-small">
|
<td class="padding-left-1 text-size-small">
|
||||||
<input aria-hidden="true" class="display-none" value="{{ contact.email }}" />
|
<input aria-hidden="true" class="display-none" value="{{ contact.email }}" />
|
||||||
<button
|
<button
|
||||||
class="usa-button usa-button--unstyled padding-right-1 usa-button--icon button--clipboard copy-to-clipboard usa-button__small-text text-no-underline"
|
class="usa-button--dja usa-button usa-button__small-text usa-button--unstyled padding-right-1 usa-button--icon button--clipboard copy-to-clipboard usa-button__small-text text-no-underline"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
|
@ -277,6 +277,7 @@ This is using a custom implementation fieldset.html (see admin/fieldset.html)
|
||||||
>
|
>
|
||||||
<use aria-hidden="true" xlink:href="{%static 'img/sprite.svg'%}#content_copy"></use>
|
<use aria-hidden="true" xlink:href="{%static 'img/sprite.svg'%}#content_copy"></use>
|
||||||
</svg>
|
</svg>
|
||||||
|
<!-- the span is targeted in JS, do not remove -->
|
||||||
<span>Copy email</span>
|
<span>Copy email</span>
|
||||||
</button>
|
</button>
|
||||||
</td>
|
</td>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue