diff --git a/fec/data/constants.py b/fec/data/constants.py index cf48e73305..a669530b39 100644 --- a/fec/data/constants.py +++ b/fec/data/constants.py @@ -982,3 +982,57 @@ ['AL', 'AK', 'AZ', 'AR', 'CA', 'CO', 'CT', 'FL', 'GA', 'HI', 'ID', 'IL', 'IN', 'IA', 'KS', 'KY', 'LA', 'MD', 'MO', 'NV', 'NH', 'NY', 'NC', 'ND', 'OH', 'OK', 'OR', 'PA', 'SC', 'SD', 'UT', 'VT', 'WA', 'WI'] } + +mur_disposition_category_ids = OrderedDict([ + ('1', 'Approved by Commission'), + ('2', 'Approved In Part Recs.'), + ('3', 'Approved Recs.'), + ('4', 'Case Activated'), + ('5', 'Case Activation'), + ('8', 'Dismiss and Remind'), + ('9', 'Dismissed'), + ('10', 'Dismissed - Agreement Rejected'), + ('11', 'Dismissed-Low Rated'), + ('12', 'Dismissed-Other'), + ('13', 'Dismissed-Stale'), + ('14', 'Dismiss pursuant to prosecutorial discretion'), + ('15', 'Dismiss pursuant to prosecutorial discretion, and caution'), + ('16', 'Enforcement - Disposition - Dismissed "Dismiss" - Dismiss and Caution'), + ('17', 'Failed to Approve Recs.'), + ('18', 'First General Counsel Report'), + ('19', 'Formal Discovery Authorized'), + ('20', 'Investigative Activity'), + ('21', 'Mailed to Respondent'), + ('22', 'Merged'), + ('23', 'No PCTB'), + ('24', 'No RTB'), + ('25', 'Offer from Respondent Received'), + ('26', 'Other'), + ('27', 'PC Brief'), + ('28', 'PC Conciliation Approved'), + ('30', 'PCTB Finding'), + ('31', 'Pre-PCC Commenced'), + ('32', 'Received'), + ('33', 'Received from Audit Division'), + ('34', 'Received from Commission'), + ('35', 'Received from OGC'), + ('36', 'Received from RAD'), + ('37', 'Request for Extension of Time Approved'), + ('38', 'Request for Extension of Time Approved/Denied'), + ('39', 'Request for Extension of Time Received'), + ('40', 'Response Received'), + ('41', 'RTB Finding'), + ('42', 'RTB/NFA'), + ('43', 'Settlement Agreement'), + ('44', 'Suit Authorization'), + ('45', 'Take no action'), + ('46', 'Take No Further Action'), + ('47', 'To Respondent'), + ('48', 'Transferred to ADR'), +]) + +suggested_mur_disposition_category_ids = OrderedDict([ + ('29', 'Probable Cause/NFA'), + ('7', 'Conciliation: Pre Probable Cause'), + ('6', 'Conciliation: Probable Cause'), +]) diff --git a/fec/fec/static/scss/components/_dropdowns.scss b/fec/fec/static/scss/components/_dropdowns.scss index b0924f54f2..d946aeb166 100644 --- a/fec/fec/static/scss/components/_dropdowns.scss +++ b/fec/fec/static/scss/components/_dropdowns.scss @@ -136,6 +136,10 @@ padding-right: u(1.5rem); cursor: default; } + + &[data-label*="mur_disposition_category_id-"] { + pointer-events: none; + } } &:last-of-type { diff --git a/fec/legal/templates/layouts/legal-doc-search-results.jinja b/fec/legal/templates/layouts/legal-doc-search-results.jinja index ee4c77d298..63d4e4ceeb 100644 --- a/fec/legal/templates/layouts/legal-doc-search-results.jinja +++ b/fec/legal/templates/layouts/legal-doc-search-results.jinja @@ -76,6 +76,7 @@ {% endif %} + {% endblock %} {% include 'partials/legal-disclaimer.jinja' %} @@ -120,6 +121,19 @@ url.searchParams.append('case_doc_category_id', cat); } }); + } else if (tag && tag.startsWith('disposition_category_')) { // Check if tag is not null or undefined + // Get the index from the tag + const index = tag.split('_')[2]; + // Get all selected mur_disposition_category_ids from the URL + const selectedCategories_d = url.searchParams.getAll('mur_disposition_category_id'); + // Remove all instances of 'mur_disposition_category_id' from the URL + url.searchParams.delete('mur_disposition_category_id'); + // Re-add all categories except the one at the specified index + selectedCategories_d.forEach((cat, i) => { + if (i != index) { + url.searchParams.append('mur_disposition_category_id', cat); + } + }); } else { // For all other tags, remove the corresponding search parameter 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 a3eb23408a..290498df54 100644 --- a/fec/legal/templates/legal-search-results-murs.jinja +++ b/fec/legal/templates/legal-search-results-murs.jinja @@ -1,5 +1,6 @@ {% extends "layouts/legal-doc-search-results.jinja" %} {% import 'macros/legal.jinja' as legal %} +{% import 'macros/filters/checkbox.jinja' as checkbox %} {% set document_type_display_name = 'Closed Matters Under Review' %} {% block header %} @@ -57,10 +58,24 @@ -
- +
+
+ +
+ {{ checkbox.checkbox_dropdown_multiple( + 'mur_disposition_category_id', + 'Final disposition', + selected=suggested_mur_disposition_category_ids, + options=mur_disposition_category_ids_display, + legend=True, + prefix='mur_disposition_category_id' + ) }}
+
+ +
+ {% endblock %} {% block message %} @@ -114,6 +129,13 @@ {% endfor %} {% endif %} + {% if selected_mur_disposition_names and selected_mur_disposition_names | reject('equalto', none) | list %} +
  • + {% for selected_mur_disposition_name in selected_mur_disposition_names %} +
    {{ selected_mur_disposition_name }}
    + {% endfor %} +
  • + {% endif %} @@ -171,5 +193,58 @@ localStorage.setItem('scrollpos', window.scrollY); location.reload(); }; - + + + // Allow the selected-item button to uncheck box in list above + $(document).on('click','.dropdown__item', function(e){ + const btn = $(this).find('.dropdown__item--selected'); + if (btn) { + $('#' + btn.data('label')).trigger('click'); + } + }); +/* + Checks the checkboxes for the chosen items because the existing JS does not do it as expected. + This is specific to this particular filter, but could be extended to handle all checkbox-dropdown + filters on a page as we do in tables.js with the checkFromQuery() function. +*/ + // Get the context vars from the view to use in JS + window.context = {{ context_vars|to_json|safe }}; + setTimeout(function() { + (function() { + //Create an object of the mur_disposition_category_id parameter value(s) from the request + const queryFields = {'mur_disposition_category_id':window.context.mur_disposition_category_id} + // Create an array to hold checkbox html elements + const queryBoxes = []; + // Iterate the key/vals of queryFields + $.each(queryFields, function(key, val){ + // Create a variable for matching checkbox + let queryBox; + // Handle val as array + if (Array.isArray(val)) { + // iterate the val array + val.forEach(i => { + // Find matching checkboxes + queryBox = $(`input:checkbox[name="${key}"][value="${i}"]`); + // Push matching checkboxes to the array + queryBoxes.push(queryBox); + }); + } + // Handle singular val + else { + // find matching checkbox + queryBox = $(`input:checkbox[name="${key}"][value="${val}"]`); + // Push matching checkbox to the array + queryBoxes.push(queryBox); + } + }); + // Iterate the array of matching checkboxes(queryBoxes), check by triggering click + // ...if they are not already checked + for (let box of queryBoxes) { + if (!($(box).is(':checked'))) { + $(box).trigger('click'); + } + } + })(); + }, 500) + {% endblock %} diff --git a/fec/legal/templates/partials/legal-pagination.jinja b/fec/legal/templates/partials/legal-pagination.jinja index a78a184b97..5ae590d3b4 100644 --- a/fec/legal/templates/partials/legal-pagination.jinja +++ b/fec/legal/templates/partials/legal-pagination.jinja @@ -31,7 +31,7 @@ {% endif %} {% if current_page > 1 %} - + {% else %} Previous {% endif %} @@ -41,12 +41,12 @@ {% if page == current_page %} {{ page }} {% else %} - {{ page }} + {{ page }} {% endif %} {% endfor %} {% if offset + limit < total_all %} - + {% else %} Next {% endif %} diff --git a/fec/legal/views.py b/fec/legal/views.py index 72becfa1db..78889e81b7 100644 --- a/fec/legal/views.py +++ b/fec/legal/views.py @@ -282,6 +282,7 @@ def legal_doc_search_mur(request): case_min_close_date = request.GET.get('case_min_close_date', '') 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', []) query, query_exclude = parse_query(original_query) @@ -306,6 +307,7 @@ def legal_doc_search_mur(request): case_min_close_date=case_min_close_date, case_max_close_date=case_max_close_date, case_doc_category_id=case_doc_category_ids, + mur_disposition_category_id=mur_disposition_category_ids ) # Define MUR document categories dictionary @@ -321,6 +323,21 @@ def legal_doc_search_mur(request): # Return the selected document category name mur_document_category_names = [mur_document_categories.get(id) for id in case_doc_category_ids] + # mur_disposition_category_id variables: + # Dropdown options + mur_disposition_category_ids_display = constants.mur_disposition_category_ids + # Suggested items above dropdown + suggested_mur_disposition_category_ids = constants.suggested_mur_disposition_category_ids + # Combine the dropdown options and suggested for the full list + mur_disposition_category_ids_list = {**mur_disposition_category_ids_display, **suggested_mur_disposition_category_ids} + # Get list of selected names + selected_mur_disposition_names = [mur_disposition_category_ids_list.get(id) for id in mur_disposition_category_ids] + + # Pass chosen ids to Javascript + context_vars = { + "mur_disposition_category_id": mur_disposition_category_ids, + } + for mur in results['murs']: # Process MUR subjects mur['subject_list'] = process_mur_subjects(mur) @@ -350,7 +367,12 @@ def legal_doc_search_mur(request): 'social_image_identifier': 'legal', 'selected_doc_category_ids': case_doc_category_ids, 'selected_doc_category_names': mur_document_category_names, + 'mur_disposition_category_ids': mur_disposition_category_ids, + 'selected_mur_disposition_names': selected_mur_disposition_names, + 'mur_disposition_category_ids_display': mur_disposition_category_ids_display, + 'suggested_mur_disposition_category_ids' : suggested_mur_disposition_category_ids, 'is_loading': True, # Indicate that the page is loading initially + "context_vars": context_vars, })