extends ../../../layouts/admin

block head
  title Manage Users

block neck
  link(rel='stylesheet', href='/views/admin/users/index.min.css?#{cacheBreaker}')

block feet
  script(src='/views/admin/users/index.min.js?#{cacheBreaker}')

block body
  div.row
    div.col-xs-12
      div#header
      div#filters
      div#results-table
      div#results-paging

  script(type='text/template', id='tmpl-header')
    div.page-header
      form.form-inline.pull-right
        div.input-group
          input.form-control(name='username', type='text', placeholder='enter a username', value!='<%= username %>')
          button.btn.btn-primary.btn-add(type='button') Add New
      h1 Users

  script(type='text/template', id='tmpl-filters')
    form.filters
      div.row
        div.col-sm-3
          label Username Search
          input.form-control(name='username', type='text')
        div.col-sm-3
          label Can Play Role
          select.form-control(name='roles')
            option(value='') any
            option(value='admin') admin
            option(value='account') account
        div.col-sm-2
          label Is Active
          select.form-control(name='isActive')
            option(value='') either
            option(value='yes') yes
            option(value='no') no
        div.col-sm-2
          label Sort By
          select.form-control(name='sort')
            option(value='_id') id &#9650;
            option(value='-_id') id &#9660;
            option(value='username') username &#9650;
            option(value='-username') username &#9660;
            option(value='email') email &#9650;
            option(value='-email') email &#9660;
        div.col-sm-2
          label Limit
          select.form-control(name='limit')
            option(value='10') 10 items
            option(value='20', selected='selected') 20 items
            option(value='50') 50 items
            option(value='100') 100 items

  script(type='text/template', id='tmpl-results-table')
    table.table.table-striped
      thead
        tr
          th
          th username
          th.stretch email
          th active
          th id
      tbody#results-rows

  script(type='text/template', id='tmpl-results-row')
    td
      input.btn.btn-default.btn-sm.btn-details(type='button', value='Edit')
    td <%= username %>
    td <%= email %>
    td <%= isActive %>
    td <%= _id %>

  script(type='text/template', id='tmpl-results-empty-row')
    tr
      td(colspan='5') no documents matched

  script(type='text/template', id='tmpl-results-paging')
    div.well
      div.btn-group.pull-left
        button.btn.btn-default(disabled=true) Page <%= pages.current %> of <%= pages.total %>
        button.btn.btn-default(disabled=true) Rows <%= items.begin %> - <%= items.end %> of <%= items.total %>
      div.btn-group.pull-right
        button.btn.btn-default.btn-page.btn-prev(data-page!='<%= pages.prev %>') Prev
        button.btn.btn-default.btn-page.btn-next(data-page!='<%= pages.next %>')  Next
      div.clearfix

  script(type='text/template', id='data-results') !{data.results}
