Skip to content

Commit

Permalink
Small fixes to the submissions table, mainly the ability to filter by…
Browse files Browse the repository at this point in the history
… mutliple funds, rounds & leads
  • Loading branch information
wes-otf committed Jan 23, 2025
1 parent 09aac2c commit 4f254fe
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 39 deletions.
44 changes: 22 additions & 22 deletions hypha/apply/funds/templates/submissions/all.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends base_template %}

{% load i18n static %}
{% load querystrings heroicons %}
{% load querystrings heroicons table_tags %}
{% load humanize %}

{% block title %}{% trans "Submissions" %}{% endblock %}
Expand Down Expand Up @@ -205,43 +205,43 @@

{% if selected_statuses %}
<span class="inline-flex items-center py-1 px-2 text-xs font-medium text-blue-800 bg-blue-100 rounded select-none me-2">
status:{% for s in selected_statuses %}{{ s }}{% endfor %}
Status: {% for s in selected_statuses %}{{ s }}{% endfor %}
<a href="{% remove_from_query "status" %}" role="button" class="inline-flex items-center p-0.5 text-xs text-blue-400 bg-transparent rounded-sm hover:text-blue-900 hover:bg-blue-200 ms-1" aria-label="Remove">
{% heroicon_mini "x-mark" aria_hidden="true" fill="currentColor" %}
<span class="sr-only">{% trans "Remove status filter" %}</span>
</a>
</span>
{% endif %}
{% if selected_fund_objects %}
{% for fund in selected_fund_objects %}
<span class="inline-flex items-center py-1 px-2 text-xs font-medium text-blue-800 bg-blue-100 rounded select-none me-2">
fund:{% for s in selected_fund_objects %}"{{ s }}"{% endfor %}
<a href="{% remove_from_query "fund" %}" role="button" class="inline-flex items-center p-0.5 text-xs text-blue-400 bg-transparent rounded-sm hover:text-blue-900 hover:bg-blue-200 ms-1 dark:hover:bg-blue-800 dark:hover:text-blue-300" aria-label="Remove">
Fund: {{ fund }}
<a href="{% remove_from_query fund=fund.id %}" role="button" class="inline-flex items-center p-0.5 text-xs text-blue-400 bg-transparent rounded-sm hover:text-blue-900 hover:bg-blue-200 ms-1 dark:hover:bg-blue-800 dark:hover:text-blue-300" aria-label="Remove">
{% heroicon_mini "x-mark" aria_hidden="true" fill="currentColor" %}
<span class="sr-only">{% trans "Remove fund filter" %}</span>
</a>
</span>
{% endif %}
{% if selected_round_objects %}
{% endfor %}
{% for round in selected_round_objects %}
<span class="inline-flex items-center py-1 px-2 text-xs font-medium text-blue-800 bg-blue-100 rounded select-none me-2">
round:{% for s in selected_round_objects %}"{{ s }}"{% endfor %}
<a href="{% remove_from_query "round" %}" role="button" class="inline-flex items-center p-0.5 text-xs text-blue-400 bg-transparent rounded-sm hover:text-blue-900 hover:bg-blue-200 ms-1 dark:hover:bg-blue-800 dark:hover:text-blue-300" aria-label="Remove">
Round: {{ round }}
<a href="{% remove_from_query round=round.id %}" role="button" class="inline-flex items-center p-0.5 text-xs text-blue-400 bg-transparent rounded-sm hover:text-blue-900 hover:bg-blue-200 ms-1 dark:hover:bg-blue-800 dark:hover:text-blue-300" aria-label="Remove">
{% heroicon_mini "x-mark" aria_hidden="true" fill="currentColor" %}
<span class="sr-only">{% trans "Remove round filter" %}</span>
</a>
</span>
{% endif %}
{% if selected_leads %}
{% endfor %}
{% for s in selected_leads %}
<span class="inline-flex items-center py-1 px-2 text-xs font-medium text-blue-800 bg-blue-100 rounded select-none me-2">
Lead:{% for s in selected_leads %}{{ s }}{% endfor %}
<a href="{% remove_from_query "lead" %}" role="button" class="inline-flex items-center p-0.5 text-xs text-blue-400 bg-transparent rounded-sm hover:text-blue-900 hover:bg-blue-200 ms-1 dark:hover:bg-blue-800 dark:hover:text-blue-300" aria-label="Remove">
Lead: {{ s|get_display_name_from_id }}
<a href="{% remove_from_query lead=s %}" role="button" class="inline-flex items-center p-0.5 text-xs text-blue-400 bg-transparent rounded-sm hover:text-blue-900 hover:bg-blue-200 ms-1 dark:hover:bg-blue-800 dark:hover:text-blue-300" aria-label="Remove">
{% heroicon_mini "x-mark" aria_hidden="true" fill="currentColor" %}
<span class="sr-only">{% trans "Remove leads filter" %}</span>
</a>
</span>
{% endif %}
{% endfor %}
{% if selected_applicants %}
<span class="inline-flex items-center py-1 px-2 text-xs font-medium text-blue-800 bg-blue-100 rounded select-none me-2">
Applicant:{% for s in selected_applicants %}{{ s }}{% endfor %}
Applicant: {% for s in selected_applicants %}{{ s }}{% endfor %}
<a href="{% remove_from_query "applicants" %}" role="button" class="inline-flex items-center p-0.5 text-xs text-blue-400 bg-transparent rounded-sm hover:text-blue-900 hover:bg-blue-200 ms-1 dark:hover:bg-blue-800 dark:hover:text-blue-300" aria-label="Remove">
{% heroicon_mini "x-mark" aria_hidden="true" fill="currentColor" %}
<span class="sr-only">{% trans "Remove applicant filter" %}</span>
Expand All @@ -250,7 +250,7 @@
{% endif %}
{% for s in selected_reviewers %}
<span class="inline-flex items-center py-1 px-2 text-xs font-medium text-blue-800 bg-blue-100 rounded select-none me-2">
Reviewer:{{ s }}
Reviewer: {{ s|get_display_name_from_id }}
<a href="{% remove_from_query reviewers=s %}" role="button" class="inline-flex items-center p-0.5 text-xs text-blue-400 bg-transparent rounded-sm hover:text-blue-900 hover:bg-blue-200 ms-1 dark:hover:bg-blue-800 dark:hover:text-blue-300" aria-label="Remove">
{% heroicon_mini "x-mark" aria_hidden="true" fill="currentColor" %}
<span class="sr-only">{% trans "Remove reviewer filter" %}</span>
Expand All @@ -259,7 +259,7 @@
{% endfor %}
{% for s in selected_meta_terms %}
<span class="inline-flex items-center py-1 px-2 text-xs font-medium text-blue-800 bg-blue-100 rounded select-none me-2">
Meta Term:{{ s }}
Meta Term: {{ s }}
<a href="{% remove_from_query meta_terms=s %}" role="button" class="inline-flex items-center p-0.5 text-xs text-blue-400 bg-transparent rounded-sm hover:text-blue-900 hover:bg-blue-200 ms-1 dark:hover:bg-blue-800 dark:hover:text-blue-300" aria-label="Remove">
{% heroicon_mini "x-mark" aria_hidden="true" fill="currentColor" %}
<span class="sr-only">{% trans "Remove meta term filter" %}</span>
Expand All @@ -268,7 +268,7 @@
{% endfor %}
{% for s in selected_category_options %}
<span class="inline-flex items-center py-1 px-2 text-xs font-medium text-blue-800 bg-blue-100 rounded select-none me-2">
Category:{{ s.value }}
Category: {{ s.value }}
<a href="{% remove_from_query category_options=s.id %}" role="button" class="inline-flex items-center p-0.5 text-xs text-blue-400 bg-transparent rounded-sm hover:text-blue-900 hover:bg-blue-200 ms-1 dark:hover:bg-blue-800 dark:hover:text-blue-300" aria-label="Remove">
{% heroicon_mini "x-mark" aria_hidden="true" fill="currentColor" %}
<span class="sr-only">{% trans "Remove category filter" %}</span>
Expand All @@ -277,7 +277,7 @@
{% endfor %}
{% for s in selected_screening_statuses_objects %}
<span class="inline-flex items-center py-1 px-2 text-xs font-medium text-blue-800 bg-blue-100 rounded select-none me-2">
screening:"{{ s.title }}"
Screening: "{{ s.title }}"
<a href="{% remove_from_query screening_statuses=s.slug %}" role="button" class="inline-flex items-center p-0.5 text-xs text-blue-400 bg-transparent rounded-sm hover:text-blue-900 hover:bg-blue-200 ms-1 dark:hover:bg-blue-800 dark:hover:text-blue-300" aria-label="Remove">
{% heroicon_mini "x-mark" aria_hidden="true" fill="currentColor" %}
<span class="sr-only">{% trans "Remove screening decisions filter" %}</span>
Expand All @@ -286,7 +286,7 @@
{% endfor %}
{% if selected_sort %}
<span class="inline-flex items-center py-1 px-2 text-xs font-medium text-blue-800 bg-blue-100 rounded select-none me-2">
sort:{{ selected_sort }}
Sort: {{ selected_sort }}
<a href="{% remove_from_query "sort" %}" role="button" class="inline-flex items-center p-0.5 text-xs text-blue-400 bg-transparent rounded-sm hover:text-blue-900 hover:bg-blue-200 ms-1 dark:hover:bg-blue-800 dark:hover:text-blue-300" aria-label="Remove">
{% heroicon_mini "x-mark" aria_hidden="true" fill="currentColor" %}
<span class="sr-only">{% trans "Remove sort filter" %}</span>
Expand Down Expand Up @@ -374,7 +374,7 @@

{% dropdown_menu title="Status" heading="Filter by current status" enable_search=True %}
<ul
class="flex overflow-scroll flex-col max-h-80 text-gray-700 divide-y"
class="flex overflow-auto flex-col max-h-80 text-gray-700 divide-y"
data-filter-list>
{% if selected_statuses %}
<li>
Expand Down Expand Up @@ -412,7 +412,7 @@

{% dropdown_menu title="Screening" heading="Filter by screening decision" %}
<ul
class="flex overflow-scroll flex-col max-h-80 text-gray-700 divide-y"
class="flex overflow-auto flex-col max-h-80 text-gray-700 divide-y"
>
{% for s in screening_options %}
<li>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% load i18n %}
{% load querystrings %}
<ul class="overflow-scroll max-h-80 text-gray-700 divide-y" aria-labelledby="dropdown-change-status" data-filter-list>
<ul class="overflow-auto max-h-80 text-gray-700 divide-y" aria-labelledby="dropdown-change-status" data-filter-list>
{% for user in leads %}
<li data-filter-item-text>
<a
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% load i18n %}
{% load querystrings %}
<ul class="overflow-scroll max-h-80 text-gray-700" aria-labelledby="dropdown-categories"
<ul class="overflow-auto max-h-80 text-gray-700" aria-labelledby="dropdown-categories"
data-filter-list>
{% if selected_category_options %}
<li data-filter-item-text>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% load i18n %}
{% load querystrings %}
<ul class="overflow-scroll max-h-80 text-gray-700 divide-y" aria-labelledby="dropdown-change-status">
<ul class="overflow-auto max-h-80 text-gray-700 divide-y" aria-labelledby="dropdown-change-status">
{% for slug, value in statuses %}
<li data-filter-for="change-status-filter-field">
<a
Expand Down
6 changes: 3 additions & 3 deletions hypha/apply/funds/templates/submissions/submenu/funds.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% load i18n %}
{% load querystrings heroicons %}

<ul class="overflow-scroll max-h-80 text-gray-700 divide-y" aria-labelledby="dropdownBgHoverButton" data-filter-list>
<ul class="overflow-auto max-h-80 text-gray-700 divide-y" aria-labelledby="dropdownBgHoverButton" data-filter-list>
{% if selected_funds %}
<li data-filter-item-text>
<a href="{% url "apply:submissions:list" %}{% remove_from_query "only_query_string" "page" "fund" %}"
Expand All @@ -19,8 +19,8 @@
href="{% url "apply:submissions:list" %}{% remove_from_query "only_query_string" "page" fund=f.id %}"
hx-get="{% url "apply:submissions:list" %}{% remove_from_query "only_query_string" "page" fund=f.id %}"
{% else %}
href="{% url "apply:submissions:list" %}{% modify_query "only_query_string" "page" "round" fund=f.id %}"
hx-get="{% url "apply:submissions:list" %}{% modify_query "only_query_string" "page" "round" fund=f.id %}"
href="{% url "apply:submissions:list" %}{% add_to_query "only_query_string" "page" "round" fund=f.id %}"
hx-get="{% url "apply:submissions:list" %}{% add_to_query "only_query_string" "page" "round" fund=f.id %}"
{% endif %}
hx-push-url="true"
class="flex {% if f.selected %}ps-2 font-medium{% else %}ps-8{% endif %} pe-3 py-2 text-gray-600 items-center hover:bg-gray-100 focus:bg-gray-100{% if f.selected %}bg-gray-100{% endif %}">
Expand Down
11 changes: 8 additions & 3 deletions hypha/apply/funds/templates/submissions/submenu/leads.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% load i18n %}
{% load querystrings heroicons %}
<ul class="overflow-scroll max-h-80 text-gray-700 divide-y" aria-labelledby="dropdownBgHoverButton" data-filter-list>
<ul class="overflow-auto max-h-80 text-gray-700 divide-y" aria-labelledby="dropdownBgHoverButton" data-filter-list>
{% if selected_leads %}
<li data-filter-item-text>
<a href="{% url "apply:submissions:list" %}{% remove_from_query "only_query_string" "page" "lead" %}"
Expand All @@ -14,8 +14,13 @@
{% for user in leads %}
<li data-filter-item-text>
<a
href="{% url "apply:submissions:list" %}{% modify_query "only_query_string" "page" lead=user.id %}"
hx-get="{% url "apply:submissions:list" %}{% modify_query "only_query_string" "page" lead=user.id %}"
{% if user.selected %}
href="{% url "apply:submissions:list" %}{% remove_from_query "only_query_string" "page" lead=user.id %}"
hx-get="{% url "apply:submissions:list" %}{% remove_from_query "only_query_string" "page" lead=user.id %}"
{% else %}
href="{% url "apply:submissions:list" %}{% add_to_query "only_query_string" "page" lead=user.id %}"
hx-get="{% url "apply:submissions:list" %}{% add_to_query "only_query_string" "page" lead=user.id %}"
{% endif %}
hx-push-url="true"
class="flex {% if user.selected %}ps-2 font-medium bg-gray-100{% else %}ps-8{% endif %} pe-3 py-2 text-gray-600 items-center hover:bg-gray-100 focus:bg-gray-100"
aria-selected="{% if user.selected %}true{% else %}false{% endif %}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% load i18n %}
{% load querystrings %}
<ul class="overflow-scroll max-h-80 text-gray-700 divide-y" aria-labelledby="dropdown-meta-terms" data-filter-list>
<ul class="overflow-auto max-h-80 text-gray-700 divide-y" aria-labelledby="dropdown-meta-terms" data-filter-list>
{% if selected_meta_terms %}
<li data-filter-item-text>
<a href="{% url "apply:submissions:list" %}{% remove_from_query "only_query_string" "page" "meta_terms" %}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% load i18n %}
{% load querystrings %}
<ul class="overflow-scroll max-h-80 text-gray-700 divide-y" aria-labelledby="dropdown-reviewers" data-filter-list>
<ul class="overflow-auto max-h-80 text-gray-700 divide-y" aria-labelledby="dropdown-reviewers" data-filter-list>
{% if selected_reviewers %}
<li data-filter-item-text>
<a href="{% url "apply:submissions:list" %}{% remove_from_query "only_query_string" "page" "reviewers" %}"
Expand Down
23 changes: 17 additions & 6 deletions hypha/apply/funds/templates/submissions/submenu/rounds.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,21 @@

<div data-filter-list>
{% if closed_rounds %}
<div class="overflow-scroll max-h-80 divide-y tab-closed-rounds"
<div class="overflow-auto max-h-80 divide-y tab-closed-rounds"
x-show="tab === 'closed_rounds'"
:aria-hidden="tab === 'closed_rounds' ? 'false' : 'true'"
role="tabpanel"
>
{% for f in closed_rounds %}
<a data-filter-item-text
href="{% url "apply:submissions:list" %}{% modify_query "only_query_string" "page" round=f.id %}"
hx-get="{% url "apply:submissions:list" %}{% modify_query "only_query_string" "page" round=f.id %}"
{% if f.selected %}
href="{% url "apply:submissions:list" %}{% remove_from_query "only_query_string" "page" round=f.id %}"
hx-get="{% url "apply:submissions:list" %}{% remove_from_query "only_query_string" "page" round=f.id %}"
{% else %}
href="{% url "apply:submissions:list" %}{% add_to_query "only_query_string" "page" round=f.id %}"
hx-get="{% url "apply:submissions:list" %}{% add_to_query "only_query_string" "page" round=f.id %}"
{% endif %}

hx-push-url="true"
class="flex {% if f.selected %}ps-2 font-medium{% else %}ps-8{% endif %} pe-3 py-2 text-gray-600 items-center hover:bg-gray-100 focus:bg-gray-100{% if f.selected %}bg-gray-100{% endif %}">
{% if f.selected %}
Expand All @@ -63,16 +69,21 @@
{% endif %}

{% if open_rounds %}
<div class="overflow-scroll max-h-80 divide-y tab-open-rounds"
<div class="overflow-auto max-h-80 divide-y tab-open-rounds"
x-show="tab === 'open_rounds'"
:aria-hidden="tab === 'open_rounds' ? 'false' : 'true'"
role="tabpanel"
>
{% for f in open_rounds %}
<a
data-filter-item-text
href="{% url "apply:submissions:list" %}{% modify_query "only_query_string" "page" round=f.id %}"
hx-get="{% url "apply:submissions:list" %}{% modify_query "only_query_string" "page" round=f.id %}"
{% if f.selected %}
href="{% url "apply:submissions:list" %}{% remove_from_query "only_query_string" "page" round=f.id %}"
hx-get="{% url "apply:submissions:list" %}{% remove_from_query "only_query_string" "page" round=f.id %}"
{% else %}
href="{% url "apply:submissions:list" %}{% add_to_query "only_query_string" "page" round=f.id %}"
hx-get="{% url "apply:submissions:list" %}{% add_to_query "only_query_string" "page" round=f.id %}"
{% endif %}
hx-push-url="true"
class="flex {% if f.selected %}ps-2 font-medium{% else %}ps-8{% endif %} pe-3 py-2 text-gray-600 items-center hover:bg-gray-100 focus:bg-gray-100{% if f.selected %}bg-gray-100{% endif %}">
{% if f.selected %}
Expand Down
7 changes: 7 additions & 0 deletions hypha/apply/funds/templatetags/table_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

from django import template

from hypha.apply.users.models import User

register = template.Library()


Expand All @@ -16,3 +18,8 @@ def row_from_record(row, record):
@register.simple_tag
def total_num_of_pages(total_no_of_rows, per_page):
return math.ceil(total_no_of_rows / per_page)


@register.filter
def get_display_name_from_id(user_id: int) -> str:
return User.objects.get(id=user_id).get_display_name()
7 changes: 7 additions & 0 deletions hypha/apply/funds/views/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ def submissions_all(
can_view_archives = permissions.can_view_archived_submissions(request.user)
can_access_drafts = permissions.can_access_drafts(request.user)

# Filter out anything that isn't an int
if selected_funds:
selected_funds = [id for id in selected_funds if id.isdigit()]

if selected_rounds:
selected_rounds = [id for id in selected_rounds if id.isdigit()]

selected_fund_objects = (
Page.objects.filter(id__in=selected_funds) if selected_funds else []
)
Expand Down

0 comments on commit 4f254fe

Please sign in to comment.