Improving table list display

This commit is contained in:
2023-03-17 14:35:55 +01:00
parent 46ac3295e3
commit 78c4ee119a
3 changed files with 12 additions and 4 deletions

View File

@@ -0,0 +1,3 @@
.table-row-link {
cursor: pointer;
}

View File

@@ -19,15 +19,15 @@
<span class="col col-form-label" i18n *ngIf="loading$ | async">Loading...</span> <span class="col col-form-label" i18n *ngIf="loading$ | async">Loading...</span>
</div> </div>
<div class="table-responsive-md"> <div class="table-responsive-md">
<table class="table table-striped"> <table class="table table-striped table-hover">
<thead> <thead>
<tr> <tr>
<th *ngFor="let col of this.displayedColumns" scope="col" sortable="name" (sort)="onSort($event)">{{ col.title }}</th> <th *ngFor="let col of this.displayedColumns" scope="col" sortable="name" (sort)="onSort($event)">{{ col.title }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr *ngFor="let row of listData$ | async" (click)="onSelect(row._id)"> <tr *ngFor="let row of listData$ | async" (click)="onRowClick(row._id)" (auxclick)="onRowMiddleClick(row._id);" class="table-row-link">
<td *ngFor="let col of this.displayedColumns"> <td class="text-truncate" *ngFor="let col of this.displayedColumns" style="max-width: 150px;">
<ngb-highlight [result]="getColumnValue(row, col.path)" [term]="searchTerm"></ngb-highlight> <ngb-highlight [result]="getColumnValue(row, col.path)" [term]="searchTerm"></ngb-highlight>
</td> </td>
</tr> </tr>

View File

@@ -144,10 +144,15 @@ export class ListComponent implements OnInit {
this.sortDirection = direction; this.sortDirection = direction;
} }
onSelect(id: string) { onRowClick(id: string) {
this.router.navigate([`../${id}`], {relativeTo: this.route}); this.router.navigate([`../${id}`], {relativeTo: this.route});
} }
onRowMiddleClick(id: string) {
let newUrl = window.location.href.replace('list', id)
window.open(newUrl, '_blank');
}
onCreate() { onCreate() {
this.router.navigate([`../new`], {relativeTo: this.route}); this.router.navigate([`../new`], {relativeTo: this.route});
} }