<a class="btn btn-default" href="{{ request.path }}/edit"><i class="icon-edit"></i>{{ _("Edit") }}</a>
{%- if view.options.allow_delete is defined and view.options.allow_delete() %}
<a class="btn btn-danger" id="delete-button"><i class="icon-trash icon-white"></i>{{ _("Delete") }}</a>

{%- deferJS %}
<script type="text/javascript">
  $(function () {
    $("#delete-button").click(function () {
      bootbox.dialog({
       title: '<strong class="text-danger"><i class="glyphicon glyphicon-warning-sign"></i> La suppression est irréversible</strong>',
       message: '<p class="lead">Do you really want to delete this entity?</p>',
       closeButton: true,
       buttons: {
         confirm: {
           "label" : "Delete",
           "className" : "btn-danger",   // or btn-primary, or btn-danger, or nothing at all
           "callback": function() {
             // Hack to provoke a POST instead of a GET.
             var path = "{{ request.path }}/delete";
             var form = document.createElement("form");
             form.setAttribute("method", "POST");
             form.setAttribute("action", path);
             form.setAttribute('enctype', 'multipart/form-data');
             var input = document.createElement('input');
             input.setAttribute('type', 'hidden');
             input.setAttribute('name', Abilian.csrf_fieldname);
             input.setAttribute('value', Abilian.csrf_token);
             form.appendChild(input);
             document.body.appendChild(form);
             form.submit();
           }
         },
         cancel: {
           "label" : "Cancel",
           "className" : ""   // or btn-primary, or btn-danger, or nothing at all
         }
       },
       'keyboard': true
      });
    });
  });
</script>
{%- enddeferJS %}
{%- endif %}

{%- for panel, data in panels %}
<div class="panel" style="margin-top: 10px;">
  <h2>{{ panel.label }}</h2>

  <table class="table table-striped table-condensed" style="margin: 10px 0 15px 0;">
    <tbody>
    {%- for row in panel %}
    {%- if row.cols[0] in data %}
      {%- set label, value = data[row.cols[0]] %}
      <tr class="row">
        <th class="col-sm-4">{{ label }}</th>
        <td class="col-sm-8" colspan="3">{{ value }}</td>
      </tr>
    {%- endif %}
    {%- endfor %}
    </tbody>
  </table>
</div>
{% endfor %}
