{% extends "view_page_detail.html" %}
{% load my_tags %}

{% block content %} 

   <script type="text/javascript">
   $(function(){
     $('#tabs').tabs({
	'select': function(event, ui){
			document.location.hash = ui.panel.id;
		}
     });
   });
   </script>

<div class="content" id="IndividualDetail">

   {% filter breadcrumb %}
      {% format "/browse|Browse" %} ||
      {% format "/person|People" %} ||
      {% format "/person/%s|Person [%s]" object.handle object.gramps_id %} ||
      {% format "/person/%s/name/%s|Name #%s" object.handle order order %} ||
      {% format "/person/%s/name/%s/surname/%s|Surname #%s" object.handle order sorder sorder %}
   {% endfilter %}

<h3>{{person|make_name:user}} [{{person.gramps_id}}]</h3>
<div id="summaryarea">
<table class="infolist" style="width:90%;"> {% comment %} 4 cols {% endcomment %}
<tbody>
{% for error in form.errors %}
    <p id="error">{{error}}</p>
{% endfor %}
<form method="post">{% csrf_token %}
<tr>
 <td class="ColumnAttribute">{{surnameform.name_origin_type.label}}:</td>
 <td class="ColumnValue" id="data">{% render surnameform.name_origin_type user action %}</td>
</tr>
<tr>
 <td class="ColumnAttribute">{{surnameform.primary.label}}:</td>
 <td class="ColumnValue" id="data">{% render surnameform.primary user action %}</td>
</tr>
<tr>
 <td class="ColumnAttribute">{{surnameform.prefix.label}}:</td>
 <td class="ColumnValue" id="data">{% render surnameform.prefix user action %}</td>
</tr>
<tr>
 <td class="ColumnAttribute">{{surnameform.surname.label}}:</td>
 <td class="ColumnValue" id="data">{% render surnameform.surname user action %}</td>
</tr>
<tr>
 <td class="ColumnAttribute">{{surnameform.connector.label}}:</td>
 <td class="ColumnValue" id="data">{% render surnameform.connector user action %}</td>
</tr>
</tbody>
</table>
</div>
</div>

{% if user.is_superuser %}
  {% if action == "edit" %}
    {% make_button "Cancel" "/person/%s/name/%s/surname/%s" person.handle order sorder args %}
    <input type="hidden" name="action" value="save"/>
    <input type="hidden" name="search" value="{{search}}"/>
    <input type="hidden" name="page" value="{{page}}"/>
    <input type="submit" value="Save">
  {% else %} 
    {% if action == "add" %}
      {% make_button "Cancel" "/person/%s/name/%s" person.handle order args %}
      <input type="hidden" name="action" value="create"/>
      <input type="hidden" name="search" value="{{search}}"/>
      <input type="hidden" name="page" value="{{page}}"/>
      <input type="submit" value="Save">
    {% else %}
      <div style="background-color: lightgray; padding: 2px 0px 0px 2px; clear: both;">
      {% make_button "+Add Surname" "/person/%s/name/%s/surname/add" person.handle order args %}
      {% make_button "?Edit Surname" "/person/%s/name/%s/surname/%s/edit" person.handle order sorder args %}
      {% make_button "-Delete Surname" "/person/%s/name/%s/surname/%s/delete" person.handle order sorder args %}
      </div>
    {% endif %}
  {% endif %}
{% endif %}
</form>
{% endblock %}

