Skip to content

Commit

Permalink
[Legislation explorer] Select all children filters
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielastrezea committed Jun 21, 2022
1 parent 01a82fe commit 03084c1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
21 changes: 21 additions & 0 deletions lcc/src/js/legislation_filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,27 @@ $(document).ready(function() {
});
});

$('.classification-parrent').change(function(){
if(this.checked) {
$(this).closest('li').find('input').prop('checked', true);
$(this).closest('li').find('input').each(function(i, input){
let $input = $(input);
classifications.push($input.val())
});
payload['classifications'] = classifications;
} else {
$(this).closest('li').find('input').prop('checked', false);
$(this).closest('li').find('input').each(function(i, input){
let $input = $(input);
let index = payload['classifications'].indexOf($input.val());
if (index > -1) {
payload['classifications'].splice(index, 1);
}
});
}
$('.classification-parrent').val(this.checked);
});

// Handle search and filters

$('#textSearchInput').on('change', function() {
Expand Down
3 changes: 2 additions & 1 deletion lcc/src/less/legislation-explorer.less
Original file line number Diff line number Diff line change
Expand Up @@ -236,5 +236,6 @@ li.select-deselect {
}

.logical_cat_name {
margin-bottom: 5px;
margin-bottom: 10px;
margin-top: 15px;
}
8 changes: 4 additions & 4 deletions lcc/templates/legislation/explorer.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
{% include "./_laws.html" %}
</div>
<div class="page-container half viz-container right">
<h4>Filter legislation</h4>
<h3>Filter legislation</h3>
<div class="filter-item list-container" id="classificationsSelectWrapper">
<h5>Select Legal Area</h5>
<small class="form-text text-muted">
Expand All @@ -48,14 +48,14 @@ <h5>Select Legal Area</h5>
<form autocomplete="off">
<ul class="logical_cat_list">
{% for logical_cat in logical_categories %}
<span class="logical_cat_name">{{ logical_cat.name }}</span>
<li class="logical_cat_section">
<ul class="round" id="classificationsSelect">
<h4 class="logical_cat_name">{{ logical_cat.name }}</h4>
{% for top_class in logical_cat.taxonomy_classifications.all %}
<li class="first-level level">
{% with top_class.get_children as second_classifications %}
<span class="list-header">
<input id='classification-{{ top_class.pk }}' value='{{ top_class.pk }}' type='checkbox'/>
<input class="classification-parrent" id='classification-{{ top_class.pk }}' value='{{ top_class.pk }}' type='checkbox'/>
<label for='classification-{{ top_class.pk }}'>{{ top_class.name }}
</label>
{% if second_classifications %}
Expand All @@ -72,7 +72,7 @@ <h5>Select Legal Area</h5>
{% with second_class.get_children as third_classifications %}
<li>
<span class="list-header">
<input id='classification-{{ second_class.pk }}' value='{{ second_class.pk }}' type='checkbox'/>
<input class="classification-parrent" id='classification-{{ second_class.pk }}' value='{{ second_class.pk }}' type='checkbox'/>
<label for="classification-{{ second_class.pk }}">{{ second_class.name }}</label>
{% if third_classifications %}
<i class="fa fa-caret-down caret" aria-hidden="true"></i>
Expand Down

0 comments on commit 03084c1

Please sign in to comment.