sib-router(default-route='circle-profile', hidden)
  sib-route(name='circle-profile')
  sib-route(name='circle-edit')

#circle-profile(hidden)
  include templates/hd-circle-team.pug
  .content-box__info

    .space-between
      sib-display(
        bind-resources
        fields='creationDateSet(title, creationDate)'

        value-title='Creation date:'
        
        widget-creationDate='sib-display-date'
      )
      sib-ac-checker.testblock.circle-edit-button(permission='acl:Write', bind-resources)
        sib-link(class='button text-bold text-uppercase reversed button-blue bordered with-icon icon-pencil' next='circle-edit' bind-resources) Edit and add Members


    h2(name="label-team") Members:

    //- TODO: sib-ac-checker unworking - https://git.happy-dev.fr/startinblox/framework/sib-core/issues/517
    //- sib-ac-checker(permission='acl:Write', bind-resources, nested-field='team')
    sib-form.block.team-form(
      bind-resources 
      nested-field='members'
      fields='user'
      range-user=`${endpoints.users}`

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

      submit-button='Add a member'
    )

    sib-display.block(
      bind-resources
      fields='team'

      multiple-team=''
      widget-team='circle-team-template'
    )

    div.box-button
      sib-ac-checker(permission='acl:Delete', bind-resources)
        sib-delete(
          class='button text-bold text-uppercase button-blue bordered with-icon icon-trash'
          bind-resources
          data-label='Delete Circle'
        )

      sib-widget(name='join-leave-circle-button')
        template
          sib-ac-checker(
            permission="acl:Delete"
            data-src="${value['@id']}"
          )
            sib-delete(
              class='button btn-margin-left text-bold text-uppercase reversed button-dark bordered with-icon icon-close'
              data-src="${value['@id']}"
              data-label='Leave circle'
            )

      sib-display(
        bind-resources
        fields='members'

        multiple-members=''
        widget-members='join-leave-circle-button'
      )

      button.button.btn-margin-left.text-bold.text-uppercase.reversed.button-dark.bordered.with-icon.icon-arrow-right-circle.test
        sib-form(
          bind-resources 
          nested-field='members'
          fields='user'
          label-user=''
          range-user=`${endpoints.users}`
          widget-user='sib-form-dropdown'

          set-user-id-select="user"

          submit-button='Join Circle'
        )
    

#circle-edit(hidden)
  include page-circle-edit.pug
