Merge branch 'rjm/2351-org-requests-page' into dk/2593-domain-request-search-bar

This commit is contained in:
zandercymatics 2024-09-12 09:47:44 -06:00
commit d66ad28574
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
4 changed files with 28 additions and 44 deletions

View file

@ -1436,9 +1436,9 @@ document.addEventListener('DOMContentLoaded', function() {
// NOTE: We may need to evolve this as we add more filters.
document.addEventListener('focusin', function(event) {
const accordion = document.querySelector('.usa-accordion--select');
const openFilterAccordion = document.querySelector('.usa-button--filter[aria-expanded="true"]');
const accordionThatIsOpen = document.querySelector('.usa-button--filter[aria-expanded="true"]');
if (openFilterAccordion && !accordion.contains(event.target)) {
if (accordionThatIsOpen && !accordion.contains(event.target)) {
closeFilters();
}
});
@ -1447,9 +1447,9 @@ document.addEventListener('DOMContentLoaded', function() {
// NOTE: We may need to evolve this as we add more filters.
document.addEventListener('click', function(event) {
const accordion = document.querySelector('.usa-accordion--select');
const openFilterAccordion = document.querySelector('.usa-button--filter[aria-expanded="true"]');
const accordionThatIsOpen = document.querySelector('.usa-button--filter[aria-expanded="true"]');
if (openFilterAccordion && !accordion.contains(event.target)) {
if (accordionThatIsOpen && !accordion.contains(event.target)) {
closeFilters();
}
});
@ -1631,7 +1631,7 @@ document.addEventListener('DOMContentLoaded', function() {
const actionLabel = request.action_label;
const submissionDate = request.last_submitted_date ? new Date(request.last_submitted_date).toLocaleDateString('en-US', options) : `<span class="text-base">Not submitted</span>`;
// Delete markup will either be a simple trigger or a 3 dots menu with a hidden trigger (in the case of portfolio requests page)
// The markup for the delete function either be a simple trigger or a 3 dots menu with a hidden trigger (in the case of portfolio requests page)
// Even if the request is not deletable, we may need these empty strings for the td if the deletable column is displayed
let modalTrigger = '';
@ -1734,7 +1734,7 @@ document.addEventListener('DOMContentLoaded', function() {
domainRequestsSectionWrapper.appendChild(modal);
// Request is deletable, modal and modalTrigger are built. Now test is portfolio requests page and enhace the modalTrigger markup
// Request is deletable, modal and modalTrigger are built. Now check if we are on the portfolio requests page (by seeing if there is a portfolio value) and enhance the modalTrigger accordingly
if (portfolioValue) {
modalTrigger = `
<a
@ -1946,9 +1946,9 @@ document.addEventListener('DOMContentLoaded', function() {
});
}
function closeMoreActionMenu(openFilterAccordion) {
if (openFilterAccordion.getAttribute("aria-expanded") === "true") {
openFilterAccordion.click();
function closeMoreActionMenu(accordionThatIsOpen) {
if (accordionThatIsOpen.getAttribute("aria-expanded") === "true") {
accordionThatIsOpen.click();
}
}
@ -1990,42 +1990,24 @@ document.addEventListener('DOMContentLoaded', function() {
}
document.addEventListener('focusin', function(event) {
const openMoreActionsAccordions = document.querySelectorAll('.usa-button--more-actions[aria-expanded="true"]');
openMoreActionsAccordions.forEach((openMoreActionsAccordionButton) => {
const moreActionsAccordion = openMoreActionsAccordionButton.closest('.usa-accordion--more-actions'); // Find the corresponding accordion
if (moreActionsAccordion && !moreActionsAccordion.contains(event.target)) {
closeMoreActionMenu(openMoreActionsAccordionButton); // Close the accordion if the focus is outside
}
});
const openFilterAccordion = document.querySelector('.usa-button--filter[aria-expanded="true"]');
const moreFilterAccordion = openFilterAccordion ? openFilterAccordion.closest('.usa-accordion--select') : undefined;
if (openFilterAccordion) {
if (!moreFilterAccordion.contains(event.target)) {
closeFilters();
}
}
closeOpenAccordions(event);
});
document.addEventListener('click', function(event) {
const openMoreActionsAccordions = document.querySelectorAll('.usa-button--more-actions[aria-expanded="true"]');
closeOpenAccordions(event);
});
openMoreActionsAccordions.forEach((openMoreActionsAccordionButton) => {
const accordion = openMoreActionsAccordionButton.closest('.usa-accordion--more-actions'); // Find the corresponding accordion
function closeOpenAccordions(event) {
const openAccordions = document.querySelectorAll('.usa-button--more-actions[aria-expanded="true"]');
openAccordions.forEach((openAccordionButton) => {
// Find the corresponding accordion
const accordion = openAccordionButton.closest('.usa-accordion--more-actions');
if (accordion && !accordion.contains(event.target)) {
closeMoreActionMenu(openMoreActionsAccordionButton); // Close the accordion if the click is outside
// Close the accordion if the click is outside
closeMoreActionMenu(openAccordionButton);
}
});
const openFilterAccordion = document.querySelector('.usa-button--filter[aria-expanded="true"]');
const moreFilterAccordion = openFilterAccordion ? openFilterAccordion.closest('.usa-accordion--select') : undefined;
if (openFilterAccordion && moreFilterAccordion && !moreFilterAccordion.contains(event.target)) {
closeFilters();
}
});
}
// Initial load
loadDomainRequests(1);

View file

@ -60,7 +60,7 @@ def add_has_profile_feature_flag_to_context(request):
def portfolio_permissions(request):
"""Make portfolio permissions for the request user available in global context"""
default_context = {
portfolio_context = {
"has_base_portfolio_permission": False,
"has_any_domains_portfolio_permission": False,
"has_any_requests_portfolio_permission": False,
@ -94,8 +94,8 @@ def portfolio_permissions(request):
"has_organization_requests_flag": request.user.has_organization_requests_flag(),
"has_organization_members_flag": request.user.has_organization_members_flag(),
}
return default_context
return portfolio_context
except AttributeError:
# Handles cases where request.user might not exist
return default_context
return portfolio_context

View file

@ -54,7 +54,7 @@
{% if has_organization_requests_flag %}
<li class="usa-nav__primary-item">
<!-- user hasone of the view permissions plus the edit permission, show the dropdown -->
<!-- user has one of the view permissions plus the edit permission, show the dropdown -->
{% if has_edit_request_portfolio_permission %}
{% url 'domain-requests' as url %}
<button

View file

@ -10,7 +10,9 @@ from django.db.models import Q
@login_required
def get_domain_requests_json(request):
"""Given the current request,
get all domain requests that are associated with the request user and exclude the APPROVED ones"""
get all domain requests that are associated with the request user and exclude the APPROVED ones.
If we are on the portfolio requests page, limit the response to only those requests associated with
the given portfolio."""
domain_request_ids = get_domain_request_ids_from_request(request)