<kt-portlet>
	<kt-portlet-header [title]="titulo" [class]="'kt-portlet__head--lg'">
		<div ktPortletTools>
			<button [routerLink]="['../roles/add']" *ngxPermissionsOnly="'administrador.roles.store'" mat-raised-button class="btn btn-primary" matTooltip="Crear nuevo rol">
				<i class="la la-plus"></i>
				<span class="kt-hidden-mobile ml-2">Nuevo rol</span>
			</button>
		</div>
	</kt-portlet-header>

	<kt-portlet-body>

		<div class="kt-form kt-margin-b-30">
			<div class="kt-form__filtration">
				<div class="row align-items-center">
					<div class="col-md-1 kt-margin-bottom-10-mobile">
						<mat-form-field>
							<input matInput (keyup)="onKeyUp($event)" (keydown)="onKeyDown()" placeholder="Buscar..." class="mat-form-field mat-form-field-fluid">
							<mat-hint align="start">
								<strong>Buscar en todos los campos</strong>
							</mat-hint>
						</mat-form-field>
					</div>
				</div>
			</div>
		</div>

		<div class="mat-table__wrapper">
			<mat-table class="lmat-elevation-z8" [dataSource]="dataSourceRol" (matSortChange)="sort($event)" matSort matSortActive="id" matSortDirection="asc" matSortDisableClear>

				<ng-container matColumnDef="name">
					<mat-header-cell *matHeaderCellDef mat-sort-header>Nombre</mat-header-cell>
					<mat-cell *matCellDef="let rol">{{rol.name}}</mat-cell>
				</ng-container>

				<ng-container matColumnDef="slug">
					<mat-header-cell *matHeaderCellDef mat-sort-header>Slug</mat-header-cell>
					<mat-cell *matCellDef="let rol">{{rol.slug}}</mat-cell>
				</ng-container>

				<ng-container matColumnDef="web">
					<mat-header-cell *matHeaderCellDef mat-sort-header>Web</mat-header-cell>
					<mat-cell *matCellDef="let rol"><mat-icon>{{(rol.web == 1 || rol.web == '1') ? 'done' : 'clear'}}</mat-icon></mat-cell>
				</ng-container>

				<ng-container matColumnDef="movil">
					<mat-header-cell *matHeaderCellDef mat-sort-header>Móvil</mat-header-cell>
					<mat-cell *matCellDef="let rol"><mat-icon>{{(rol.movil == 1 || rol.movil  == '1') ? 'done' : 'clear'}}</mat-icon></mat-cell>
				</ng-container>

				<ng-container matColumnDef="actions">
					<mat-header-cell *matHeaderCellDef></mat-header-cell>
					<mat-cell *matCellDef="let rol" class="justify-content-center">
						<button mat-icon-button type="button" *ngxPermissionsOnly="'administrador.roles.show'" (click)="editRol(rol.id)" class="btn-primary" matTooltip="Editar rol">
							<mat-icon>create</mat-icon>
						</button>
						<button mat-icon-button type="button" *ngxPermissionsOnly="'administrador.roles.destroy'" (click)="deleteRol(rol)" class="btn-primary" matTooltip="Eliminar rol">
							<mat-icon>delete</mat-icon>
						</button>
					</mat-cell>
				</ng-container>

				<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
				<mat-row *matRowDef="let row; columns: displayedColumns"></mat-row>
			</mat-table>
			<div class="mat-table__message" *ngIf="dataSourceRol.data.length == 0">No se encontraron registros.</div>
			<div class="mat-table__message" *ngIf="showMessageWait">Espera un momento....</div>
		</div>

		<div class="mat-table__bottom">
			<mat-spinner [diameter]="25" *ngIf="isLoading"></mat-spinner>
			<mat-paginator [pageSize]="perPage" [pageSizeOptions]="pages" [length]="total" (page)="paginator($event)"></mat-paginator>
		</div>
	</kt-portlet-body>

</kt-portlet>
