|
|
@@ -1,49 +1,73 @@
|
|
|
-<div class="activity-container">
|
|
|
- <div class="toolbar">
|
|
|
+<div class="toolbar">
|
|
|
+ <!-- Left side: Title + Search + Refresh -->
|
|
|
+ <div class="left-section">
|
|
|
<h2>Activities</h2>
|
|
|
- <button mat-flat-button color="primary" (click)="openCreateDialog()">
|
|
|
- <mat-icon>add</mat-icon>
|
|
|
- New Activity
|
|
|
+
|
|
|
+ <!-- 🔍 Search -->
|
|
|
+ <mat-form-field appearance="outline" class="search-field">
|
|
|
+ <mat-label>Search activities</mat-label>
|
|
|
+ <input type="text" matInput [formControl]="searchControl" [matAutocomplete]="auto"
|
|
|
+ placeholder="Type to search..." />
|
|
|
+
|
|
|
+ <!-- ❌ Clear button -->
|
|
|
+ <button *ngIf="searchControl.value" mat-icon-button matSuffix aria-label="Clear search" (click)="clearSearch()">
|
|
|
+ <mat-icon>close</mat-icon>
|
|
|
+ </button>
|
|
|
+
|
|
|
+ <mat-autocomplete #auto="matAutocomplete">
|
|
|
+ <mat-option *ngFor="let name of uniqueActivityNames" [value]="name">
|
|
|
+ {{ name }}
|
|
|
+ </mat-option>
|
|
|
+ </mat-autocomplete>
|
|
|
+ </mat-form-field>
|
|
|
+
|
|
|
+ <!-- 🔄 Refresh -->
|
|
|
+ <button mat-icon-button color="primary" (click)="refresh()" [disabled]="loading" [class.spin]="loading"
|
|
|
+ matTooltip="Reload activities">
|
|
|
+ <mat-icon>refresh</mat-icon>
|
|
|
</button>
|
|
|
</div>
|
|
|
|
|
|
- <mat-progress-spinner *ngIf="loading" mode="indeterminate" diameter="48"></mat-progress-spinner>
|
|
|
-
|
|
|
- <table mat-table [dataSource]="dataSource" class="mat-elevation-z8" *ngIf="!loading">
|
|
|
- <ng-container matColumnDef="name">
|
|
|
- <th mat-header-cell *matHeaderCellDef>Name</th>
|
|
|
- <td mat-cell *matCellDef="let row">{{ row.name }}</td>
|
|
|
- </ng-container>
|
|
|
-
|
|
|
- <ng-container matColumnDef="type">
|
|
|
- <th mat-header-cell *matHeaderCellDef>Type</th>
|
|
|
- <td mat-cell *matCellDef="let row">{{ row.type }}</td>
|
|
|
- </ng-container>
|
|
|
-
|
|
|
- <ng-container matColumnDef="dateStart">
|
|
|
- <th mat-header-cell *matHeaderCellDef>Start</th>
|
|
|
- <td mat-cell *matCellDef="let row">
|
|
|
- {{ row.dateStart | date: 'shortDate' }}
|
|
|
- </td>
|
|
|
- </ng-container>
|
|
|
-
|
|
|
- <ng-container matColumnDef="dateEnd">
|
|
|
- <th mat-header-cell *matHeaderCellDef>End</th>
|
|
|
- <td mat-cell *matCellDef="let row">
|
|
|
- {{ row.dateEnd | date: 'shortDate' }}
|
|
|
- </td>
|
|
|
- </ng-container>
|
|
|
-
|
|
|
- <ng-container matColumnDef="actions">
|
|
|
- <th mat-header-cell *matHeaderCellDef></th>
|
|
|
- <td mat-cell *matCellDef="let row">
|
|
|
- <button mat-icon-button color="warn">
|
|
|
- <mat-icon (click)="deleteActivity(row._id); $event.stopPropagation()">delete</mat-icon>
|
|
|
- </button>
|
|
|
- </td>
|
|
|
- </ng-container>
|
|
|
-
|
|
|
- <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
|
|
- <tr mat-row *matRowDef="let row; columns: displayedColumns" (click)="onRowClick(row)" class="clickable-row"></tr>
|
|
|
- </table>
|
|
|
-</div>
|
|
|
+ <!-- Right side: Create Activity -->
|
|
|
+ <button mat-flat-button color="primary" (click)="openCreateDialog()">
|
|
|
+ <mat-icon>add_circle</mat-icon>
|
|
|
+ New Activity
|
|
|
+ </button>
|
|
|
+</div>
|
|
|
+
|
|
|
+<mat-progress-spinner *ngIf="loading" mode="indeterminate" diameter="48"></mat-progress-spinner>
|
|
|
+
|
|
|
+<!-- 🧾 Table -->
|
|
|
+<table mat-table [dataSource]="filteredActivities" class="mat-elevation-z8" *ngIf="!loading">
|
|
|
+ <ng-container matColumnDef="name">
|
|
|
+ <th mat-header-cell *matHeaderCellDef>Name</th>
|
|
|
+ <td mat-cell *matCellDef="let row">{{ row.name }}</td>
|
|
|
+ </ng-container>
|
|
|
+
|
|
|
+ <ng-container matColumnDef="type">
|
|
|
+ <th mat-header-cell *matHeaderCellDef>Type</th>
|
|
|
+ <td mat-cell *matCellDef="let row">{{ row.type }}</td>
|
|
|
+ </ng-container>
|
|
|
+
|
|
|
+ <ng-container matColumnDef="dateStart">
|
|
|
+ <th mat-header-cell *matHeaderCellDef>Start</th>
|
|
|
+ <td mat-cell *matCellDef="let row">{{ row.dateStart | date: 'shortDate' }}</td>
|
|
|
+ </ng-container>
|
|
|
+
|
|
|
+ <ng-container matColumnDef="dateEnd">
|
|
|
+ <th mat-header-cell *matHeaderCellDef>End</th>
|
|
|
+ <td mat-cell *matCellDef="let row">{{ row.dateEnd | date: 'shortDate' }}</td>
|
|
|
+ </ng-container>
|
|
|
+
|
|
|
+ <ng-container matColumnDef="actions">
|
|
|
+ <th mat-header-cell *matHeaderCellDef></th>
|
|
|
+ <td mat-cell *matCellDef="let row">
|
|
|
+ <button mat-icon-button color="warn">
|
|
|
+ <mat-icon (click)="deleteActivity(row._id); $event.stopPropagation()">delete</mat-icon>
|
|
|
+ </button>
|
|
|
+ </td>
|
|
|
+ </ng-container>
|
|
|
+
|
|
|
+ <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
|
|
+ <tr mat-row *matRowDef="let row; columns: displayedColumns" (click)="onRowClick(row)" class="clickable-row"></tr>
|
|
|
+</table>
|