Patrick Mueller
0e6d1b4390
- Create Component - Add logic to switch "pages" in component - add "select player" logic
40 lines
972 B
TypeScript
40 lines
972 B
TypeScript
import {Component, ElementRef, EventEmitter, HostListener, Input, OnInit, Output} from '@angular/core';
|
|
import {User} from '../../models/user';
|
|
|
|
@Component({
|
|
selector: 'app-profile',
|
|
templateUrl: './profile.component.html',
|
|
styleUrls: ['./profile.component.scss']
|
|
})
|
|
export class ProfileComponent implements OnInit {
|
|
|
|
initialClick = true;
|
|
@Input() user?: User;
|
|
@Output() showProfilePopOverChange = new EventEmitter<boolean>();
|
|
|
|
constructor(private eRef: ElementRef) {
|
|
}
|
|
|
|
ngOnInit(): void {
|
|
}
|
|
|
|
/**
|
|
* Used to close Profile component when user clicks outside the component
|
|
* @param event
|
|
*/
|
|
@HostListener('document:click', ['$event'])
|
|
@HostListener('document:touchstart', ['$event'])
|
|
handleOutsideClick(event: any) {
|
|
if (this.initialClick) {
|
|
this.initialClick = false;
|
|
return;
|
|
}
|
|
|
|
if (!this.eRef.nativeElement.contains(event.target)) {
|
|
this.showProfilePopOverChange.emit(false);
|
|
}
|
|
}
|
|
|
|
// TODO: Close modal also when "escape" is clicked
|
|
}
|