Default bootstrap tables

* refactors old table index template into bootstrap-fontawesome generic table
pull/2/head
mipel 3 years ago
parent c72a7faa3d
commit 596d61f667

@ -25,7 +25,9 @@ def index_view(request: HttpRequest):
""" """
template = "generic_index.html" template = "generic_index.html"
user = request.user user = request.user
interventions = Intervention # ToDo interventions = Intervention.objects.filter(
)
table = InterventionTable( table = InterventionTable(
request=request, request=request,
queryset=interventions queryset=interventions

@ -24,16 +24,14 @@ STRF_DATE_TIME = "%d.%m.%Y %H:%M:%S"
# Tables # Tables
RESULTS_PER_PAGE_PARAM = "rpp" RESULTS_PER_PAGE_PARAM = "rpp"
PAGE_PARAM = "page" PAGE_PARAM = "page"
PAGE_SIZE_OPTIONS = [5, 10, 15, 20, 25, 30, 50, 75, 100] PAGE_SIZE_OPTIONS = [5, 10, 15, 20, 25, 50, 100]
PAGE_SIZE_OPTIONS_TUPLES = [ PAGE_SIZE_OPTIONS_TUPLES = [
(5, 5), (5, 5),
(10, 10), (10, 10),
(15, 15), (15, 15),
(20, 20), (20, 20),
(25, 25), (25, 25),
(30, 30),
(50, 50), (50, 50),
(75, 75),
(100, 100), (100, 100),
] ]
PAGE_SIZE_DEFAULT = 5 PAGE_SIZE_DEFAULT = 5

@ -138,4 +138,15 @@ nav{
border: 1px solid var(--rlp-red); border: 1px solid var(--rlp-red);
*/ */
box-shadow: 1px 1px 3px var(--rlp-gray-dark); box-shadow: 1px 1px 3px var(--rlp-gray-dark);
}
.cursor-pointer{
cursor: pointer;
}
input:focus, textarea:focus, select:focus{
border: 1px solid var(--rlp-red) !important;
box-shadow: 0 0 3px var(--rlp-red) !important;
-moz-box-shadow: 0 0 3px var(--rlp-red) !important;
-webkit-box-shadow: 0 0 3px var(--rlp-red) !important;
} }

@ -34,7 +34,7 @@
</a> </a>
</div> </div>
<div class="row my-1"> <div class="row my-1">
<a href="{% url 'home' %}"> <a href="{% url 'intervention:index' %}">
<button class="btn btn-default">{% fa5_icon 'eye' %} {% trans 'Show' %}</button> <button class="btn btn-default">{% fa5_icon 'eye' %} {% trans 'Show' %}</button>
</a> </a>
</div> </div>

@ -15,7 +15,7 @@
</a> </a>
</li> </li>
<li class=" menu-elem"> <li class=" menu-elem">
<a class="nav-btn nav-link" href="{% url 'home' %}"> <a class="nav-btn nav-link" href="{% url 'intervention:index' %}">
{% fa5_icon 'pencil-ruler' %} {% fa5_icon 'pencil-ruler' %}
{% trans 'Intervention' %} {% trans 'Intervention' %}
</a> </a>

@ -1,44 +1,78 @@
{% load django_tables2 %} {% load django_tables2 %}
{% load i18n static %} {% load i18n static fontawesome_5 %}
<div class="rows"> <div class="col-md">
{% if table.title is not None %} {% if table.title is not None %}
<div class="rows"> <div class="row">
<h3> <h3>
{{ table.title }} {{ table.title }}
</h3> </h3>
</div> </div>
{% endif %} {% endif %}
<div class="column large-2"> <div class="row">
{% if table.user.is_superuser and table.add_new_entries %} {% if table.add_new_entries %}
<a href="{{ table.add_new_url }}"> <div class="col-md">
<button class="button small" title="{% trans 'New entry' %}"> <a href="{{ table.add_new_url }}">
<i class="fas fa-plus"></i> <button class="btn btn-default" title="{% trans 'New entry' %}">
{% trans 'New' %} <i class="fas fa-plus mr-2"></i>
</button> {% trans 'New' %}
</a> </button>
{% else %} </a>
&nbsp; </div>
{% endif %} {% endif %}
</div> </div>
<div class="column large-8"> <div class="row my-1">
<div class="col-sm-12 col-md">
<form method="get" action="{{table.filter}}">
<div class="input-group">
<input type="text" class="form-control" aria-label="{% trans 'Search for keywords' %}" placeholder="{% trans 'Search' %}">
<div class="input-group-append" title="{% trans 'Start search' %}">
<button type="submit" class="btn btn-default input-group-text">
<span class="">
{% fa5_icon 'search' %}
</span>
</button>
</div>
</div>
</form>
</div>
<div class="col-md d-flex justify-content-end">
<div class="dropdown show">
<div class="btn btn-default dropdown-toggle" href="#" role="button" id="rppToggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{% trans 'Results per page' %}
</div>
<div class="dropdown-menu dropdown-menu-right">
{% for rpp_option in table.results_per_page_choices %}
<a class="dropdown-item {% if table.results_per_page_chosen == rpp_option %}selected{% endif %}" href="{% querystring table.results_per_page_parameter=rpp_option %}">
{{ rpp_option }}
</a>
{% endfor %}
</div>
</div>
</div>
&nbsp; &nbsp;
</div> </div>
<div class="column large-2 dropdown-area">
<form method="get"> <div class="row">
{{ table.filter.form.as_p }} <div class="col-md">
</form> <div class="card">
<div class="header-meta-dropdown"> <div id="filterHeader" class="card-header cursor-pointer" data-toggle="collapse" data-target="#filter" aria-expanded="true" aria-controls="filter">
<button data-dropdown="rpp-choice" aria-controls="rpp-choice" aria-expanded="false" class="custom-dropdown left">{% trans 'Results per page' %}</button> <h5>
<ul id="rpp-choice" class="custom-dropdown-content" data-dropdown-content aria-hidden="true" style="position: absolute; left: -99999px; top: 25px; right: auto;"> {% fa5_icon 'filter' %}
{% for rpp_option in table.results_per_page_choices %} {% trans 'Filter' %}
<li class="{% if table.results_per_page_chosen == rpp_option %}selected{% endif %}"> </h5>
<a class="" href="{% querystring table.results_per_page_parameter=rpp_option %}">{{ rpp_option }}</a> </div>
</li> <div id="filter" class="collapse" aria-labelledby="filterHeader">
{% endfor %} <div class="card-body">
</ul> <form method="get">
{{ table.filter.form.as_p }}
</form>
</div>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
<div class="row">
<div class="table-container">
{% render_table table %} {% render_table table %}
</div> </div>

Loading…
Cancel
Save