From 41ac191ed3d85760d05680cf63770c516b347a49 Mon Sep 17 00:00:00 2001 From: Robert Date: Tue, 10 Dec 2024 15:29:28 -0500 Subject: [PATCH 1/6] Add MURs citations to views --- fec/legal/views.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/fec/legal/views.py b/fec/legal/views.py index 661274f42..f3003436c 100644 --- a/fec/legal/views.py +++ b/fec/legal/views.py @@ -372,6 +372,9 @@ def legal_doc_search_mur(request): case_max_close_date = request.GET.get('case_max_close_date', '') case_doc_category_ids = request.GET.getlist('case_doc_category_id', []) mur_disposition_category_ids = request.GET.getlist('mur_disposition_category_id', []) + case_citation_require_all = request.GET.get('case_citation_require_all', '') + case_regulatory_citation = request.GET.getlist('case_regulatory_citation', []) + case_statutory_citation = request.GET.getlist('case_statutory_citation', []) primary_subject_id = request.GET.get('primary_subject_id', '') secondary_subject_id = request.GET.get('secondary_subject_id', '') @@ -392,12 +395,15 @@ def legal_doc_search_mur(request): limit=limit, case_no=case_no, sort=sort, - case_respondents=case_respondents, - case_min_open_date=case_min_open_date, + case_citation_require_all=case_citation_require_all, + case_doc_category_id=case_doc_category_ids, + case_max_close_date=case_max_close_date, case_max_open_date=case_max_open_date, case_min_close_date=case_min_close_date, - case_max_close_date=case_max_close_date, - case_doc_category_id=case_doc_category_ids, + case_min_open_date=case_min_open_date, + case_regulatory_citation=case_regulatory_citation, + case_respondents=case_respondents, + case_statutory_citation=case_statutory_citation, mur_disposition_category_id=mur_disposition_category_ids, primary_subject_id=primary_subject_id, secondary_subject_id=secondary_subject_id, @@ -487,7 +493,10 @@ def get_secondary_subject_name(id): 'primary_subject_id_name': primary_subject_id_name, 'secondary_subject_id_name': secondary_subject_id_name, 'is_loading': True, # Indicate that the page is loading initially - "context_vars": context_vars, + 'context_vars': context_vars, + 'case_citation_require_all': case_citation_require_all, + 'case_regulatory_citation': case_regulatory_citation, + 'case_statutory_citation': case_statutory_citation, }) From abfde22647ae2a819be314e1e5d3bbb2620a8877 Mon Sep 17 00:00:00 2001 From: Robert Date: Tue, 10 Dec 2024 15:29:49 -0500 Subject: [PATCH 2/6] Add MURs citations to typeahead --- fec/fec/static/js/modules/typeahead.js | 38 ++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/fec/fec/static/js/modules/typeahead.js b/fec/fec/static/js/modules/typeahead.js index 1dc2e3f5c..e20d7242d 100644 --- a/fec/fec/static/js/modules/typeahead.js +++ b/fec/fec/static/js/modules/typeahead.js @@ -342,6 +342,42 @@ const aoStatutoryCitationDataset = { } }; +const caseRegulatoryCitationDataset = { + name: 'aoRegulatoryCitation', + display: 'name', + limit: 10, + source: citationRegulationEngine, + templates: { + header: 'Select a citation:', + pending: + 'Loading citations…', + notFound: compileHBS(''), // This has to be empty to not show anything + suggestion: function(datum) { + return ( + '' + datum.name + '' + ); + } + } +}; + +const caseStatutoryCitationDataset = { + name: 'aoStatutoryCitation', + display: 'name', + limit: 10, + source: citationStatuteEngine, + templates: { + header: 'Select a citation:', + pending: + 'Loading citations…', + notFound: compileHBS(''), // This has to be empty to not show anything + suggestion: function(datum) { + return ( + '' + datum.name + '' + ); + } + } +}; + export const datasets = { candidates: candidateDataset, committees: committeeDataset, @@ -350,6 +386,8 @@ export const datasets = { regulations: regulationDataset, aoRegulatoryCitations: aoRegulatoryCitationDataset, aoStatutoryCitations: aoStatutoryCitationDataset, + caseRegulatoryCitations: caseRegulatoryCitationDataset, + caseStatutoryCitations: caseStatutoryCitationDataset, allData: [candidateDataset, committeeDataset], all: [candidateDataset, committeeDataset, individualDataset, siteDataset, legalDataset] }; From 253dd4c482f07d8c99808017edde0e1cde6ec450 Mon Sep 17 00:00:00 2001 From: Robert Date: Tue, 10 Dec 2024 15:30:22 -0500 Subject: [PATCH 3/6] Update MURS templates to include MURS citation filters --- .../layouts/legal-doc-search-results.jinja | 29 ++++- .../templates/legal-search-results-murs.jinja | 123 +++++++++++------- 2 files changed, 102 insertions(+), 50 deletions(-) diff --git a/fec/legal/templates/layouts/legal-doc-search-results.jinja b/fec/legal/templates/layouts/legal-doc-search-results.jinja index 9e315f138..1ea8e6c00 100644 --- a/fec/legal/templates/layouts/legal-doc-search-results.jinja +++ b/fec/legal/templates/layouts/legal-doc-search-results.jinja @@ -100,7 +100,8 @@ const tag = this.getAttribute('data-tag'); const url = new URL(window.location); - // Remove tags logic + // "Remove tags" logic + // Assigns a URL to each remove/"⤫" button that removes its own value from the URL if (tag === 'query') { url.searchParams.delete('search'); url.searchParams.delete('search_exclude'); @@ -135,6 +136,32 @@ } else if (tag && tag == 'secondary_subject_id') { // Check if tag is not null or undefined // Remove 'secondary_subject_id' from the URL url.searchParams.delete('secondary_subject_id'); + } else if (tag && tag == 'case_citation_require_all') { + url.searchParams.delete('case_citation_require_all'); + } else if (tag && tag.startsWith('case_regulatory_citation')) { + // Get the 0-indexed position of this item + const index = tag.split('_').at(-1); + // Hold all the case_regulatory_citation from the URL + const citations = url.searchParams.getAll('case_regulatory_citation'); + // Remove all of the case_regulatory_citation from the URL + url.searchParams.delete('case_regulatory_citation'); + // For all of the held citations, + citations.forEach((cite, i) => { + // Add all but this element back to the URL + if (i != index) url.searchParams.append('case_regulatory_citation', cite); + }); + } else if (tag && tag.startsWith('case_statutory_citation')) { + // Get the 0-indexed position of this item + const index = tag.split('_').at(-1); + // Hold all the case_statutory_citation from the URL + const citations = url.searchParams.getAll('case_statutory_citation'); + // Remove all of the case_statutory_citation from the URL + url.searchParams.delete('case_statutory_citation'); + // For all of the held citations, + citations.forEach((cite, i) => { + // Add all but this element back to the URL + if (i != index) url.searchParams.append('case_statutory_citation', cite); + }); } else { url.searchParams.delete(tag); } diff --git a/fec/legal/templates/legal-search-results-murs.jinja b/fec/legal/templates/legal-search-results-murs.jinja index f444aece7..0d92bdfb9 100644 --- a/fec/legal/templates/legal-search-results-murs.jinja +++ b/fec/legal/templates/legal-search-results-murs.jinja @@ -2,6 +2,7 @@ {% import 'macros/legal.jinja' as legal %} {% import 'macros/filters/checkbox.jinja' as checkbox %} {% import 'macros/filters/dropdown-json.jinja' as dropdown %} +{% import 'macros/filters/typeahead-filter.jinja' as typeahead %} {% set document_type_display_name = 'Closed Matters Under Review' %} {% block header %} @@ -26,43 +27,44 @@ Document Type {% for category_id, category_label in mur_document_categories.items() %}
- - + +
{% endfor %} -
- Case open date range -
-
- - -
-
-
-
- - +
+
+ + +
+
+ Case open date range +
+
+ + +
+
-
+
+ + +
-
-
- Case close date range -
-
- - -
-
-
-
- - +
+ Case close date range +
+
+ + +
+
-
+
+ + +
-
-
-
- -
{{ checkbox.checkbox_dropdown_multiple( 'mur_disposition_category_id', 'Final disposition', @@ -72,31 +74,35 @@ prefix='mur_disposition_category_id', show_tooltip_text='Final disposition does not search archived cases' ) }} + {{ dropdown.select_json( + 'primary_subject_id', + 'Case subject', + options=constants.primary_subject_ids, + default="", + show_tooltip_text='Case subject does not search archived cases' + ) }} + {{ dropdown.select_json_indentation( + 'secondary_subject_id', + 'Secondary case subject', + options=constants.secondary_subject_placeholder, + default="" + ) }} +
- {{ - dropdown.select_json( - 'primary_subject_id', - 'Case subject', - options=constants.primary_subject_ids, - default="", - show_tooltip_text='Case subject does not search archived cases' - - ) - }} - {{ - dropdown.select_json_indentation( - 'secondary_subject_id', - 'Secondary case subject', - options=constants.secondary_subject_placeholder, - default="" - ) - }} + +
+ + + + + + {{ typeahead.field('case_regulatory_citation', 'Regulatory citation', False, dataset='caseRegulatoryCitations', allow_text=False) }} + {{ typeahead.field('case_statutory_citation', 'Statutory citation', False, dataset='caseStatutoryCitations', allow_text=False) }}
- {% endblock %} {% block message %} @@ -167,6 +173,25 @@ {% endif %} {% endif %} + {% if case_citation_require_all %} +
  • +
    Cases with all citations
    +
  • + {% endif %} + {% if case_regulatory_citation %} +
  • + {% for case_reg_citation in case_regulatory_citation %} +
    {{ case_reg_citation }}
    + {% endfor %} +
  • + {% endif %} + {% if case_statutory_citation %} +
  • + {% for case_stat_citation in case_statutory_citation %} +
    {{ case_stat_citation }}
    + {% endfor %} +
  • + {% endif %}
    From 67655cab0624a5e836d7b5d0c3f4f33f71c9dae2 Mon Sep 17 00:00:00 2001 From: Robert Date: Tue, 10 Dec 2024 15:30:46 -0500 Subject: [PATCH 4/6] Make legal pagination more human-readable and add MURs citations --- .../templates/partials/legal-pagination.jinja | 87 ++++++++++++++++++- 1 file changed, 84 insertions(+), 3 deletions(-) diff --git a/fec/legal/templates/partials/legal-pagination.jinja b/fec/legal/templates/partials/legal-pagination.jinja index d67a8b991..23fea957a 100644 --- a/fec/legal/templates/partials/legal-pagination.jinja +++ b/fec/legal/templates/partials/legal-pagination.jinja @@ -30,8 +30,35 @@ {% set start_page = 1 %} {% endif %} + {#- Previous page button -#} {% if result_type != 'advisory_opinions' and current_page > 1 %} - + {% elif result_type == 'advisory_opinions' and current_page > 1 %} {{ page }} + {{ page }} {% elif result_type == 'advisory_opinions' %} Next + {% elif result_type == 'advisory_opinions' and offset + limit < total_all %} diff --git a/fec/legal/templates/partials/legal-search-results-advisory-opinion.jinja b/fec/legal/templates/partials/legal-search-results-advisory-opinion.jinja index f55cbd280..bef149c2a 100644 --- a/fec/legal/templates/partials/legal-search-results-advisory-opinion.jinja +++ b/fec/legal/templates/partials/legal-search-results-advisory-opinion.jinja @@ -15,7 +15,7 @@
    - AO {{ advisory_opinion.ao_no }}
    {{ advisory_opinion.name }}
    + AO {{ advisory_opinion.ao_no }}
    {{ advisory_opinion.name }}
    {% if advisory_opinion.status == 'Pending' %}
    diff --git a/fec/legal/templates/partials/legal-search-results-afs.jinja b/fec/legal/templates/partials/legal-search-results-afs.jinja index 16e2ae960..d29bd0685 100644 --- a/fec/legal/templates/partials/legal-search-results-afs.jinja +++ b/fec/legal/templates/partials/legal-search-results-afs.jinja @@ -15,7 +15,7 @@
    - AF #{{ admin_fine.no }}
    + AF #{{ admin_fine.no }}
    {{ admin_fine.name.upper() }} {% if admin_fine.highlights %}
    Keyword match:
    diff --git a/fec/legal/templates/partials/legal-search-results-mur.jinja b/fec/legal/templates/partials/legal-search-results-mur.jinja index 770f3a09c..b39606dfb 100644 --- a/fec/legal/templates/partials/legal-search-results-mur.jinja +++ b/fec/legal/templates/partials/legal-search-results-mur.jinja @@ -20,14 +20,14 @@
    {% if mur.mur_type == 'current' %} - + {{ mur.name|upper }} {% elif mur.no == ARCHIVED_MUR_EXCEPTION and mur.mur_type == 'archived'%} - + {{ mur.mur_name|upper }} {% else %} - + {{ mur.mur_name|upper }} {% endif %} From d9dee3ac885b33447571a5305362d8874d5214eb Mon Sep 17 00:00:00 2001 From: Robert Date: Wed, 11 Dec 2024 11:50:22 -0500 Subject: [PATCH 6/6] Add the date range tooltip for MURs filters --- fec/legal/templates/legal-search-results-murs.jinja | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fec/legal/templates/legal-search-results-murs.jinja b/fec/legal/templates/legal-search-results-murs.jinja index 9892ddca0..e9772cc8b 100644 --- a/fec/legal/templates/legal-search-results-murs.jinja +++ b/fec/legal/templates/legal-search-results-murs.jinja @@ -41,7 +41,13 @@ {% endfor %}
    - Document date range + +
    + +
    +

    Document date range does not search archived cases

    +
    +