Affichage des DZs favorites +
tri des DZs en fonction de cela
This commit is contained in:
@@ -3,9 +3,9 @@
|
||||
<ng-container matColumnDef="isfavorite">
|
||||
<th mat-header-cell *matHeaderCellDef></th>
|
||||
<td mat-cell *matCellDef="let element" style="text-align: center;">
|
||||
<img src="../../assets/img/favorite.png" alt="favorite DZ" *ngIf="element.isfavorite"
|
||||
<img src="../../assets/img/favorite.png" alt="favorite DZ" *ngIf="element.isFavorite === true"
|
||||
(click)="removeToFavorite(element)">
|
||||
<img src="../../assets/img/not-favorite.png" alt="favorite DZ" *ngIf="!element.isfavorite"
|
||||
<img src="../../assets/img/not-favorite.png" alt="favorite DZ" *ngIf="element.isFavorite === false"
|
||||
(click)="setToFavorite(element)">
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
@@ -40,6 +40,7 @@ export class ListOfDzsComponent implements OnInit {
|
||||
|
||||
private getListOfDropZones() {
|
||||
this.serviceApiGet.getListOfDropZones().subscribe(data => {
|
||||
data.sort((a, b) => (b.isFavorite ? 1 : 0) - (a.isFavorite ? 1 : 0));
|
||||
this.dataSourceTable = new MatTableDataSource<DropZoneResp>(data);
|
||||
this.dataSourceTable.paginator = this.paginator;
|
||||
this.resultsLength = data.length;
|
||||
@@ -47,10 +48,10 @@ export class ListOfDzsComponent implements OnInit {
|
||||
}
|
||||
|
||||
public setToFavorite(dropzone: DropZoneResp) {
|
||||
dropzone.isfavorite = this.serviceApiPut.SetFavoriteDropZone(dropzone);
|
||||
dropzone.isFavorite = this.serviceApiPut.SetFavoriteDropZone(dropzone);
|
||||
}
|
||||
|
||||
public removeToFavorite(dropzone: DropZoneResp) {
|
||||
dropzone.isfavorite = this.serviceApiPut.RemoveFavoriteDropZone(dropzone);
|
||||
dropzone.isFavorite = this.serviceApiPut.RemoveFavoriteDropZone(dropzone);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user