diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts index ae9d237..8bb7b3d 100644 --- a/frontend/src/app/app.module.ts +++ b/frontend/src/app/app.module.ts @@ -64,6 +64,7 @@ import { import { ExpenseSplitWidgetComponent } from './widgets/expense-split-widget/expense-split-widget.component'; import { CreateEditExpenseEntryDialogComponent } from './widgets/expense-split-widget/create-edit-expense-entry-dialog/create-edit-expense-entry-dialog.component'; import {MatSelectModule} from "@angular/material/select"; +import { ExpenseEntryCardComponent } from './widgets/expense-split-widget/expense-entry-card/expense-entry-card.component'; registerLocaleData(localeDe); @@ -114,6 +115,7 @@ function loadMapApi(httpClient: HttpClient) { ParticipantCardComponent, ExpenseSplitWidgetComponent, CreateEditExpenseEntryDialogComponent, + ExpenseEntryCardComponent, ], imports: [ BrowserModule, 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 new file mode 100644 index 0000000..f1c4b1c --- /dev/null +++ b/frontend/src/app/widgets/expense-split-widget/expense-entry-card/expense-entry-card.component.html @@ -0,0 +1,34 @@ + + + {{ entry.description }} + + + + +
+
+ call_split + @if (isEveryoneInvolved) { + jeder + } @else { + {{ getInvolvedUserNames.join(", ") }} + } +
+ +
+ +
+ +
+ @if (creator) { + + {{ creator.firstName }} {{ creator.lastName }} + } @else { +

Zahlungsempfänger konnte nicht ermittelt werden.

+ } +
+
+
+
diff --git a/frontend/src/app/widgets/expense-split-widget/expense-entry-card/expense-entry-card.component.scss b/frontend/src/app/widgets/expense-split-widget/expense-entry-card/expense-entry-card.component.scss new file mode 100644 index 0000000..5aebe2c --- /dev/null +++ b/frontend/src/app/widgets/expense-split-widget/expense-entry-card/expense-entry-card.component.scss @@ -0,0 +1,17 @@ +.menu-button { + margin-left: auto; +} + +.content-container { + display: flex; + flex-direction: row; + flex-wrap: wrap; + justify-content: space-between; + gap: var(--size-12); +} + +.user-profile-picture { + border-radius: 50%; + vertical-align: middle; + margin-right: 5px; +} diff --git a/frontend/src/app/widgets/expense-split-widget/expense-entry-card/expense-entry-card.component.spec.ts b/frontend/src/app/widgets/expense-split-widget/expense-entry-card/expense-entry-card.component.spec.ts new file mode 100644 index 0000000..31779f2 --- /dev/null +++ b/frontend/src/app/widgets/expense-split-widget/expense-entry-card/expense-entry-card.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ExpenseEntryCardComponent } from './expense-entry-card.component'; + +describe('ExpenseEntryCardComponent', () => { + let component: ExpenseEntryCardComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ExpenseEntryCardComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(ExpenseEntryCardComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); 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 new file mode 100644 index 0000000..1bd2fe3 --- /dev/null +++ b/frontend/src/app/widgets/expense-split-widget/expense-entry-card/expense-entry-card.component.ts @@ -0,0 +1,34 @@ +import {Component, Input} from '@angular/core'; +import {ExpenseEntry} from "../../../../model/expense-split-widget"; +import {SimpleUser} from "../../../../model/user"; +import {Event} from "../../../../model/event"; + +@Component({ + selector: 'app-expense-entry-card', + templateUrl: './expense-entry-card.component.html', + styleUrl: './expense-entry-card.component.scss' +}) +export class ExpenseEntryCardComponent { + + @Input() + entry!: ExpenseEntry; + + @Input() + eventData!: Event; + + get getInvolvedUserNames(): string[] { + return this.entry.involvedUsers.map(u => [u.user.firstName, u.user.firstName].join(" ")); + } + + get isEveryoneInvolved(): boolean { + const eventParticipantIds = this.eventData.participants.map(p => p.id); + const involvedUserIds = this.entry.involvedUsers.map(u => u.user.id); + return eventParticipantIds.length === involvedUserIds.length && + eventParticipantIds.every(id => involvedUserIds.includes(id)); + } + + get creator(): SimpleUser | undefined { + return this.eventData.participants.find(p => p.id === this.entry.creatorId); + } + +} diff --git a/frontend/src/app/widgets/expense-split-widget/expense-split-widget.component.html b/frontend/src/app/widgets/expense-split-widget/expense-split-widget.component.html index 19c0949..862df9b 100644 --- a/frontend/src/app/widgets/expense-split-widget/expense-split-widget.component.html +++ b/frontend/src/app/widgets/expense-split-widget/expense-split-widget.component.html @@ -4,6 +4,17 @@ add Ausgabe erstellen + + } @else {
diff --git a/frontend/src/app/widgets/expense-split-widget/expense-split-widget.component.scss b/frontend/src/app/widgets/expense-split-widget/expense-split-widget.component.scss index a8d8726..04a30b5 100644 --- a/frontend/src/app/widgets/expense-split-widget/expense-split-widget.component.scss +++ b/frontend/src/app/widgets/expense-split-widget/expense-split-widget.component.scss @@ -1,3 +1,9 @@ +.expense-entry-list { + list-style: none; + margin: 0; + padding: 0; +} + .no-entries-container { display: grid; place-items: center;