open user details without routing

This commit is contained in:
Chneemann 2024-05-25 09:41:26 +02:00
parent 9708d370e0
commit 0271ec8654
4 changed files with 14 additions and 18 deletions

View file

@ -29,7 +29,6 @@ export const routes: Routes = [
{ path: 'task/:id', component: TaskOverlayComponent }, { path: 'task/:id', component: TaskOverlayComponent },
{ path: 'task-edit/:id', component: TaskEditOverlayComponent }, { path: 'task-edit/:id', component: TaskEditOverlayComponent },
{ path: 'contacts', component: ContactsComponent }, { path: 'contacts', component: ContactsComponent },
{ path: 'contacts/:id', component: ContactsComponent },
{ path: 'help', component: HelpComponent }, { path: 'help', component: HelpComponent },
{ path: 'imprint', component: ImprintComponent }, { path: 'imprint', component: ImprintComponent },
{ path: 'privacy-policy', component: PrivacyPolicyComponent }, { path: 'privacy-policy', component: PrivacyPolicyComponent },

View file

@ -32,7 +32,7 @@ export class ContactDetailComponent {
) {} ) {}
closeUserDetails() { closeUserDetails() {
this.router.navigate(['contacts']); this.sharedService.currentUserId = '';
} }
checkUserData(userId: string) { checkUserData(userId: string) {

View file

@ -1,7 +1,9 @@
<section> <section>
<div <div
class="left-frame" class="left-frame"
[ngClass]="{ 'd-none': !showAllUsers && currentUserId != undefined }" [ngClass]="{
'd-none': !showAllUsers && sharedService.currentUserId != undefined
}"
> >
<button class="btn-new" type="submit" (click)="openNewContactDialog()"> <button class="btn-new" type="submit" (click)="openNewContactDialog()">
<div class="btn-inside"> <div class="btn-inside">
@ -20,9 +22,9 @@
index = $index) { index = $index) {
<div <div
class="contact" class="contact"
routerLink="/contacts/{{ user.id }}" (click)="showUserId(user.id)"
[ngClass]="{ [ngClass]="{
'contact-active': currentUserId === user.id 'contact-active': sharedService.currentUserId === user.id
}" }"
> >
<div <div
@ -63,8 +65,10 @@
</div> </div>
<div class="right-frame"> <div class="right-frame">
<app-contact-detail <app-contact-detail
[ngClass]="{ 'd-none': !showAllUsers && currentUserId == undefined }" [ngClass]="{
[currentUserId]="currentUserId" 'd-none': !showAllUsers && sharedService.currentUserId == undefined
}"
[currentUserId]="sharedService.currentUserId"
></app-contact-detail> ></app-contact-detail>
</div> </div>
</section> </section>

View file

@ -19,31 +19,24 @@ export class ContactsComponent {
usersFirstLetter: string[] = []; usersFirstLetter: string[] = [];
usersByFirstLetter: { [key: string]: string[] } = {}; usersByFirstLetter: { [key: string]: string[] } = {};
showAllUsers!: boolean; showAllUsers!: boolean;
currentUserId: string = '';
constructor( constructor(
public firebaseService: FirebaseService, public firebaseService: FirebaseService,
private route: ActivatedRoute, private route: ActivatedRoute,
private sharedService: SharedService public sharedService: SharedService
) {} ) {}
ngOnInit(): void { ngOnInit(): void {
this.routeUserId();
this.onResize(); this.onResize();
} }
routeUserId() { showUserId(userId: string = '') {
if (this.route.params.subscribe()) { this.sharedService.currentUserId = userId;
this.route.params.subscribe((params) => {
this.currentUserId = params['id'];
this.sharedService.currentUserId = params['id'];
});
}
} }
@HostListener('window:resize', ['$event']) @HostListener('window:resize', ['$event'])
onResize() { onResize() {
if (window.innerWidth <= 1150 && this.currentUserId != '') { if (window.innerWidth <= 1150 && this.sharedService.currentUserId != '') {
this.showAllUsers = false; this.showAllUsers = false;
} else { } else {
this.showAllUsers = true; this.showAllUsers = true;