Newer
Older
gitbucket_jkp / src / main / twirl / account / edit.scala.html
@(account: Option[model.Account], info: Option[Any])(implicit context: app.Context)
@import context._
@import view.helpers._
@import util.AccountUtil
@html.main((if(account.isDefined) "Edit your profile" else "Create your account")){
@helper.html.information(info)
  @if(account.isDefined && AccountUtil.hasLdapDummyMailAddress(account.get)) {
    <div class="alert alert-danger">Please register your mail address.</div>
  }
  @if(account.isDefined){
    <h3>Edit your profile</h3>
  } else {
    <h3>Create your account</h3>
  }
  <form action="@if(account.isDefined){@url(account.get.userName)/_edit}else{@path/register}" method="POST" validate="true">
    <div class="row-fluid">
      <div class="span6">
        @if(account.isEmpty){
          <fieldset>
            <label for="userName" class="strong">Username:</label>
            <input type="text" name="userName" id="userName" value=""/>
            <span id="error-userName" class="error"></span>
          </fieldset>
        }
        @if(account.map(_.password.nonEmpty).getOrElse(true)){
          <fieldset>
            <label for="password" class="strong">
              Password
              @if(account.nonEmpty){
                (input to change password)
              }
              :
            </label>
            <input type="password" name="password" id="password" value=""/>
            <span id="error-password" class="error"></span>
          </fieldset>
        }
        <fieldset>
          <label for="fullName" class="strong">Full Name:</label>
          <input type="text" name="fullName" id="fullName" value="@account.map(_.fullName)"/>
          <span id="error-fullName" class="error"></span>
        </fieldset>
        <fieldset>
          <label for="mailAddress" class="strong">Mail Address:</label>
          <input type="text" name="mailAddress" id="mailAddress" value="@if(account.isDefined && !AccountUtil.hasLdapDummyMailAddress(account.get)){@account.map(_.mailAddress)}"/>
          <span id="error-mailAddress" class="error"></span>
        </fieldset>
        <fieldset>
          <label for="url" class="strong">URL (optional):</label>
          <input type="text" name="url" id="url" style="width: 400px;" value="@account.map(_.url)"/>
          <span id="error-url" class="error"></span>
        </fieldset>
      </div>
      <div class="span6">
        <fieldset>
          <label for="avatar" class="strong">Image (optional):</label>
          @helper.html.uploadavatar(account)
        </fieldset>
      </div>
    </div>
    <fieldset class="margin">
      @if(account.isDefined){
        <div class="pull-right">
          <a href="@path/@account.get.userName/_delete" class="btn btn-danger" id="delete">Delete account</a>
        </div>
        <input type="submit" class="btn btn-success" value="Save"/>
        @if(!AccountUtil.hasLdapDummyMailAddress(account.get)){
        <a href="@url(account.get.userName)" class="btn">Cancel</a>
        }
      } else {
        <input type="submit" class="btn btn-success" value="Create account"/>
      }
    </fieldset>
  </form>
}
<script>
$(function(){
  $('#delete').click(function(){
    return confirm('Once you delete your account, there is no going back.\nAre you sure?');
  });
});
</script>