Skip to content

Commit

Permalink
Ticket #1644 wann darf ich eine neue liga erstellen (#407)
Browse files Browse the repository at this point in the history
* Added Ligaleiter Functionality to Add Subordinate League if League editet was lowest in Region X

* Added Tests for lowestLiga in Frontend, not complete!
  • Loading branch information
SunnyPaladin committed Jun 5, 2024
1 parent bd74a5d commit 1164c94
Show file tree
Hide file tree
Showing 11 changed files with 132 additions and 15 deletions.
16 changes: 16 additions & 0 deletions bogenliga/cypress/e2e/bsapp/bsapp-e2e-default.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,22 @@ describe('Ligadetailseite', function(){
cy.get('[id="goToLigadetailsButton"]').click();
cy.url().should('include', '#/home/' + randomID)
})

it('Neue unterste Liga hinzufuegen',function (){


cy.visit('http://localhost:4200/#/verwaltung/liga')

cy.get('bla-navbar > #navbar > #navbar-right > .nav-link > .btn').click()

cy.get('bla-alert > #undefined > p:nth-child(7) > bla-button > #undefined').click()

cy.get('.sidebar-link > div > .ng-fa-icon > .fa-cogs > path').click()

cy.get('.navigation-card > .tooltip-navigation-card > .card-body > .button-container > .btn').click()

})

})

describe('Ligaleiter User Tests', function(){
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,10 @@ export enum UserPermission {
CAN_MODIFY_SYSTEMDATEN_LIGALEITER,
CAN_CREATE_SYSTEMDATEN_LIGALEITER,
CAN_CREATE_STAMMDATEN_LIGALEITER,
CAN_MODIFY_STAMMDATEN_LIGALEITER
CAN_MODIFY_STAMMDATEN_LIGALEITER,

//Spezielles Recht für den Ligaleiter der untersten Region, der eine neue Liga als unterste Liga anlegen darf und diese bearbeiten kann
CAN_CREATE_MY_LIGA,
CAN_MODIFY_MY_LIGA,
CAN_READ_MY_LIGA
}
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,16 @@
(onClick)="onDelete($event)">
{{ 'MANAGEMENT.LIGA_DETAIL.FORM.DELETE' | translate }}
</bla-actionbutton>

<bla-actionbutton *ngIf="isLowestLiga"
[loading] ="saveLoading"
[color]="ActionButtonColors.SUCCESS"
[iconClass]="'plus'"
(onClick)="onCreateLowest($event)"
data-cy="lowest-liga-create-button">
{{ 'MANAGEMENT.LIGA_DETAIL.FORM.NEW_LOWEST' | translate}}
</bla-actionbutton>

</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ export class LigaDetailComponent extends CommonComponentDirective implements OnI
public currentUbergeordneteLiga: LigaDO = new LigaDO();
public allUebergeordnete: Array<LigaDO> = [new LigaDO()];

public allLowestLiga: Array<LigaDO> = [new LigaDO];
public isLowestLiga: boolean = false;
public lowestLiga: LigaDO = new LigaDO;

public currentDisziplin: DisziplinDO = new DisziplinDO();
public allDisziplin: Array<DisziplinDO> = [new DisziplinDO()];

Expand Down Expand Up @@ -101,16 +105,28 @@ export class LigaDetailComponent extends CommonComponentDirective implements OnI
if (!isUndefined(params[ID_PATH_PARAM])) {
this.id = params[ID_PATH_PARAM];
if (this.id === 'add') {
this.currentLiga = new LigaDO();
if(this.isLowestLiga) {
this.isLowestLiga = false;
this.loadByRestricted();

this.currentLiga = new LigaDO();
this.loading = false;
this.deleteLoading = false;
this.saveLoading = false;
}
else{
this.currentLiga = new LigaDO();

this.loadDisziplin();
this.loadUebergeordnete(); // additional Request for all 'liga' to get all uebergeordnete
this.loadRegions(); // Request all regions from backend
this.loadUsers();
this.loadDisziplin();
this.loadUebergeordnete(); // additional Request for all 'liga' to get all uebergeordnete
this.loadRegions(); // Request all regions from backend
this.loadUsers();
this.loadByLowest(); // Get all lowest Liga in all Regions

this.loading = false;
this.deleteLoading = false;
this.saveLoading = false;
this.loading = false;
this.deleteLoading = false;
this.saveLoading = false;
}
} else {
this.loadById(params[ID_PATH_PARAM]);
}
Expand Down Expand Up @@ -329,16 +345,49 @@ export class LigaDetailComponent extends CommonComponentDirective implements OnI
this.notificationService.showNotification(notification);
}

public onCreateLowest(ignore:any):void{
this.router.navigateByUrl("/verwaltung/liga/add");
}

public entityExists(): boolean {
return this.currentLiga.id >= 0;
}

public checkLowestLiga(): boolean{
for(var i = 0; i<this.allLowestLiga.length; i++){
if(this.allLowestLiga[i].id === this.currentLiga.id){
this.lowestLiga = this.allLowestLiga[i];
return true;
}
}
return false;
}

public loadByRestricted():void{
this.allDisziplin = [];
this.regionen = [];
this.allUebergeordnete = [];
this.allUsers = [];
this.currentUbergeordneteLiga = this.currentLiga;//TODO Da funktioniert noch was nicht ganz!

this.allDisziplin.push(this.currentDisziplin);
this.regionen.push(this.currentRegion);
this.allUebergeordnete.push(this.currentLiga);
this.allUsers.push(this.currentUser);
}

private loadById(id: number) {
this.ligaDataProvider.findById(id)
.then((response: BogenligaResponse<LigaDO>) => this.handleSuccess(response))
.catch((response: BogenligaResponse<LigaDO>) => this.handleFailure(response));
}

private loadByLowest(){
this.ligaDataProvider.findByLowest()
.then((response: BogenligaResponse<LigaDO[]>) => this.handleLowestResponseArraySuccess(response))
.catch((response: BogenligaResponse<LigaDTO[]>) => this.handleLowestResponseArrayFailure(response));
}

private loadDisziplin() {
this.disziplinDataProvider.findAll()
.then((response: BogenligaResponse<DisziplinDO[]>) => this.handleDisziplinResponseArraySuccess(response))
Expand Down Expand Up @@ -375,6 +424,7 @@ export class LigaDetailComponent extends CommonComponentDirective implements OnI
this.loadUebergeordnete(); // additional Request for all 'liga' to get all uebergeordnete
this.loadRegions(); // Request all regions from backend
this.loadUsers();
this.loadByLowest();
}

private handleFailure(response: BogenligaResponse<LigaDO>) {
Expand Down Expand Up @@ -427,6 +477,19 @@ export class LigaDetailComponent extends CommonComponentDirective implements OnI
this.notificationService.showNotification(notification);
}

private handleLowestResponseArraySuccess(response: BogenligaResponse<LigaDO[]>) : void{
this.allLowestLiga = [];
this.allLowestLiga = response.payload;
console.log(this.allLowestLiga);
this.isLowestLiga = this.checkLowestLiga();
this.loading = false;
}

private handleLowestResponseArrayFailure(response:BogenligaResponse<LigaDO[]>):void{
this.allLowestLiga = [];
this.loading = false;
}

private handleDisziplinResponseArraySuccess(response: BogenligaResponse<DisziplinDO[]>): void {
this.allDisziplin = [];
this.allDisziplin = response.payload;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,11 @@ export class LigaOverviewComponent extends CommonComponentDirective implements O
this.handleLoadTableRowsSuccess(response);
} else {
let filtered = response.payload.filter(ligadto => {
if (ligadto.ligaVerantwortlichMail == this.currentUserService.getEmail())
return true;
return false;
if (ligadto.ligaVerantwortlichMail === this.currentUserService.getEmail()){
return true;}
else {
return false;
}
})
this.handleLoadTableRows(filtered);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ export const LIGA_OVERVIEW_CONFIG: OverviewDialogConfig = {
editPermission : [UserPermission.CAN_MODIFY_SYSTEMDATEN],
deletePermission : [UserPermission.CAN_DELETE_SYSTEMDATEN]
},
createPermission : [UserPermission.CAN_CREATE_SYSTEMDATEN, UserPermission.CAN_CREATE_SYSTEMDATEN_LIGALEITER]
createPermission : [UserPermission.CAN_CREATE_SYSTEMDATEN]
};
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,25 @@ export class LigaDataProviderService extends DataProviderService {
});
}

public findByLowest(): Promise<BogenligaResponse<LigaDO[]>> {
// return promise
// sign in success -> resolve promise
// sign in failure -> reject promise with result
return new Promise((resolve, reject) => {
this.restClient.GET<Array<VersionedDataTransferObject>>(new UriBuilder().fromPath(this.getUrl()).path('lowest/').build())
.then((data: VersionedDataTransferObject[]) => {
resolve({result: RequestResult.SUCCESS, payload: fromPayloadArray(data)});
}, (error: HttpErrorResponse) => {

if (error.status === 0) {
reject({result: RequestResult.CONNECTION_PROBLEM});
} else {
reject({result: RequestResult.FAILURE});
}
});
});
}

public findBySearch(searchTerm: string): Promise<BogenligaResponse<LigaDO[]>> {
// return promise
// sign in success -> resolve promise
Expand Down
3 changes: 2 additions & 1 deletion bogenliga/src/assets/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,8 @@
},
"SAVE": "Speichern",
"UPDATE": "Aktualisieren",
"DELETE": "Löschen"
"DELETE": "Löschen",
"NEW_LOWEST": "Untergeordnete Liga erzeugen"
},
"NOTIFICATION": {
"DELETE": {
Expand Down
3 changes: 2 additions & 1 deletion bogenliga/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,8 @@
},
"SAVE": "Save",
"UPDATE": "Refresh",
"DELETE": "Delete"
"DELETE": "Delete",
"NEW_LOWEST": "Create subordinate League"
},
"NOTIFICATION": {
"DELETE": {
Expand Down

0 comments on commit 1164c94

Please sign in to comment.