Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add the filters form to a collapsible container #154

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
41 changes: 4 additions & 37 deletions core/templates/dataset-detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,44 +53,10 @@ <h4>{{ dataset.name }}</h4>
</ul>
</div>
<div id="data" class="col s12">
<div class="row">
<div class="col s12 m12">
<h5>Filtros</h5>

<form method="get">
<div class="row">

<div class="input-field col s6">
<label class="active" for="search">Busca</label>
<input type="text" id="search" name="search" value="{{ query_dict.search|default:'' }}">
</div>

{% for field in fields %}
{% if field.frontend_filter %}{% with value=query_dict|getplainattribute:field|default:'' %}
<div class="input-field col s6">
<label class="active" for="{{ field.name }}">{{ field.title }}</label>
{% if field.has_choices %}
<select name="{{ field.name }}">
<option value="" {% if value == "" %} selected{% endif %}>Todos</option>
{% for choice in field.choices.data %}
<option value="{{ choice }}"{% if value == choice %} selected{% endif %}>{% if choice == 'None' %}(vazio){% else %}{{ choice }}{% endif %}</option>
{% endfor %}
</select>
{% else %}
<input type="text" name="{{ field.name }}" value="{{ value }}">
{% endif %}
</div>
{% endwith %}{% endif %}
{% endfor %}

</div>
<div class="row">
<input class="btn" type="submit" value="Filtrar">
</div>

</form>
<div class="row">
{% include "filters-form.html" with fields=fields query_dict=query_dict %}
</div>
</div>
</div>

<div class="row">
<p>
Expand Down Expand Up @@ -197,5 +163,6 @@ <h5>Filtros</h5>
"bInfo": false,
});
});

</script>
{% endblock %}
48 changes: 48 additions & 0 deletions core/templates/filters-form.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{% load utils %}

<ul class="collapsible">
<li {% if not query_dict %} class="active" {% endif %}>
<div class="collapsible-header" style="display:block">
<i class="material-icons">filter_list</i>
Filtros
<i class="material-icons right">keyboard_arrow_down</i>
</div>
<div class="collapsible-body">

<form method="get">
<div class="row">
<div class="input-field col s6">
<label class="active" for="search">Busca</label>
<input type="text" id="search" name="search" value="{{ query_dict.search|default:'' }}">
</div>
{% for field in fields %}
{% if field.frontend_filter %}{% with value=query_dict|getplainattribute:field|default:'' %}
<div class="input-field col s6">
<label class="active" for="{{ field.name }}">{{ field.title }}</label>
{% if field.has_choices %}
<select name="{{ field.name }}">
<option value="" {% if value == "" %} selected{% endif %}>Todos</option>
{% for choice in field.choices.data %}
<option value="{{ choice }}"{% if value == choice %} selected{% endif %}>{% if choice == 'None' %}(vazio){% else %}{{ choice }}{% endif %}</option>
{% endfor %}
</select>
{% else %}
<input type="text" name="{{ field.name }}" value="{{ value }}">
{% endif %}
</div>
{% endwith %}{% endif %}
{% endfor %}
</div>
<div class="row">
<input class="btn" type="submit" value="Filtrar">
</div>
</form>
</div>
</li>
</ul>

<script>
$(document).ready(function(){
$('.collapsible').collapsible();
});
</script>