{% extends 'django_admin_tailwind/filters/_dropdown.html' %} {% load i18n %} {% block input_placeholder %}{% if spec.lookup_val %}{{ spec.lookup_val|length }} selected{% else %}{% trans "All" %}{% endif %}{% endblock %} {% block init %} this.open = false this.term = '' this.allChoices = [{% for choice in choices %}{% if forloop.counter0 > 0 %}{id: '{{ forloop.counter0 }}', text: '{{ choice.display }}', href: '{{ choice.query_string|iriencode }}', selected: {% if choice.selected %}true{% else %}false{% endif %}}{% if not forloop.last %},{% endif %}{% endif %}{% endfor %}] this.choices = this.allChoices this.lookupKwarg = '{{ spec.lookup_kwarg }}' {% endblock %} {% block choice_href %} let url = new URL(window.location) let params = new URLSearchParams(url.search) let lookupValue = params.get(this.lookupKwarg) if (lookupValue !== null) { params.set(this.lookupKwarg, `${lookupValue},${choice.text}`) } else { params.set(this.lookupKwarg, choice.text) } return `?${params.toString()}` {% endblock %} {% block choice_selected %} return choice.selected {% endblock %} {% block input_change %} this.choices = [] this.open = true this.term = event.target.value if (this.term === '') { this.choices = this.allChoices } else { this.allChoices.forEach(choice => { if (choice.text.toLowerCase().includes(this.term.toLowerCase())) { this.choices.push(choice) } }) } {% endblock %} {% block template_pagination %}{% endblock %}