Browse Source

Filtro flutuante no changelist

pull/159/head
Sesostris Vieira 3 years ago
parent
commit
59e4cc1a2f
  1. 22
      sigi/static/css/changelists.css
  2. 125
      sigi/templates/admin/change_list.html

22
sigi/static/css/changelists.css

@ -0,0 +1,22 @@
.side-wrapper {
width: 100%;
}
#changelist {
width:100%
}
.float-filter {
right: 0;
left: auto;
position: fixed;
width: 300px;
top: 0;
margin: 0;
height: calc(100% + 60px);
padding-bottom: 60px;
background-color: #fff;
z-index: 999;
overflow-y: auto;
will-change: transform;
backface-visibility: hidden;
}

125
sigi/templates/admin/change_list.html

@ -4,73 +4,76 @@
{% block extrastyle %} {% block extrastyle %}
{{ block.super }} {{ block.super }}
<style> <link rel="stylesheet" type="text/css" href="{% static 'material/admin/css/changelists.min.css' %}">
.side-wrapper { <link rel="stylesheet" type="text/css" href="{% static 'css/changelists.css' %}">
width: 100%; {% endblock %}
}
#changelist {
width:100%
}
.float-filter { {% block content %}
right: 0; <div id="content-main" class="list-content">
left: auto; {% block object-tools %}
position: fixed; <div class="fixed-action-btn">
width: 300px; <a class="btn-floating btn-large">
top: 0; <i class="large material-icons">build</i>
margin: 0; </a>
height: calc(100% + 60px); <ul>
padding-bottom: 60px; {% block object-tools-items %}
background-color: #fff; <li>
z-index: 999; <a href="#" data-target="float-filter" class="btn-floating tooltipped waves-effect waves-light sidenav-trigger" data-position="left" data-tooltip="{% trans 'Filter' %}">
overflow-y: auto; <i class="material-icons" aria-hidden="true">filter_list</i>
will-change: transform; </a>
backface-visibility: hidden; </li>
} {% if has_add_permission %}
<li>
{% url cl.opts|admin_urlname:'add' as add_url %}
<a href="{% add_preserved_filters add_url is_popup to_field %}" class="btn-floating tooltipped waves-effect waves-light" data-position="left" data-tooltip="{% trans 'Add' %}">
<i class="material-icons" aria-hidden="true">add</i>
</a>
</li>
{% endif %}
{% endblock %}
</ul>
</div>
{% endblock %}
{% if cl.formset.errors %}
<p class="errornote">
{% if cl.formset.total_error_count == 1 %}{% trans "Please correct the error below." %}{% else %}{% trans "Please correct the errors below." %}{% endif %}
</p>
{{ cl.formset.non_form_errors }}
{% endif %}
<div class="module{% if cl.has_filters %} filtered{% endif %}" id="changelist">
</style> {% block date_hierarchy %}{% date_hierarchy cl %}{% endblock %}
{% endblock extrastyle %}
{% block object-tools %} <form id="changelist-form" method="post"{% if cl.formset.is_multipart %} enctype="multipart/form-data"{% endif %} novalidate>{% csrf_token %}
<div class="fixed-action-btn"> {% if cl.formset %}
<a class="btn-floating btn-large"> <div>{{ cl.formset.management_form }}</div>
<i class="large material-icons">build</i>
</a>
<ul>
{% block object-tools-items %}
<li>
<a href="#" data-target="float-filter" class="btn-floating tooltipped waves-effect waves-light sidenav-trigger" data-position="left" data-tooltip="{% trans 'Filter' %}">
<i class="material-icons" aria-hidden="true">filter_list</i>
</a>
</li>
{% if has_add_permission %}
<li>
{% url cl.opts|admin_urlname:'add' as add_url %}
<a href="{% add_preserved_filters add_url is_popup to_field %}" class="btn-floating tooltipped waves-effect waves-light" data-position="left" data-tooltip="{% trans 'Add' %}">
<i class="material-icons" aria-hidden="true">add</i>
</a>
</li>
{% endif %} {% endif %}
{% endblock %}
</ul>
</div>
{% endblock %}
{% block side_wrapper %} {% block result_list %}
<div id="float-filter" class="float-filter hide"> {% result_list cl %}
<div id="side-wrapper" class="side-wrapper"> {% if action_form and actions_on_bottom and cl.show_admin_actions %}{% admin_actions %}{% endif %}
<div id="changelist-form" class="card"> {% endblock %}
{% if action_form and actions_on_top and cl.show_admin_actions %}{% admin_actions %}{% endif %} {% block pagination %}{% pagination cl %}{% endblock %}
</div> </form>
<div class="card"> </div>
{% block search %}{% search_form cl %}{% endblock %} {% block side_wrapper %}
</div> <div id="float-filter" class="float-filter hide">
<div class="card"> <div id="side-wrapper" class="side-wrapper">
{% block filters %} <div id="changelist-form" class="card">
{{ block.super }} {% if action_form and actions_on_top and cl.show_admin_actions %}{% admin_actions %}{% endif %}
{% endblock %} </div>
<div class="card">
{% block search %}{% search_form cl %}{% endblock %}
</div>
<div class="card">
{% block filters %}
{{ block.super }}
{% endblock %}
</div>
</div> </div>
</div> </div>
{% endblock %}
</div>
</div> </div>
{% endblock %} {% endblock %}
@ -80,7 +83,6 @@
$(document).ready(function(){ $(document).ready(function(){
$('.fixed-action-btn').floatingActionButton(); $('.fixed-action-btn').floatingActionButton();
M.Tooltip.init($('.tooltipped'), {}); M.Tooltip.init($('.tooltipped'), {});
// M.Sidenav.init($("#filter"), {edge: 'right'});
$('.float-filter').each(function() { $('.float-filter').each(function() {
var id=this.id; var id=this.id;
$(`[data-target="${id}"]`).on("click", function(e) { $(`[data-target="${id}"]`).on("click", function(e) {
@ -93,4 +95,3 @@
}); });
</script> </script>
{% endblock footer %} {% endblock footer %}

Loading…
Cancel
Save