{% extends "bases/app.html" %}
{% block title %}Records - {{ current_zone }} - {% endblock title %}

{% block main %}
    <h1>Zone {{ current_zone }} records</h1>
    <svg width="0" height="0" aria-hidden="true">
        <defs>
          <clipPath id="corner-folder-tab-right" clipPathUnits="objectBoundingBox">
            <path d="m 0,0 c .25,0 0.75,1 1,1 l -1,0 z"/>
          </clipPath>
        </defs>
    </svg>
    <section>
        <h2>Records</h2>

        {% set current_domain = '' %}
        {% set current_rtype = '' %}

        {% for record in records %}
            {% if record.name != current_domain %}
            {% if current_domain %}
                                </ul>
                            </li>
                    </ul>
                </div>
            </article>
            {% endif %}
            {% set_global current_domain = record.name %}
            {% set_global current_rtype = '' %}
            <article class="domain">
                <header>
                    <h3 class="folder-tab">{{ record.name }}</h3>
                    <span class="sep"></span>
                    <a href="#" class="button">
                        <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-plus-circle" viewBox="0 0 16 16" aria-hidden="true">
                            <path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16"/>
                            <path d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4"/>
                        </svg>
                        Add record
                    </a>
                </header>
                <div class="records">
                    <ul>
            {% endif %}
                        {% if record.type != current_rtype %}
                            {% if current_rtype %}
                                </ul>
                            </li>
                            {% endif %}
                            {% set_global current_rtype = record.type %}
                            <li class="rrset">
                                <span class="rtype">{{ record.type }}</span>
                                <ul>
                                    <li>
                        {% endif %}
                                        <div class="rdata">
                                            {% if record.type == "A" or record.type == "AAAA" %}
                                            <div class="rdata-main">
                                                <span class="pill">
                                                    {{ record.rdata.address }}
                                                </span>
                                            </div>
                                            {% elif record.type == "MX" %}
                                            <div class="rdata-main">
                                                <span class="pill">
                                                    {{ record.rdata.mail_exchanger }}
                                                </span>
                                            </div>
                                            <div class="rdata-complementary">
                                                <span class="pill">
                                                    Preference: {{ record.rdata.mail_exchanger }}
                                                </span>
                                            </div>
                                            {% elif record.type == "NS" %}
                                            <div class="rdata-main">
                                                <span class="pill">
                                                    {{ record.rdata.target }}
                                                </span>
                                            </div>
                                            {% endif %}
                                        </div>
                                        <div class="action">
                                            <button class="icon">
                                                <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-trash" viewBox="0 0 16 16">
                                                    <path d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5m2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5m3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0z"/>
                                                    <path d="M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1zM4.118 4 4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4zM2.5 3h11V2h-11z"/>
                                                </svg>
                                            </button>
                                            <a class="button icon" href="#">
                                                <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-pencil" viewBox="0 0 16 16">
                                                    <path d="M12.146.146a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1 0 .708l-10 10a.5.5 0 0 1-.168.11l-5 2a.5.5 0 0 1-.65-.65l2-5a.5.5 0 0 1 .11-.168zM11.207 2.5 13.5 4.793 14.793 3.5 12.5 1.207zm1.586 3L10.5 3.207 4 9.707V10h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.293zm-9.761 5.175-.106.106-1.528 3.821 3.821-1.528.106-.106A.5.5 0 0 1 5 12.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.468-.325"/>
                                                </svg>
                                            </a>
                                        </div>
                                    </li>
        {% endfor %}
                            </ul>
                        </li>
                </ul>
            </div>
        </article>
    </section>
{% endblock main %}