{%- set widget = view -%}

{%- set view = widget.options.view -%}

<div class="model-view">
  <div class="actions pull-right">
    {%- for action in view.object_actions %}
      {{ action.render() }}
    {%- endfor %}
  </div>

  <h1>{{ entity.name }}</h1>
  <small>
    {{ _("Created at:") }} {{ entity.created_at|datetimeformat("medium") }}
    {% if entity.creator %}
    {{ _("by") }} <a href="{{ url_for(entity.creator) }}">{{ entity.creator }}</a>
    {% endif %}

    {% if entity.created_at != entity.updated_at %}
      - {{ _("Updated at:") }} {{ entity.updated_at|datetimeformat("medium") }}
      {#  TODO: link to last updater #}
    {% endif %}
  </small>

  {%- for panel, data in panels %}
    <h2>{{ panel.label }}</h2>

    <table class="table table-striped table-condensed">
      <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 text-muted">{{ label.text }}</td>
            <td class="col-sm-8" colspan="3">{{ value }}</td>
          </tr>
        {%- endif %}
      {%- endfor %}
      </tbody>
    </table>
  {% endfor %}

</div>
