{% 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">

{% include "detail_breadcrumb.html" %}

<div id="summaryarea">

<table class="infolist" style="width:90%;">
<trbody>
  {% if tagform.errors %}
    <hr>
    <p id="error">The following fields have errors. Please correct and try again.</p>
    <div id="error">{{tagform.errors}}</div>
    <hr>
  {% endif %}
<form method="post">{% csrf_token %}
<tr>
<td class="ColumnAttribute">{{tagform.name.label}}:</td>
<td class="ColumnValue" id="data" colspan="5">{% render tagform.name user action %} </td>
</tr>
<tr>
<td class="ColumnAttribute">{{tagform.color.label}}:</td>
<td class="ColumnValue" id="data">{% render tagform.color user action %}</td>
</tr>
<tr>
<td class="ColumnAttribute" >{{tagform.priority.label}}:</td>
<td class="ColumnValue" id="data">{% render tagform.priority user action %}</td>
</tr>
</table>

<div class="ui-tabs ui-widget ui-widget-content ui-corner-all" id="tabs" style="border: none;">
  <ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
    <li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active"><a class="tab-references" href="#tab-references" style=":hover {color: black;}">Reference</a></li>
  </ul>
  <div class="ui-tabs-panel ui-widget-content ui-corner-bottom" id="tab-references" style="background-color: #f4f0ec;"> 
    {% tag_reference_table tag user action %}
  </div>
</div>

{% if user.is_superuser %}
  {% if action == "edit" %}
    {% make_button "Cancel" "/tag/%s" tag.handle 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 %}
    {% ifequal action "add" %}
      {% make_button "Cancel" "/tag/" 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="Create"/>
    {% else %}
      <div style="background-color: lightgray; padding: 2px 0px 0px 2px; clear: both;">
      {% make_button "+Add Tag" "/tag/add" args %}
      {% make_button "?Edit Tag" "/tag/%s/edit" tag.handle args %}
      {% make_button "-Delete Tag" "/tag/%s/delete" tag.handle args %}
      </div>
    {% endifequal %}
  {% endif %}
{% else %}
{% endif %}
</form>
{% endblock %}

