2022-09-03 11:01:54 +00:00
|
|
|
import {Component, ElementRef, EventEmitter, HostListener, Input, OnInit, Output} from '@angular/core';
|
|
|
|
import {User} from '../../models/user';
|
2022-09-02 12:39:24 +00:00
|
|
|
|
|
|
|
@Component({
|
2022-09-02 15:55:19 +00:00
|
|
|
selector: 'app-profile',
|
|
|
|
templateUrl: './profile.component.html',
|
|
|
|
styleUrls: ['./profile.component.scss']
|
2022-09-02 12:39:24 +00:00
|
|
|
})
|
|
|
|
export class ProfileComponent implements OnInit {
|
|
|
|
|
2022-09-02 15:55:19 +00:00
|
|
|
initialClick = true;
|
2022-09-03 11:01:54 +00:00
|
|
|
@Input() user?: User;
|
2022-09-08 14:10:05 +00:00
|
|
|
@Output() showProfilePopOverChange = new EventEmitter<boolean>();
|
2022-09-02 12:39:24 +00:00
|
|
|
|
2022-09-02 15:55:19 +00:00
|
|
|
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)) {
|
2022-09-08 14:10:05 +00:00
|
|
|
this.showProfilePopOverChange.emit(false);
|
2022-09-02 15:55:19 +00:00
|
|
|
}
|
|
|
|
}
|
2022-09-02 12:39:24 +00:00
|
|
|
|
|
|
|
}
|