{% extends "ticket.html" %}
{% block title %}
<title>
  Edit {{ ticket.ref() }}: {{ ticket.title }}
  &mdash;
  {{ cfg("sr.ht", "site-name") }} todo
</title>
{% endblock %}

{% block content %}
<div class="container">
  <div class="row">
    <form class="col-md-8" method="POST">
      {{csrf_token()}}
      <div class="form-group">
        <label for="title">Title</label>
        <input
           type="text"
           dir="auto"
           class="form-control {{ valid.cls("title") }}"
           maxlength="2048"
           id="title"
           name="title"
           autofocus
           value="{{ title or ticket.title or "" }}"
           required />
        {{valid.summary("title")}}
      </div>
      <div class="form-group">
        <label for="description">Description</label>
        <textarea
          dir="auto"
          class="form-control {{ valid.cls("description") }}"
          name="description"
          rows="10"
          placeholder="Markdown supported"
          maxlength="16384"
        >{{ description or ticket.description or "" }}</textarea>
        {{valid.summary("description")}}
      </div>

      <div class="text-right">
        <a href="{{ ticket|ticket_url }}" class="btn btn-default">
          Cancel
        </a>
        <button type="submit" name="preview" class="btn btn-default">
          Preview {{icon("caret-right")}}
        </button>
        <button
          type="submit"
          class="btn btn-primary"
        >Save changes {{icon("caret-right")}}</button>
      </div>

      {% if rendered_preview %}
      <div class="ticket-preview">
        <span class="preview-tag">Ticket preview</span>
        <h2>{{ title }}</h2>
        {{ rendered_preview }}
      </div>
      {% endif %}
    </div>
  </div>
</div>
{% endblock %}
