diff --git a/fec/data/constants.py b/fec/data/constants.py index a669530b3..76d29678f 100644 --- a/fec/data/constants.py +++ b/fec/data/constants.py @@ -373,75 +373,27 @@ primary_category_keys = ['primary_category_id', 'primary_category_name'] sub_category_keys = ['sub_category_id', 'sub_category_name'] -audit_primary_categories_options = [ - { - "primary_category_id": 'all', - "primary_category_name": 'All' - }, - { - "primary_category_id": '2', - "primary_category_name": 'Allocation Issues' - }, - { - "primary_category_id": '3', - "primary_category_name": 'Disclosure' - }, - { - "primary_category_id": '5', - "primary_category_name": 'Excessive Contributions' - }, - { - "primary_category_id": '1', - "primary_category_name": 'Failure to File Reports/Schedules/Notices' - }, - { - "primary_category_id": '8', - "primary_category_name": 'Loans' - }, - { - "primary_category_id": '7', - "primary_category_name": 'Misstatement of Financial Activity' - }, - { - "primary_category_id": '14', - "primary_category_name": 'Net Outstanding Campaign/Convention ' + 'Expenditures/Obligations' - }, - { - "primary_category_id": '16', - "primary_category_name": 'No Findings or Issues/Not a Committee' - }, - { - "primary_category_id": '9', - "primary_category_name": 'Other' - }, - { - "primary_category_id": '15', - "primary_category_name": 'Payments/Disgorgements' - }, - { - "primary_category_id": '6', - "primary_category_name": 'Prohibited Contributions' - }, - { - "primary_category_id": '4', - "primary_category_name": 'Recordkeeping' - }, - { - "primary_category_id": '17', - "primary_category_name": 'Referred Findings Not Listed' - }, - { - "primary_category_id": '13', - "primary_category_name": 'Repayment to US Treasury' - } -] +audit_primary_categories_options = OrderedDict([ + ('all', 'All'), + ('2', 'Allocation Issues'), + ('3', 'Disclosure'), + ('5', 'Excessive Contributions'), + ('1', 'Failure to File Reports/Schedules/Notices'), + ('8', 'Loans'), + ('7', 'Misstatement of Financial Activity'), + ('14', 'Net Outstanding Campaign/Convention ' + 'Expenditures/Obligations'), + ('16', 'No Findings or Issues/Not a Committee'), + ('9', 'Other'), + ('15', 'Payments/Disgorgements'), + ('6', 'Prohibited Contributions'), + ('4', 'Recordkeeping'), + ('17', 'Referred Findings Not Listed'), + ('13', 'Repayment to US Treasury') +]) -audit_sub_categories_options = [ - { - "sub_category_id": 'all', - "sub_category_name": ' ' - } -] +audit_sub_categories_options = OrderedDict([ + ('all', 'All') +]) table_columns = OrderedDict([ @@ -1036,3 +988,59 @@ ('7', 'Conciliation: Pre Probable Cause'), ('6', 'Conciliation: Probable Cause'), ]) + + +primary_subject_ids = { + "": "All", + "1": "Allocation", + "2": "Committees", + "3": "Contributions", + "4": "Disclaimer", + "5": "Disbursements", + "6": "Electioneering", + "7": "Expenditures", + "8": "Express Advocacy", + "9": "Foreign Nationals", + "10": "Fraudulent misrepresentation", + "11": "Issue Advocacy", + "12": "Knowing and Willful", + "13": "Loans", + "14": "Non-federal", + "15": "Other", + "16": "Personal use", + "17": "Presidential", + "18": "Reporting", + "19": "Soft Money", +} + +secondary_subject_placeholder = { + "": "All", +} + +secondary_subject_ids = { + "2": { + "1": "Candidate", + "2": "Multi-candidate", + "3": "Non-Party", + "4": "PAC", + "5": "Party", + "6": "Political", + "7": "Presidential", + }, + "3": { + "8": "Corporations", + "9": "Excessive", + "10": "Exemptions", + "11": "In the name of another", + "12": "Labor Unions", + "13": "Limitations", + "14": "National Bank", + "15": "Prohibited", + }, + "7": { + "10": "Exemptions", + "16": "Coordinated", + "17": "Limits", + "18": "Prohibitions", + } +} diff --git a/fec/data/templates/macros/filters/dropdown-json.jinja b/fec/data/templates/macros/filters/dropdown-json.jinja index 2a8c254ca..eee85eabf 100644 --- a/fec/data/templates/macros/filters/dropdown-json.jinja +++ b/fec/data/templates/macros/filters/dropdown-json.jinja @@ -1,23 +1,30 @@ -{% macro select_json(name, label, keys, options={}, default=none) %} +{% macro select_json(name, label, keys, options={}, default=none, show_tooltip_text='') %}
- + + {% if show_tooltip_text != '' %} +
+ +
+

{{ show_tooltip_text }}

+
+
+ {% endif %}
{% endmacro %} - {% macro select_json_indentation(name, label, keys, options={}, default=none) %}
diff --git a/fec/fec/static/scss/components/_filters.scss b/fec/fec/static/scss/components/_filters.scss index 9a51664ac..80506682d 100644 --- a/fec/fec/static/scss/components/_filters.scss +++ b/fec/fec/static/scss/components/_filters.scss @@ -240,6 +240,7 @@ $filter-button-width: u(4.6rem); } select { + width: 100%; max-width: 26rem; } @@ -250,12 +251,27 @@ $filter-button-width: u(4.6rem); } &.sub--filter--indent { - border-left: 3px solid $gray; + position: relative; padding-left: 5%; - - select, input { + + select { width: 100%; } + + &::before { + display: block; + position: absolute; + left: 0; + content: ''; + height: 6rem; + border-left: 3px solid $gray; + } + + .filter__message { + border-left: 3px solid $gray; + padding: 5% 0 0 5%; + margin: -5% 0 4% -5.2%; + } } } diff --git a/fec/legal/templates/layouts/legal-doc-search-results.jinja b/fec/legal/templates/layouts/legal-doc-search-results.jinja index 63d4e4cee..7bce67b20 100644 --- a/fec/legal/templates/layouts/legal-doc-search-results.jinja +++ b/fec/legal/templates/layouts/legal-doc-search-results.jinja @@ -134,15 +134,81 @@ url.searchParams.append('mur_disposition_category_id', cat); } }); + } else if (tag && tag == 'primary_subject_id') { // Check if tag is not null or undefined + // Get the index from the tag + // const selectedCategories = url.searchParams.getAll('primary_subject_id'); + // // Remove all instances of 'case_doc_category_id' from the URL + url.searchParams.delete('primary_subject_id'); + url.searchParams.delete('secondary_subject_id'); + } else if (tag && tag == 'secondary_subject_id') { // Check if tag is not null or undefined + // // Get the index from the tag + // const selectedCategories = url.searchParams.getAll('primary_subject_id'); + // Remove all instances of 'case_doc_category_id' from the URL + url.searchParams.delete('secondary_subject_id'); } else { // For all other tags, remove the corresponding search parameter url.searchParams.delete(tag); } - + + // Go back to first page in case there are fewer pages in new result set + url.searchParams.set('offset', 0) // Redirect to the updated URL window.location = url.toString(); }); }); + + // JS for subject MUR/ADR selects + // The window.context is declared in the child templates (MURm, ADR(maybe later)) + if (window.context && window.context.result_type == 'murs') { + const secondary_subject_ids = window.context.secondary_subject_ids; + const primary_subject_id = window.context.primary_subject_id; + const secondary_subject_id = window.context.secondary_subject_id; + + const subject_select = document.getElementById('primary_subject_id'); + const secondary_select_div = document.querySelector("[data-modifies-filter='secondary_subject_id']"); + const secondary_select = document.getElementById('secondary_subject_id'); + + // Populate secondary select on page load + load_secondary_select(primary_subject_id); + + // Add aria attribute to selected option in primary select + Array.from(subject_select.options).forEach(option => { + if (option.value == primary_subject_id) { + option.setAttribute('aria-selected', 'true'); + }; + }); + + // Load secondary select, upon change of primary select + subject_select.addEventListener('change', (event) => { + const selected_id = event.target.value; + load_secondary_select(selected_id); + }); + + function load_secondary_select(id){ + // First, reset the secondary select to default + secondary_select.replaceChildren(new Option('All', "", false, true)) + // Show and populate secondary select options, if applicable + if (id in secondary_subject_ids) { + // Show secondary select + secondary_select_div.style.display = 'block'; + // Append secondary select options + for (const [key, value] of Object.entries(secondary_subject_ids[id])) { + //If there is a current secondary_subject_id, append it as the selected option + if (key == secondary_subject_id) { + secondary_select.append(new Option(value, key, true, true)); + // Add aria-selected to that option + secondary_select.options[secondary_select.selectedIndex].setAttribute('aria-selected', 'true'); + // Append other options, unselected + } else { + secondary_select.append(new Option(value, key)); + }; + }; + + } else { + secondary_select_div.style.display = 'none'; + }; + }; + } }); {% endblock %} diff --git a/fec/legal/templates/legal-search-results-adrs.jinja b/fec/legal/templates/legal-search-results-adrs.jinja index 3e3849542..c9da5d43d 100644 --- a/fec/legal/templates/legal-search-results-adrs.jinja +++ b/fec/legal/templates/legal-search-results-adrs.jinja @@ -57,13 +57,11 @@ - -
- -
+ +
+
{% endblock %} - {% block message %}
@@ -130,3 +128,7 @@ {% include 'partials/legal-pagination.jinja' %} {% endwith %} {% endblock %} +{% block scripts %} + {# super loads scripts from parent #} + {{ super() }} +{% endblock %} diff --git a/fec/legal/templates/legal-search-results-murs.jinja b/fec/legal/templates/legal-search-results-murs.jinja index cb1af56a5..f444aece7 100644 --- a/fec/legal/templates/legal-search-results-murs.jinja +++ b/fec/legal/templates/legal-search-results-murs.jinja @@ -1,6 +1,7 @@ {% extends "layouts/legal-doc-search-results.jinja" %} {% import 'macros/legal.jinja' as legal %} {% import 'macros/filters/checkbox.jinja' as checkbox %} +{% import 'macros/filters/dropdown-json.jinja' as dropdown %} {% set document_type_display_name = 'Closed Matters Under Review' %} {% block header %} @@ -71,6 +72,25 @@ 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="" + ) + }}
@@ -137,6 +157,16 @@ {% endfor %} {% endif %} + {% if primary_subject_id or secondary_subject_id_name %} +
  • + {% if primary_subject_id_name and primary_subject_id %} +
    {{ primary_subject_id_name }}
    + {% endif %} + {% if secondary_subject_id_name %} +
    {{ secondary_subject_id_name }}
    + {% endif %} +
  • + {% endif %}
    @@ -155,6 +185,9 @@ {% endblock %} {% block scripts %} + {# super loads scripts from parent #} {{ super() }}