{% extends "pyfarm/user_interface/layout.html" %}
{% block title %}Software {{software.software}}{% endblock %}
{% block software_nb_class %}active{% endblock %}
{% block content %}

<h1>{{software.software}}<h1>

<h4>Versions</h4>
<table class="table table-striped table-bordered" style="margin-top:20px;">
  <tr>
    <th></th>
    <th>
      Version
    </th>
     <th>
      Available On New Agents
    </th>
   <th>
      Rank
    </th>
  </tr>
  {% for version in software.versions %}
  <tr>
    <td>
      <form style="display: inline;" role="form" method="POST" action="{{ url_for('delete_single_version_ui', software_id=software.id, version_id=version.id) }}">
        <label for="delete-version-{{version.id}}-submit" class="clickable-icon" title="Delete version"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></label>
        <input id="delete-version-{{version.id}}-submit" type="submit" class="hidden" onclick="return confirm('Are you sure you want to delete this version?');"/>
      </form>
    </td>
    <td>
      {{ version.version }}
    </td>
    <td>
      <form method="post" action="/software/{{software.id}}/versions/{{version.id}}/default_status">
        {{ version.default }}
        <input type="hidden" name="default" value="{{ 'false' if version.default else 'true' }}"/>
        <input type="submit" class="btn" value="Make{{' Not' if version.default }} Default"/>
      </form>
    </td>
    <td>
      <form method="post" action="/software/{{software.id}}/versions/{{version.id}}/update_rank">
        <div class="col-md-2">
          <input type="text" class="form-control" value="{{ version.rank }}" name="rank"/>
        </div>
        <input type="submit" class="btn" value="Update Rank"/>
      </form>
    </td>
  </tr>
  {% endfor %}
</table>

<form method="POST" action="{{ url_for('add_single_version_ui', software_id=software.id) }}" class="form-inline" role="form">
  <label for="version">Version</label>
  <input type="text" class="form-control" id="version" name="version" placeholder="Version"/>
  <label for="rank">Rank</label>
  <input type="text" class="form-control" id="rank" name="rank" placeholder="Rank" value="{{next_rank}}"/>
  <input type="submit" class="btn" value="Add"/>
</form>
{% endblock %}
