From 6c521903ede11e2a886c223d34b5a0da91e1dd73 Mon Sep 17 00:00:00 2001 From: John Carroll Date: Fri, 18 Oct 2024 14:44:22 -0400 Subject: [PATCH 1/7] final disp. filter for mur, constants, template js, parent template js and views --- fec/data/constants.py | 67 +++++++++++++++++ .../static/scss/components/_dropdowns.scss | 4 ++ .../layouts/legal-doc-search-results.jinja | 14 ++++ .../templates/legal-search-results-murs.jinja | 71 ++++++++++++++++++- fec/legal/views.py | 23 ++++++ 5 files changed, 178 insertions(+), 1 deletion(-) diff --git a/fec/data/constants.py b/fec/data/constants.py index cf48e73305..b47e8de87b 100644 --- a/fec/data/constants.py +++ b/fec/data/constants.py @@ -982,3 +982,70 @@ ['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'] } + +pac_party_types = OrderedDict([ + ('N', 'PAC - nonqualified'), + ('Q', 'PAC - qualified'), + ('V', 'Hybrid PAC - nonqualified'), + ('W', 'Hybrid PAC - qualified'), + ('P', 'Party - nonqualified'), + ('Y', 'Party - qualified'), + ('Z', 'National party nonfederal account'), + ('U', 'Single candidate independent expenditure'), + ('O', 'Super PAC (independent expenditure only'), + ('I', 'Independent expenditure filer (not a committee)') +]) + +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..479e2f5091 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,6 +58,9 @@ + + {{ 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') }} +
@@ -114,6 +118,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 +182,63 @@ 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'); + } + } + + // Remove the loading label GIF on the filter panel + $('button.is-loading, label.is-loading').removeClass('is-loading'); + //$('.dropdown__item--selected.is-checked').css('pointer-events','none') + +})(); +}, 500) + {% endblock %} diff --git a/fec/legal/views.py b/fec/legal/views.py index 72becfa1db..16a4a633cc 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,19 @@ 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 variables + mur_disposition_category_ids_display = constants.mur_disposition_category_ids + mur_disposition_category_ids_list = {**mur_disposition_category_ids_display, **constants.suggested_mur_disposition_category_ids} + selected_mur_disposition_names = [mur_disposition_category_ids_list.get(id) for id in mur_disposition_category_ids] + selected_mur_disposition_categories = dict((k, mur_disposition_category_ids_list[k]) for k in mur_disposition_category_ids) + + selected_mur_disposition_category_query = ['mur_disposition_category_id-'+i for i in mur_disposition_category_ids] + suggested_mur_disposition_category_ids = constants.suggested_mur_disposition_category_ids + # For 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 +365,15 @@ 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, + 'selected_mur_disposition_categories': selected_mur_disposition_categories, + 'mur_disposition_category_ids_list': mur_disposition_category_ids_list, + 'selected_mur_disposition_names': selected_mur_disposition_names, + 'mur_disposition_category_ids': mur_disposition_category_ids, + 'selected_mur_disposition_category_query': selected_mur_disposition_category_query, + '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, }) From d624716c69bad2071418eecefb09b46f9686f312 Mon Sep 17 00:00:00 2001 From: John Carroll Date: Fri, 18 Oct 2024 14:49:42 -0400 Subject: [PATCH 2/7] rm extra dict in constants --- fec/data/constants.py | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/fec/data/constants.py b/fec/data/constants.py index b47e8de87b..a669530b39 100644 --- a/fec/data/constants.py +++ b/fec/data/constants.py @@ -983,19 +983,6 @@ 'MO', 'NV', 'NH', 'NY', 'NC', 'ND', 'OH', 'OK', 'OR', 'PA', 'SC', 'SD', 'UT', 'VT', 'WA', 'WI'] } -pac_party_types = OrderedDict([ - ('N', 'PAC - nonqualified'), - ('Q', 'PAC - qualified'), - ('V', 'Hybrid PAC - nonqualified'), - ('W', 'Hybrid PAC - qualified'), - ('P', 'Party - nonqualified'), - ('Y', 'Party - qualified'), - ('Z', 'National party nonfederal account'), - ('U', 'Single candidate independent expenditure'), - ('O', 'Super PAC (independent expenditure only'), - ('I', 'Independent expenditure filer (not a committee)') -]) - mur_disposition_category_ids = OrderedDict([ ('1', 'Approved by Commission'), ('2', 'Approved In Part Recs.'), From dc2e5301375c10e5bfb4d108d7593ce705bde931 Mon Sep 17 00:00:00 2001 From: John Carroll Date: Fri, 18 Oct 2024 18:42:35 -0400 Subject: [PATCH 3/7] rm unused vars --- .../templates/legal-search-results-murs.jinja | 2 +- fec/legal/views.py | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/fec/legal/templates/legal-search-results-murs.jinja b/fec/legal/templates/legal-search-results-murs.jinja index 479e2f5091..03d807853f 100644 --- a/fec/legal/templates/legal-search-results-murs.jinja +++ b/fec/legal/templates/legal-search-results-murs.jinja @@ -60,7 +60,7 @@ {{ 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') }} - +
    diff --git a/fec/legal/views.py b/fec/legal/views.py index 16a4a633cc..560aaafcf5 100644 --- a/fec/legal/views.py +++ b/fec/legal/views.py @@ -324,14 +324,16 @@ def legal_doc_search_mur(request): mur_document_category_names = [mur_document_categories.get(id) for id in case_doc_category_ids] # mur_disposition_category variables + # Dropdown options mur_disposition_category_ids_display = constants.mur_disposition_category_ids - mur_disposition_category_ids_list = {**mur_disposition_category_ids_display, **constants.suggested_mur_disposition_category_ids} - selected_mur_disposition_names = [mur_disposition_category_ids_list.get(id) for id in mur_disposition_category_ids] - selected_mur_disposition_categories = dict((k, mur_disposition_category_ids_list[k]) for k in mur_disposition_category_ids) - - selected_mur_disposition_category_query = ['mur_disposition_category_id-'+i for i in mur_disposition_category_ids] + # Suggested items above dropdown suggested_mur_disposition_category_ids = constants.suggested_mur_disposition_category_ids - # For JavaScript + # Combine the dropdown options and suggested + mur_disposition_category_ids_list = {**mur_disposition_category_ids_display, **suggested_mur_disposition_category_ids} + # Iterate the combined list to find 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, } @@ -365,13 +367,10 @@ 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, - 'selected_mur_disposition_categories': selected_mur_disposition_categories, - 'mur_disposition_category_ids_list': mur_disposition_category_ids_list, 'selected_mur_disposition_names': selected_mur_disposition_names, - 'mur_disposition_category_ids': mur_disposition_category_ids, - 'selected_mur_disposition_category_query': selected_mur_disposition_category_query, '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, }) From 0464088a149f3748d74da1a044d0dbf585b24b3a Mon Sep 17 00:00:00 2001 From: John Carroll Date: Sat, 19 Oct 2024 03:02:12 -0400 Subject: [PATCH 4/7] add pagination --- fec/legal/templates/partials/legal-pagination.jinja | 6 +++--- fec/legal/views.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fec/legal/templates/partials/legal-pagination.jinja b/fec/legal/templates/partials/legal-pagination.jinja index a78a184b97..84868960bd 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 560aaafcf5..1406d34614 100644 --- a/fec/legal/views.py +++ b/fec/legal/views.py @@ -367,10 +367,10 @@ 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, - + #'suggested_mur_disposition_category_ids': suggested_mur_disposition_category_ids, 'is_loading': True, # Indicate that the page is loading initially "context_vars": context_vars, }) From 2adf73dd2531715efbe7b6001fada85fa9db5817 Mon Sep 17 00:00:00 2001 From: John Carroll Date: Sat, 19 Oct 2024 03:06:44 -0400 Subject: [PATCH 5/7] rm extra & --- fec/legal/templates/partials/legal-pagination.jinja | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fec/legal/templates/partials/legal-pagination.jinja b/fec/legal/templates/partials/legal-pagination.jinja index 84868960bd..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 %} From fd84dafe1756276b78f9aa55a62e0438725ae685 Mon Sep 17 00:00:00 2001 From: John Carroll Date: Sun, 20 Oct 2024 18:30:43 -0400 Subject: [PATCH 6/7] better comments, restore commented-out var --- fec/legal/templates/legal-search-results-murs.jinja | 11 +++++++++-- fec/legal/views.py | 8 ++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/fec/legal/templates/legal-search-results-murs.jinja b/fec/legal/templates/legal-search-results-murs.jinja index 03d807853f..7ed8a50dd9 100644 --- a/fec/legal/templates/legal-search-results-murs.jinja +++ b/fec/legal/templates/legal-search-results-murs.jinja @@ -58,8 +58,15 @@ - - {{ 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') }} + + {{ 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' + ) }}
    diff --git a/fec/legal/views.py b/fec/legal/views.py index 1406d34614..78889e81b7 100644 --- a/fec/legal/views.py +++ b/fec/legal/views.py @@ -323,14 +323,14 @@ 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 variables + # 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 + # 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} - # Iterate the combined list to find selected names + # 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 @@ -370,7 +370,7 @@ def legal_doc_search_mur(request): '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, + 'suggested_mur_disposition_category_ids' : suggested_mur_disposition_category_ids, 'is_loading': True, # Indicate that the page is loading initially "context_vars": context_vars, }) From f5cbe552445664ecf2faad4cde02de3435d48806 Mon Sep 17 00:00:00 2001 From: John Carroll Date: Sun, 20 Oct 2024 19:14:35 -0400 Subject: [PATCH 7/7] add accordion for filter --- .../templates/legal-search-results-murs.jinja | 103 +++++++++--------- 1 file changed, 51 insertions(+), 52 deletions(-) diff --git a/fec/legal/templates/legal-search-results-murs.jinja b/fec/legal/templates/legal-search-results-murs.jinja index 7ed8a50dd9..290498df54 100644 --- a/fec/legal/templates/legal-search-results-murs.jinja +++ b/fec/legal/templates/legal-search-results-murs.jinja @@ -58,20 +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' - ) }} - -
    - +
    +
    + +
    + {{ 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 %} @@ -205,47 +209,42 @@ */ // 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 + 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); - } - }); - // 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'); + }); + } + // Handle singular val + else { + // find matching checkbox + queryBox = $(`input:checkbox[name="${key}"][value="${val}"]`); + // Push matching checkbox to the array + queryBoxes.push(queryBox); } - } - - // Remove the loading label GIF on the filter panel - $('button.is-loading, label.is-loading').removeClass('is-loading'); - //$('.dropdown__item--selected.is-checked').css('pointer-events','none') - -})(); -}, 500) + }); + // 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 %}