table_macros.html 2.77 KB
Newer Older
Pierre Dittgen's avatar
Pierre Dittgen committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{% 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 %}
Pierre Dittgen's avatar
Pierre Dittgen committed
34
35
            <th scope="col" data-toggle="popover" title="{{ report.table.headers_title[loop.index - 1] }}" data-content="{{ report.table.headers_description[loop.index - 1]}}">{{
                h }}</th>
Pierre Dittgen's avatar
Pierre Dittgen committed
36
37
38
39
40
41
            {% endfor %}
        </thead>
        <tbody>
            {% for row in report.table.errors.by_rows %}
            <tr>
                {% if 'row' in row.errors %}
Pierre Dittgen's avatar
Pierre Dittgen committed
42
43
44
                <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
45
46
                {% 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
47
                <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
48
49
50
51
52
53
54
                {% 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
55
                <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
56
                    {% elif 'row' in row.errors %}
Pierre Dittgen's avatar
Pierre Dittgen committed
57
                <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
58
59
60
61
62
63
64
65
66
67
68
69
                    {% else %}
                <td>
                    {% endif %}
                    {{ d }}
                </td>
                {% endfor %}
            </tr>
            {% endfor %}
        </tbody>
    </table>
</div>
{% endmacro %}