mirror of https://github.com/interlegis/sigi.git
Sesostris Vieira
3 years ago
4 changed files with 83 additions and 28 deletions
@ -1,13 +1,11 @@ |
|||
{% load i18n %} |
|||
{% with choice=choices.0 %} |
|||
<div class="col s12"> |
|||
<form method="get" action="{{ choice.query_string|iriencode }}"> |
|||
<label>{% blocktrans with filter_title=title %} By {{ filter_title }} {% endblocktrans %}</label> |
|||
<button class="btn-floating btn-small right pulse waves-effect waves-light" type="submit"><i class="material-icons tiny">send</i></button> |
|||
<a href="{{ choice.query_string|iriencode }}">{% trans 'All' %}</a> |
|||
<p></p><a href="{{ choice.query_string|iriencode }}">{% trans 'All' %}</a></p> |
|||
{% for field in choice.form %} |
|||
<input id="{{ field.id }}" name="{{ field.name }}" type="text" class="datepicker" value="{{ field.value|default_if_none:''|date:"SHORT_DATE_FORMAT" }}"/> |
|||
{{ field }} |
|||
<!-- input id="{{ field.id }}" name="{{ field.name }}" type="text" class="datepicker admin_filter" value="{{ field.value|default_if_none:''|date:'SHORT_DATE_FORMAT' }}" placeholder="{{ field.label }}" data-clear="{{ choice.query_string|iriencode }}"/ --> |
|||
{% endfor %} |
|||
</form> |
|||
</div> |
|||
{% endwith %} |
@ -0,0 +1,26 @@ |
|||
$("#apply-filters").on("click", function () { |
|||
var query = []; |
|||
var retorno = decodeURIComponent(window.location.search).replace("?", "").split("&"); |
|||
var remove = []; |
|||
var filters = $(".admin_filter"); |
|||
for (i = 0; i < filters.length; i++) { |
|||
var element = $(filters[i]); |
|||
var filter; |
|||
if (element.attr("type") == "text") { |
|||
var cleaner = decodeURIComponent(element.attr("data-clear")).replace("?", "").split("&"); |
|||
if (element.val() == "") { |
|||
filter = [] |
|||
} else { |
|||
filter = [element.attr("name") + '=' + decodeURIComponent(element.val())]; |
|||
} |
|||
filter = filter.concat(cleaner); |
|||
} else { |
|||
filter = decodeURIComponent(element.val()).replace("?", "").split("&"); |
|||
} |
|||
remove = remove.concat(retorno.filter(x => !filter.includes(x))); |
|||
query = query.concat(filter.filter(x => !retorno.includes(x))); |
|||
} |
|||
query = query.concat(retorno.filter(x => !remove.includes(x))); |
|||
query = query.filter(x => x != ""); |
|||
window.location.href = "?" + (query.join("&")); |
|||
}); |
Loading…
Reference in new issue