maestrano/mnoe-admin-panel

View on GitHub
src/app/components/mnoe-staffs-list/mnoe-staffs-list.html

Summary

Maintainability
Test Coverage
<mno-widget icon="fa-wrench" heading="{{$ctrl.staff.widgetTitle}}" is-loading="staff.loading">
  <mno-widget-header>
    &nbsp;{{ 'mnoe_admin_panel.dashboard.staffs.widget.list.title' | translate}}
  </mno-widget-header>
  <mno-widget-body class="large no-padding">
    <div>
      <table st-pipe="$ctrl.callServer" st-table="$ctrl.listOfStaff" class="table table-striped" >
        <thead>
          <tr>
            <th st-sort="name" class="col-lg-2" translate>mnoe_admin_panel.dashboard.staffs.widget.list.table.first_name</th>
            <th st-sort="surname" class="col-lg-2" translate>mnoe_admin_panel.dashboard.staffs.widget.list.table.last_name</th>
            <th st-sort="email" class="col-lg-3" translate>mnoe_admin_panel.dashboard.staffs.widget.list.table.email</th>
            <th st-sort="created_at" class="col-lg-2" translate>mnoe_admin_panel.dashboard.staffs.widget.list.table.created_at</th>
            <th st-sort="admin_role" class="col-lg-3" translate>mnoe_admin_panel.dashboard.staffs.widget.list.table.role</th>
            <th ng-if="!$ctrl.readOnly"></th>
            <th ng-if="!$ctrl.readOnly"></th>
            </tr>
            <tr>
            <th>
                <input st-search="name" placeholder="{{'mnoe_admin_panel.dashboard.staffs.widget.list.placeholder.search_name' | translate}}" class="form-control input-sm search-bar" type="text"/>
            </th>
            <th>
                <input st-search="surname" placeholder="{{'mnoe_admin_panel.dashboard.staffs.widget.list.placeholder.search_surname' | translate}}" class="form-control input-sm search-bar" type="text"/>
            </th>
            <th>
              <input st-search="email" placeholder="{{'mnoe_admin_panel.dashboard.staffs.widget.list.placeholder.search_email' | translate}}" class="form-control input-sm search-bar" type="text"/>
            </th>
            <th></th>
            <th>
              <select st-search="admin_role" class="form-control input-sm">
                <option value="" selected translate>mnoe_admin_panel.dashboard.staffs.widget.list.table.admin_role.all</option>
                <option value="{{role.value}}" ng-repeat="role in $ctrl.staff.roles">{{ role.label | translate }}</option>
              </select>
            </th>
            <th ng-if="!$ctrl.readOnly"></th>
            <th ng-if="!$ctrl.readOnly"></th>
            </tr>
          </thead>
        <tbody ng-show="$ctrl.staff.loading">
          <tr>
            <td colspan="6" class="text-center" translate>mnoe_admin_panel.dashboard.staffs.widget.list.loading_staff</td>
          </tr>
        </tbody>
          <tbody ng-show="!$ctrl.staff.loading" >
          <tr ng-repeat="staffElem in $ctrl.listOfStaff">
            <td><a ui-sref="dashboard.staff({staffId: staffElem.id})">{{staffElem.name}}</a></td>
            <td>{{staffElem.surname}}</td>
            <td>{{staffElem.email}}</td>
            <td>{{staffElem.created_at | date: 'dd/MM/yyyy'}}</td>
            <td><span ng-show="!$ctrl.staff.editmode[staffElem.id]" translate>{{$ctrl.getAdminRoleLabel(staffElem.admin_role)}}</span>
              <select ng-model="staffElem.admin_role" ng-show="$ctrl.staff.editmode[staffElem.id]" class="user-role-select form-control input-sm">
                <option ng-repeat="role in $ctrl.staff.roles" value="{{role.value}}">{{role.label | translate}}</option>
              </select>
            </td>
            <td ng-if="!$ctrl.readOnly">
              <div ng-hide="$ctrl.staff.oneAdminLeft && staffElem.admin_role == 'admin'">
                <a href="" ng-hide="$ctrl.staff.editmode[staffElem.id]" ng-click="$ctrl.staff.editmode[staffElem.id] = true"><i class="fa fa-pencil"></i></a>
              </div>
            </td>
            <td ng-if="!$ctrl.readOnly">
              <div ng-hide="$ctrl.staff.oneAdminLeft && staffElem.admin_role == 'admin'">
                <a href="" ng-hide="$ctrl.staff.editmode[staffElem.id]" ng-click="$ctrl.staff.remove(staffElem)"><i class="fa fa-times"></i></a>
              </div>
              <a href="" ng-show="$ctrl.staff.editmode[staffElem.id]" ng-click="$ctrl.staff.update(staffElem)"><i class="fa fa-check"></i></a>
            </td>
          </tr>
          </tbody>
      </table>
    </div>
  </mno-widget-body>
  <mno-widget-footer ng-show="$ctrl.listOfStaff && !searchMode">
    <mno-pagination
      page="$ctrl.staff.page"
      nb-items="$ctrl.staff.nbItems"
      total-items="$ctrl.staff.totalItems"
      on-change-cb="$ctrl.staff.pageChangedCb(nbItems, page)"
      is-loading="$ctrl.staff.loading">
    </mno-pagination>
  </mno-widget-footer>
</mno-widget>