extends /layout

block pageSpecificScipts
  script(nonce=cspNonce src="/javascripts/admin.js")

block body
  section#fixed-top-section
    include /common/main-navigation
    +main-navigation(false)
  include /common/side-menu-mixin-admin
  - const d = { activeLvl1: 'users', activeLvl2: 'portals' }
  +sideNavigation(d)

  include /utilities/dictionaries-main-panel-header
  - const c = { sideMenu: true, h2: 'Uporabniki', h1: 'Portal', description: 'V tem razdelku lahko določite glavne administratorske pravice na terminološkem portalu.', buttons: [{ type: 'disabled', content: 'Shrani', form: 'form-user-roles' }] }
  +mainHeader(c)

  .content-hold-prerequisites.mt-4
    #offset-main.main-container.mt-1
      span.users-subtitle-txt.ms-0.mt-3 Uporabniške pravice/vloge
      form#form-user-roles(method="post")
        table#user-roles-table.table-users.table-borderless.align-middle.mt-3
          thead
            tr
              th.col-2
                span.user-rights-column-title Uporabnik
              th.col-2
                span.user-rights-column-title Skrbnik portala
              th.col-2
                span.user-rights-column-title.ms-xxl-4 Skrbnik slovarjev
              th.col-2
                span.user-rights-column-title.ms-xxl-4 Skrbnik svetovalnice
              th.col-1.justify-content-center
                span.hidden-text Izbriši polje
          each el in users
            tbody.user-data.pb-xl-2
              tr
                input.hidden-user-id(type="hidden" value=el.id)
                td.d-grid.justify-content-left.justify-content-xl-center.pt-(
                  scope="row"
                  data-label=""
                )
                  span.user-name-last-name= el.username
                  span.user-email= el.email
                td.pt-1.pb-1(data-label="Skrbnik portala")
                  .form-check.d-flex.justify-content-left.justify-content-xl-center
                    if (el.roles.isPortalAdmin)
                      input.form-check-input(
                        type="checkbox"
                        checked
                        name=`rolesPerUser['${el.id}'][isPortalAdmin]`
                      )
                    else
                      input.form-check-input(
                        type="checkbox"
                        name=`rolesPerUser['${el.id}'][isPortalAdmin]`
                      )

                td.pt-1.pb-1(data-label="Skrbnik slovarjev")
                  .form-check.d-flex.justify-content-left.justify-content-xl-center
                    if (el.roles.isDictionariesAdmin)
                      input.form-check-input(
                        type="checkbox"
                        checked
                        name=`rolesPerUser['${el.id}'][isDictionariesAdmin]`
                      )
                    else
                      input.form-check-input(
                        type="checkbox"
                        name=`rolesPerUser['${el.id}'][isDictionariesAdmin]`
                      )

                td.pt-1.pb-1(data-label="Skrbnik svetovalnice")
                  .form-check.d-flex.justify-content-left.justify-content-xl-center
                    if (el.roles.isConsultancyAdmin)
                      input.form-check-input(
                        type="checkbox"
                        checked
                        name=`rolesPerUser['${el.id}'][isConsultancyAdmin]`
                      )
                    else
                      input.form-check-input(
                        type="checkbox"
                        name=`rolesPerUser['${el.id}'][isConsultancyAdmin]`
                      )

                td.pt-3.delete-row(
                  data-bs-target="#alert-modal"
                  data-bs-toggle="modal"
                )
                  img.icon-trash-delete(
                    src="/images/red-trash-icon.svg"
                    alt="Delete"
                  )

      form#form-add-user.container-xl.new-user-input.mt-4.ps-0.ms-0(
        action="/api/v1/users/addUser"
      )
        span.new-user-info NOV UPORABNIK
        .row.d-flex.justify-content-lg-start.align-items-center.mt-2.ms-0.ps-0
          .col-lg-6.ms-0.ps-0.me-2
            input.name-input.d-inline.form-control.ms-0.ps-0(
              type="text"
              name="userNameEmail"
              autocomplete="off"
            )
          .col.ms-xl-4.ms-0.ps-0.d-flex.justify-content-start.mt-2.mt-lg-0
            button.btn.btn-primary Dodaj
    include /utilities/modal-alert
    include /utilities/modal-response
    +responseModal
  include /utilities/modal-alert-mixin
  +alertModal('unsaved-data', 'Shrani', 'Ne', 'modal-save-btn', 'modal-dont-save-btn', 'Imate neshranjene spremebe. Ali jih želite shraniti?')
  include /common/footer
