{% extends "stg_detail.html" %}

{% block details %}
<h1><a href="{{ obj.get_absolute_url }}">Table {{ obj.pk }}: {{ obj.name }}</a></h1>

<h2>Attributes</h2>

<ul>
    <li>Imported Via: {{ obj.imported_via }}</li>
    <li>Parent: {{ obj.parent }}</li>
    <li>Name: {{ obj.name }}</li>
    <li>Schema: {{ obj.schema }}</li>
    <li>Database: {{ obj.database }}</li>
    <li>Category: {{ obj.category }}</li>
    <li>Work-in-Progress: {{ obj.wip }}</li>
    <li>Records: {{ obj.records }}</li>
    <li>Creation Time: {{ obj.created_at }}</li>
    <li>Void: {{ obj.void }}</li>
    <li>Void Time: {{ obj.voided_at }}</li>
</ul>

<h2>Derived Properties</h2>

<ul>
    <li>State: {{ obj.state }}</li>
    <li>Year: {{ obj.year }}</li>
    <li>Data Source: {{ obj.data_source }}</li>
</ul>


<h2>Columns in this Table</h2>
{% if columns|length > 0 %}
    <table>
    <tr>
        <th class="txt_col">Column</th>
        <th class="num_col">Count Not-Null</th>
        <th class="num_col">Integrity</th>
        <th class="txt_col">Reference Column</th>
    </tr>
    {% for c in columns %}
    <tr>
        <td class="txt_col"><a href="{{ c.get_absolute_url }}">{{ c.name }}<br />(Column {{ c.pk }})</a>{% if c.description %}<br />{{ c.description }}{% endif %}</td>
        <td class="num_col">{{ c.count_notnull }}</td>
        <td class="num_col">{{ c.integrity_status }}{% if c.integrity_detail %}<br />{{ c.integrity_detail }}{% endif %}</td>
        <td class="txt_col">{% if c.ref_col %}{% with c.ref_col as rc %}{{ rc.name }}<br />(ReferenceColumn {{ rc.pk }}){% endwith %}{% endif %}</td>
    </tr>
    {% endfor %}
    </table>
    
{% else %}
<p>No Columns recorded for this table. If this seems unusual, bear in mind that 1) Column records are only generated for imports, not processed tables and 2) Column records aren't generated until the table has finished processing.</p>

{% endif %}

{% endblock %}
