[% WRAPPER layout.tt title=(create ? "New Release" : "Edit Release") %]
[% PROCESS common.tt %]
[% USE HTML %]

<h1>[% IF create %]New Release[% ELSE %]Release <tt>[% release.name %]</tt>[% END %]</h1>

<form action="[% IF create %][% c.uri_for('/project' project.name 'create-release/submit') %][% ELSE %][% c.uri_for('/release' project.name release.name 'submit') %][% END %]" method="post">

  <table class="layoutTable">
    <tr>
      <th>Identifier:</th>
      <td><input type="text" class="string" name="name" [% HTML.attributes(value => release.name) %] /></td>
    </tr>
    <tr>
      <th>Description:</th>
      <td><input type="text" class="string" name="description" [% HTML.attributes(value => release.description) %] /></td>
    </tr>
  </table>

  <h3>Release Members</h3>

  <p><em>Note:</em> to add a build to this release, go to the build’s
  information page and click on “Add to release”.</p>

  [% FOREACH m IN release.releasemembers %]

    <div class="releaseMember">

    <h4>Build [% m.build.id %] <button type="button" onclick='$(this).parents(".releaseMember").remove()'><img src="/static/images/failure.gif" alt="Delete input" /></button></h4>

    <table class="layoutTable">
      <tr>
        <th>Label:</th>
        <td><input type="text" class="string longString" name="member-[% m.build.id %]-description" [% HTML.attributes(value => m.description) %] /></td>
      </tr>
    </table>

    </div>

  [% END %]

  <hr />

  <p>
    <button type="submit"><img alt="Apply" src="/static/images/success.gif" />[%IF create %]Create[% ELSE %]Apply changes[% END %]</button>
    [% IF !create %]
    <button id="delete-release" type="submit" name="action" value="delete"><img alt="Delete" src="/static/images/failure.gif" />Delete this release</button>
    <script type="text/javascript">
      $("#delete-release").click(function() {
        return confirm("Are you sure you want to delete this release?");
      });
    </script>
    [% END %]
  </p>
  
</form>

[% END %]
