<div class="row">
  <div class="col span-6">
    <label class="acc-label">
      {{t "generic.member"}}
    </label>
    {{input-identity
      allowTeams=true
      action=(action "addAuthorized")
      onError=(action "gotError")
    }}
  </div>
  <div class="col span-12">
  </div>
</div>

{{#accordion-list-item
   title=(t "formScopedRoles.title" type=cTyped)
   detail=(t "formScopedRoles.description" type=cTyped)
   expandOnInit=true
   showExpand=false
}}
  {{#if showAdmin}}
    <div class="radio">
      <label>
        {{radio-button
          selection=mode
          value=admin
        }}
        {{t "formScopedRoles.mode.admin.label"}}
        <p class="help-block">
          {{t "formScopedRoles.mode.admin.detail" type=cTyped}}
        </p>
      </label>
    </div>
  {{/if}}

  {{#if showStdUser}}
    <div class="radio">
      <label>
        {{radio-button
          selection=mode
          value=stdUser
        }}
        {{t "formScopedRoles.mode.user.label"}}
        <p class="help-block">
          {{t "formScopedRoles.mode.user.detail" type=cTyped}}
        </p>
      </label>
    </div>
  {{/if}}

  {{#if (and showReadOnly (eq type "project"))}}
    <div class="radio">
      <label>
        {{radio-button
          selection=mode
          value="read-only"
        }}
        {{t "formScopedRoles.mode.readOnly.label"}}
        <p class="help-block">
          {{t "formScopedRoles.mode.readOnly.detail" type=cTyped}}
        </p>
      </label>
    </div>
  {{/if}}

  {{#each userRoles as |role| }}
    <div class="radio">
      <label>
        {{radio-button
          selection=mode
          value=role
        }}
        {{role.role.displayName}}
        <p class="help-block">
          {{#if role.role.description}}
            {{role.role.description}}
          {{else}}
            {{t "formScopedRoles.mode.userDef.detail"}}
          {{/if}}
        </p>
      </label>
    </div>
  {{/each}}
  <div class="radio">
    <label>
      {{radio-button
        selection=mode
        value="custom"
      }}
      {{t "formScopedRoles.mode.custom.label"}}
      <p class="help-block">
        {{t "formScopedRoles.mode.custom.detail" type=cTyped}}
      </p>
    </label>
  </div>

  {{#if (eq mode "custom")}}
    <div class="pl-20">
      {{#each custom as |row|}}
        <div class="input-group mb-10 border">
          <label class="input-group-addon bg-default p-10 vertical-middle">
            {{input
              type="checkbox"
              checked=row.active
            }}
          </label>
          <div class="form-control p-10 vertical-middle">
            {{row.role.displayName}}
            {{#if row.role.detail}}
              <p class="help-block">{{row.role.detail}}</p>
            {{/if}}
          </div>
        </div>
      {{/each}}
    </div>
  {{/if}}

{{/accordion-list-item}}

{{top-errors errors=errors}}
{{save-cancel
  save=(action "save")
  cancel=(action "cancel")
}}
