{% extends "layout.html" %}
{% block title %}{{title}}{% endblock %}
{% block content %}
<h1>{{title}}</h1>

<p>The search string was:</p>

<div class="row">
  <div class="col-md-6">
    <textarea class="form-control" rows="4" readonly>{{search_text}}</textarea>
  </div>
</div>

{% if error_message %}

<p>It produced the error:</p>

<div class="row">
  <div class="col-md-6">
    <textarea class="form-control" rows="10" readonly>{{error_message}}</textarea>
  </div>
</div>

<p>You might want to check your syntax
  using <a href="https://jsonlint.com/">jsonlint.com</a>. If your syntax is
  correct, there may be a bug;
  please <a href="https://github.com/HERA-Team/librarian/issues/new">file an
  issue</a> with a copy-paste of your query.</p>

{% else %}

{% if files %}

<p>The matched files are listed below.
{% if staging_available %}
<a href="#staging">Skip down to the {{staging_dest_displayed}} staging section</a>.
{% endif %}
</p>

{{macros.file_listing(files)}}

{% else %}

<p>No files matched this search.</p>

{% endif %}

{% if staging_available %}

<h2 id="staging">Staging to {{staging_dest_displayed}}</h2>

<p>You can launch a task that re-runs this search and copies the matched files
  to {{staging_dest_displayed}}. Only files that have instances that are directly
  accessible to the Librarian can be copied.</p>

<form role="form" action="/" method="post"> <!-- note: POST method since non-idempotent op -->
  <input name="search" type="hidden" value="{{search_text}}">
  {{macros.staging_form_ui(staging_username_placeholder, staging_dest_path)}}
</form>

{% endif %}

{% endif %}

{% endblock %}
