From 0a9c16e9e9f170ad93b7b40644ee587f6d166bf2 Mon Sep 17 00:00:00 2001 From: Marc Schmidt Date: Sat, 20 Jul 2024 17:26:50 +0200 Subject: [PATCH] feat: enable admins to edit events from the player events routes (#149) Closes: #146 --- .../player-event-details.component.html | 27 +++++-- .../player-events.component.html | 74 ++++++++++--------- .../player-events/player-events.component.ts | 11 ++- .../user-dialog/user-dialog.component.html | 4 +- .../app/components/users/users.component.html | 2 +- 5 files changed, 71 insertions(+), 47 deletions(-) diff --git a/src/client/src/app/components/player-events/player-event-details/player-event-details.component.html b/src/client/src/app/components/player-events/player-event-details/player-event-details.component.html index d01d883..79fa3ff 100644 --- a/src/client/src/app/components/player-events/player-event-details/player-event-details.component.html +++ b/src/client/src/app/components/player-events/player-event-details/player-event-details.component.html @@ -1,12 +1,23 @@
- @if (hasFailed() || isBusy() || event()) { - - } +
+ @if (hasFailed() || isBusy() || event()) { + + @if (user()?.roles?.includes('admin') && event()) { + + } + } +
@if (isBusy()) { diff --git a/src/client/src/app/components/player-events/player-events.component.html b/src/client/src/app/components/player-events/player-events.component.html index 271cc06..d3aaeb9 100644 --- a/src/client/src/app/components/player-events/player-events.component.html +++ b/src/client/src/app/components/player-events/player-events.component.html @@ -19,23 +19,9 @@

{{ translations.playerEvents_greetings({ name: user.alias }) }}

{{ translations.playerEvents_currentEvents() }}

@for (event of currentEvents(); track event.id; let index = $index) { - - {{ - event.date | date: 'fullDate' : undefined : locale() - }} - - @if (getRegisteredTimeslotsCount(event); as timeslotCount) { - {{ translations.playerEvents_registered({ timeslots: timeslotCount }) }} - } @else { - {{ translations.playerEvents_notRegistered() }} - } - - + } @if (currentEvents().length === 0) {
@@ -46,24 +32,10 @@

{{ translations.playerEvents_currentEvents() }}

{{ translations.playerEvents_pastEvents() }}

- @for (event of pastEvents(); track event.id; let index = $index) { - - {{ - event.date | date: 'fullDate' : undefined : locale() - }} - - @if (getRegisteredTimeslotsCount(event); as timeslotCount) { - {{ translations.playerEvents_registered({ timeslots: timeslotCount }) }} - } @else { - {{ translations.playerEvents_notRegistered() }} - } - - + @for (event of pastEvents(); track event.id) { + } @if (pastEvents().length === 0) {
@@ -77,3 +49,35 @@

{{ translations.playerEvents_pastEvents() }}

}
} + + + + {{ + event.date | date: 'fullDate' : undefined : locale() + }} + + @if (getRegisteredTimeslotsCount(event); as timeslotCount) { + {{ translations.playerEvents_registered({ timeslots: timeslotCount }) }} + } @else { + {{ translations.playerEvents_notRegistered() }} + } + + @if (user()?.roles?.includes('admin')) { + + } + + diff --git a/src/client/src/app/components/player-events/player-events.component.ts b/src/client/src/app/components/player-events/player-events.component.ts index a65412d..16d449f 100644 --- a/src/client/src/app/components/player-events/player-events.component.ts +++ b/src/client/src/app/components/player-events/player-events.component.ts @@ -2,8 +2,10 @@ import { CommonModule } from '@angular/common'; import { ChangeDetectionStrategy, Component, computed, inject } from '@angular/core'; import { toSignal } from '@angular/core/rxjs-interop'; import { RouterLink } from '@angular/router'; +import { ButtonModule } from 'primeng/button'; import { MessagesModule } from 'primeng/messages'; import { ProgressSpinnerModule } from 'primeng/progressspinner'; +import { TooltipModule } from 'primeng/tooltip'; import { map, timer } from 'rxjs'; import { hasActionFailed, isActionBusy } from '../../+state/action-state'; @@ -20,7 +22,14 @@ const dayMillis = 24 * 60 * 60 * 1000; @Component({ selector: 'app-player-events', standalone: true, - imports: [CommonModule, MessagesModule, ProgressSpinnerModule, RouterLink], + imports: [ + ButtonModule, + CommonModule, + MessagesModule, + ProgressSpinnerModule, + RouterLink, + TooltipModule, + ], templateUrl: './player-events.component.html', styleUrl: './player-events.component.scss', changeDetection: ChangeDetectionStrategy.OnPush, diff --git a/src/client/src/app/components/users/user-dialog/user-dialog.component.html b/src/client/src/app/components/users/user-dialog/user-dialog.component.html index 1c66130..70216c9 100644 --- a/src/client/src/app/components/users/user-dialog/user-dialog.component.html +++ b/src/client/src/app/components/users/user-dialog/user-dialog.component.html @@ -103,7 +103,7 @@

{{ translations.users_dialog_roles_title() }}

> {{ translations.users_dialog_roles_title() }} > }