[% WRAPPER layout.tt title=(create ? "New project" : "Editing project $project.name") %]
[% PROCESS common.tt %]

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

  <fieldset>

    <div class="control-group">
      <div class="controls">
        <label class="checkbox">
          <input type="checkbox" name="enabled" [% IF project.enabled; 'checked="checked"'; END %]></input>Enabled
        </label>
      </div>
      <div class="controls">
        <label class="checkbox">
          <input type="checkbox" name="visible" [% IF !project.hidden; 'checked="checked"'; END %]></input>Visible in the list of projects
        </label>
      </div>
    </div>

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

    <div class="control-group">
      <label class="control-label">Display name</label>
      <div class="controls">
        <input type="text" class="span3" name="displayname" [% HTML.attributes(value => project.displayname) %]></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 => project.description) %]></input>
      </div>
    </div>

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

    <div class="control-group">
      <label class="control-label">Owner</label>
      <div class="controls">
        <input type="text" class="span3" name="owner" [% HTML.attributes(value => project.owner.username || c.user.username) %]></input>
      </div>
    </div>

    <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-project" type="submit" class="btn btn-danger" name="submit" value="delete">
          <i class="icon-trash icon-white"></i>
          Delete this project
        </button>
        <script type="text/javascript">
          $("#delete-project").click(function() {
            return confirm("Are you sure you want to delete this project?");
          });
        </script>
      [% END %]
    </div>

  </fieldset>

</form>

[% END %]
