{% extends "admin/change_form.html" %}
{% load i18n %}
{% load tree_menu_tags %}

{% block after_related_objects %}
{% if change %}
  <fieldset class="module aligned">
  <h2>{% trans "Menu Items" %}</h2>

  <div class="form-row" >
  	  <img src="{% get_treemenus_static_prefix %}/icon_addlink.gif" width="10" height="10"/> <a href="items/add/">{% trans "Add an item" %}</a>
  </div>

  <style type="text/css">
      .form-row tbody tr:hover{
          background-color: #ffffbe;
      }
  </style>

  <div class="form-row" >
	  <table cellspacing="0" width="100%">
		<thead>
			<tr>
				<th>{% trans "Caption" %}</th>
				<th>{% trans "Url" %}</th>
				<th>{% trans "Named url" %}</th>
				<th colspan="2">{% trans "Move" %}</th>
			</tr>
		</thead>

		<tbody>
		  {% for menu_item in original.root_item.get_flattened %}
			<tr class="{% cycle 'row1' 'row2' %}">

				{% if forloop.first %}
					<td colspan="3">
						{% trans "[Root]" %}
					</td>
				{% else %}
					<td width="35%">
						<a href="items/{{ menu_item.pk }}/">{{ menu_item.caption_with_spacer|safe }}</a>
					</td>
					<td width="25%">
						{{ menu_item.url }}
					</td>
					<td width="25%">
						{{ menu_item.named_url }}
					</td>
				{% endif %}

				{% if menu_item.has_siblings %}
					{% ifnotequal menu_item.rank menu_item.siblings.count %}
						<td width="20" align="center"><a href="items/{{ menu_item.pk }}/move_down/"><img src="{% get_treemenus_static_prefix %}/arrow-down.gif" border="0" alt="{% trans 'Down' %}"/></b></td>
					{% else %}
						<td width="20">&nbsp;</td>
					{% endifnotequal %}

					{% ifnotequal menu_item.rank 0 %}
						<td width="20" align="center"><a href="items/{{ menu_item.pk }}/move_up/"><img src="{% get_treemenus_static_prefix %}/arrow-up.gif" border="0" alt="{% trans 'Up' %}"/></a></td>
					{% else %}
						<td width="20">&nbsp;</td>
					{% endifnotequal %}
				{% else %}
					<td width="20">&nbsp;</td><td width="20">&nbsp;</td>
				{% endif %}
			</tr>
		  {% endfor %}
		</tbody>
	  </table>
  </div>
  </fieldset>
{% endif %}
{% endblock %}
