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

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

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

{% block subnav %}
  <div class="subnav">
    <a href="/comic/artists/">Artists</a>
    <a href="/comic/publishers/">Publishers</a>
    <a href="/comic/worktypes">WorkTypes</a>
  </div>
{% endblock %}

{% block content %}
  {% with msg=msg %}
    {% include "components/alerts.html" %}
  {% endwith %}
  <div class="row">
    <form class="form-inline" action="/comic/comics">
      <input type="text" placeholder="Search" name="query">
      <label>
        <input type="checkbox" name="completed" {% if request.query_params.get("completed")=="on" %}checked{% endif %}>Completed
      </label>
      <label>
        <input type="checkbox" name="order" {% if request.query_params.get("order")=="on" %}checked{% endif %}>Order
      </label>
      <button type="submit">Search</button>
      <div class="pill-nav">
        <a href="/comic/comic/add">Add Comic</a>
      </div>
    </form>
  </div>
  <div class="row">
    <div class="maincolumn">
      <table class="table table-hover">
        <thead><tr>
          <th scope="col">Title</th>
          <th scope="col">Publisher</th>
          <th scope="col">Completed</th>
          <th colspan="2">Actions</th>
        </tr></thead>
        <tbody>
        {% for comic in comics %}
          <tr>
            <th scope="row"><a href="/comic/comics/{{comic.id}}">{{comic.title}}</a></th>
            <td><a href="/comic/publishers/{{comic.publisher.id}}">{{comic.publisher.name}}</a></td>
            <td>{% with check=comic.completed %}{% include "components/check.html" %}{% endwith %}</td>
            <td><a href="/comic/comics/edit/{{comic.id}}" class="btn btn-outline-primary btn-sm active" role="button" aria-pressed="true">Edit</a></td>
            <td><a href="/comic/comics/delete/{{comic.id}}" class="btn btn-outline-danger btn-sm active" role="button" aria-pressed="true">Delete</a></td>
          </tr>
        {% endfor %}
        </tbody>
      </table>
    </div>
  </div>
{% endblock %}
