Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[scorecards] fix the show specific council section page dropdown #598

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions scoring/static/scoring/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,27 @@ forEachElement('.js-methodology-council-autocomplete', function(input){
});
});

forEachElement('.js-section-council-autocomplete', function(input){
var ac = new Awesomplete(
input,
{
list: councils.map(function(council){
return council.name;
}),
minChars: 3,
autoFirst: true
}
);
input.parentNode.addEventListener('awesomplete-selectcomplete', function(data){
var council = findItem(councils, {'name': data.text });
var sp = new URLSearchParams(window.location.search)
sp.delete('type');
sp.delete('council');
sp.append('council', council.slug);
window.location.href = window.location.pathname + '?' + sp.toString() + '#questions';
});
});

function ajaxLoadCouncilTypeScorecard(url) {
var selectors = [
'#council-type-filter',
Expand Down
2 changes: 1 addition & 1 deletion scoring/templates/scoring/section.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ <h3 class="mb-4" id="questions">Questions in this section</h3>
<div class="col-lg-6">
<div class="bg-primary-100 p-3 mb-4 border rounded">
<label for="questions-council-name" class="d-block mb-2">Show questions for a specific council</label>
<input class="form-control searchbar js-methodology-council-autocomplete" type="search" placeholder="Council name" aria-label="Council name" id="questions-council-name">
<input class="form-control searchbar js-section-council-autocomplete" type="search" placeholder="Council name" aria-label="Council name" id="questions-council-name">
<p class="mt-3 mt-lg-4 mb-2">Or show questions by type of council</p>
<div class="d-flex flex-wrap gap-1">
<a href="{% url 'scoring:section' section.code %}?type=single#questions" class="btn btn-outline-primary btn-sm is--with-label" data-methodology-switch-council-type="single" data-bs-toggle="tooltip" data-bs-placement="top"
Expand Down