{% extends 'base.html.twig' %}

{% set filesWithErrors = project.files|filter(file => file.allErrors is not empty) %}

{% block title %}
    {{ project.name }} &raquo; Compilation errors
{% endblock %}

{% block content %}
<ul class="phpdocumentor-breadcrumbs">
    <li><a href="{{ path("/") }}">Home</a></li>
</ul>

<div class="phpdocumentor-row">
    <h2 class="phpdocumentor-content__title">Errors</h2>

    {% if filesWithErrors is not empty %}
    <h3>Table of Contents</h3>
    <table class="phpdocumentor-table_of_contents">
        {% set errorCount = 0 %}
        {% for file in project.files|filter(file => file.allErrors is not empty) %}
            {% if file.allerrors.count > 0 %}
                <tr>
                    <td class="phpdocumentor-cell"><a href="{{ target_path }}#{{ file.path }}">{{ file.path }}</a></td>
                    <td class="phpdocumentor-cell">{{ file.allErrors.count }}</td>
                </tr>
            {% endif %}
            {% set errorCount = errorCount + file.allerrors.count %}
        {% endfor %}
    </table>
    {% endif %}

    {% if errorCount <= 0 %}
        <div class="phpdocumentor-admonition phpdocumentor-admonition--success">No errors have been found in this project.</div>
    {% endif %}

    {% for file in filesWithErrors %}
        <a id="{{ file.path }}"></a>
        <h3><abbr title="{{ file.path }}">{{ file.name }}</abbr></h3>
        <table>
            <thead>
                <tr>
                    <th class="phpdocumentor-heading">Type</th>
                    <th class="phpdocumentor-heading">Line</th>
                    <th class="phpdocumentor-heading">Description</th>
                </tr>
            </thead>
            <tbody>
            {% for error in file.allerrors %}
                <tr>
                    <td class="phpdocumentor-cell">{{ error.severity }}</td>
                    <td class="phpdocumentor-cell">{{ error.line }}</td>
                    <td class="phpdocumentor-cell">{{ error.code|trans(error.context) }}</td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
    {% endfor %}
</div>
{% endblock %}
