Skip to content

Commit 3069fda

Browse files
authored
Merge pull request #628 from bettercodepaul/1722-suche-des-vereins-bei-neuem-vereinsmitglied
1722 suche des vereins bei neuem vereinsmitglied, 1952 Fehlender Text bei NoPermissionException
2 parents c9d52c1 + 3a5ace7 commit 3069fda

6 files changed

Lines changed: 121 additions & 94 deletions

File tree

bogenliga/src/app/components/sidebar/sidebar.component.ts

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ import { LigaContextService } from '@shared/services/liga-context/liga-context.s
1313
import { Subscription } from 'rxjs';
1414
import { distinctUntilChanged } from 'rxjs/operators';
1515
import { LigaDO } from '@verwaltung/types/liga-do.class';
16-
import {slugifyLigaName} from "@shared/functions/slug-utils";
16+
import {slugifyLigaName} from '@shared/functions/slug-utils';
1717
import {isNullOrUndefined, isUndefined} from '@shared/functions';
1818
import { AnalyticsService } from '@shared/services';
19-
import {SelectedLigaDataprovider} from '../../modules/shared/data-provider/SelectedLigaDataprovider'
19+
import {SelectedLigaDataprovider} from '../../modules/shared/data-provider/SelectedLigaDataprovider';
2020

2121

2222

2323
const ID_PATH_PARAM = 'id';
24-
export var ligaID: number;
24+
export let ligaID: number;
2525

2626
@Component({
2727
selector: 'bla-sidebar',
@@ -65,7 +65,7 @@ export class SidebarComponent implements OnInit, OnDestroy {
6565
// Liga-Kontext beobachten
6666
this.ligaSub = this.ligaContext.currentLiga$
6767
.pipe(distinctUntilChanged((a, b) => a?.id === b?.id))
68-
.subscribe(liga => {
68+
.subscribe((liga) => {
6969
this.currentLiga = liga ?? null;
7070
});
7171
}
@@ -96,33 +96,35 @@ export class SidebarComponent implements OnInit, OnDestroy {
9696
public getRoute(route: string, detailType: string): string {
9797
let result: string = route;
9898
this.URLRoute = this.router.url;
99-
if (this.URLRoute.startsWith("/ligatabelle") ||this.URLRoute.startsWith("/home") ) {
99+
if (this.URLRoute.startsWith('/ligatabelle') || this.URLRoute.startsWith('/home') ) {
100100
const lastSlashIndex = this.URLRoute.lastIndexOf('/');
101-
switch(lastSlashIndex){
101+
switch (lastSlashIndex) {
102102
case 0:
103-
//forget liga ID if no liga ID is part of the URL-route
103+
// forget liga ID if no liga ID is part of the URL-route
104104
this.ligaID = undefined;
105105
break;
106106
case result.length:
107-
!(this.URLRoute.substring(lastSlashIndex + 1).toString() === "ligaid") ?
108-
this.ligaID = parseInt(this.URLRoute.substring(lastSlashIndex + 1)) : undefined;
107+
const currentPathParam = this.URLRoute.substring(lastSlashIndex + 1);
108+
if (currentPathParam !== 'ligaid') {
109+
this.ligaID = parseInt(currentPathParam, 10);
110+
}
109111
break;
110112
}
111113

112114
}
113115

114116
if (detailType === 'undefined') {
115117
return(route);
116-
} else if (detailType === 'verein'){
118+
} else if (detailType === 'verein') {
117119
result = result + '/' + this.currentUserService.getVerein();
118120
} else {
119121
result = result;
120122
}
121123

122124
// Für die Home-Seite wollen wir NICHT automatisch eine Liga-ID anhängen,
123125
// damit man immer zurück auf die echte Startseite kommt.
124-
if(this.ligaID != undefined && route.startsWith("/ligatabelle")){
125-
result = result + '/'+ this.ligaID.toString();
126+
if (this.ligaID !== undefined && route.startsWith('/ligatabelle')) {
127+
result = result + '/' + this.ligaID.toString();
126128
}
127129

128130
this.selectedLigaDataprovider.setSelectedLigaID(this.ligaID);
@@ -191,6 +193,12 @@ export class SidebarComponent implements OnInit, OnDestroy {
191193
}
192194

193195
isSelected(itemroute: string): boolean {
194-
return (this.router.url.indexOf(itemroute) >= 0);
196+
const currentPath = this.getCurrentPath();
197+
return currentPath === itemroute || currentPath.startsWith(`${itemroute}/`);
198+
}
199+
200+
private getCurrentPath(): string {
201+
const url = this.router.url || '';
202+
return url.split('?')[0].split('#')[0];
195203
}
196204
}

bogenliga/src/app/modules/verwaltung/components/dsb-mitglied/dsb-mitglied-detail/dsb-mitglied-detail.component.html

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,24 @@
135135
<span> *</span>
136136
</label>
137137
<div class="col-sm-9">
138+
<input type="text"
139+
class="form-control mb-2"
140+
id="dsbMitgliedVereinSuche"
141+
name="dsbMitgliedVereinSuche"
142+
[(ngModel)]="vereinSearchTerm"
143+
(ngModelChange)="onVereinSearch($event)"
144+
placeholder="{{ 'SELECTIONLIST.SEARCH_PLACEHOLDER' | translate }}"
145+
autocomplete="off"
146+
data-cy="detail-vereine-dsb-search"
147+
[readonly]="isReadOnly">
138148
<select class="form-control"
139149
id="dsbMitgliedVerein"
140150
name="dsbMitgliedVerein"
141151
#dsbMitgliedVerein="ngModel"
142152
[(ngModel)]="currentVerein"
143153
data-cy="detail-vereine-dsb"
144154
[disabled]="isReadOnly">
145-
<option [ngValue]="verein" *ngFor="let verein of vereine"> {{verein.name}}</option>
155+
<option [ngValue]="verein" *ngFor="let verein of filteredVereine"> {{verein.name}}</option>
146156
</select>
147157
<div class="invalid-feedback">
148158
{{ 'MANAGEMENT.DSBMITGLIEDER_DETAIL.FORM.VEREIN.ERROR' | translate }}

bogenliga/src/app/modules/verwaltung/components/dsb-mitglied/dsb-mitglied-detail/dsb-mitglied-detail.component.ts

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ export class DsbMitgliedDetailComponent extends CommonComponentDirective impleme
4848
public ButtonType = ButtonType;
4949
public currentMitglied: DsbMitgliedDO = new DsbMitgliedDO();
5050
public currentVerein: VereinDO = new VereinDO();
51-
// public vereine: Array<VereinDO> = [new VereinDO()];
52-
public vereine: VereinDO[];
53-
// public currentVerein: VereinDO;
51+
public vereine: VereinDO[] = [];
52+
public filteredVereine: VereinDO[] = [];
53+
public vereinSearchTerm = '';
5454

5555
public dsbMitgliedNationalitaet: string[];
5656
public loadingVereine = true;
@@ -373,6 +373,7 @@ export class DsbMitgliedDetailComponent extends CommonComponentDirective impleme
373373

374374
}
375375
});
376+
this.applyVereinFilter();
376377
}
377378

378379
private handleFailure(response: BogenligaResponse<DsbMitgliedDO>) {
@@ -432,13 +433,43 @@ export class DsbMitgliedDetailComponent extends CommonComponentDirective impleme
432433
if (this.currentUserService.hasPermission(UserPermission.CAN_CREATE_VEREIN_DSBMITGLIEDER)) {
433434
response.payload = response.payload.filter((entry) => this.currentUserService.getVerein() === entry.id);
434435
}
435-
// this.currentVerein = response.payload[0];
436436
this.vereine = response.payload;
437+
this.applyVereinFilter();
437438
this.loadingVereine = false;
438439
this.vereineLoaded = true;
439440
})
440441
.catch((response: BogenligaResponse<VereinDTO[]>) => {
441442
this.vereine = response.payload;
443+
this.applyVereinFilter();
442444
});
443445
}
446+
447+
public onVereinSearch(searchTerm: string): void {
448+
this.vereinSearchTerm = searchTerm;
449+
this.applyVereinFilter();
450+
}
451+
452+
private applyVereinFilter(): void {
453+
const normalizedSearchTerm = (this.vereinSearchTerm || '').trim().toLocaleLowerCase();
454+
455+
if (!normalizedSearchTerm) {
456+
this.filteredVereine = [...this.vereine];
457+
return;
458+
}
459+
460+
this.filteredVereine = this.vereine.filter((verein: VereinDO) => this.matchesVereinSearch(verein, normalizedSearchTerm));
461+
462+
if (this.currentVerein?.id && !this.filteredVereine.some((verein: VereinDO) => verein.id === this.currentVerein.id)) {
463+
const selectedVerein = this.vereine.find((verein: VereinDO) => verein.id === this.currentVerein.id);
464+
if (selectedVerein) {
465+
this.filteredVereine = [selectedVerein, ...this.filteredVereine];
466+
}
467+
}
468+
}
469+
470+
private matchesVereinSearch(verein: VereinDO, normalizedSearchTerm: string): boolean {
471+
return [verein.name, verein.identifier, verein.regionName]
472+
.filter((value: string) => !!value)
473+
.some((value: string) => value.toLocaleLowerCase().includes(normalizedSearchTerm));
474+
}
444475
}

bogenliga/src/app/modules/verwaltung/components/veranstaltung/veranstaltung-detail/veranstaltung-detail.component.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ const NOTIFICATION_DELETE_MANNSCHAFT = 'mannschaft_detail_delete';
7171
const NOTIFICATION_FINISH_VERANSTALTUNG = 'veranstaltung_detail_finish';
7272
const NOTIFICATION_CREATE_PLATZHALTER = 'platzhalter_create';
7373
const NOTIFICATION_CREATE_PLATZHALTER_FAILURE = 'platzhalter_create_failure';
74+
const NOTIFICATION_CREATE_PLATZHALTER_PERMISSION_FAILURE = 'platzhalter_create_permission_failure';
7475

7576

7677

@@ -517,7 +518,7 @@ export class VeranstaltungDetailComponent extends CommonComponentDirective imple
517518
this.saveLoading = true;
518519

519520
const platzhalterId = 99;
520-
const platzhalterNummer = "1";
521+
const platzhalterNummer = '1';
521522

522523

523524
this.selectedMannschaft.vereinId = platzhalterId;
@@ -531,7 +532,6 @@ export class VeranstaltungDetailComponent extends CommonComponentDirective imple
531532
&& !isNullOrUndefined(response.payload)
532533
&& !isNullOrUndefined(response.payload.id)) {
533534
console.log('Saved with id: ' + response.payload.id);
534-
console.log('Wir sind der Sturm, der über das Ziel hinwegfegt, niemand kann uns aufhalten!');
535535
const notification: Notification = {
536536
id: NOTIFICATION_CREATE_PLATZHALTER,
537537
title: 'MANAGEMENT.VERANSTALTUNG_DETAIL.NOTIFICATION.PLATZHALTER_SAVE.TITLE',
@@ -555,16 +555,26 @@ export class VeranstaltungDetailComponent extends CommonComponentDirective imple
555555
}
556556
)
557557
.catch((response) => {
558+
let notificationId = NOTIFICATION_CREATE_PLATZHALTER_FAILURE;
559+
let title = 'MANAGEMENT.VERANSTALTUNG_DETAIL.NOTIFICATION.PLATZHALTER_FAILURE.TITLE';
560+
let description = 'MANAGEMENT.VERANSTALTUNG_DETAIL.NOTIFICATION.PLATZHALTER_FAILURE.DESCRIPTION';
561+
562+
if (response.error && response.error.status === 403) {
563+
notificationId = NOTIFICATION_CREATE_PLATZHALTER_PERMISSION_FAILURE;
564+
title = 'Keine Berechtigung';
565+
description = 'Sie haben keine Berechtigung für diese Aktion. Die Änderungen wurden nicht gespeichert.';
566+
}
567+
558568
const notification: Notification = {
559-
id: NOTIFICATION_CREATE_PLATZHALTER_FAILURE,
560-
title: 'MANAGEMENT.VERANSTALTUNG_DETAIL.NOTIFICATION.PLATZHALTER_FAILURE.TITLE',
561-
description: 'MANAGEMENT.VERANSTALTUNG_DETAIL.NOTIFICATION.PLATZHALTER_FAILURE.DESCRIPTION',
569+
id: notificationId,
570+
title: title,
571+
description: description,
562572
severity: NotificationSeverity.ERROR,
563573
origin: NotificationOrigin.USER,
564574
type: NotificationType.OK,
565575
userAction: NotificationUserAction.PENDING
566576
};
567-
this.notificationService.observeNotification(NOTIFICATION_CREATE_PLATZHALTER_FAILURE)
577+
this.notificationService.observeNotification(notificationId)
568578
.subscribe((myNotification) => {
569579
if (myNotification.userAction === NotificationUserAction.ACCEPTED) {
570580
this.saveLoading = false;

0 commit comments

Comments
 (0)