[% WRAPPER layout.tt title=(create ? "New release" : "Edit release ${release.name}") %]
[% PROCESS common.tt %]
[% USE HTML %]

<form class="form-horizontal" 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">

<fieldset>

  <div class="control-group">
    <label class="control-label">Identifier</label>
    <div class="controls">
      <input type="text" class="span3" name="name" [% HTML.attributes(value => release.name) %]></input>
    </div>
  </div>

  <div class="control-group">
    <label class="control-label">Description</label>
    <div class="controls">
      <input type="text" class="span3" name="description" [% HTML.attributes(value => release.description) %]></input>
    </div>
  </div>

  <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 members %]

    <div class="releaseMember control-group">
      <label class="control-label">Build [% m.build.id %] Label</label>
      <div class="controls">
        <input type="text" class="span3" name="member-[% m.build.id %]-description" [% HTML.attributes(value => m.description) %]></input>
        <button class="btn btn-warning" type="button" onclick='$(this).parents(".releaseMember").remove()'><i class="icon-trash icon-white"></i></button>
      </div>
    </div>

  [% END %]

  <div class="form-actions">
    <button type="submit" class="btn btn-primary">
      <i class="icon-ok icon-white"></i>
      [%IF create %]Create[% ELSE %]Apply changes[% END %]
    </button>
    [% IF !create %]
      <button id="delete-release" type="submit" class="btn btn-danger" name="action" value="delete">
        <i class="icon-trash icon-white"></i>
        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 %]
  </div>

</fieldset>

</form>

[% END %]
