add-game.component.ts code cleanup

This commit is contained in:
Patrick Müller 2022-09-10 18:45:22 +02:00
parent c6302ad8c0
commit f69f7f1731
Signed by: Paddy
GPG Key ID: 37ABC11275CAABCE

View File

@ -16,6 +16,16 @@ export class AddGameComponent implements OnInit {
currentPage: number = 0; currentPage: number = 0;
constructor() { constructor() {
this.generateDemoData();
}
ngOnInit(): void {
}
/**
* Generates demo data to test the UI
*/
generateDemoData() {
this.potentialPlayers.push({ this.potentialPlayers.push({
firebonkId: 1, firebonkId: 1,
uuid: 'abc-def-ghi-j', uuid: 'abc-def-ghi-j',
@ -42,19 +52,32 @@ export class AddGameComponent implements OnInit {
firstName: 'Moritz' firstName: 'Moritz'
}); });
this.actualPlayers.push(...this.potentialPlayers.slice(0,4)); this.actualPlayers.push(...this.potentialPlayers.slice(0, 4));
} }
ngOnInit(): void { /**
* Switches the entry mask UI to the next page
*/
switchToNextPage(): void {
this.currentPage++;
} }
/**
* ____ __
* / __ \/ /___ ___ _____ __________
* / /_/ / / __ `/ / / / _ \/ ___/ ___/
* / ____/ / /_/ / /_/ / __/ / (__ )
* /_/ /_/\__,_/\__, /\___/_/ /____/
* /____/
*/
/** /**
* Toggles if the given player is should be an active player for the current game * Toggles if the given player is should be an active player for the current game
* @param player The player to toggle the activity for * @param player The player to toggle the activity for
*/ */
togglePlayer(player: Player): void { togglePlayer(player: Player): void {
let index = this.actualPlayers.indexOf(player); let index = this.actualPlayers.indexOf(player);
if(index !== -1){ if (index !== -1) {
this.actualPlayers.splice(index, 1); this.actualPlayers.splice(index, 1);
} else { } else {
this.actualPlayers.push(player); this.actualPlayers.push(player);
@ -78,11 +101,12 @@ export class AddGameComponent implements OnInit {
} }
/** /**
* Switches the entry mask UI to the next page * ___ __
* / | ____ ____ ____ __ ______ ________ ____ ___ ___ ____ / /______
* / /| | / __ \/ __ \/ __ \/ / / / __ \/ ___/ _ \/ __ `__ \/ _ \/ __ \/ __/ ___/
* / ___ |/ / / / / / / /_/ / /_/ / / / / /__/ __/ / / / / / __/ / / / /_(__ )
* /_/ |_/_/ /_/_/ /_/\____/\__,_/_/ /_/\___/\___/_/ /_/ /_/\___/_/ /_/\__/____/
*/ */
switchToNextPage(): void {
this.currentPage++;
}
/** /**
* Toggles the activity status for the given announcement * Toggles the activity status for the given announcement
@ -90,7 +114,7 @@ export class AddGameComponent implements OnInit {
*/ */
toggleAnnouncement(announcement: Announcement.Announcement): void { toggleAnnouncement(announcement: Announcement.Announcement): void {
let index = this.selectedAnnouncements.indexOf(announcement); let index = this.selectedAnnouncements.indexOf(announcement);
if(index !== -1){ if (index !== -1) {
this.selectedAnnouncements.splice(index, 1); this.selectedAnnouncements.splice(index, 1);
} else { } else {
this.selectedAnnouncements.push(announcement); this.selectedAnnouncements.push(announcement);