{% extends "layers/layer_base.html" %}
{% load i18n %}
{% load bootstrap_tags %}

{% block title %}{{ layer.typename }} — {{ block.super }}{% endblock %}

{% block body_class %}data{% endblock %}

{% block body_outer %}  
<form class="form-horizontal" action="{% url "layer_metadata" layer.typename %}" method="POST">
    <legend>
      {% blocktrans with layer.typename as layer_title %}
        Editing details for {{ layer_title }}
      {% endblocktrans %}
    </legend>
    {% if layer.metadata_uploaded %}
	<div style="background-color: orange;">{% blocktrans %}Note: this layer's orginal metadata was populated by importing a metadata XML file.
        GeoNode's metadata import supports a subset of ISO, FGDC, and Dublin Core metadata elements.
        Some of your original metadata may have been lost.{% endblocktrans %}</div>
    {% endif %}

    {% if layer_form.errors or attribute_form.errors %}
	<div style="background-color: pink">{% blocktrans %}Error updating metadata.  Please check the following fields: {% endblocktrans %}
            <ul>
        {% for field in layer_form %}
            {% if field.errors %}
                <li>{{ field.label }}</li>
            {% endif %}
        {% endfor %}

        {% if attribute_form.errors %}
        <li>{% trans "Attributes" %}</li>
        	{% for field in attribute_form %}
            	{% if field.errors %}
                	<li>{{ field.errors }}</li>
            	{% endif %}
        	{% endfor %}
        {% endif %}
            </ul>
        </div>
    {% endif %}
    <br/>
    {% csrf_token %}
    <div class="form-controls">
      {{ layer_form|as_bootstrap }}
    </div>
      <header>{% trans "Attributes" %}</header>
      {{ attribute_form.management_form }}
      <table cellpadding="5" cellspacing="5" width="100%"><tr><th style="text-align: left;">{% trans "Attribute" %}</th><th style="text-align: left;">{% trans "Label" %}</th><th style="text-align: left;">{% trans "Description" %}</th><th style="text-align: left;">{% trans "Display Order" %}</th></tr>
          {% for form in attribute_form.forms %}
          {% if form.attribute %}
          <tr><td><div style="display:none">{{form.id}}</div>{{form.attribute}}</td><td> {{form.attribute_label}}</td><td> {{form.description}}</td><td> {{form.display_order}}</td></tr>
          {% endif %}
          {% endfor %}
      </table>
    <fieldset class="form-controls modal-forms modal hide fade" id="poc_form" >
      <h2>{% trans "Point of Contact" %}</h2>
      {{ poc_form|as_bootstrap }}
      <button type='button' class="modal-cloose-btn btn btn-primary">Done</button>
    </fieldset>
    <fieldset class="form-controls modal-forms modal hide fade" id="metadata_form">
      <h2>{% trans "Metadata Provider" %}</h2>
        {{ author_form|as_bootstrap }}
      <button type='button' class="modal-cloose-btn btn btn-primary">Done</button>
    </fieldset>
    <div class="form-actions">
      <input type="submit" class="btn btn-primary" value="{% trans "Update" %}"/>
    </div>
  </form>

{% endblock %}
{% block extra_script %}
 {% include 'metadata_form_js.html' %} 
{% endblock %}
