diff --git a/aleksis/core/templates/components/chips.html b/aleksis/core/templates/components/chips.html new file mode 100644 index 0000000000000000000000000000000000000000..6f88dee5f100801f68203500f0cbdac4aed37005 --- /dev/null +++ b/aleksis/core/templates/components/chips.html @@ -0,0 +1,29 @@ +{% load material_form_internal %} + +<div> + {% for group, items in form_field|select_options %} + {% for choice, value, selected in items %} + <label class="{% if selected %} active{% endif %}"> + <input type="checkbox" + {% if value == None or value == '' %}disabled{% else %}value="{{ value }}"{% endif %} + {% if selected %} checked="checked"{% endif %} name="{{ form_field.name }}"> + <span> {{ choice }} </span> + </label> + {% endfor %} + {% endfor %} +</div> + +<script> + $(document).ready(function () { + $("input[type='checkbox']").each(function () { + $(this).addClass("chips-checkbox"); + $(this).parent("label").addClass("chips-checkbox"); + }); + + $("label.chips-checkbox > span").click(function () { + $(this).parent("label.chips-checkbox").toggleClass("active"); + let input = $(this).next("input[type='checkbox']"); + input.prop("checked", !input.prop("checked")); + }); + }); +</script> diff --git a/aleksis/core/templates/components/pagination.html b/aleksis/core/templates/components/pagination.html new file mode 100644 index 0000000000000000000000000000000000000000..5eb33cdf8fff272d766a628e1656c109ed87e32c --- /dev/null +++ b/aleksis/core/templates/components/pagination.html @@ -0,0 +1,29 @@ +{% load django_tables2 %} + +{% if page and paginator.num_pages > 1 %} + <ul class="pagination center"> + {% if page.has_previous %} + <li class="waves-effect"> + <a href="?page={{ page.previous_page_number }}" class="page-link"> + <i class="material-icons">chevron_left</i> + </a> + </li> + {% endif %} + {% if page.has_previous or page.has_next %} + {% for p in page|table_page_range:paginator %} + <li class="{% if page.number == p %} active{% endif %} waves-effect"> + <a {% if p != '...' %}href="?page={{ p }}"{% endif %}> + {{ p }} + </a> + </li> + {% endfor %} + {% endif %} + {% if page.has_next %} + <li class="waves-effect"> + <a href="?page={{ page.next_page_number }}" class="page-link"> + <i class="material-icons">chevron_right</i> + </a> + </li> + {% endif %} + </ul> +{% endif %} diff --git a/aleksis/core/templates/search/search.html b/aleksis/core/templates/search/search.html index d463f1569793168d6644c80a1dc63fe60cb06234..caff1cc6f62f30c67dcb0e2fe082dfa08db389a8 100644 --- a/aleksis/core/templates/search/search.html +++ b/aleksis/core/templates/search/search.html @@ -14,18 +14,7 @@ <input type="text" name="{{ form.q.name }}" id="{{ form.q.id }}" value="{% firstof form.q.value "" %}" placeholder="{% trans "Search Term" %}"> - <div> - {% for group, items in form.models|select_options %} - {% for choice, value, selected in items %} - <label class="{% if selected %} active{% endif %}"> - <input type="checkbox" - {% if value == None or value == '' %}disabled{% else %}value="{{ value }}"{% endif %} - {% if selected %} checked="checked"{% endif %} name="{{ form.models.name }}"> - <span> {{ choice }} </span> - </label> - {% endfor %} - {% endfor %} - </div> + {% include "components/chips.html" with form_field=form.models %} <p> <button type="submit" class="btn waves-effect waves-light green"> @@ -61,14 +50,20 @@ </a> </li> {% else %} - <li class="disabled"><a href="#"><i class="material-icons">chevron_left</i></a></li> + <li class="disabled"> + <a href="#"><i class="material-icons">chevron_left</i></a> + </li> {% endif %} {% for page_num in page.paginator.page_range %} {% if page.number == page_num %} - <li class="active"><a href="#">{{ page_num }}</a></li> + <li class="active"> + <a href="#">{{ page_num }}</a> + </li> {% else %} - <li class="waves-effect"><a href="?q={{ query }}&page={{ page_num }}">{{ page_num }}</a></li> + <li class="waves-effect"> + <a href="?q={{ query }}&page={{ page_num }}">{{ page_num }}</a> + </li> {% endif %} {% endfor %} @@ -79,7 +74,9 @@ </a> </li> {% else %} - <li class="disabled"><a href="#"><i class="material-icons">chevron_right</i></a></li> + <li class="disabled"> + <a href="#"><i class="material-icons">chevron_right</i></a> + </li> {% endif %} </ul> {% endif %} @@ -95,19 +92,4 @@ </form> - - <script> - $(document).ready(function () { - $("input[type='checkbox']").each(function () { - $(this).addClass("chips-checkbox"); - $(this).parent("label").addClass("chips-checkbox"); - }); - - $("label.chips-checkbox > span").click(function () { - $(this).parent("label.chips-checkbox").toggleClass("active"); - let input = $(this).next("input[type='checkbox']"); - input.prop("checked", !input.prop("checked")); - }); - }); - </script> {% endblock %}