Skip to content

Commit

Permalink
JavaScript: Hide has-selected-item when input value is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
francoisfreitag committed May 23, 2024
1 parent aa0ae90 commit 8f250be
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion itou/static/js/htmx_dropdown_filter.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
htmx.onLoad((target) => {
function toggleHasSelectedItem() {
const dropdown = this.closest('.dropdown');
this.classList.toggle('has-selected-item', dropdown.querySelectorAll('input:checked').length);
this.classList.toggle('has-selected-item', dropdown.querySelector('input:checked:not([value=""])'));
}
target.querySelectorAll('.btn-dropdown-filter.dropdown-toggle').forEach((dropdownFilter) => {
dropdownFilter.addEventListener('hide.bs.dropdown', toggleHasSelectedItem);
Expand Down
2 changes: 1 addition & 1 deletion itou/www/approvals_views/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class ApprovalExpiry(TextChoices):
LESS_THAN_1_MONTH = "1", "Moins d'1 mois"
LESS_THAN_3_MONTHS = "3", "Moins de 3 mois"
LESS_THAN_7_MONTHS = "7", "Moins de 7 mois"
ALL = "0", "Tous"
ALL = "", "Tous"


class ApprovalForm(forms.Form):
Expand Down

0 comments on commit 8f250be

Please sign in to comment.