Readonly view

This commit is contained in:
zandercymatics 2024-07-15 08:07:28 -06:00
parent 58605f11e5
commit 2bb2af5089
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
2 changed files with 39 additions and 2 deletions

View file

@ -559,7 +559,7 @@ function initializeWidgetOnList(list, parentId) {
if (sessionStorage.getItem(`actionNeededEmailSent-${domainRequestId}`) === null) {
sessionStorage.setItem(`actionNeededEmailSent-${domainRequestId}`, domainRequestId);
}
actionNeededEmail.readOnly = true
hideReadonly(actionNeededEmail.parentElement)
}
});
}
@ -587,7 +587,7 @@ function initializeWidgetOnList(list, parentId) {
if (emailSent !== null){
sessionStorage.removeItem(`actionNeededEmailSent-${domainRequestId}`);
}
actionNeededEmail.readOnly = false;
showReadonly(actionNeededEmail.parentElement)
}
}else {
// Show the no email message
@ -601,4 +601,21 @@ function initializeWidgetOnList(list, parentId) {
}
});
}
function showReadonly(actionNeededEmailParent) {
let readonlyView = document.querySelector("#action-needed-reason-email-readonly")
if (readonlyView) {
hideElement(readonlyView)
showElement(actionNeededEmailParent)
}
}
function hideReadonly(actionNeededEmailParent) {
let readonlyView = document.querySelector("#action-needed-reason-email-readonly")
if (readonlyView) {
showElement(readonlyView)
hideElement(actionNeededEmailParent)
}
}
})();

View file

@ -145,9 +145,29 @@ This is using a custom implementation fieldset.html (see admin/fieldset.html)
{% block field_other %}
{% if field.field.name == "action_needed_reason_email" %}
<div id="action-needed-reason-email-readonly" class="readonly textarea-wrapper display-none">
<div id="action_needed_reason_email_readonly" class="dja-readonly-textarea-container padding-1 margin-top-0 padding-top-0 margin-bottom-1 thin-border collapse--dgsimple collapsed">
<label class="max-full" for="action_needed_reason_email_view_more">
<strong>Sent to {% if has_profile_feature_flag %}creator{%else%}submitter{%endif%}</strong>
</label>
<textarea id="action_needed_reason_email_view_more" cols="40" rows="20" class="{% if not original_object.action_needed_reason %}display-none{% endif %}" readonly>
{{ original_object.action_needed_reason_email }}
</textarea>
<p id="no-email-message" class="{% if original_object.action_needed_reason %}display-none{% endif %}">No email will be sent.</p>
</div>
<button type="button" class="collapse-toggle--dgsimple usa-button usa-button--unstyled margin-top-0 margin-bottom-1 margin-left-1">
<span>Show details</span>
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24" height="24">
<use xlink:href="/public/img/sprite.svg#expand_more"></use>
</svg>
</button>
</div>
<div>
{{ field.field }}
<p id="no-email-message" class="{% if original_object.action_needed_reason %}display-none{% endif %}">No email will be sent.</p>
<input id="action-needed-email-sent" class="display-none" value="{{action_needed_email_sent}}">
</div>
{% else %}
{{ field.field }}
{% endif %}