div.content-box__info

  include ../../templates/hd-user-avatar.pug

  sib-widget(name='hd-user-groups')
    template ${await value.name}

  sib-widget(name='team-template-edit')
    template
      sib-display(
        class='w50 cell border cell-with-id-card'
        data-src='${await value.user}'
        fields='account.picture, sup(name, groups), sub(profile.city)'

        widget-account.picture='hd-user-avatar'

        multiple-groups=''
        widget-groups='hd-user-groups'
      )

      sib-ac-checker(
        class='w50 cell border'
        permission="acl:Delete"
        data-src="${value['@id']}"
      )
        sib-delete(
          class='button text-bold text-uppercase reversed button-dark bordered with-icon icon-close'
          data-src="${value['@id']}"
          data-label='Leave the circle'
        )

      //- Only to show the table grid
      sib-ac-checker(
        class='w50 cell border'
        no-permission="acl:Delete"
        data-src="${value['@id']}"
      )

  sib-link(class="backlink", bind-resources, next='circle-profile') Back

  sib-ac-checker(permission='acl:Write', bind-resources)
    h1 Edit your circle

    sib-form.block.form-edit(
      bind-resources

      fields='block-circle__info(name, owner), description'
      range-owner=`${endpoints.users || endpoints.get.users}`

      label-owner='owner'
      label-description='circle subtitle'

      class-name='form-label is-light is-half-width'
      class-owner='form-label is-light is-half-width member-select color'
      class-description='form-label is-light is-full-width'

      widget-owner='sib-form-auto-completion'

      partial=''

      submit-button='Save'
      next='circle-information'
    )

  h2 Members list

  sib-ac-checker(permission='acl:Append', bind-resources, nested-field='members')
    sib-form.block.select-add-member(
      bind-resources 
      nested-field='members'
      fields='user'
      range-user=`${endpoints.users || endpoints.get.users}`

      class-user='team form-label is-dark'
      label-user=''
      widget-user='sib-form-auto-completion'

      submit-button='Add a member'
    )

  .table

    div.table-header.grey-color
      div Name
      div Access

    //-class='table-body'
    sib-display(
      class='table-body'
      bind-resources
      fields='members'

      multiple-members=''
      widget-members='team-template-edit'
    )

