<div class="container-fluid py-5">
    <div class="row">
        <div class="col-12">
            <div class="jumbotron jumbotron-small jumbotron-list-container bg-light mat-elevation-z5 mb-0">
                <div class="jumbotron-heading lign-items-center justify-content-between row ">
                    <div class="col-md-6">
                        <h2 class="shadowed">Service Categories</h2>
                        <p class="shadowed">View and manage service categories</p>
                    </div>
                    <div class="col-md-6 text-md-right">
                        <button type="button" class="btn btn-success" routerLink='/{{appService.portalDomain}}/service_categories_update'>
                            <i class="fas fa-clipboard-list mr-2"></i>Create New Category
                        </button>
                    </div>
                </div>
                <div class="filter-container pt-3 px-3 row">
                    <!-- <input class="form-control " (keyup)="applyFilter($event.target.value)" placeholder="Apply Filter..."> -->
                    <mat-form-field appearance="" class="white-background col-12">
                        <mat-label>Apply Filter...</mat-label>
                        <input matInput (keyup)="applyFilter($event.target.value)">
                    </mat-form-field>
                </div>

                <div class="table-responsive mat-elevation-z1" [@fadeIn]>
                    <table mat-table [dataSource]="dataSource" matSort class="table table-generic">

                        <ng-container matColumnDef="name">
                            <th mat-header-cell *matHeaderCellDef mat-sort-header> Name </th>
                            <td mat-cell *matCellDef="let element"> <a routerLink="/{{appService.portalDomain}}/service_categories_update/{{element.id}}">{{element.name}}</a> </td>
                        </ng-container>

                        <ng-container matColumnDef="description">
                            <th mat-header-cell *matHeaderCellDef mat-sort-header> Description </th>
                            <td mat-cell *matCellDef="let element">
                                <span *ngIf="element.description">{{element.description | slice:0:49}}<span *ngIf="element.description.length > 49">...</span> </span> 
                            </td>
                        </ng-container>

                        <ng-container matColumnDef="lastUpdate">
                            <th mat-header-cell *matHeaderCellDef mat-sort-header> Last Update (Local Time)</th>
                            <td mat-cell *matCellDef="let element"> {{element.lastUpdate | date:'d MMM y, h:mm a'}}
                            </td>
                        </ng-container>

                        <ng-container matColumnDef="lifecycleStatus">
                            <th mat-header-cell *matHeaderCellDef mat-sort-header> Lifecycle Status </th>
                            <td mat-cell *matCellDef="let element"> {{element.lifecycleStatus}} </td>
                        </ng-container>

                        <ng-container matColumnDef="isRoot">
                            <th mat-header-cell *matHeaderCellDef mat-sort-header> isRoot </th>
                            <td mat-cell *matCellDef="let element">
                                <i *ngIf="element.isRoot" class="material-icons checked">check</i>
                                <i *ngIf="!element.isRoot" class="material-icons crossed">close</i>
                            </td>
                        </ng-container>

                        <ng-container matColumnDef="parent">
                            <th mat-header-cell *matHeaderCellDef mat-sort-header> Parent Category </th>
                            <td mat-cell *matCellDef="let element"> <a routerLink="/{{appService.portalDomain}}/service_categories_update/{{element.parentId}}">{{element.parentName}}</a> </td>
                        </ng-container>

                        <ng-container matColumnDef="version">
                            <th mat-header-cell *matHeaderCellDef mat-sort-header> Version </th>
                            <td mat-cell *matCellDef="let element"> {{element.version}} </td>
                        </ng-container>


                        <ng-container matColumnDef="actions">
                            <th mat-header-cell *matHeaderCellDef>Actions</th>
                            <td mat-cell *matCellDef="let element">
                                <a routerLink='/{{appService.portalDomain}}/service_categories_update/{{element.id}}'>
                                    <button class="btn btn-warning btn-sm m-1"><i class="far fa-edit"></i></button>
                                </a>
                                <button class="btn btn-danger btn-sm m-1" (click)="openCategoryDeleteDialog(element)"><i
                                        class="far fa-trash-alt"></i></button>
                            </td>
                        </ng-container>


                        <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
                        <tr mat-row *matRowDef="let row; columns: displayedColumns;" [class.isRoot-class]="row.isRoot"></tr>
                    </table>

                    

                    <mat-paginator [pageSizeOptions]="[20, 50, 100]" showFirstLastButtons></mat-paginator>
                    
                </div>

                <div class="mt-3">
                    <mat-hint class="px-3 bg-light">*Root Categories' names are displayed in <span class="isRootDecoration">underlined</span> text*</mat-hint>
                </div>


            </div>
        </div>
    </div>
</div>