Browse Source

Ajusta classe util report para bootstrap

sigi-4.0
Sesóstris Vieira 2 weeks ago
parent
commit
4f05953fa1
  1. 82
      sigi/apps/utils/templates/utils/report/report.html
  2. 41
      sigi/apps/utils/templates/utils/report/report_items_snippet.html
  3. 20
      sigi/apps/utils/templates/utils/report/report_pdf.html

82
sigi/apps/utils/templates/utils/report/report.html

@ -0,0 +1,82 @@
{% extends "admin/base_site.html" %}
{% load static i18n djbs_extras %}
{% if form %}
{% block extrastyle %}
{{ block.super }}
{{ form.media }}
{% endblock extrastyle %}
{% endif %}
{% block breadcrumbs %}
<li class="breadcrumb-item">{% translate "Relatórios" %}</li>
<li class="breadcrumb-item">{{ report_title }}</li>
{% endblock %}
{% block content_title %}
<h5>{{ report_title }}</h5>
{% endblock %}
{% block content %}
{% block form %}
{% if form %}
<form>
<div class="card mb-3">
<div class="card-header">
<a class="icon-link" data-bs-toggle="collapse" href="#filterFormCollapse" aria-expanded="{% if not object_list %}true{% else %}false{% endif %}" aria-controls="filterFormCollapse">
{% icon "filter" %} {% translate "Filtros" %}
</a>
</div>
<div class="card-body collapse{% if not object_list %} show{% endif %}" id="filterFormCollapse">
{% block filterform %}{{ form }}{% endblock %}
</div>
<div class="card-footer d-flex justify-content-end">
<div>
{% block formactionbar %}
<button type="submit" class="btn btn-primary">{% trans 'Ver dados' %}</button>
<button type="submit" name="fmt" value="pdf" class="btn btn-primary" title="{% trans 'Exportar para PDF' %}">
{% icon "pdf" %}
{% trans 'Exportar para PDF' %}
</button>
<button type="submit" name="fmt" value="csv" class="btn btn-primary" title="{% trans 'Exportar para CSV' %}">
{% icon "csv" %}
{% trans 'Exportar para CSV' %}
</button>
{% endblock formactionbar %}
</div>
</div>
</div>
</form>
{% else %}
{% block actionbar %}
<nav class="nav my-3 bg-body-tertiary">
<a class="nav-link ms-lg-auto" href="?fmt=pdf">{% icon "pdf" %}Exportar para PDF</a>
<a class="nav-link" href="?fmt=csv&casas=yes">{% icon "csv" %} Exportar para CSV</a>
</nav>
{% endblock actionbar %}
{% endif %}
{% endblock form %}
{% block datacard %}
<div class="card">
<div class="card-body">
{% block data %}
{% include "utils/report/report_items_snippet.html" with mode="html" %}
{% endblock data %}
</div>
</div>
{% endblock datacard %}
{% endblock %}
{% block footer %}
{{ block.super }}
{% if form %}
{{ form.media }}
{% endif %}
<script>
$(document).ready(function(){
M.FloatingActionButton.init($('.fixed-action-btn'), {hoverEnabled: false});
M.Modal.init($(".modal"));
})
</script>
{% endblock %}

41
sigi/apps/utils/templates/utils/report/report_items_snippet.html

@ -0,0 +1,41 @@
{% load i18n admin_urls sigi_tags %}
<table class="table table-sm table-striped">
<thead>
<tr>
{% for label in list_labels %}
<th>{{ label }}</th>
{% endfor %}
</tr>
</thead>
<tbody class="table-group-divider">
{% for obj in object_list %}
{% if break_field %}
{% with obj|valueof:break_field as monitor_break %}
{% ifchanged monitor_break %}
<tr><th colspan="{{ list_fields|length }}">{{ monitor_break }}</th></tr>
{% endifchanged %}
{% endwith %}
{% endif %}
<tr{% if change_field %}{% with obj|valueof:change_field as monitor_change %}{% ifchanged monitor_change %} class="changed {{ change_field }}-changed"{% endifchanged %}{% endwith %}{% endif %}>
{% for field_name in list_fields %}
<td>
{% if field_name in link_fields %}
<a href="{% url opts|admin_urlname:'change' obj.pk %}">
{{ obj|valueof:field_name|safe }}
</a>
{% else %}
{{ obj|valueof:field_name|safe }}
{% endif %}
</td>
{% endfor %}
</tr>
{% empty %}
<tr>
<td colspam="{{ list_labels|length }}">
{{ empty_message|default:_("Nenhum dado para exibir") }}
</td>
</tr>
{% endfor %}
</tbody>
</table>

20
sigi/apps/utils/templates/utils/report/report_pdf.html

@ -0,0 +1,20 @@
{% extends "pdf/base_report.html" %}
{% load static i18n %}
{% block page_size %}A4 landscape{% endblock %}
{% block extra_style %}
{{ block.super }}
tr.changed {
border-top: 1px solid var(--body-fg);
}
tr.changed td {
border-top: 1px solid var(--body-fg);
}
{% endblock %}
{% block report_name %}{{ report_title }}{% endblock report_name %}
{% block main_content %}
{% include "utils/report/report_items_snippet.html" %}
{% endblock %}
Loading…
Cancel
Save