{% extends "layout.html" %}
{% block content %}
<div class="col-12">
  <div class="card">
    <div class="card-header">
      <h3 class="card-title">{{ model_admin.pk_column.name }}: {{ model_admin.get_attr_value(model, model_admin.pk_column) }}</h3>
    </div>
    <div class="card-body border-bottom py-3">
      <div class="table-responsive">
        <table class="table card-table table-vcenter text-nowrap datatable table-hover table-bordered">
          <thead>
            <tr>
              <th class="w-1">Column</th>
              <th class="w-1">Value</th>
            </tr>
          </thead>
          <tbody>
            {% for name, attr in model_admin._details_attrs %}
            <tr>
              <td>{{ name }}</td>
              <td>{{ model_admin.get_attr_value(model, attr) }}</td>
            </tr>
            {% endfor %}
          </tbody>
        </table>
      </div>
      <div class="card-footer d-flex align-items-right">
        <div class="row">
          <div class="col">
            <a href="{{ url_for('admin:list', identity=model_admin.identity) }}" class="btn">
              Go Back
            </a>
          </div>
          {% if model_admin.can_delete %}
          <div class="col">
            <a href="#" data-name="{{ model_admin.name }}" data-pk="{{ model_admin.get_attr_value(model, model_admin.pk_column) }}" data-url="{{ url_for('admin:delete', identity=model_admin.identity, pk=model_admin.get_attr_value(model, model_admin.pk_column)) }}" data-bs-toggle="modal" data-bs-target="#modal-delete" class="btn btn-danger">
              Delete
            </a>
          </div>
          {% endif %}
        </div>
      </div>
    </div>
  </div>
</div>
{% if model_admin.can_delete %}
{% include 'modals/delete.html' %}
{% endif %}
{% endblock %}
