<table class="table">
  <tr ng-show="!users.empty()">
    <th class="col-md-1" translate>Номер</th>
    <th class="col-md-2" translate translate-context="(в значении 'код взятия/снятия')">Код</th>
    <th ng-if="!useAltonikaKeypad" class="col-md-4" translate>Ключи</th>
    <th ng-if="useAltonikaKeypad" class="col-md-4" translate>Код Риф-КТМ (Си-Норд)</th>
    <th ng-if="hasWireless"  ng-class="useAltonikaKeypad?'col-md-8':'col-md-4'" translate>Брелоки</th>
    <th class="col-md-1"></th>
  </tr>
  <tr ng-show="users.empty()">
    <td translate>
      Нет пользователей
    </td>
  </tr>
  <tbody class="no-border" ng-repeat="(user_index, user) in users.all()" ng-show="user.enabled"><tr>
    <td>{[ user_index + 1 ]}</td>
    <td>
      <button class="btn btn-default"
              ng-click="newUserCode(user_index)"
              translate translate-context="(в значении 'поменять на другое')">
        Изменить
      </button>
    </td>

    <!-- TM-ключи или коды Риф-КТМ (Си-Норд) -->
    <td style="line-height:2em;white-space:nowrap">
      <div ng-repeat="key_index in users.userKeys(user_index)">
        <span class="badge" style="font-family:monospace;"
              ng-class="{'alert-danger': isKeyUnclaimed(key_index)}"
              tooltip-enable="isKeyUnclaimed(key_index)"
              tooltip-placement="bottom"
              uib-tooltip="{['Необходимо привязать ключ к разделу' | translate]}">
          <span ng-if="!useAltonikaKeypad"><span ng-hide="!isKeyUnclaimed(key_index)" class="glyphicon glyphicon-alert"></span> {[ keys.all()[key_index].id ]}</span>
          <span ng-if="useAltonikaKeypad">{[ keys.all()[key_index].id | altonikaReadableCode]}</span>
          <span class="glyphicon glyphicon-remove"
                              ng-click="keys.delete(key_index)"
                              style="cursor:pointer"></span>
        </span>
      </div>
      <div ng-show="canAddTM()">
        <div ng-if="useAltonikaKeypad">
          <a href="" ng-click="newKey(user_index)">
            <translate>Ввести код</translate>
          </a>
        </div>
        <div ng-if="!useAltonikaKeypad">
          <a href="" ng-click="newKey(user_index)">
            <translate  translate-context="(подразумевается 'проcканировать приложенную к считывателю таблетку')">Считать</translate>
          </a>
          <a href="" class="alternative-link-color" style="margin-left: 10px" ng-click="newKeyEntry(user_index)">
            <translate>Ввести номер</translate>
          </a>
        </div>
      </div>
    </td>

    <!-- Беспроводные брелоки -->
    <td ng-if="hasWireless" style="line-height:2em">
      <span ng-repeat="devnum in users.userRemotes(user_index)">
        <span class="badge" style="font-family:monospace;"
                ng-class="{'alert-danger': isRemoteUnclaimed(devnum)}"
                tooltip-enable="isRemoteUnclaimed(devnum)"
                tooltip-placement="bottom"
                uib-tooltip="{['Необходимо привязать брелок к разделу' | translate]}">
          <span ng-hide="!isRemoteUnclaimed(devnum)" class="glyphicon glyphicon-alert"></span>
          <translate>Брелок</translate> №{[ rielta.getRemoteIndex(devnum) + 1 ]}
          <span class="glyphicon glyphicon-remove"
                ng-click="remotes.delete(devnum)"
                style="cursor:pointer"></span>
        </span>
      </span>
      <div class="btn-group" ng-show="remotes.unclaimed().length">
        <button type="button" class="btn btn-xs dropdown-toggle" data-toggle="dropdown">
          <translate>Добавить брелок</translate> <span class="caret"></span>
        </button>
        <ul class="dropdown-menu" role="menu">
          <li ng-repeat="devnum in remotes.unclaimed()">
            <a href="#" ng-click="addRemote(devnum, user_index, $event)"><translate>Брелок</translate> №{[ rielta.getRemoteIndex(devnum) + 1 ]}</a>
          </li>
        </ul>
      </div>
    </td>

    <td>
      <button class="pull-right btn btn-default"
          ng-click="users.delete(user_index)">
        <span class="glyphicon glyphicon-trash"></span>
      </button>
    </td>
    </tr>
  </tbody>
</table>
<button
    class="btn btn-success"
    ng-click="addUser()"
    ng-show="!users.full()"><translate>Добавить пользователя</translate>…</button>
