validation_macros.html 5.07 KB
Newer Older
1
{% macro preview(report, source_data) %}
Christophe Benz's avatar
Christophe Benz committed
2
3
<p>
    Prévisualisation de {{ source_data.preview_rows_nb }} ligne{% if source_data.preview_rows_nb > 1 %}s{% endif %} sur {{ source_data.rows_nb }} au total :
Pierre Dittgen's avatar
Pierre Dittgen committed
4
5
6
7
8
</p>
<div class="table-responsive">
    <table class="table table-striped table-bordered table-sm table-hover">
        <thead class="thead-light">
            <tr>
9
10
11
12
              {% for h in source_data.header %}
                <th scope="col" data-toggle="popover" title="{{ report.table.headers_title[loop.index - 1]}}" data-content="{{ report.table.headers_description[loop.index - 1] | commonmark2html | escape}}">{{
                h }}</th>
              {% endfor %}
Pierre Dittgen's avatar
Pierre Dittgen committed
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
            </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 %}

Pierre Dittgen's avatar
Pierre Dittgen committed
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
{% macro body_errors(report, source_data, print_mode) %}
    {% if print_mode %}
        {{ body_errors_pdf(report, source_data) }}
    {% else %}
        {{ body_errors_screen(report, source_data) }}
    {% endif %}
{% endmacro %}


{% macro body_errors_pdf(report, source_data) %}
<table id="table-errors" class="table table-striped table-bordered table-sm">
<thead class="thead-light">
    <th>Ligne</th>
    <th>Colonne</th>
    <th>Valeur</th>
    <th>Erreur</th>
</thead>
<tbody>
{% for row in report.table.errors.body_by_rows %}
    {% if 'row' in row.errors %}
        <tr>
            <td>{{ row.row_id }}</td>
            <td colspan="3">{{ row.errors.row.title }}</td>
        </tr>
    {% else %}
        {% for d in source_data.data_rows[row.row_id - 2] %}
            {% if loop.index in row.errors %}
            <tr>
                <td>{{ row.row_id }}</td>
                <td>{{ source_data.header[loop.index - 1] }}</td>
                <td>{{ d }}</td>
                <td>
                    <h5>{{row.errors[loop.index].title}}</h5>
                    {{ row.errors[loop.index].content | safe }}
                </td>
            </tr>
            {% endif %}
        {% endfor %}
    {% endif %}
{% endfor %}
{% endmacro %}


{% macro body_errors_screen(report, source_data) %}
Pierre Dittgen's avatar
Pierre Dittgen committed
72
73
74
75
<div class="table-responsive-sm">
    <table class="table-sm table-bordered table-striped table-hover">
        <thead class="thead-light">
            <th scope="col">1</th>
76
            {% for h in source_data.header %}
Pierre Dittgen's avatar
Pierre Dittgen committed
77
            <th scope="col" data-toggle="popover" title="{{ report.table.headers_title[loop.index - 1]}}" data-content="{{ report.table.headers_description[loop.index - 1] | commonmark2html | escape}}">{{
Pierre Dittgen's avatar
Pierre Dittgen committed
78
                h }}</th>
Pierre Dittgen's avatar
Pierre Dittgen committed
79
80
81
            {% endfor %}
        </thead>
        <tbody>
82
            {% for row in report.table.errors.body_by_rows %}
Pierre Dittgen's avatar
Pierre Dittgen committed
83
84
            <tr>
                {% if 'row' in row.errors %}
Pierre Dittgen's avatar
Pierre Dittgen committed
85
86
87
                <th class="table-danger" data-toggle="popover" title="{{ row.errors.row.title }}" data-content="{{ row.errors.row.content }}">
                    {{ row.row_id }}
                </th>
Pierre Dittgen's avatar
Pierre Dittgen committed
88
89
                {% if row.errors.row.code == 'blank-row' and not source_data.data_rows[row.row_id -2] %}
                {% for _ in report.table.headers %}
Pierre Dittgen's avatar
Pierre Dittgen committed
90
                <td class="table-danger" data-toggle="popover" title="{{ row.errors.row.title }}" data-content="{{ row.errors.row.content }}"></td>
Pierre Dittgen's avatar
Pierre Dittgen committed
91
92
93
94
95
96
97
                {% 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 %}
Pierre Dittgen's avatar
Pierre Dittgen committed
98
                <td class="table-danger" data-toggle="popover" title="{{row.errors[loop.index].title}}" data-content="{{ row.errors[loop.index].content }}">
Pierre Dittgen's avatar
Pierre Dittgen committed
99
                    {% elif 'row' in row.errors %}
Pierre Dittgen's avatar
Pierre Dittgen committed
100
                <td class="table-danger" data-toggle="popover" title="{{ row.errors.row.title }}" data-content="{{ row.errors.row.content }}">
Pierre Dittgen's avatar
Pierre Dittgen committed
101
102
103
104
105
106
107
108
109
110
111
                    {% else %}
                <td>
                    {% endif %}
                    {{ d }}
                </td>
                {% endfor %}
            </tr>
            {% endfor %}
        </tbody>
    </table>
</div>
Pierre Dittgen's avatar
Pierre Dittgen committed
112
113
114
115
116
{% endmacro %}

{% macro error_statistics(report) %}

{% set structure_errors = report.table['error-stats']['structure-errors'] %}
117
{% if structure_errors['count'] != 0 %}
Christophe Benz's avatar
Christophe Benz committed
118
<p>Erreur de structure ({{ structure_errors['count'] }}) :</p>
Pierre Dittgen's avatar
Pierre Dittgen committed
119
<ul>
Christophe Benz's avatar
Christophe Benz committed
120
121
    {% for item in structure_errors['count-by-code'] %}
    <li>{{ item[0] }} ({{ item[1] }})</li>
Pierre Dittgen's avatar
Pierre Dittgen committed
122
123
    {% endfor %}
</ul>
Pierre Dittgen's avatar
Pierre Dittgen committed
124
{% else %}
Christophe Benz's avatar
Christophe Benz committed
125
<p>Aucune erreur de structure.</p>
Pierre Dittgen's avatar
Pierre Dittgen committed
126
127
128
{% endif %}

{% set value_errors = report.table['error-stats']['value-errors'] %}
Christophe Benz's avatar
Christophe Benz committed
129
130
{% if value_errors['count'] > 0 %}
<p>Erreur de contenu ({{ value_errors['count'] }} sur {{ value_errors['rows-count'] }} ligne{% if value_errors['rows-count'] > 1 %}s{% endif %}) :</p>
Pierre Dittgen's avatar
Pierre Dittgen committed
131
<ul>
Christophe Benz's avatar
Christophe Benz committed
132
133
    {% for item in value_errors['count-by-code'] %}
    <li>{{ item[0] }} ({{ item[1] }})</li>
Pierre Dittgen's avatar
Pierre Dittgen committed
134
135
    {% endfor %}
</ul>
136
137
{% else %}
<p>Aucune erreur de contenu</p>
Pierre Dittgen's avatar
Pierre Dittgen committed
138
139
{% endif %}

Pierre Dittgen's avatar
Pierre Dittgen committed
140
{% endmacro %}