Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix "Browse Chants" page "Source" drop-down bug #1362

Merged
merged 4 commits into from
Mar 19, 2024
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
4 changes: 2 additions & 2 deletions django/cantusdb_project/main_app/templates/chant_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ <h3>Browse Chants</h3>
<label for="sourceFilter"><small><b>Source</b></small></label>
<select id="sourceFilter" name="source" class="form-control custom-select custom-select-sm">
{% comment %} <option value="">- Any -</option> {% endcomment %}
{% for source in sources %}
<option value="{{ source.id }}">{{ source.siglum }}</option>
{% for source_obj in sources %}
<option value="{{ source_obj.id }}"{% if source_obj.id == source.id %} selected {% endif %}>{{ source_obj.siglum }}</option>
{% endfor %}
</select>
</div>
Expand Down
15 changes: 8 additions & 7 deletions django/cantusdb_project/static/js/chant_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,15 @@ window.addEventListener("load", function () {
window.location.assign(url);
}

// if the source is reset, reset every selector
// if the source is reset, redirect to source/<int:source_id>/chants/
function setSource() {
url.searchParams.set('folio', '');
url.searchParams.set('feast', '');
url.searchParams.set('search_text', '');
url.searchParams.set('genre', '');
const source = sourceFilter.options[sourceFilter.selectedIndex].value;
url.searchParams.set('source', source);
const sourceId = sourceFilter.options[sourceFilter.selectedIndex].value;
url.pathname = "/source/" + sourceId + "/chants/";
url.searchParams.delete('source');
url.searchParams.delete('feast');
url.searchParams.delete('search_text');
url.searchParams.delete('genre');
url.searchParams.delete('folio');
window.location.assign(url);
}

Expand Down