Skip to content

Commit

Permalink
Merge pull request #911 from nationalarchives/feature/1380-court-heir…
Browse files Browse the repository at this point in the history
…archy

First pass at heirarchical courts list
  • Loading branch information
jacksonj04 authored Oct 12, 2023
2 parents 8922f25 + 2e134be commit c1cff47
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 32 deletions.
3 changes: 2 additions & 1 deletion config/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ class StructuredSearchView(TemplateViewWithContext):

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["context"]["courts"] = courts.get_selectable()
context["context"]["courts"] = courts.get_grouped_selectable_courts()
context["context"]["tribunals"] = courts.get_grouped_selectable_tribunals()
context["feedback_survey_type"] = "structured_search"
return context

Expand Down
22 changes: 20 additions & 2 deletions ds_judgements_public_ui/sass/includes/_structured_search.scss
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,15 @@
width: 100%;

@media (min-width: $grid__breakpoint-medium) {
column-count: 2;
column-gap: calc(2 * $spacer__unit);
display: flex;
gap: calc(2 * $spacer__unit);
}
}

&__court-options-column {
break-inside: avoid;
}

&__court-option {
margin-top: calc($spacer__unit * 0.5);

Expand Down Expand Up @@ -252,8 +256,22 @@
}
}

&__court-group-label {
margin-top: calc(0.5 * $spacer__unit);
line-height: calc(1.5 * $spacer__unit);
vertical-align: baseline;
margin-bottom: calc(0.5 * $spacer__unit);
}

&__court-group {
margin-left: calc(2 * $spacer__unit);
break-inside: avoid;
}

&__court-option-label {
margin-left: calc(0.5 * $spacer__unit);
line-height: calc(1.5 * $spacer__unit);
vertical-align: baseline;
}
&__court-date-range {
color: $color__dark-grey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ <h3 id="browse-by-court" class="judgment-browse__sub-header">By court</h3>
{% for court in courts %}
<li class="judgment-browse__list-item">
<a class="judgment-browse__link"
href="{% url "search" %}?court={{ court.canonical_param }}">{{ court.list_name }}</a>
href="{% url "search" %}?court={{ court.canonical_param }}">{{ court.name }}</a>
<span class="judgment-browse__year-range">&mdash; {{ court|get_court_date_range }}</span>
</li>
{% endfor %}
Expand All @@ -24,7 +24,7 @@ <h3 id="browse-by-tribunal" class="judgment-browse__sub-header">By tribunal</h3>
{% for tribunal in tribunals %}
<li class="judgment-browse__list-item">
<a class="judgment-browse__link"
href="{% url "search" %}?court={{ tribunal.canonical_param }}">{{ tribunal.list_name }}</a>
href="{% url "search" %}?court={{ tribunal.canonical_param }}">{{ tribunal.name }}</a>
<span class="judgment-browse__year-range">&mdash; {{ tribunal|get_court_date_range }}</span>
</li>
{% endfor %}
Expand Down
14 changes: 14 additions & 0 deletions ds_judgements_public_ui/templates/includes/court_option.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% load query_filters court_utils %}
<div class="structured-search__court-option {% if ungrouped %}ungrouped{% endif %}">
<label for="court_{{ court.canonical_param }}">
<input type="checkbox"
name="court"
value="{{ court.canonical_param }}"
id="court_{{ court.canonical_param }}"
{% for alias in context.court %}{% if alias in court.param_aliases %}checked="checked"{% endif %}
{% endfor %} />
<span class="structured-search__court-option-label">{{ court.grouped_name }}
<span class="structured-search__court-date-range">&mdash; {{ court|get_court_date_range }}</span>
</span>
</label>
</div>
28 changes: 13 additions & 15 deletions ds_judgements_public_ui/templates/includes/courts_options.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
{% load query_filters court_utils %}
{% for court in context.courts %}
<div class="structured-search__court-option">
<label for="court_{{ court.canonical_param }}">
<input type="checkbox"
name="court"
value="{{ court.canonical_param }}"
id="court_{{ court.canonical_param }}"
{% for alias in context.court %}{% if alias in court.param_aliases %}checked="checked"{% endif %}
{% endfor %} />
<span class="structured-search__court-option-label">{{ court.name }}
<span class="structured-search__court-date-range">&mdash; {{ court|get_court_date_range }}</span>
</span>
</label>
</div>
{% for group in courts %}
{% if group.display_heading %}
<div class="structured-search__court-group-label">{{ group.name }}</div>
<div class="structured-search__court-group">
{% for court in group.courts %}
{% include "includes/court_option.html" with court=court %}
{% endfor %}
</div>
{% else %}
{% for court in group.courts %}
{% include "includes/court_option.html" with court=court ungrouped=True %}
{% endfor %}
{% endif %}
{% endfor %}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,14 @@
<div class="structured-search__limit-to-container">
<fieldset>
<legend class="structured-search__limit-to-label">From specific courts or tribunals</legend>
<div class="structured-search__court-options" id="court">{% include "includes/courts_options.html" %}</div>
<div class="structured-search__court-options" id="court">
<div class="structured-search__court-options-column">
{% include "includes/courts_options.html" with courts=context.courts %}
</div>
<div class="structured-search__court-options-column">
{% include "includes/courts_options.html" with courts=context.tribunals %}
</div>
</div>
</fieldset>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ <h2 id="section-coverage">Current coverage of courts and tribunals available on
<h3>Date ranges for judgments and decisions available on Find Case Law</h3>
<ul class="court-listing">
{% for group in context.courts %}
{% if group.name %}
{% if group.display_heading %}
<li>
<span>{{ group.name }}</span>
<ul>
{% for court in group.courts %}<li>{{ court.list_name }} &mdash;{{ court|get_court_date_range }}</li>{% endfor %}
{% for court in group.courts %}<li>{{ court.grouped_name }} &mdash; {{ court|get_court_date_range }}</li>{% endfor %}
</ul>
</li>
{% else %}
{% for court in group.courts %}<li>{{ court.list_name }} &mdash;{{ court|get_court_date_range }}</li>{% endfor %}
{% for court in group.courts %}<li>{{ court.grouped_name }} &mdash; {{ court|get_court_date_range }}</li>{% endfor %}
{% endif %}
{% endfor %}
</ul>
Expand Down
8 changes: 4 additions & 4 deletions judgments/tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ def test_judgment_advanced_search_court_filters(
draggable="false"
class="results-search-component__removable-options-link"
href="/judgments/search?query=&amp;court=ewhc/ipec&amp;judge=&amp;party=&amp;neutral_citation=&amp;specific_keyword=&amp;order=&amp;from=&amp;from_day=&amp;from_month=&amp;from_year=&amp;to=&amp;to_day=&amp;to_month=&amp;to_year=&amp;per_page=&amp;page="
title="Chancery Division of the High Court">
title="High Court (Chancery Division)">
<span class="results-search-component__removable-options-value">
<span class="results-search-component__removable-options-value-text">
Chancery Division of the High Court
High Court (Chancery Division)
</span>
</span>
</a>
Expand All @@ -118,10 +118,10 @@ def test_judgment_advanced_search_court_filters(
draggable="false"
class="results-search-component__removable-options-link"
href="/judgments/search?query=&amp;court=ewhc/ch&amp;judge=&amp;party=&amp;neutral_citation=&amp;specific_keyword=&amp;order=&amp;from=&amp;from_day=&amp;from_month=&amp;from_year=&amp;to=&amp;to_day=&amp;to_month=&amp;to_year=&amp;per_page=&amp;page="
title="Intellectual Property Enterprise Court">
title="High Court (Intellectual Property Enterprise Court)">
<span class="results-search-component__removable-options-value">
<span class="results-search-component__removable-options-value-text">
Intellectual Property Enterprise Court
High Court (Intellectual Property Enterprise Court)
</span>
</span>
</a>
Expand Down
3 changes: 2 additions & 1 deletion judgments/views/advanced_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ def advanced_search(request):
context = {
"errors": errors,
"query": query_params["query"],
"courts": all_courts.get_selectable(),
"courts": all_courts.get_grouped_selectable_courts(),
"tribunals": all_courts.get_grouped_selectable_tribunals(),
"query_params": query_params,
}

Expand Down
4 changes: 2 additions & 2 deletions judgments/views/browse.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def browse(request, court=None, subdivision=None, year=None):
context["total"] = search_response.total
context["per_page"] = per_page
context["paginator"] = paginator(page, search_response.total, per_page)
context["courts"] = all_courts.get_selectable()

context["courts"] = all_courts.get_grouped_selectable_courts()
context["tribunals"] = all_courts.get_grouped_selectable_tribunals()
context["page_title"] = gettext("results.search.title")

except MarklogicResourceNotFoundError:
Expand Down
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ requests-toolbelt~=1.0.0
lxml~=4.9.3
wsgi-basic-auth~=1.1.0
ds-caselaw-marklogic-api-client~=14.1.0
ds-caselaw-utils~=1.0.2
ds-caselaw-utils==1.2.1
rollbar
django-weasyprint==2.2.0
# pinned to avoid https://github.com/fdemmer/django-weasyprint/issues/71
Expand Down

0 comments on commit c1cff47

Please sign in to comment.