holder contact updates
This commit is contained in:
parent
c10991a468
commit
1ffd6713f4
5
src/app/core/models/contact-title.ts
Normal file
5
src/app/core/models/contact-title.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
export interface ContactTitle {
|
||||||
|
name: string;
|
||||||
|
id: string;
|
||||||
|
value: string;
|
||||||
|
}
|
||||||
@ -18,6 +18,7 @@ import { PaymentType } from '../../models/payment-type';
|
|||||||
import { FormOfSecurity } from '../../models/formofsecurity';
|
import { FormOfSecurity } from '../../models/formofsecurity';
|
||||||
import { UserService } from './user.service';
|
import { UserService } from './user.service';
|
||||||
import { ExtensionReason } from '../../models/extension-reason';
|
import { ExtensionReason } from '../../models/extension-reason';
|
||||||
|
import { ContactTitle } from '../../models/contact-title';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@ -218,6 +219,18 @@ export class CommonService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getContactTitles(): Observable<ContactTitle[]> {
|
||||||
|
return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/GetParamValues?P_PARAMTYPE=012&P_SPID=${this.userService.getUserSpid()}`).pipe(
|
||||||
|
map((response) =>
|
||||||
|
response.map((item) => ({
|
||||||
|
name: item.PARAMDESC,
|
||||||
|
id: item.PARAMID,
|
||||||
|
value: item.PARAMVALUE,
|
||||||
|
}))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
formatUSDate(datetime: Date): string {
|
formatUSDate(datetime: Date): string {
|
||||||
const date = new Date(datetime);
|
const date = new Date(datetime);
|
||||||
const month = String(date.getUTCMonth() + 1).padStart(2, '0');
|
const month = String(date.getUTCMonth() + 1).padStart(2, '0');
|
||||||
|
|||||||
@ -25,6 +25,12 @@
|
|||||||
<td mat-cell *matCellDef="let contact">{{ contact.firstName }}</td>
|
<td mat-cell *matCellDef="let contact">{{ contact.firstName }}</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
|
<!-- Middle Initial Column -->
|
||||||
|
<ng-container matColumnDef="middleInitial">
|
||||||
|
<th mat-header-cell *matHeaderCellDef mat-sort-header>Middle Initial</th>
|
||||||
|
<td mat-cell *matCellDef="let contact">{{ contact.middleInitial }}</td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
<!-- Last Name Column -->
|
<!-- Last Name Column -->
|
||||||
<ng-container matColumnDef="lastName">
|
<ng-container matColumnDef="lastName">
|
||||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>Last Name</th>
|
<th mat-header-cell *matHeaderCellDef mat-sort-header>Last Name</th>
|
||||||
@ -34,7 +40,7 @@
|
|||||||
<!-- Title Column -->
|
<!-- Title Column -->
|
||||||
<ng-container matColumnDef="title">
|
<ng-container matColumnDef="title">
|
||||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>Title</th>
|
<th mat-header-cell *matHeaderCellDef mat-sort-header>Title</th>
|
||||||
<td mat-cell *matCellDef="let contact">{{ contact.title }}</td>
|
<td mat-cell *matCellDef="let contact">{{ getContactTitleLabel(contact.title) }}</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<!-- Phone Column -->
|
<!-- Phone Column -->
|
||||||
@ -49,6 +55,12 @@
|
|||||||
<td mat-cell *matCellDef="let contact">{{ contact.mobile | phone }}</td>
|
<td mat-cell *matCellDef="let contact">{{ contact.mobile | phone }}</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
|
<!-- Fax Column -->
|
||||||
|
<ng-container matColumnDef="fax">
|
||||||
|
<th mat-header-cell *matHeaderCellDef mat-sort-header>Fax</th>
|
||||||
|
<td mat-cell *matCellDef="let contact">{{ contact.fax }}</td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
<!-- Email Column -->
|
<!-- Email Column -->
|
||||||
<ng-container matColumnDef="email">
|
<ng-container matColumnDef="email">
|
||||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>Email</th>
|
<th mat-header-cell *matHeaderCellDef mat-sort-header>Email</th>
|
||||||
@ -147,20 +159,18 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
|
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<mat-label>Title</mat-label>
|
<mat-label>Title</mat-label>
|
||||||
<input matInput formControlName="title" required>
|
<mat-select formControlName="title" required>
|
||||||
<mat-icon matSuffix>work</mat-icon>
|
<mat-option *ngFor="let contactTitle of contactTitles" [value]="contactTitle.value">
|
||||||
|
{{ contactTitle.name }}
|
||||||
|
</mat-option>
|
||||||
|
</mat-select>
|
||||||
<mat-error *ngIf="contactForm.get('title')?.errors?.['required']">
|
<mat-error *ngIf="contactForm.get('title')?.errors?.['required']">
|
||||||
Title is required
|
Title is required
|
||||||
</mat-error>
|
</mat-error>
|
||||||
<mat-error *ngIf="contactForm.get('title')?.errors?.['maxlength']">
|
|
||||||
Maximum 100 characters allowed
|
|
||||||
</mat-error>
|
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<mat-label>Phone</mat-label>
|
<mat-label>Phone</mat-label>
|
||||||
|
|||||||
@ -16,8 +16,10 @@ import { MatDialog } from '@angular/material/dialog';
|
|||||||
import { ConfirmDialogComponent } from '../../shared/components/confirm-dialog/confirm-dialog.component';
|
import { ConfirmDialogComponent } from '../../shared/components/confirm-dialog/confirm-dialog.component';
|
||||||
import { NavigationService } from '../../core/services/common/navigation.service';
|
import { NavigationService } from '../../core/services/common/navigation.service';
|
||||||
import { StorageService } from '../../core/services/common/storage.service';
|
import { StorageService } from '../../core/services/common/storage.service';
|
||||||
import { finalize } from 'rxjs';
|
import { finalize, Subject, takeUntil } from 'rxjs';
|
||||||
import { environment } from '../../../environments/environment';
|
import { environment } from '../../../environments/environment';
|
||||||
|
import { ContactTitle } from '../../core/models/contact-title';
|
||||||
|
import { CommonService } from '../../core/services/common/common.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-contacts',
|
selector: 'app-contacts',
|
||||||
@ -40,7 +42,7 @@ export class ContactsComponent {
|
|||||||
|
|
||||||
@ViewChild(MatSort) sort!: MatSort;
|
@ViewChild(MatSort) sort!: MatSort;
|
||||||
|
|
||||||
displayedColumns: string[] = ['firstName', 'lastName', 'title', 'phone', 'mobile', 'email', 'actions'];
|
displayedColumns: string[] = ['firstName', 'middleInitial', 'lastName', 'title', 'phone', 'mobile', 'fax', 'email', 'actions'];
|
||||||
dataSource = new MatTableDataSource<any>();
|
dataSource = new MatTableDataSource<any>();
|
||||||
contactForm: FormGroup;
|
contactForm: FormGroup;
|
||||||
|
|
||||||
@ -51,6 +53,8 @@ export class ContactsComponent {
|
|||||||
showForm = false;
|
showForm = false;
|
||||||
showInactiveContacts = false;
|
showInactiveContacts = false;
|
||||||
contacts: Contact[] = [];
|
contacts: Contact[] = [];
|
||||||
|
contactTitles: ContactTitle[] = [];
|
||||||
|
|
||||||
currentApplicationDetails: { headerid: number, applicationName: string } | null = null;
|
currentApplicationDetails: { headerid: number, applicationName: string } | null = null;
|
||||||
returnTo: string = environment.appType === 'client' ? 'edit-carnet' : 'process-carnet';
|
returnTo: string = environment.appType === 'client' ? 'edit-carnet' : 'process-carnet';
|
||||||
|
|
||||||
@ -61,8 +65,11 @@ export class ContactsComponent {
|
|||||||
inactivatedDate: null
|
inactivatedDate: null
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private destroy$ = new Subject<void>();
|
||||||
|
|
||||||
private fb = inject(FormBuilder);
|
private fb = inject(FormBuilder);
|
||||||
private dialog = inject(MatDialog);
|
private dialog = inject(MatDialog);
|
||||||
|
private commonService = inject(CommonService);
|
||||||
private contactService = inject(ContactService);
|
private contactService = inject(ContactService);
|
||||||
private notificationService = inject(NotificationService);
|
private notificationService = inject(NotificationService);
|
||||||
private errorHandler = inject(ApiErrorHandlerService);
|
private errorHandler = inject(ApiErrorHandlerService);
|
||||||
@ -74,7 +81,7 @@ export class ContactsComponent {
|
|||||||
firstName: ['', [Validators.required, Validators.maxLength(50)]],
|
firstName: ['', [Validators.required, Validators.maxLength(50)]],
|
||||||
lastName: ['', [Validators.required, Validators.maxLength(50)]],
|
lastName: ['', [Validators.required, Validators.maxLength(50)]],
|
||||||
middleInitial: ['', [Validators.maxLength(1)]],
|
middleInitial: ['', [Validators.maxLength(1)]],
|
||||||
title: ['', [Validators.required, Validators.maxLength(100)]],
|
title: ['', [Validators.required]],
|
||||||
phone: ['', [Validators.required, Validators.pattern(/^[0-9\-\(\)]{10,15}$/)]],
|
phone: ['', [Validators.required, Validators.pattern(/^[0-9\-\(\)]{10,15}$/)]],
|
||||||
mobile: ['', [Validators.required, Validators.pattern(/^[0-9\-\(\)]{10,15}$/)]],
|
mobile: ['', [Validators.required, Validators.pattern(/^[0-9\-\(\)]{10,15}$/)]],
|
||||||
fax: ['', [Validators.pattern(/^[0-9\-\(\)]{10,15}$/)]],
|
fax: ['', [Validators.pattern(/^[0-9\-\(\)]{10,15}$/)]],
|
||||||
@ -85,11 +92,17 @@ export class ContactsComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
this.loadContactTitles();
|
||||||
if (this.holderid > 0) {
|
if (this.holderid > 0) {
|
||||||
this.loadContacts();
|
this.loadContacts();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnDestroy(): void {
|
||||||
|
this.destroy$.next();
|
||||||
|
this.destroy$.complete();
|
||||||
|
}
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
this.dataSource.paginator = this.paginator;
|
this.dataSource.paginator = this.paginator;
|
||||||
this.dataSource.sort = this.sort;
|
this.dataSource.sort = this.sort;
|
||||||
@ -113,6 +126,19 @@ export class ContactsComponent {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadContactTitles(): void {
|
||||||
|
this.commonService.getContactTitles()
|
||||||
|
.pipe(takeUntil(this.destroy$))
|
||||||
|
.subscribe({
|
||||||
|
next: (contactTitles) => {
|
||||||
|
this.contactTitles = contactTitles;
|
||||||
|
},
|
||||||
|
error: (error) => {
|
||||||
|
console.error('Failed to load contact titles', error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
addNewContact(): void {
|
addNewContact(): void {
|
||||||
this.showForm = true;
|
this.showForm = true;
|
||||||
this.isEditing = false;
|
this.isEditing = false;
|
||||||
@ -260,4 +286,9 @@ export class ContactsComponent {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getContactTitleLabel(value: string): string {
|
||||||
|
const type = this.contactTitles.find(t => t.value === value);
|
||||||
|
return type ? type.name : value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user