<a class="btn btn-default" href="{{ request.path }}/edit"><i class="fa fa-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="fa fa-trash fa-inverse"></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')|tojson }},
           "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');
             // csrf
             var input = document.createElement('input');
             input.setAttribute('type', 'hidden');
             input.setAttribute('name', Abilian.csrf_fieldname);
             input.setAttribute('value', Abilian.csrf_token);             
             form.appendChild(input);
             // action value
             input = document.createElement('input');
             input.setAttribute('type', 'hidden');
             input.setAttribute('name', '__action');
             input.setAttribute('value', 'delete');
             form.appendChild(input);

             document.body.appendChild(form);
             form.submit();
           }
         },
         cancel: {
           "label" : {{ _('Cancel')|tojson }},
           "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">
        <td class="col-sm-4">{{ label }}</td>
        <td class="col-sm-8" colspan="3">{{ value }}</td>
      </tr>
    {%- endif %}
    {%- endfor %}
    </tbody>
  </table>
</div>
{% endfor %}
