This commit is contained in:
parent
1990c9a42d
commit
8fa2b8cb5f
|
@ -17,10 +17,17 @@
|
|||
<span> | </span>
|
||||
<span>Filter: </span>
|
||||
<select [(ngModel)]="eventFilter" (change)="getEvents()">
|
||||
<option value="" disabled selected hidden>Select filter</option>
|
||||
<option value="all">All Events</option>
|
||||
<option value="future">Future Events only</option>
|
||||
<option value="past">Past Events only</option>
|
||||
</select>
|
||||
<span> | </span>
|
||||
<span>Sorting: </span>
|
||||
<select [(ngModel)]="eventSorting" (change)="sortEvents()">
|
||||
<option value="start_asc">Start Date - Ascending</option>
|
||||
<option value="start_desc">Start Date - Descending</option>
|
||||
<option value="created_asc">Created Date - Ascending</option>
|
||||
<option value="created_desc">Created Date - Descending</option>
|
||||
</select>
|
||||
<app-events-table [events]="this.events" [selectedCalendar]="getCalendarId(selectedCalendar)"></app-events-table>
|
||||
</div>
|
||||
|
|
|
@ -15,7 +15,8 @@ export class AdminComponent implements OnInit {
|
|||
selectedCalendar: string = '';
|
||||
password: string = '';
|
||||
name: string = '';
|
||||
eventFilter: string = '';
|
||||
eventFilter: string = 'all';
|
||||
eventSorting: string = 'start_asc';
|
||||
|
||||
constructor(
|
||||
private api: ApiService
|
||||
|
@ -46,9 +47,10 @@ export class AdminComponent implements OnInit {
|
|||
startDateTime: new Date(event.startDateTime),
|
||||
endDateTime: new Date(event.endDateTime),
|
||||
createdDate: new Date(event.createdDate)
|
||||
})
|
||||
});
|
||||
}
|
||||
})
|
||||
this.sortEvents();
|
||||
});
|
||||
}
|
||||
|
||||
login(): void {
|
||||
|
@ -101,4 +103,24 @@ export class AdminComponent implements OnInit {
|
|||
getUserName(): string {
|
||||
return UtilsService.getNameFromLocalStorage();
|
||||
}
|
||||
|
||||
sortEvents(): void {
|
||||
this.events.sort((a,b) => {
|
||||
switch (this.eventSorting) {
|
||||
case '':
|
||||
return 1;
|
||||
case 'start_asc':
|
||||
return a.startDateTime > b.startDateTime ? 1 : -1;
|
||||
case 'start_desc':
|
||||
return a.startDateTime > b.startDateTime ? -1 : 1;
|
||||
case 'created_asc':
|
||||
return a.createdDate > b.createdDate ? 1 : -1;
|
||||
case 'created_desc':
|
||||
return a.createdDate > b.createdDate ? -1 : 1;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user