{% extends "entities/base.html" %}
{% load entity_tags %}
{% load styled_forms %}
{% load i18n %}

{% block title %}{{ block.super }}Edit{% endblock %}

{% block extra_head %}
{{ block.super }}
<link rel="stylesheet" href="{{ STATIC_URL }}css/entities.css">
{% endblock %}

{% block body %}
<div class="t">
    
    {% entity_nav request.user entity %}

    <h1>{% firstof MODULE_ENTITIES_LABEL 'Entities' %} {% trans "Edit" %}</h1>

    <div class="entities-wrap">
		<div class="options">
             <div class="quick-options">
				{% entity_options request.user entity %} 	       
             </div>
		</div>

    	<form action="{% url entity.edit entity.pk %}" method="post">{% csrf_token %}
    	<div class="forms">
            {{ form|styled_form }}
        	<input type="submit" value="Save Changes" />
		</div>
        </form>
    </div>

</div>
{% endblock %}

{% block extra_body %}
    <script type="text/javascript">
		$(document).ready(function(){
			// delete confirmation
			$('.delete').click(function(){
				var delete_entity = confirm("Permenantly delete {% firstof MODULE_ENTITIES_LABEL 'Entity' %}?");	// confirm
				if(delete_entity) $('.t').find('form[name="entity-delete"]').submit() // delete: if OK
				return false;	// cancel
			});
		});
    </script>
    <script type="text/javascript" src="{{ STATIC_URL }}js/global/dropdown.js"></script>
	<script type="text/javascript">
		var iconrow = new dropdown({
			container:	'more-options-wrap',
			trigger:	'more-options-trigger',
			target:		'more-options-target'
		});
	</script>
{% endblock %}
