diff --git a/frontend/src/app/eventpage/participants-sidenav/participant-card/participant-card.component.html b/frontend/src/app/eventpage/participants-sidenav/participant-card/participant-card.component.html index be10464..13ddd24 100644 --- a/frontend/src/app/eventpage/participants-sidenav/participant-card/participant-card.component.html +++ b/frontend/src/app/eventpage/participants-sidenav/participant-card/participant-card.component.html @@ -4,10 +4,12 @@ width="35" height="35" [ngSrc]="user.profilePictureUrl" + [class.left-participant-profile-picture]="user.hasLeft" + referrerpolicy="no-referrer" alt="Profilbild"> - {{ user.firstName }} {{ user.lastName }} + {{ getUserNameForParticipant(user) }} @if (isOwner) {
(Ersteller) diff --git a/frontend/src/app/eventpage/participants-sidenav/participant-card/participant-card.component.ts b/frontend/src/app/eventpage/participants-sidenav/participant-card/participant-card.component.ts index 59265b7..20debe9 100644 --- a/frontend/src/app/eventpage/participants-sidenav/participant-card/participant-card.component.ts +++ b/frontend/src/app/eventpage/participants-sidenav/participant-card/participant-card.component.ts @@ -1,5 +1,6 @@ import {Component, Input} from '@angular/core'; -import {SimpleUser} from "../../../../model/user"; +import {EventParticipant} from "../../../../model/user"; +import {getUserNameForParticipant} from "../../../../utils/user.utils"; @Component({ selector: 'app-participant-card', @@ -8,8 +9,9 @@ import {SimpleUser} from "../../../../model/user"; }) export class ParticipantCardComponent { @Input() - user!: SimpleUser + user!: EventParticipant @Input() isOwner!: boolean; + protected readonly getUserNameForParticipant = getUserNameForParticipant; } diff --git a/frontend/src/app/eventpage/participants-sidenav/participants-sidenav.component.ts b/frontend/src/app/eventpage/participants-sidenav/participants-sidenav.component.ts index 090eadf..838ff9a 100644 --- a/frontend/src/app/eventpage/participants-sidenav/participants-sidenav.component.ts +++ b/frontend/src/app/eventpage/participants-sidenav/participants-sidenav.component.ts @@ -1,6 +1,6 @@ import {Component, Input, OnInit} from '@angular/core'; import {Event} from "../../../model/event"; -import {SimpleUser} from "../../../model/user"; +import {EventParticipant} from "../../../model/user"; @Component({ selector: 'app-participants-sidenav', @@ -11,13 +11,13 @@ export class ParticipantsSidenavComponent implements OnInit { @Input() eventData!: Event; - owner: SimpleUser | undefined; + owner: EventParticipant | undefined; ngOnInit(): void { this.owner = this.eventData.participants.find((user) => user.id === this.eventData.creatorId) } - allParticipantsExceptOwner(): SimpleUser[] { + allParticipantsExceptOwner(): EventParticipant[] { return this.eventData.participants.filter((user) => user.id !== this.eventData.creatorId) } diff --git a/frontend/src/app/widgets/expense-split-widget/create-edit-expense-entry-dialog/create-edit-expense-entry-dialog.component.html b/frontend/src/app/widgets/expense-split-widget/create-edit-expense-entry-dialog/create-edit-expense-entry-dialog.component.html index 1821006..0828137 100644 --- a/frontend/src/app/widgets/expense-split-widget/create-edit-expense-entry-dialog/create-edit-expense-entry-dialog.component.html +++ b/frontend/src/app/widgets/expense-split-widget/create-edit-expense-entry-dialog/create-edit-expense-entry-dialog.component.html @@ -16,11 +16,19 @@

Ausgabe {{ isCreatingNewEntry ? 'erstellen' : 'bearbeiten'  € - @if (userService.user | async; as user) { + @if (creator | async; as creator) {

Zahlungsempfänger

- - {{ user.firstName }} {{ user.lastName }} + + {{ getUserNameForParticipant(creator) }}
} @@ -29,8 +37,16 @@

Ausgabe {{ isCreatingNewEntry ? 'erstellen' : 'bearbeiten' @for (user of users; track user.id) { - - {{ user.firstName }} {{ user.lastName }} + + {{ getUserNameForParticipant(user) }} } diff --git a/frontend/src/app/widgets/expense-split-widget/create-edit-expense-entry-dialog/create-edit-expense-entry-dialog.component.ts b/frontend/src/app/widgets/expense-split-widget/create-edit-expense-entry-dialog/create-edit-expense-entry-dialog.component.ts index b2054c2..3d41a8b 100644 --- a/frontend/src/app/widgets/expense-split-widget/create-edit-expense-entry-dialog/create-edit-expense-entry-dialog.component.ts +++ b/frontend/src/app/widgets/expense-split-widget/create-edit-expense-entry-dialog/create-edit-expense-entry-dialog.component.ts @@ -1,9 +1,11 @@ import {Component, Inject} from '@angular/core'; import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog"; -import {SimpleUser} from "../../../../model/user"; +import {EventParticipant} from "../../../../model/user"; import {ExpenseEntry, ExpenseEntryAddCommand, ExpenseEntryUpdateCommand} from "../../../../model/expense-split-widget"; import {FormBuilder, FormControl, FormGroup, Validators} from "@angular/forms"; import {UserService} from "../../../../services/user.service"; +import {getUserNameForParticipant} from "../../../../utils/user.utils"; +import {filter, map, Observable, of} from "rxjs"; @Component({ selector: 'app-create-edit-expense-split-dialog', @@ -12,13 +14,13 @@ import {UserService} from "../../../../services/user.service"; }) export class CreateEditExpenseEntryDialogComponent { - users: SimpleUser[]; + users: EventParticipant[]; entry: ExpenseEntry | undefined; formGroup: FormGroup; constructor( - @Inject(MAT_DIALOG_DATA) data: { users: SimpleUser[], entry: ExpenseEntry | undefined }, + @Inject(MAT_DIALOG_DATA) data: { users: EventParticipant[], entry: ExpenseEntry | undefined }, private dialogRef: MatDialogRef, public userService: UserService, fb: FormBuilder @@ -51,8 +53,19 @@ export class CreateEditExpenseEntryDialogComponent { this.dialogRef.close(data); } + get creator(): Observable { + if (this.isCreatingNewEntry) { + return this.userService.user.asObservable().pipe( + filter(user => user != null), + map(user => this.users.find(p => p.id === user!.id)) + ); + } + return of(this.users.find(p => p.id === this.entry?.creatorId)); + } + get isCreatingNewEntry(): boolean { return !this.entry; } + protected readonly getUserNameForParticipant = getUserNameForParticipant; } diff --git a/frontend/src/app/widgets/expense-split-widget/expense-debt-overview/expense-debt-overview.component.html b/frontend/src/app/widgets/expense-split-widget/expense-debt-overview/expense-debt-overview.component.html index 3d1635e..9745f18 100644 --- a/frontend/src/app/widgets/expense-split-widget/expense-debt-overview/expense-debt-overview.component.html +++ b/frontend/src/app/widgets/expense-split-widget/expense-debt-overview/expense-debt-overview.component.html @@ -18,8 +18,16 @@ } - - {{ debt.user.firstName }} {{ debt.user.lastName }} + + {{ getUserNameForParticipant(debt.user)}} {{ Math.abs(debt.debtAmount) | currency: "EUR" }} diff --git a/frontend/src/app/widgets/expense-split-widget/expense-debt-overview/expense-debt-overview.component.ts b/frontend/src/app/widgets/expense-split-widget/expense-debt-overview/expense-debt-overview.component.ts index 2023607..2906fd2 100644 --- a/frontend/src/app/widgets/expense-split-widget/expense-debt-overview/expense-debt-overview.component.ts +++ b/frontend/src/app/widgets/expense-split-widget/expense-debt-overview/expense-debt-overview.component.ts @@ -1,5 +1,6 @@ import {Component, Input} from '@angular/core'; import {Debt} from "../../../../model/expense-split-widget"; +import {getUserNameForParticipant} from "../../../../utils/user.utils"; @Component({ selector: 'app-expense-debt-overview', @@ -16,4 +17,5 @@ export class ExpenseDebtOverviewComponent { } protected readonly Math = Math; + protected readonly getUserNameForParticipant = getUserNameForParticipant; } diff --git a/frontend/src/app/widgets/expense-split-widget/expense-entry-card/expense-entry-card.component.html b/frontend/src/app/widgets/expense-split-widget/expense-entry-card/expense-entry-card.component.html index 6d1a296..9166049 100644 --- a/frontend/src/app/widgets/expense-split-widget/expense-entry-card/expense-entry-card.component.html +++ b/frontend/src/app/widgets/expense-split-widget/expense-entry-card/expense-entry-card.component.html @@ -42,8 +42,16 @@
@if (creator) { - - {{ creator.firstName }} {{ creator.lastName }} + + {{ getUserNameForParticipant(creator) }} } @else {

Zahlungsempfänger konnte nicht ermittelt werden.

} diff --git a/frontend/src/app/widgets/expense-split-widget/expense-entry-card/expense-entry-card.component.ts b/frontend/src/app/widgets/expense-split-widget/expense-entry-card/expense-entry-card.component.ts index 62aaed6..0fa8431 100644 --- a/frontend/src/app/widgets/expense-split-widget/expense-entry-card/expense-entry-card.component.ts +++ b/frontend/src/app/widgets/expense-split-widget/expense-entry-card/expense-entry-card.component.ts @@ -1,7 +1,8 @@ import {Component, EventEmitter, Input, Output} from '@angular/core'; import {ExpenseEntry} from "../../../../model/expense-split-widget"; -import {SimpleUser} from "../../../../model/user"; +import {EventParticipant} from "../../../../model/user"; import {Event} from "../../../../model/event"; +import {getUserNameForParticipant} from "../../../../utils/user.utils"; @Component({ selector: 'app-expense-entry-card', @@ -23,7 +24,7 @@ export class ExpenseEntryCardComponent { onEdit = new EventEmitter(); get getInvolvedUserNames(): string[] { - return this.entry.involvedUsers.map(u => [u.user.firstName, u.user.lastName].join(" ")); + return this.entry.involvedUsers.map(u => getUserNameForParticipant(u.user)); } get isEveryoneInvolved(): boolean { @@ -33,8 +34,9 @@ export class ExpenseEntryCardComponent { eventParticipantIds.every(id => involvedUserIds.includes(id)); } - get creator(): SimpleUser | undefined { + get creator(): EventParticipant | undefined { return this.eventData.participants.find(p => p.id === this.entry.creatorId); } + protected readonly getUserNameForParticipant = getUserNameForParticipant; } diff --git a/frontend/src/app/widgets/expense-split-widget/expense-split-widget.component.ts b/frontend/src/app/widgets/expense-split-widget/expense-split-widget.component.ts index 8f6d2de..0957417 100644 --- a/frontend/src/app/widgets/expense-split-widget/expense-split-widget.component.ts +++ b/frontend/src/app/widgets/expense-split-widget/expense-split-widget.component.ts @@ -37,7 +37,7 @@ export class ExpenseSplitWidgetComponent { createNewExpenseEntry() { const dialogRef = this.dialog.open(CreateEditExpenseEntryDialogComponent, { width: "600px", - data: {users: this.eventData.participants} + data: {users: this.eventData.participants.filter(p => !p.hasLeft)} }); dialogRef.afterClosed().subscribe(addCommand => { diff --git a/frontend/src/app/widgets/shopping-list-widget/shopping-list-entry-list-item/shopping-list-entry-list-item.component.html b/frontend/src/app/widgets/shopping-list-widget/shopping-list-entry-list-item/shopping-list-entry-list-item.component.html index 68a1345..95c02da 100644 --- a/frontend/src/app/widgets/shopping-list-widget/shopping-list-entry-list-item/shopping-list-entry-list-item.component.html +++ b/frontend/src/app/widgets/shopping-list-widget/shopping-list-entry-list-item/shopping-list-entry-list-item.component.html @@ -5,7 +5,7 @@ @if (item.buyerId) {

person - {{ buyer?.firstName }} {{ buyer?.lastName }} + {{ buyer ? getUserName(buyer) : '?' }}

}