long profile issues

This commit is contained in:
mashfiq 2025-07-24 14:35:20 +06:00
parent 748988bcc6
commit 4b26cda07a
8 changed files with 164 additions and 41 deletions

View File

@ -504,7 +504,7 @@ export class EmployeeServices {
return this.apiService.httpPost('/Employee/updateBanglaInformation', params);
}
updateBanglaContactInformation(params : any) {
return this.apiService.httpPost('/Employee/updateBanglaContactInformation', params);
return this.apiService.httpPost<number>('/Employee/updateBanglaContactInformation', params);
}
getPFExceptionData() {
return this.apiService.httpGet<any[]>('/Employee/getPFExceptionData');

View File

@ -35,6 +35,7 @@ import { TextBoxModule } from "@progress/kendo-angular-inputs";
import { LabelModule } from "@progress/kendo-angular-label";
import { FloatingLabelModule } from "@progress/kendo-angular-label";
import { IconsModule } from "@progress/kendo-angular-icons";
import { UploadModule } from '@progress/kendo-angular-upload';
import { ReactiveFormsModule, FormsModule } from '@angular/forms';
import { TabViewModule } from 'primeng/tabview';
@ -129,7 +130,8 @@ import { HallOfFameUploaderComponent } from './hall-of-fame-uploader/hall-of-fam
IconsModule,
LabelModule,
PanelModule,
CardManagemnetModule
CardManagemnetModule,
UploadModule
],
declarations: [
NationalityComponent,

View File

@ -45,8 +45,9 @@ export class ContactComponent implements OnInit {
this.basicService.getAllDistricts().subscribe((resp) => {
this.districts = resp;
},
() => {
(err: any) => {
this.loadingPanel.ShowLoadingPanel = false;
this.notificationService.showError(err.error);
},
() => {
@ -58,8 +59,9 @@ export class ContactComponent implements OnInit {
this.basicService.getAllThanas(value).subscribe((resp) => {
this.permanentThanas = resp;
},
() => {
(err: any) => {
this.loadingPanel.ShowLoadingPanel = false;
this.notificationService.showError(err.error);
},
() => {
@ -71,8 +73,9 @@ export class ContactComponent implements OnInit {
this.basicService.getAllThanas(value).subscribe((resp) => {
this.presentThanas = resp;
},
() => {
(err: any) => {
this.loadingPanel.ShowLoadingPanel = false;
this.notificationService.showError(err.error);
},
() => {
@ -135,7 +138,8 @@ export class ContactComponent implements OnInit {
}
},
(err: any) => {
this.loadingPanel.ShowLoadingPanel = false;
this.notificationService.showError(err.error);
},
() => {
if (this.employeeService.hrEmployee.id != undefined && this.employeeService.hrEmployee.id != 0) {
@ -147,7 +151,9 @@ export class ContactComponent implements OnInit {
this.basicService.getAllRelations().subscribe((resp) => {
this.relations = resp;
},
() => {
(err) => {
this.loadingPanel.ShowLoadingPanel = false;
this.notificationService.showError(err.error);
},
() => {
@ -186,8 +192,9 @@ export class ContactComponent implements OnInit {
(resp) => {
this.contact.id = resp;
},
() => {
(err) => {
this.loadingPanel.ShowLoadingPanel = false;
this.notificationService.showError(err.error);
},
() => {
this.loadingPanel.ShowLoadingPanel = false;
@ -222,8 +229,9 @@ export class ContactComponent implements OnInit {
this.presentThanas = resp;
this.contact.presentThanaID = this.contact.permanentThanaID;
},
() => {
(err) => {
this.loadingPanel.ShowLoadingPanel = false;
this.notificationService.showError(err.error);
},
() => {

View File

@ -40,8 +40,9 @@ export class EmployeeProfileComponent implements OnInit {
activeIndex: number = 0;
previousIndex: number = 0; // 👈 track the previous tab index manually
@ViewChild('general') generalComponent!: GeneralComponent;
@ViewChild('Contact') contactComponent!: ContactComponent;
@ViewChild('contact') contactComponent!: ContactComponent;
newEmpSaved: boolean = false;
newEmpContactSaved: boolean = false;
constructor(private fb: FormBuilder,
@ -351,7 +352,7 @@ export class EmployeeProfileComponent implements OnInit {
setTimeout(() => {
if (this.generalComponent.personalInfo.valid === false && this.generalComponent.hrEmployee.employeeNo === '') {
if (this.generalComponent != undefined && this.generalComponent.personalInfo.valid === false && this.generalComponent.hrEmployee.employeeNo === '') {
this.notificationService.showError('Required Fields Can\'t Be Empty');
this.activeIndex = currentIndex;
this.previousIndex = currentIndex;
@ -362,30 +363,57 @@ export class EmployeeProfileComponent implements OnInit {
return;
});
}
if (currentTab.header.toLowerCase() == 'contacts') {
debugger
// this.contactComponent.ngOnInit();
if (currentTab.header.toLowerCase() == 'contacts' && !this.newEmpContactSaved) {
setTimeout(() => {
if (!this.contactComponent.contactForm.valid) {
this.notificationService.showWarning('Must Entry field can\'t be Empty');
this.activeIndex = currentIndex;
this.previousIndex = currentIndex;
return;
}
this.contactComponent.SaveContact();
this.newEmpContactSaved = true;
return;
});
}
}
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;
// }
if (currentTab.header.toLowerCase() == 'general') {
if (this.generalComponent != undefined && this.contactComponent != undefined) {
if (this.generalComponent.contact.id == 0) {
this.contactComponent.contact.id = this.generalComponent.contact.id;
}
if (this.generalComponent.contact.presentPOInBangla != null && this.generalComponent.contact.presentPOInBangla != "") {
this.contactComponent.contact.presentPOInBangla = this.generalComponent.contact.presentPOInBangla;
}
if (this.generalComponent.contact.presentAddressInBangla != null && this.generalComponent.contact.presentAddressInBangla != "") {
this.contactComponent.contact.presentAddressInBangla = this.generalComponent.contact.presentAddressInBangla;
}
if (this.generalComponent.contact.parmanentPOInBangla != null && this.generalComponent.contact.parmanentPOInBangla != "") {
this.contactComponent.contact.parmanentPOInBangla = this.generalComponent.contact.parmanentPOInBangla;
}
if (this.generalComponent.contact.permanentAddressInBangla != null && this.generalComponent.contact.permanentAddressInBangla != "") {
this.contactComponent.contact.permanentAddressInBangla = this.generalComponent.contact.permanentAddressInBangla;
}
}
}
if (nextTab.header.toLowerCase() == 'attachments') {
debugger;
this.employeeService.getEmployeeAttachments(this.selectedEmployee.employeeID)
.subscribe(
(resp) => {
this.attachments = resp;
},
(x) => {
console.log(x);
this.loadingPanel.ShowLoadingPanel = false;
},
() => {
this.loadingPanel.ShowLoadingPanel = false;
this.hrEmployeeProfile.attachments = this.attachments;
}
);
}
// ✅ Save current as previous after successful switch
this.previousIndex = nextIndex;
}

View File

@ -260,8 +260,11 @@
<!-- [readonly]="!active" -->
<button class="k-button k-primary" kendoButton icon="k-i-attachment-45 k-i-clip-45"
style="width: 15.5%; vertical-align: bottom; padding: 16px;"
(click)="popUpAttachment('NID')"></button>
<!-- [disabled]="!active" -->
(click)="popUpAttachment('NID')" [disabled]="!active"></button>
<!-- <input [(ngModel)]="NIDFiles" (change)="selectFileNationalId($event)" type="file" pInputText
style="width: 100%;padding: 5px;margin:5px 0;"> -->
<!-- <kendo-upload [saveUrl]="uploadSaveUrl" [removeUrl]="uploadRemoveUrl">
</kendo-upload> -->
</div>
<div class="p-col-12 p-md-12 p-lg-4">
<label for="txtPassportNo">Passport No</label>
@ -363,7 +366,7 @@
<div class="p-col-12 p-md-12 p-lg-4" ></div>
<div class="p-col-12 p-md-12 p-lg-4" style="margin-top: 11px;" >
<button class="k-button k-primary" kendoButton icon="add"
(click)="AddAccessCard()">
(click)="AddAccessCard()" [disabled]="!active">
Add Access Card
</button>
</div>
@ -597,7 +600,7 @@
</div>
<div class="p-col-12 p-md-12 p-lg-12" style="margin: auto;" align="right">
<button class="k-button k-primary" kendoButton icon="save"
(click)="SaveBanglaContactInformation()">
(click)="saveBanglaInfo()">
Save
</button>
</div>

View File

@ -33,6 +33,8 @@ import { Nationality } from '../../nationality/nationality';
import { EmpContact } from 'src/app/_models/HREmployee/empContact';
import { Thana } from '../../thana/thana';
import { CardManagemnetModule } from 'src/app/attendance/access-card-management/card-management.module';
import { Observable, EMPTY } from 'rxjs';
import { tap, finalize, catchError } from 'rxjs/operators';
@Component({
selector: 'app-general',
@ -557,6 +559,75 @@ export class GeneralComponent implements OnInit {
this.NIDFiles = undefined;
}
}
private getSavePersonalInfoObservable(): Observable<HrEmployee> | null {
debugger;
if (this.personalInfo.valid === false && this.hrEmployee.employeeNo === '') {
this.notificationService.showError('Required Fields Can\'t Be Empty');
return null;
}
this.loadingPanel.ShowLoadingPanel = true;
this.hrEmployee.name = this.hrEmployee.firstName;
if (this.hrEmployee.middleName !== null) {
this.hrEmployee.name += ' ' + this.hrEmployee.middleName;
}
if (this.hrEmployee.lastName !== null) {
this.hrEmployee.name += ' ' + this.hrEmployee.lastName;
}
return this.employeeService.saveHrPersonalInfo(this.hrEmployee).pipe(
tap((resp: HrEmployee) => {
debugger;
if (resp != undefined) {
this.hrEmployee.id = resp.id;
if (!this.active) {
this.hrEmployee.employeeNo = resp.employeeNo;
this.employeeService.hrEmployee = resp;
}
if (this.selectedTinFiles?.length > 0) {
this.saveFile(this.hrEmployee.id, this.selectedTinFiles, enumEmpFileUploadType.TIN);
}
if (this.selectedNidFiles?.length > 0) {
this.saveFile(this.hrEmployee.id, this.selectedNidFiles, enumEmpFileUploadType.nationalID);
}
if (this.selectedDlFiles?.length > 0) {
this.saveFile(this.hrEmployee.id, this.selectedDlFiles, enumEmpFileUploadType.DrivingLicense);
}
}
}),
finalize(() => {
this.loadingPanel.ShowLoadingPanel = false;
}),
catchError((err) => {
debugger;
console.error(err);
this.notificationService.showError(err.error);
return EMPTY; // No emission on error
})
);
}
saveBanglaInfo() {
if (!this.active) {
const personalInfo$ = this.getSavePersonalInfoObservable();
if (personalInfo$) {
personalInfo$.subscribe({
next: () => {
debugger;
this.isDisplay = false;
this.notificationService.showSuccess('Data saved successfully');
this.SaveBanglaContactInformation();
}
});
}
else {
this.isDisplay = false;
}
// If null, validation failed — nothing is executed
} else {
this.SaveBanglaContactInformation();
}
}
saveBanglaPersonalInformation() {
const data = {
employeeNo: this.employeeService.hrEmployee.employeeNo,
@ -591,6 +662,14 @@ export class GeneralComponent implements OnInit {
this.loadingPanel.ShowLoadingPanel = true;
this.employeeService.updateBanglaContactInformation(data).subscribe(
(resp: any) => {
// debugger
// if(this.contact.id == 0)
// this.employeeService.hrEmployee.contacts[0].id = resp;
// this.employeeService.hrEmployee.contacts[0].presentPOInBangla = this.contact.presentPOInBangla;
// this.employeeService.hrEmployee.contacts[0].presentAddressInBangla = this.contact.presentAddressInBangla,
// this.employeeService.hrEmployee.contacts[0].parmanentPOInBangla = this.contact.parmanentPOInBangla;
// this.employeeService.hrEmployee.contacts[0].permanentAddressInBangla = this.contact.permanentAddressInBangla;
}, (err) => {
this.loadingPanel.ShowLoadingPanel = false;
@ -956,4 +1035,6 @@ export class GeneralComponent implements OnInit {
this.passnoPopUp = false;
this.signaturePopUp = false;
}
// uploadSaveUrl = "saveUrl"; // should represent an actual API endpoint
// uploadRemoveUrl = "removeUrl"; // should represent an actual API endpoint
}

View File

@ -2165,6 +2165,7 @@ namespace HRM.UI.Controllers
ec.PresentAddressInBangla = presentAddressInBangla;
ec.PermanentAddressInBangla = presentAddressInBangla;
_hrEmployeeService.SaveContact(ec);
return Ok(ec.ID);
}
}
catch (Exception ex)

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 KiB