{% extends "shared/base.html" %}

{% block title %}
  <title>MediaFiles List</title>
{% endblock %}

{% block header %}
  <h1>MediaFiles..</h1>
{% endblock %}

{% block subnav %}
    {% include "media/media_nav.html" %}
{% endblock %}

{% block content %}
  {% with msg=msg %}
    {% include "components/alerts.html" %}
  {% endwith %}
  <div class="row">
    <form class="form-inline" action="/media/files">
      <input type="text" placeholder="Search" name="query">
      <label>
        <input type="checkbox" name="review" {% if request.query_params.get("review")=="on" %}checked{% endif %}>Review
      </label>
      <label>
        <input type="checkbox" name="download" {% if request.query_params.get("download")=="on" %}checked{% endif %}>Download
      </label>
      <button type="submit">Search</button>
      <div class="pill-nav">
        <a href="/media/files/add">Add MediaFile</a>
      </div>
    </form>
  </div>
  <div class="row">
    <div class="maincolumn">
      <table class="table table-hover">
        <thead><tr>
          <th scope="col">Titel</th>
          <th scope="col">Review</th>
          <th scope="col">Download</th>
          <th colspan="2">Actions</th>
        </tr></thead>
        <tbody>
        {% for mediafile in mediafiles %}
          <tr>
            <th scope="row"><a href="/media/files/{{mediafile.id}}">{{mediafile.title}}</a></th>
            <td>{% with check=mediafile.review %}{% include "components/check.html" %}{% endwith %}</td>
            <td>{% with check=mediafile.should_download %}{% include "components/check.html" %}{% endwith %}</td>
            <td><a href="/media/files/edit/{{mediafile.id}}" class="btn btn-outline-primary btn-sm active" role="button" aria-pressed="true">Edit</a></td>
            <td><a href="/media/files/delete/{{mediafile.id}}" class="btn btn-outline-danger btn-sm active" role="button" aria-pressed="true">Delete</a></td>
          </tr>
        {% endfor %}
        </tbody>
      </table>
    </div>
  </div>
{% endblock %}
