From 8e50ac82f2e3cadb6cf2b7f1e2c6a344c2573f1d Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Thu, 20 Jun 2024 13:42:14 -0400 Subject: [PATCH 01/25] added status filter to domain json search --- src/registrar/views/domains_json.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/registrar/views/domains_json.py b/src/registrar/views/domains_json.py index 6b286ab6e..a14e607f9 100644 --- a/src/registrar/views/domains_json.py +++ b/src/registrar/views/domains_json.py @@ -20,11 +20,18 @@ def get_domains_json(request): # Handle sorting sort_by = request.GET.get("sort_by", "id") # Default to 'id' order = request.GET.get("order", "asc") # Default to 'asc' - search_term = request.GET.get("search_term") + # Handle search term + search_term = request.GET.get("search_term") if search_term: objects = objects.filter(Q(name__icontains=search_term)) + # Handle state + status_param = request.GET.get("status") + if status_param: + status_list = status_param.split(',') + objects = objects.filter(state__in=status_list) + if sort_by == "state_display": # Fetch the objects and sort them in Python objects = list(objects) # Evaluate queryset to a list From b263c7e144dd9af07b017b660299dd1e6f2fdb73 Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Thu, 20 Jun 2024 15:01:27 -0400 Subject: [PATCH 02/25] updated domain json query to handle expired logic --- src/registrar/views/domains_json.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/registrar/views/domains_json.py b/src/registrar/views/domains_json.py index a14e607f9..e626a88f9 100644 --- a/src/registrar/views/domains_json.py +++ b/src/registrar/views/domains_json.py @@ -1,3 +1,4 @@ +from datetime import timezone from django.http import JsonResponse from django.core.paginator import Paginator from registrar.models import UserDomainRole, Domain @@ -30,7 +31,27 @@ def get_domains_json(request): status_param = request.GET.get("status") if status_param: status_list = status_param.split(',') - objects = objects.filter(state__in=status_list) + + # Split the status list into normal states and custom states + normal_states = [state for state in status_list if state in Domain.State.values] + custom_states = [state for state in status_list if state == 'expired'] + + # Construct Q objects for normal states that can be queried through ORM + state_query = Q() + if normal_states: + state_query |= Q(state__in=normal_states) + + # Handle custom states in Python, as expired can not be queried through ORM + if 'expired' in custom_states: + expired_domains = [domain.id for domain in objects if domain.state_display() == 'Expired'] + state_query |= Q(id__in=expired_domains) + + # Apply the combined query + objects = objects.filter(state_query) + + # NOTE: when a domain has a state of 'ready' and is_expired(), a search for + # status=ready will include the domain, even though the domain's state_display + # is Expired. if sort_by == "state_display": # Fetch the objects and sort them in Python From 38610d204415fd4ce821bb9faa479210b556e636 Mon Sep 17 00:00:00 2001 From: Rachid Mrad Date: Thu, 20 Jun 2024 15:16:23 -0400 Subject: [PATCH 03/25] base dropdown UI --- .../assets/sass/_theme/_accordions.scss | 36 ++++++ src/registrar/assets/sass/_theme/_base.scss | 4 + src/registrar/assets/sass/_theme/styles.scss | 1 + .../templates/includes/domains_table.html | 103 ++++++++++++++++++ 4 files changed, 144 insertions(+) create mode 100644 src/registrar/assets/sass/_theme/_accordions.scss diff --git a/src/registrar/assets/sass/_theme/_accordions.scss b/src/registrar/assets/sass/_theme/_accordions.scss new file mode 100644 index 000000000..065bfb6d8 --- /dev/null +++ b/src/registrar/assets/sass/_theme/_accordions.scss @@ -0,0 +1,36 @@ +@use "uswds-core" as *; + +.usa-accordion--select { + display: inline-block; + width: auto; + position: relative; + .usa-accordion__button { + background: color('white'); + border: solid 1px color('base-lighter'); + border-radius: 4px; + padding: units(1) units(2); + color: color('primary-darker'); + font-weight: font-weight('normal'); + font-size: size('ui', 'xs'); + } + .usa-accordion__button[aria-expanded=false], + .usa-accordion__button[aria-expanded=false]:hover { + background-image: none; + } + .usa-accordion__content { + // Note, width is determined by a custom width class on one of the children + position: absolute; + z-index: 1; + top: 36.48px; + left: 0; + } + h2 { + font-size: size('body', 'sm'); + } + .usa-button { + width: 100%; + } + .margin-top-0 { + margin-top: 0 !important; + } +} \ No newline at end of file diff --git a/src/registrar/assets/sass/_theme/_base.scss b/src/registrar/assets/sass/_theme/_base.scss index e5e8b89ee..82884ce15 100644 --- a/src/registrar/assets/sass/_theme/_base.scss +++ b/src/registrar/assets/sass/_theme/_base.scss @@ -211,3 +211,7 @@ abbr[title] { .usa-logo button.usa-button--unstyled.disabled-button:hover{ color: #{$dhs-dark-gray-85}; } + +.width-145 { + width: 145px; +} diff --git a/src/registrar/assets/sass/_theme/styles.scss b/src/registrar/assets/sass/_theme/styles.scss index 921976b44..622448d1c 100644 --- a/src/registrar/assets/sass/_theme/styles.scss +++ b/src/registrar/assets/sass/_theme/styles.scss @@ -12,6 +12,7 @@ @forward "typography"; @forward "links"; @forward "lists"; +@forward "accordions"; @forward "buttons"; @forward "pagination"; @forward "forms"; diff --git a/src/registrar/templates/includes/domains_table.html b/src/registrar/templates/includes/domains_table.html index 4347520cc..a818af905 100644 --- a/src/registrar/templates/includes/domains_table.html +++ b/src/registrar/templates/includes/domains_table.html @@ -33,6 +33,109 @@ + {% if portfolio %} +
+
+ +
+
+

Status

+
+ Select to apply status filter +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + + + +
+
+ {% endif %}