{% extends "base.html" %}
{% set active_page = "players" %}
{% block title %}Players {{ super() }}{% endblock %}

{% block page %}
  {% if g.is_editor %}
    <div class="btn-toolbar" role="toolbar">
      <a class="btn btn-primary" href="{{ url_for('player_new') }}" role="button"><span class="fas fa-plus"></span> Player</a>
    </div>
  {% endif %}
  {% if not model.player_list %}
    There are no players.
  {% else %}
      <table class="table table-hover table-striped table-bordered">
        <thead>
          <tr>
            {% for prop, caption in model.columns %}
              <th scope="col" class="col-sm-auto text-center">{{ caption }}</th>
            {% endfor %}

            {% if g.is_editor %}
              <th scope="col" class="col-sm-auto text-center">Edit</th>
            {% endif %}
          </tr>
        </thead>
        <tbody>
          {% for player in model.player_list %}
          <tr>
            {% for prop, caption in model.columns %}
              <td class="col-sm-auto text-center">{{ player[prop] }}</td>
            {% endfor %}

            {% if g.is_editor %}
              <td class="col-sm-auto text-center">
                <a class="btn btn-default" href="{{ url_for('player_edit', player_id = player.id) }}">
                  <span class="fas fa-pencil-alt"></span>
                </a>
              </td>
            {% endif %}
          </tr>
        {% endfor %}
        </tbody>
      </table>

  {% endif %}
{% endblock %}