long profile modification
This commit is contained in:
parent
36d850a326
commit
748988bcc6
|
@ -25,14 +25,17 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p-tabView [scrollable]="true">
|
<p-tabView #tabView
|
||||||
|
[(activeIndex)]="activeIndex"
|
||||||
|
(onChange)="onTabChange($event, tabView)"
|
||||||
|
[scrollable]="true">
|
||||||
<p-tabPanel header="General" leftIcon="pi pi-user">
|
<p-tabPanel header="General" leftIcon="pi pi-user">
|
||||||
<app-general [isActive]="!newEmployee" [employeeNo]="this.employeeService.hrEmployee.employeeNo"
|
<app-general #general [isActive]="!newEmployee" [employeeNo]="this.employeeService.hrEmployee.employeeNo"
|
||||||
(defaultNationalityHandler)="defaultNationalityHandler($event)"
|
(defaultNationalityHandler)="defaultNationalityHandler($event)"
|
||||||
(defaultEmployeeTypeHandler)="defaultEmployeeTypeHandler($event)"></app-general>
|
(defaultEmployeeTypeHandler)="defaultEmployeeTypeHandler($event)"></app-general>
|
||||||
</p-tabPanel>
|
</p-tabPanel>
|
||||||
<p-tabPanel header="Contacts" leftIcon="pi pi-phone">
|
<p-tabPanel header="Contacts" leftIcon="pi pi-phone">
|
||||||
<app-contact (saveContact)="saveContact($event)"></app-contact>
|
<app-contact #contact (saveContact)="saveContact($event)"></app-contact>
|
||||||
</p-tabPanel>
|
</p-tabPanel>
|
||||||
<!-- <p-tabPanel header="Bangla" leftIcon="pi pi-star">
|
<!-- <p-tabPanel header="Bangla" leftIcon="pi pi-star">
|
||||||
<app-bangla></app-bangla>
|
<app-bangla></app-bangla>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||||
import { EmployeeServices } from '../../_services/employee/employee.service';
|
import { EmployeeServices } from '../../_services/employee/employee.service';
|
||||||
import { empFileuploads, HrEmployee } from '../../_models/HREmployee/hrEmployee';
|
import { empFileuploads, HrEmployee } from '../../_models/HREmployee/hrEmployee';
|
||||||
|
@ -13,6 +13,8 @@ import { HRMNotificationService } from '../../app.notification.service';
|
||||||
import { DomSanitizer } from '@angular/platform-browser';
|
import { DomSanitizer } from '@angular/platform-browser';
|
||||||
import { Nationality } from '../nationality/nationality';
|
import { Nationality } from '../nationality/nationality';
|
||||||
import { Category } from 'src/app/_models/Basic/category';
|
import { Category } from 'src/app/_models/Basic/category';
|
||||||
|
import { GeneralComponent } from './general/general.component';
|
||||||
|
import { ContactComponent } from './contact/contact.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-employee-profile',
|
selector: 'app-employee-profile',
|
||||||
|
@ -34,6 +36,14 @@ export class EmployeeProfileComponent implements OnInit {
|
||||||
isDisplay = false;
|
isDisplay = false;
|
||||||
defaultNationality: Nationality;
|
defaultNationality: Nationality;
|
||||||
defaultEmployeeType: Category;
|
defaultEmployeeType: Category;
|
||||||
|
|
||||||
|
activeIndex: number = 0;
|
||||||
|
previousIndex: number = 0; // 👈 track the previous tab index manually
|
||||||
|
@ViewChild('general') generalComponent!: GeneralComponent;
|
||||||
|
@ViewChild('Contact') contactComponent!: ContactComponent;
|
||||||
|
newEmpSaved: boolean = false;
|
||||||
|
|
||||||
|
|
||||||
constructor(private fb: FormBuilder,
|
constructor(private fb: FormBuilder,
|
||||||
public employeeService: EmployeeServices,
|
public employeeService: EmployeeServices,
|
||||||
public basicService: BasicService,
|
public basicService: BasicService,
|
||||||
|
@ -326,5 +336,58 @@ export class EmployeeProfileComponent implements OnInit {
|
||||||
defaultEmployeeTypeHandler(dataItem: Category) {
|
defaultEmployeeTypeHandler(dataItem: Category) {
|
||||||
this.defaultEmployeeType = dataItem;
|
this.defaultEmployeeType = dataItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onTabChange(event: any, tabView: any) {
|
||||||
|
const nextIndex = event.index;
|
||||||
|
const currentIndex = this.previousIndex; // 👈 previous tab before switch
|
||||||
|
|
||||||
|
const currentTab = tabView.tabs[currentIndex];
|
||||||
|
const nextTab = tabView.tabs[nextIndex];
|
||||||
|
|
||||||
|
debugger
|
||||||
|
if (this.newEmployee) {
|
||||||
|
|
||||||
|
if (currentTab.header.toLowerCase() == 'general' && !this.newEmpSaved) {
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
|
||||||
|
if (this.generalComponent.personalInfo.valid === false && this.generalComponent.hrEmployee.employeeNo === '') {
|
||||||
|
this.notificationService.showError('Required Fields Can\'t Be Empty');
|
||||||
|
this.activeIndex = currentIndex;
|
||||||
|
this.previousIndex = currentIndex;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.generalComponent.SavePersonalInfo();
|
||||||
|
this.newEmpSaved = true;
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (currentTab.header.toLowerCase() == 'contacts') {
|
||||||
|
debugger
|
||||||
|
// this.contactComponent.ngOnInit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
console.log('Previous Tab:', currentIndex, currentTab.header);
|
||||||
|
console.log('Next Tab:', nextIndex, nextTab.header);
|
||||||
|
|
||||||
|
// // Example validation logic on current tab before switching
|
||||||
|
// if (currentIndex === 0 && this.form1.invalid) {
|
||||||
|
// this.form1.markAllAsTouched();
|
||||||
|
// setTimeout(() => (this.activeIndex = currentIndex)); // cancel switch
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (currentIndex === 1 && this.form2.invalid) {
|
||||||
|
// this.form2.markAllAsTouched();
|
||||||
|
// setTimeout(() => (this.activeIndex = currentIndex)); // cancel switch
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// ✅ Save current as previous after successful switch
|
||||||
|
this.previousIndex = nextIndex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,7 @@ export class GeneralComponent implements OnInit {
|
||||||
nationalities: Nationality[];
|
nationalities: Nationality[];
|
||||||
defaultNationality: Nationality;
|
defaultNationality: Nationality;
|
||||||
defaultEmployeeType: Category;
|
defaultEmployeeType: Category;
|
||||||
nameBangla: string = 'asasas';
|
nameBangla: string = '';
|
||||||
defaultPhoto = "assets/photos/profile-default.jpg";
|
defaultPhoto = "assets/photos/profile-default.jpg";
|
||||||
photoPath = "Documents/EMPPHOTO";
|
photoPath = "Documents/EMPPHOTO";
|
||||||
isDisplay: boolean = false;
|
isDisplay: boolean = false;
|
||||||
|
@ -450,6 +450,7 @@ export class GeneralComponent implements OnInit {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
SavePersonalInfo() {
|
SavePersonalInfo() {
|
||||||
|
debugger
|
||||||
// console.log(this.hrEmployee.banglaName);
|
// console.log(this.hrEmployee.banglaName);
|
||||||
// return;
|
// return;
|
||||||
if (this.personalInfo.valid === false && this.hrEmployee.employeeNo === '') {
|
if (this.personalInfo.valid === false && this.hrEmployee.employeeNo === '') {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user