Skip to content

Commit

Permalink
Merge pull request #6522 from fecgov/feature/6499-filter-final-dispos…
Browse files Browse the repository at this point in the history
…ition-MURS

MUR Final disposition filter
  • Loading branch information
patphongs authored Oct 22, 2024
2 parents b80281c + f5cbe55 commit 92acb50
Show file tree
Hide file tree
Showing 6 changed files with 175 additions and 6 deletions.
54 changes: 54 additions & 0 deletions fec/data/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
])
4 changes: 4 additions & 0 deletions fec/fec/static/scss/components/_dropdowns.scss
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@
padding-right: u(1.5rem);
cursor: default;
}

&[data-label*="mur_disposition_category_id-"] {
pointer-events: none;
}
}

&:last-of-type {
Expand Down
14 changes: 14 additions & 0 deletions fec/legal/templates/layouts/legal-doc-search-results.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
{% endif %}
</div>
</section>

{% endblock %}

{% include 'partials/legal-disclaimer.jinja' %}
Expand Down Expand Up @@ -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);
Expand Down
81 changes: 78 additions & 3 deletions fec/legal/templates/legal-search-results-murs.jinja
Original file line number Diff line number Diff line change
@@ -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 %}
Expand Down Expand Up @@ -57,10 +58,24 @@
</div>
</div>
</div>
<div class="filter">
<button type="submit" class="button button--cta u-margin--top">Apply filters</button>
</div>
<div class="js-accordion accordion--neutral" data-content-prefix="filter" data-open-first="true">
<button type="button" class="js-accordion-trigger accordion__button">Case details</button>
<div class="accordion__content">
{{ 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'
) }}
</div>
</div>
<div class="filters__inner">
<button type="submit" class="button button--cta u-margin--top">Apply filters</button>
</div>

{% endblock %}

{% block message %}
Expand Down Expand Up @@ -114,6 +129,13 @@
{% endfor %}
</li>
{% endif %}
{% if selected_mur_disposition_names and selected_mur_disposition_names | reject('equalto', none) | list %}
<li data-tag-category="disposition_category" class="tag__category">
{% for selected_mur_disposition_name in selected_mur_disposition_names %}
<div data-removable="true" class="tag__item">{{ selected_mur_disposition_name }}<button class="button js-close tag__remove" data-tag="disposition_category_{{ loop.index0 }}"><span class="u-visually-hidden">Remove</span></button></div>
{% endfor %}
</li>
{% endif %}
</ul>
</div>
</div>
Expand Down Expand Up @@ -171,5 +193,58 @@
localStorage.setItem('scrollpos', window.scrollY);
location.reload();
};
</script>
// 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)
</script>
{% endblock %}
6 changes: 3 additions & 3 deletions fec/legal/templates/partials/legal-pagination.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
{% endif %}

{% if current_page > 1 %}
<a class="paginate_button previous" href="/data/legal/search/{{ result_type }}/?search={{ query }}&case_respondents={{ case_respondents }}{% for category_id in selected_doc_category_ids %}&case_doc_category_id={{ category_id }}{% endfor %}&case_min_open_date={{ case_min_open_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 }}&offset={{ offset - limit }}&limit={{ limit }}&sort={{ sort }}#results-{{ result_type }}">Previous</a>
<a class="paginate_button previous" href="/data/legal/search/{{ result_type }}/?search={{ query }}&case_respondents={{ case_respondents }}{% for category_id in selected_doc_category_ids %}&case_doc_category_id={{ category_id }}{% endfor %}{% for category_id in mur_disposition_category_ids %}&mur_disposition_category_id={{ category_id }}{% endfor %}&case_min_open_date={{ case_min_open_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 }}&offset={{ offset - limit }}&limit={{ limit }}&sort={{ sort }}#results-{{ result_type }}">Previous</a>
{% else %}
<span class="paginate_button previous is-disabled">Previous</span>
{% endif %}
Expand All @@ -41,12 +41,12 @@
{% if page == current_page %}
<span class="paginate_button current">{{ page }}</span>
{% else %}
<a class="paginate_button" href="/data/legal/search/{{ result_type }}/?search={{ query }}&case_respondents={{ case_respondents }}{% for category_id in selected_doc_category_ids %}&case_doc_category_id={{ category_id }}{% endfor %}&case_min_open_date={{ case_min_open_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 }}&offset={{ page_offset }}&limit={{ limit }}&sort={{ sort }}#results-{{ result_type }}">{{ page }}</a>
<a class="paginate_button" href="/data/legal/search/{{ result_type }}/?search={{ query }}&case_respondents={{ case_respondents }}{% for category_id in selected_doc_category_ids %}&case_doc_category_id={{ category_id }}{% endfor %}{% for category_id in mur_disposition_category_ids %}&mur_disposition_category_id={{ category_id }}{% endfor %}&case_min_open_date={{ case_min_open_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 }}&offset={{ page_offset }}&limit={{ limit }}&sort={{ sort }}#results-{{ result_type }}">{{ page }}</a>
{% endif %}
{% endfor %}

{% if offset + limit < total_all %}
<a class="paginate_button next" href="/data/legal/search/{{ result_type }}/?search={{ query }}&case_respondents={{ case_respondents }}{% for category_id in selected_doc_category_ids %}&case_doc_category_id={{ category_id }}{% endfor %}&case_min_open_date={{ case_min_open_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 }}&offset={{ offset + limit }}&limit={{ limit }}&sort={{ sort }}#results-{{ result_type }}">Next</a>
<a class="paginate_button next" href="/data/legal/search/{{ result_type }}/?search={{ query }}&case_respondents={{ case_respondents }}{% for category_id in selected_doc_category_ids %}&case_doc_category_id={{ category_id }}{% endfor %}{% for category_id in mur_disposition_category_ids %}&mur_disposition_category_id={{ category_id }}{% endfor %}&case_min_open_date={{ case_min_open_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 }}&offset={{ offset + limit }}&limit={{ limit }}&sort={{ sort }}#results-{{ result_type }}">Next</a>
{% else %}
<span class="paginate_button next is-disabled">Next</span>
{% endif %}
Expand Down
22 changes: 22 additions & 0 deletions fec/legal/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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,
})


Expand Down

0 comments on commit 92acb50

Please sign in to comment.