{% extends "base.html" %}

{% import "bootstrap/wtf.html" as wtf %}
{% import "bootstrap/fixes.html" as fixes %}
{% import "bootstrap/utils.html" as util %}
{% import "macros.html" as pbw %}

{% block title %}Namespace Catalog{% endblock %}

{% block content %}
    <div class="container">
        {{ util.flashed_messages(dismissible=True, container=False) }}

        <ol class="breadcrumb">
            <li><a href="{{ url_for('ui.home') }}">Catalog</a></li>
            <li><a href="{{ url_for('ui.view_namespaces') }}">Namespaces</a></li>
            <li>{{ namespace.keyword }}</li>
        </ol>

        <div class="page-header">
            <h1><code>{{ namespace.name }}</code></h1>
        </div>

        <div class="panel panel-default">
            <div class="panel-body">
                <dl class="dl-horizontal">
                    <dt>Name</dt>
                    <dd>{{ namespace.name }}</dd>
                    <dt>Keyword</dt>
                    <dd>{{ namespace.keyword }}</dd>
                    <dt>Description</dt>
                    <dd>{{ namespace.description }}</dd>
                    <dt>Version</dt>
                    <dd>{{ namespace.version }}</dd>

                    {% if namespace.url %}
                        <dt>URL</dt>
                        <dd>
                            <a href="{{ namespace.url }}">
                                {{ namespace.url }}
                            </a>
                        </dd>
                    {% else %}
                        <dt>Pattern</dt>
                        <dd>{{ namespace.pattern }}</dd>
                    {% endif %}
                </dl>
            </div>
        </div>

        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title">Sample Entries</h3>
            </div>

            <div class="list-group">
                {% for entry in namespace.entries.limit(5) %}
                    <div class="list-group-item">
                        <h4 class="list-group-item-heading">
                            <a href="{{ url_for('ui.view_name', name_id=entry.id) }}">{{ entry.name }}</a>
                        </h4>
                        {% if entry.label %}
                            <div class="list-group-item-text">
                                {{ entry.label }}
                            </div>
                        {% endif %}
                    </div>
                {% endfor %}
            </div>

            <div class="panel-footer">
                <p>Showing 5 of {{ namespace.entries.count() }} entries</p>
            </div>
        </div>
    </div>

    {% include "footer.html" %}
{% endblock %}
