Basic styling / HTML content

Needs some work, but this is fine for now
This commit is contained in:
zandercymatics 2024-03-05 14:52:25 -07:00
parent 20161fe7f6
commit 550bed1de6
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
4 changed files with 54 additions and 2 deletions

View file

@ -38,3 +38,11 @@ legend.float-left-tablet + button.float-right-tablet {
margin-top: 1rem;
}
}
/* Custom style for disabled inputs */
// TODO - UPDATE THIS!
.usa-input:disabled, .usa-select:disabled, .usa-textarea:disabled {
background-color: #f0f0f0;
color: #5b616b;
border-color: #5b616b;
}

View file

@ -222,7 +222,7 @@ class AuthorizingOfficialContactForm(ContactForm):
JOIN = "authorizing_official"
def __init__(self, *args, **kwargs):
def __init__(self, disable_fields=False, *args, **kwargs):
super().__init__(*args, **kwargs)
# Overriding bc phone not required in this form
@ -243,6 +243,17 @@ class AuthorizingOfficialContactForm(ContactForm):
"required": "Enter an email address in the required format, like name@example.com."
}
# TODO - uswds text fields dont have disabled styling??
# All fields should be disabled if the domain is federal or tribal
if disable_fields:
self._mass_disable_fields()
def _mass_disable_fields(self):
"""Given all available fields, invoke .disabled = True on them"""
for field in self.fields.values():
field.disabled = True
def save(self, commit=True):
"""
Override the save() method of the BaseModelForm.
@ -356,6 +367,20 @@ class DomainOrgNameAddressForm(forms.ModelForm):
self.fields[field_name].required = True
self.fields["state_territory"].widget.attrs.pop("maxlength", None)
self.fields["zipcode"].widget.attrs.pop("maxlength", None)
is_federal = self.instance.organization_type == DomainApplication.OrganizationChoices.FEDERAL
is_tribal = self.instance.organization_type == DomainApplication.OrganizationChoices.TRIBAL
# (Q) Should required = False be set here?
# These fields should not be None. If they are,
# it seems like an analyst should intervene?
# TODO - maybe consider adding a modal on these fields on hover
# ALSO TODO - uswds text fields dont have disabled styling??
if is_federal:
self.fields['federal_agency'].disabled = True
elif is_tribal:
self.fields['organization_name'].disabled = True
def save(self, commit=True):
"""Override the save() method of the BaseModelForm."""

View file

@ -11,6 +11,13 @@
<p>Your authorizing official is a person within your organization who can
authorize domain requests. This person must be in a role of significant, executive responsibility within the organization. Read more about <a class="usa-link" rel="noopener noreferrer" target="_blank" href="{% public_site_url 'domains/eligibility/#you-must-have-approval-from-an-authorizing-official-within-your-organization' %}">who can serve as an authorizing official</a>.</p>
{% if organization_type == "federal" or organization_type == "tribal" %}
<p>
The authorizing official for your organization cant be updated here.
To suggest an update, email <a href="mailto:help@get.gov" class="usa-link">help@get.gov</a>.
</p>
{% endif %}
{% include "includes/required_fields.html" %}
@ -24,7 +31,7 @@
{% input_with_errors form.title %}
{% input_with_errors form.email %}
<button
type="submit"
class="usa-button"

View file

@ -233,8 +233,20 @@ class DomainAuthorizingOfficialView(DomainFormBaseView):
"""Add domain_info.authorizing_official instance to make a bound form."""
form_kwargs = super().get_form_kwargs(*args, **kwargs)
form_kwargs["instance"] = self.object.domain_info.authorizing_official
domain_info = self.get_domain_info_from_domain()
invalid_fields = [DomainApplication.OrganizationChoices.FEDERAL, DomainApplication.OrganizationChoices.TRIBAL]
is_federal_or_tribal = domain_info and (domain_info.organization_type in invalid_fields)
form_kwargs["disable_fields"] = is_federal_or_tribal
return form_kwargs
def get_context_data(self, **kwargs):
"""Adds custom context."""
context = super().get_context_data(**kwargs)
context["organization_type"] = self.object.domain_info.organization_type
return context
def get_success_url(self):
"""Redirect to the overview page for the domain."""
return reverse("domain-authorizing-official", kwargs={"pk": self.object.pk})