added userInitials emitter
This commit is contained in:
parent
7170bc893d
commit
ec447ee3ad
6 changed files with 111 additions and 18 deletions
|
|
@ -28,4 +28,31 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
} @else {
|
||||||
|
<section>
|
||||||
|
<div class="dialog">
|
||||||
|
<div class="header">
|
||||||
|
<img src="./../../../../assets/img/logo.svg" alt="" />
|
||||||
|
<p>{{ "contacts.addContact" | translate }}</p>
|
||||||
|
<app-btn-close [isEditContactDialogOpen]="false"></app-btn-close>
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
<div class="badge">
|
||||||
|
<div
|
||||||
|
class="circle"
|
||||||
|
[ngStyle]="{
|
||||||
|
'background-color': randomColor
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<div class="initials">{{ userInitials }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form">
|
||||||
|
<app-contact-form
|
||||||
|
(inititalsEmitter)="inititalsEmitter($event)"
|
||||||
|
></app-contact-form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
import { Component, Input } from '@angular/core';
|
import { Component, Input, OnInit } from '@angular/core';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { BtnCloseComponent } from '../../../shared/components/buttons/btn-close/btn-close.component';
|
import { BtnCloseComponent } from '../../../shared/components/buttons/btn-close/btn-close.component';
|
||||||
import { FirebaseService } from '../../../services/firebase.service';
|
import { FirebaseService } from '../../../services/firebase.service';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { ContactFormComponent } from './contact-form/contact-form.component';
|
import { ContactFormComponent } from './contact-form/contact-form.component';
|
||||||
|
import { SharedService } from '../../../services/shared.service';
|
||||||
|
import { User } from '../../../interfaces/user.interface';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-contact-edit',
|
selector: 'app-contact-edit',
|
||||||
|
|
@ -17,8 +19,33 @@ import { ContactFormComponent } from './contact-form/contact-form.component';
|
||||||
templateUrl: './contact-edit-new.component.html',
|
templateUrl: './contact-edit-new.component.html',
|
||||||
styleUrl: './contact-edit-new.component.scss',
|
styleUrl: './contact-edit-new.component.scss',
|
||||||
})
|
})
|
||||||
export class ContactEditNewComponent {
|
export class ContactEditNewComponent implements OnInit {
|
||||||
@Input() currentUserId: string | undefined;
|
@Input() currentUserId: string | undefined;
|
||||||
|
randomColor: string = '';
|
||||||
|
userInitials: string = '';
|
||||||
|
|
||||||
constructor(public firebaseService: FirebaseService) {}
|
userData: User = {
|
||||||
|
uId: '',
|
||||||
|
firstName: '',
|
||||||
|
lastName: '',
|
||||||
|
email: '',
|
||||||
|
phone: '',
|
||||||
|
initials: '',
|
||||||
|
color: this.randomColor,
|
||||||
|
status: false,
|
||||||
|
lastLogin: 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
public firebaseService: FirebaseService,
|
||||||
|
public sharedService: SharedService
|
||||||
|
) {}
|
||||||
|
|
||||||
|
inititalsEmitter(emitter: string) {
|
||||||
|
this.userInitials = emitter;
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.randomColor = this.sharedService.generateRandomColor();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
}}"
|
}}"
|
||||||
[(ngModel)]="contactData.firstName"
|
[(ngModel)]="contactData.firstName"
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
|
(keyup)="updateFormData()"
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
@if (sharedService.isContactViewMedia) {
|
@if (sharedService.isContactViewMedia) {
|
||||||
|
|
@ -41,6 +42,7 @@
|
||||||
}}"
|
}}"
|
||||||
[(ngModel)]="contactData.lastName"
|
[(ngModel)]="contactData.lastName"
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
|
(keyup)="updateFormData()"
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,11 @@
|
||||||
import { Component, Input, OnChanges, SimpleChanges } from '@angular/core';
|
import {
|
||||||
|
Component,
|
||||||
|
EventEmitter,
|
||||||
|
Input,
|
||||||
|
OnChanges,
|
||||||
|
Output,
|
||||||
|
SimpleChanges,
|
||||||
|
} from '@angular/core';
|
||||||
import { FormsModule, NgForm } from '@angular/forms';
|
import { FormsModule, NgForm } from '@angular/forms';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { SharedService } from '../../../../services/shared.service';
|
import { SharedService } from '../../../../services/shared.service';
|
||||||
|
|
@ -13,7 +20,8 @@ import { FormBtnComponent } from '../../../../shared/components/buttons/form-btn
|
||||||
styleUrl: './contact-form.component.scss',
|
styleUrl: './contact-form.component.scss',
|
||||||
})
|
})
|
||||||
export class ContactFormComponent implements OnChanges {
|
export class ContactFormComponent implements OnChanges {
|
||||||
@Input() currentUserId!: string;
|
@Input() currentUserId: string | undefined;
|
||||||
|
@Output() inititalsEmitter = new EventEmitter<string>();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private firebaseService: FirebaseService,
|
private firebaseService: FirebaseService,
|
||||||
|
|
@ -35,7 +43,26 @@ export class ContactFormComponent implements OnChanges {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addInitials() {
|
||||||
|
const initials = this.contactData
|
||||||
|
? this.contactData.firstName.slice(0, 1) +
|
||||||
|
this.contactData.lastName.slice(0, 1)
|
||||||
|
: '';
|
||||||
|
this.inititalsEmitter.emit(initials);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateFormData() {
|
||||||
|
console.log(this.contactData);
|
||||||
|
this.addInitials();
|
||||||
|
const initials = this.contactData
|
||||||
|
? this.contactData.firstName.slice(0, 1).toUpperCase() +
|
||||||
|
this.contactData.lastName.slice(0, 1).toUpperCase()
|
||||||
|
: '';
|
||||||
|
console.log(initials);
|
||||||
|
}
|
||||||
|
|
||||||
private updateContactData() {
|
private updateContactData() {
|
||||||
|
if (this.currentUserId) {
|
||||||
this.contactData.firstName = this.firebaseService
|
this.contactData.firstName = this.firebaseService
|
||||||
.getUserDetails(this.currentUserId, 'firstName')
|
.getUserDetails(this.currentUserId, 'firstName')
|
||||||
.join(', ');
|
.join(', ');
|
||||||
|
|
@ -49,10 +76,18 @@ export class ContactFormComponent implements OnChanges {
|
||||||
.getUserDetails(this.currentUserId, 'phone')
|
.getUserDetails(this.currentUserId, 'phone')
|
||||||
.join(', ');
|
.join(', ');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onSubmit(ngForm: NgForm) {
|
onSubmit(ngForm: NgForm) {
|
||||||
if (ngForm.submitted && ngForm.form.valid) {
|
if (ngForm.submitted && ngForm.form.valid) {
|
||||||
this.firebaseService.updateUserData(this.currentUserId, this.contactData);
|
if (this.currentUserId) {
|
||||||
|
this.firebaseService.updateUserData(
|
||||||
|
this.currentUserId,
|
||||||
|
this.contactData
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
console.log('new contact');
|
||||||
|
}
|
||||||
this.closeEditDialog();
|
this.closeEditDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -141,6 +141,7 @@
|
||||||
"contactPhoneTxT": "Keine Telefonnummer",
|
"contactPhoneTxT": "Keine Telefonnummer",
|
||||||
"contactLastOnline": "Zuletzt online gesehen",
|
"contactLastOnline": "Zuletzt online gesehen",
|
||||||
"contactLastOnlineTxt": "Derzeit online",
|
"contactLastOnlineTxt": "Derzeit online",
|
||||||
|
"addContact": "Kontakt hinzufügen",
|
||||||
"editContact": "Kontakt bearbeiten",
|
"editContact": "Kontakt bearbeiten",
|
||||||
"firstName": "Vorname",
|
"firstName": "Vorname",
|
||||||
"lastName": "Nachname",
|
"lastName": "Nachname",
|
||||||
|
|
|
||||||
|
|
@ -142,6 +142,7 @@
|
||||||
"contactLastOnline": "Last seen online",
|
"contactLastOnline": "Last seen online",
|
||||||
"contactLastOnlineTxt": "Currently online",
|
"contactLastOnlineTxt": "Currently online",
|
||||||
"editContact": "Edit contact",
|
"editContact": "Edit contact",
|
||||||
|
"addContact": "Add contact",
|
||||||
"firstName": "First name",
|
"firstName": "First name",
|
||||||
"lastName": "Last name",
|
"lastName": "Last name",
|
||||||
"email": "Email",
|
"email": "Email",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue