Commit 81f84faa authored by Pierre Dittgen's avatar Pierre Dittgen
Browse files

Template refactoring

parent 938ccb79
{% macro preview(source_data) %}
<p class="text">
Affichage de {{ source_data.preview_rows_nb }} lignes sur {{ source_data.rows_nb }} au total
</p>
<div class="table-responsive">
<table class="table table-striped table-bordered table-sm table-hover">
<thead class="thead-light">
<tr>
{% for col in source_data.header %}
<th scope="col">{{ col }}</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for row in source_data.preview_rows %}
<tr>
{% for val in row %}
<td>{{ val }}</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endmacro %}
{% macro body_errors(report, source_data) %}
<h3>Problèmes de contenu</h3>
<div class="table-responsive-sm">
<table class="table-sm table-bordered table-striped table-hover">
<thead class="thead-light">
<th scope="col">1</th>
{% for h in report.table.headers %}
<th scope="col" data-toggle="tooltip" title="{{ report.table.headers_title[loop.index - 1]}}">{{ h }}</th>
{% endfor %}
</thead>
<tbody>
{% for row in report.table.errors.by_rows %}
<tr>
{% if 'row' in row.errors %}
<th class="table-danger" data-toggle="tooltip" title="{{ row.errors.row.message }}">{{
row.row_id
}}</th>
{% if row.errors.row.code == 'blank-row' and not source_data.data_rows[row.row_id -2] %}
{% for _ in report.table.headers %}
<td class="table-danger" data-toggle="tooltip" title="{{ row.errors.row.message }}"></td>
{% endfor %}
{% endif %}
{% else %}
<th>{{ row.row_id }}</th>
{% endif %}
{% for d in source_data.data_rows[row.row_id - 2] %}
{% if loop.index in row.errors %}
<td class="table-danger" data-toggle="tooltip" title="{{ row.errors[loop.index].message }}">
{% elif 'row' in row.errors %}
<td class="table-danger" data-toggle="tooltip" title="{{ row.errors.row.message }}">
{% else %}
<td>
{% endif %}
{{ d }}
</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endmacro %}
\ No newline at end of file
<p class="text">
Affichage de {{ source_data.preview_rows_nb }} lignes sur {{ source_data.rows_nb }} au total
</p>
<div class="table-responsive">
<table class="table table-striped table-bordered table-sm table-hover">
<thead class="thead-light">
<tr>
{% for col in source_data.header %}
<th scope="col">{{ col }}</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for row in source_data.preview_rows %}
<tr>
{% for val in row %}
<td>{{ val }}</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
\ No newline at end of file
...@@ -26,12 +26,13 @@ ...@@ -26,12 +26,13 @@
</div> </div>
</div> </div>
{% import 'table_macros.html' as tables %}
{% if report.error_count == 0 %} {% if report.error_count == 0 %}
<h2>La table est valide</h2> <h2>La table est valide</h2>
<p>Aucune erreur détectée</p> <p>Aucune erreur détectée</p>
{% include 'table_preview.html' %} {{ tables.preview(source_data) }}
{% else %} {% else %}
...@@ -58,53 +59,21 @@ ...@@ -58,53 +59,21 @@
{% if report.table.errors.body %} {% if report.table.errors.body %}
{% if not report.table.display_body_errors %} {% if not report.table.display_body_errors %}
Merci de corriger ce(s) erreur(s) pour visualiser les erreurs de contenu. <p class="text">
Veuillez corriger ce(s) erreur(s) pour visualiser les problèmes de contenu.<br />
<a href="#" id="show_body_errors" title="Attention, en cas de problème sur les colonnes, certains messages d'errur ne seront pas pertinents">Affichez
tout de même les erreurs de valeur</a>
</p>
<div id="body_errors" style="display: none">
{{ tables.body_errors(report, source_data) }}
</div>
{% else %} {% else %}
<div> <div>
<h3>Problèmes de contenu</h3> {{ tables.body_errors(report, source_data) }}
<div class="table-responsive-sm">
<table class="table-sm table-bordered table-striped table-hover">
<thead class="thead-light">
<th scope="col">1</th>
{% for h in report.table.headers %}
<th scope="col" data-toggle="tooltip" title="{{ report.table.headers_title[loop.index - 1]}}">{{ h }}</th>
{% endfor %}
</thead>
<tbody>
{% for row in report.table.errors.by_rows %}
<tr>
{% if 'row' in row.errors %}
<th class="table-danger" data-toggle="tooltip" title="{{ row.errors.row.message }}">{{
row.row_id
}}</th>
{% if row.errors.row.code == 'blank-row' and not source_data.data_rows[row.row_id -2] %}
{% for _ in report.table.headers %}
<td class="table-danger" data-toggle="tooltip" title="{{ row.errors.row.message }}"></td>
{% endfor %}
{% endif %}
{% else %}
<th>{{ row.row_id }}</th>
{% endif %}
{% for d in source_data.data_rows[row.row_id - 2] %}
{% if loop.index in row.errors %}
<td class="table-danger" data-toggle="tooltip" title="{{ row.errors[loop.index].message }}">
{% elif 'row' in row.errors %}
<td class="table-danger" data-toggle="tooltip" title="{{ row.errors.row.message }}">
{% else %}
<td>
{% endif %}
{{ d }}
</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
{% endif %}
</div> </div>
{% endif %}
{% endif %}
{% endif %} {% endif %}
{% endblock %} {% endblock %}
...@@ -112,12 +81,12 @@ Merci de corriger ce(s) erreur(s) pour visualiser les erreurs de contenu. ...@@ -112,12 +81,12 @@ Merci de corriger ce(s) erreur(s) pour visualiser les erreurs de contenu.
<script> <script>
$(function () { $(function () {
// Errors tooltip activate // Errors tooltip activate
$('[data-toggle="tooltip"]').tooltip() $('[data-toggle="tooltip"]').tooltip();
// Reload to re-validate // Show body errors
$('#btn-reload').on('click', function () { $('#show_body_errors').on('click', function () {
$(this).prop('disabled', true) $('#body_errors').show();
window.location.reload(true); $(this).remove();
}) })
}) })
</script> </script>
......
...@@ -156,13 +156,11 @@ def create_validata_report(goodtables_report, schema): ...@@ -156,13 +156,11 @@ def create_validata_report(goodtables_report, schema):
else: else:
report['table']['errors']['body'].append(err) report['table']['errors']['body'].append(err)
# If there are structure errors different to invalid-column-delimiter # Checks if there are structure errors different to invalid-column-delimiter
# => don't display body errors
report['table']['display_body_errors'] = all(err['code'] == 'invalid-column-delimiter' report['table']['display_body_errors'] = all(err['code'] == 'invalid-column-delimiter'
for err in report['table']['errors']['structure']) for err in report['table']['errors']['structure'])
if report['table']['display_body_errors']: # Group body errors by row id
# and group body errors by row id
rows = [] rows = []
current_row_id = 0 current_row_id = 0
for err in report['table']['errors']['body']: for err in report['table']['errors']['body']:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment