Skip to content

Commit

Permalink
kursfilter in frontend
Browse files Browse the repository at this point in the history
issue #7
  • Loading branch information
patrickuhlmann committed Jan 3, 2024
1 parent 709b02f commit e4a27c6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
9 changes: 9 additions & 0 deletions frontend/src/app/event/components/eventlist.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@
<mat-label>Text im Name</mat-label>
<input type="text" [formControl]="this.nameFilter" matInput>
</mat-form-field>
<mat-form-field>
<mat-label>Kursart</mat-label>
<mat-select (selectionChange)="filterByKursart($event)">
<mat-option value="all">Alle</mat-option>
@for (kursart of kursarten; track kursart) {
<mat-option [value]="kursart">{{kursart}}</mat-option>
}
</mat-select>
</mat-form-field>
}

@if (this.isLoadingMasterdata || this.isLoading) {
Expand Down
10 changes: 9 additions & 1 deletion frontend/src/app/event/components/eventlist.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ export class EventListComponent {
title = 'eventoverview';
events = new MatTableDataSource([] as CeviEvent[]);
organisations = [] as string[];
kursarten = [] as string[];
types = [] as string[];
isLoading = true;
isError = false;
isLoadingMasterdata = true;
isErrorMasterdata = false;
organisation = 'all';
eventType = 'all';
kursart = 'all';

displayedColumns: string[] = ['group', 'name', 'startsAt', 'finishAt', 'link'];
public nameFilter!: FormControl;
Expand Down Expand Up @@ -67,6 +69,7 @@ export class EventListComponent {
next: (data: Masterdata) => {
this.organisations = data.organisations.map(o => o.name);
this.types = data.eventTypes;
this.kursarten = data.kursarten.map(k => k.name);
this.isLoadingMasterdata = false
},
error: (e: any) => {
Expand Down Expand Up @@ -96,8 +99,13 @@ export class EventListComponent {
this.loadEventsWithFilter();
}

filterByKursart($event: MatSelectChange) {
this.kursart = $event.value;
this.loadEventsWithFilter();
}

loadEventsWithFilter() {
this.service.getEventsWithFilter(this.organisation, this.eventType, this.nameFilter.value).subscribe({
this.service.getEventsWithFilter(this.organisation, this.eventType, this.nameFilter.value, this.kursart).subscribe({
next: (data: CeviEvent[]) => {
this.events.data = data;
this.isLoading = false},
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/app/event/services/event.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface CeviEvent {
export class EventService {
constructor(private http: HttpClient) { }

getEventsWithFilter(filterOrganisation: string, filterEventType: string, nameFilter: string) {
getEventsWithFilter(filterOrganisation: string, filterEventType: string, nameFilter: string, kursartFilter: string) {
let params = new HttpParams();

if (filterOrganisation !== 'all') {
Expand All @@ -30,6 +30,9 @@ export class EventService {
if (nameFilter !== '') {
params = params.set('nameContains', nameFilter);
}
if (kursartFilter !== 'all') {
params = params.set('kursartFilter', kursartFilter);
}

return this.http.get<CeviEvent[]>(environment.apiUri + '/events?' + params.toString());
}
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/app/event/services/masterdata.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@ import { environment } from '../../../environments/environment';
export interface Masterdata {
organisations: Organisation[];
eventTypes: string[];
kursarten: Kursart[];
}

export interface Organisation {
name: string;
}

export interface Kursart {
name: string;
}

@Injectable({
providedIn: 'root'
})
Expand Down

0 comments on commit e4a27c6

Please sign in to comment.