<section class="horizontal-form container-fluid">
  <h2>Edit Account</h2>
  {{top-errors errors=errors}}

  <div class="row form-group">
    <div class="col-sm-12 col-md-3 form-label">
      <label class="form-control-static">Name</label>
    </div>
    <div class="col-sm-12 col-md-7">
      {{#if isAdmin}}
        {{input type="text" value=model.account.name classNames="form-control" placeholder="e.g. John Smith"}}
      {{else}}
        <div class="form-control-static">
          {{model.account.name}}
        </div>
      {{/if}}
    </div>
  </div>

  {{#if isAdmin}}
    <div class="row form-group">
      <div class="col-sm-12 col-md-3 form-label">
        <label class="form-control-static">Account Type</label>
      </div>
      <div class="col-sm-12 col-md-7">
        {{new-select
          classNames="form-control"
          content=accountTypeChoices
          value=model.account.kind
        }}
      </div>
    </div>
  {{/if}}

  {{#if isAdmin}}
    <div class="row form-group">
      <div class="col-sm-12 col-md-3 form-label">
        <label for="description">Description</label>
      </div>
      <div class="col-sm-12 col-md-7">
        {{textarea value=model.account.description classNames="form-control no-resize" rows="2" placeholder="e.g. This account is for John Smith"}}
      </div>
    </div>
  {{/if}}

  {{#if isLocalAuth}}
    <div class="row form-group">
      <div class="col-sm-12 col-md-3 form-label">
        <label class="form-control-static">Login Username</label>
      </div>
      <div class="col-sm-12 col-md-7">
        <div class="form-control-static">
          {{model.credential.publicValue}}
        </div>
      </div>
    </div>

    {{#if needOld}}
      <div class="row form-group">
        <div class="col-sm-12 col-md-3 form-label">
          <label class="form-control-static">Current Password</label>
        </div>
        <div class="col-sm-12 col-md-7">
          {{input type="password" value=oldPassword classNames="form-control"}}
        </div>
      </div>
    {{/if}}

    <div class="row form-group">
      <div class="col-sm-12 col-md-3 form-label">
        <label class="form-control-static">New Password</label>
      </div>
      <div class="col-sm-12 col-md-7">
        {{input-password value=newPassword generated="generated"}}
      </div>
    </div>

    {{#liquid-if showConfirm}}
      <div class="row form-group">
        <div class="col-sm-12 col-md-3 form-label">
          <label class="form-control-static">Confirm Password</label>
        </div>
        <div class="col-sm-12 col-md-7">
          {{input type="password" value=newPassword2 classNames="form-control"}}
        </div>
      </div>
    {{/liquid-if}}
  {{else}}
    <div class="row form-group">
      <div class="col-sm-12 col-md-3 form-label">
        <label class="form-control-static">Identity</label>
      </div>
      <div class="col-sm-12 col-md-7">
        {{#if (and model.account.externalId model.account.externalIdType)}}
          {{identity-block externalIdType=model.account.externalIdType externalId=model.account.externalId}}
        {{else}}
          <div class="form-control-static text-muted">
            None
          </div>
        {{/if}}
      </div>
    </div>
  {{/if}}
</section>

{{partial "save-cancel"}}
