Skip to content

Commit

Permalink
Merge pull request #256 from softwaremagico/255-dropping-back-a-user-…
Browse files Browse the repository at this point in the history
…from-a-team-generates-two-user-cards

Fixed duplicated user
  • Loading branch information
softwaremagico authored Nov 13, 2023
2 parents 1628e07 + 4ac51cd commit a4e8d04
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[![GitHub commit activity](https://img.shields.io/github/commit-activity/y/softwaremagico/KendoTournamentManager)](https://github.com/softwaremagico/KendoTournamentManager)
[![GitHub last commit](https://img.shields.io/github/last-commit/softwaremagico/KendoTournamentManager)](https://github.com/softwaremagico/KendoTournamentManager)
[![CircleCI](https://circleci.com/gh/softwaremagico/KendoTournamentManager.svg?style=shield)](https://circleci.com/gh/softwaremagico/KendoTournamentManager)
[![Time](https://img.shields.io/badge/development-513h-blueviolet.svg)]()
[![Time](https://img.shields.io/badge/development-513.5h-blueviolet.svg)]()

[![Powered by](https://img.shields.io/badge/powered%20by%20java-orange.svg?logo=OpenJDK&logoColor=white)]()
[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=kendo-tournament-backend&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=kendo-tournament-backend)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export class UserListData {
participants: Participant[];
filteredParticipants: Participant[];

filter(filter: string) {
filter(filter: string): void {
if (this.participants) {
filter = filter.toLowerCase().normalize('NFD').replace(/\p{Diacritic}/gu, "");
this.filteredParticipants = this.participants.filter(user => user.lastname.toLowerCase().normalize('NFD').replace(/\p{Diacritic}/gu, "").includes(filter) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ export class UserListComponent implements OnInit {
}

ngOnInit(): void {
this.filterResetService.resetFilter.pipe().subscribe(value => {
this.filterResetService.resetFilter.pipe().subscribe((value: boolean): void => {
if (value) {
this.filter('');
}
});
}

filter(filterString: string) {
filter(filterString: string): void {
this.userListData.filter(filterString);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {random} from "../../../utils/random/random";
import {FilterResetService} from "../../../services/notifications/filter-reset.service";
import {Fight} from "../../../models/fight";
import {Role} from "../../../models/role";
import {ScoreOfCompetitor} from "../../../models/score-of-competitor";

@Component({
selector: 'app-tournament-teams',
Expand Down Expand Up @@ -183,8 +184,12 @@ export class TournamentTeamsComponent extends RbacBasedComponent implements OnIn
this.deleteMemberFromTeam(movedParticipant);
this.updateTeam(sourceTeam, undefined);
//Add to user list.
this.userListData.participants.push(movedParticipant);
this.userListData.filteredParticipants.push(movedParticipant);
if (!this.userListData.participants.includes(movedParticipant)) {
this.userListData.participants.push(movedParticipant);
}
if (!this.userListData.filteredParticipants.includes(movedParticipant)) {
this.userListData.filteredParticipants.push(movedParticipant);
}

this.userListData.filteredParticipants.sort((a: Participant, b: Participant) => a.lastname.localeCompare(b.lastname));
this.userListData.participants.sort((a: Participant, b: Participant) => a.lastname.localeCompare(b.lastname));
Expand Down Expand Up @@ -343,8 +348,8 @@ export class TournamentTeamsComponent extends RbacBasedComponent implements OnIn
}
}
}
this.userListData.filteredParticipants.sort((a, b) => a.lastname.localeCompare(b.lastname));
this.userListData.participants.sort((a, b) => a.lastname.localeCompare(b.lastname));
this.userListData.filteredParticipants.sort((a: Participant, b: Participant) => a.lastname.localeCompare(b.lastname));
this.userListData.participants.sort((a: Participant, b: Participant) => a.lastname.localeCompare(b.lastname));

const teams: Team[] = [];
teams.push(team);
Expand Down Expand Up @@ -372,7 +377,7 @@ export class TournamentTeamsComponent extends RbacBasedComponent implements OnIn
let participants: Participant[];
participants = [...Array.prototype.concat.apply([], [...this.members.values()]), ...this.userListData.participants];

this.rankingService.getCompetitorsGlobalScoreRanking(participants).subscribe(_scoreRanking => {
this.rankingService.getCompetitorsGlobalScoreRanking(participants).subscribe((_scoreRanking: ScoreOfCompetitor[]): void => {
for (let team of this.teams) {
team.members = [];
for (let i = 0; i < (this.tournament.teamSize ? this.tournament.teamSize : 1); i++) {
Expand Down Expand Up @@ -466,7 +471,7 @@ export class TournamentTeamsComponent extends RbacBasedComponent implements OnIn
team.members[0] = member;
this.teams.push(team);
}
this.teamService.setAll(this.teams).subscribe(_teams => {
this.teamService.setAll(this.teams).subscribe((_teams: Team[]): void => {
this.messageService.infoMessage("infoTeamsAdded");
this.teams = _teams
this.userListData.participants = [];
Expand Down

0 comments on commit a4e8d04

Please sign in to comment.