{% extends 'generic/object_edit.html' %}
{% load static %}
{% load helpers %}
{% load form_helpers %}

{% block form %}
{% render_form form %}

<!-- Existing Wavelengths - only for existing objects -->
{% if object.pk %}
<div class="panel panel-default">
    <div class="panel-heading">
        <strong>Allowed Wavelengths</strong>
    </div>
    <div class="panel-body">
        {% if object.allowed_wavelengths.all %}
            <ul class="list-unstyled">
                {% for wavelength in object.allowed_wavelengths.all %}
                    <li><a href="{% url 'plugins:netbox_optics:opticalgridwavelength' pk=wavelength.pk %}">{{ wavelength.value }} nm</a></li>
                {% endfor %}
            </ul>
        {% else %}
            <span class="text-muted">None</span>
        {% endif %}
        <div class="text-center" style="margin-top: 15px;">
            <a href="{% url 'plugins:netbox_optics:opticalgridwavelength_add' %}?grid_id={{ object.pk }}" class="btn btn-primary btn-sm">
                <span class="mdi mdi-plus" aria-hidden="true"></span> Add Wavelength
            </a>
        </div>
    </div>
</div>
{% endif %}
{% endblock %} 