preparer contact updates

This commit is contained in:
Cyril Joseph 2025-07-14 09:51:12 -03:00
parent e67aa9a9cd
commit 4d81b0d97e
4 changed files with 21 additions and 29 deletions

View File

@ -2,7 +2,7 @@ export interface Contact {
clientContactId: number; clientContactId: number;
spid: number spid: number
clientid: number; clientid: number;
locationid: number; locationid?: number;
defaultContact: boolean; defaultContact: boolean;
firstName: string; firstName: string;
lastName: string; lastName: string;

View File

@ -26,7 +26,6 @@ export class ContactService {
clientContactId: contact.CLIENTCONTACTID, clientContactId: contact.CLIENTCONTACTID,
spid: contact.SPID, spid: contact.SPID,
clientid: contact.CLIENTID, clientid: contact.CLIENTID,
locationid: contact.LOCATIONID,
defaultContact: contact.DEFCONTACTFLAG === 'Y', defaultContact: contact.DEFCONTACTFLAG === 'Y',
firstName: contact.FIRSTNAME, firstName: contact.FIRSTNAME,
lastName: contact.LASTNAME, lastName: contact.LASTNAME,
@ -71,7 +70,6 @@ export class ContactService {
const contact = { const contact = {
P_SPID: this.userService.getUserSpid(), P_SPID: this.userService.getUserSpid(),
P_CLIENTCONTACTID: spContactId, P_CLIENTCONTACTID: spContactId,
P_LOCATIONID: data.locationid,
P_FIRSTNAME: data.firstName, P_FIRSTNAME: data.firstName,
P_LASTNAME: data.lastName, P_LASTNAME: data.lastName,
P_MIDDLEINITIAL: data.middleInitial, P_MIDDLEINITIAL: data.middleInitial,

View File

@ -15,12 +15,6 @@
</div> </div>
<table mat-table [dataSource]="dataSource" matSort> <table mat-table [dataSource]="dataSource" matSort>
<!-- Location Column -->
<ng-container matColumnDef="location">
<th mat-header-cell *matHeaderCellDef mat-sort-header>Location Name</th>
<td mat-cell *matCellDef="let contact">{{ getLocationLabel(contact.locationid) }}</td>
</ng-container>
<!-- First Name Column --> <!-- First Name Column -->
<ng-container matColumnDef="firstName"> <ng-container matColumnDef="firstName">
<th mat-header-cell *matHeaderCellDef mat-sort-header>First Name</th> <th mat-header-cell *matHeaderCellDef mat-sort-header>First Name</th>
@ -117,6 +111,20 @@
<h3>{{ isEditing ? 'Edit Contact' : 'Add New Contact' }}</h3> <h3>{{ isEditing ? 'Edit Contact' : 'Add New Contact' }}</h3>
</div> </div>
<div class="form-row" *ngIf="!isEditing">
<mat-form-field appearance="outline" class="location">
<mat-label>Location</mat-label>
<mat-select formControlName="locationid" required>
<mat-option *ngFor="let location of locations" [value]="location.locationid">
{{ location.name }}
</mat-option>
</mat-select>
<mat-error *ngIf="contactForm.get('locationid')?.errors?.['required']">
Location is required
</mat-error>
</mat-form-field>
</div>
<div class="form-row"> <div class="form-row">
<mat-form-field appearance="outline"> <mat-form-field appearance="outline">
<mat-label>First Name</mat-label> <mat-label>First Name</mat-label>
@ -164,18 +172,6 @@
Maximum 100 characters allowed Maximum 100 characters allowed
</mat-error> </mat-error>
</mat-form-field> </mat-form-field>
<mat-form-field appearance="outline" class="location">
<mat-label>Location</mat-label>
<mat-select formControlName="location" required>
<mat-option *ngFor="let location of locations" [value]="location.locationid">
{{ location.name }}
</mat-option>
</mat-select>
<mat-error *ngIf="contactForm.get('location')?.errors?.['required']">
Location is required
</mat-error>
</mat-form-field>
</div> </div>
<div class="form-row"> <div class="form-row">

View File

@ -29,7 +29,7 @@ export class ContactsComponent {
@ViewChild(MatPaginator) paginator!: MatPaginator; @ViewChild(MatPaginator) paginator!: MatPaginator;
@ViewChild(MatSort) sort!: MatSort; @ViewChild(MatSort) sort!: MatSort;
displayedColumns: string[] = ['location', 'firstName', 'lastName', 'title', 'phone', 'mobile', 'email', 'defaultContact', 'actions']; displayedColumns: string[] = ['firstName', 'lastName', 'title', 'phone', 'mobile', 'email', 'defaultContact', 'actions'];
dataSource = new MatTableDataSource<any>(); dataSource = new MatTableDataSource<any>();
contactForm: FormGroup; contactForm: FormGroup;
contactLoginForm: FormGroup; contactLoginForm: FormGroup;
@ -74,7 +74,7 @@ export class ContactsComponent {
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}$/)]],
email: ['', [Validators.required, Validators.email, Validators.maxLength(100)]], email: ['', [Validators.required, Validators.email, Validators.maxLength(100)]],
location: ['', [Validators.required]], locationid: [''],
defaultContact: [false] defaultContact: [false]
}); });
@ -134,6 +134,7 @@ export class ContactsComponent {
this.currentContactId = null; this.currentContactId = null;
this.contactForm.reset(); this.contactForm.reset();
// this.contactForm.patchValue({ defaultContact: false }); // this.contactForm.patchValue({ defaultContact: false });
this.contactForm.get('locationid')?.setValidators([Validators.required]);
} }
editContact(contact: Contact): void { editContact(contact: Contact): void {
@ -150,7 +151,7 @@ export class ContactsComponent {
mobile: contact.mobile, mobile: contact.mobile,
fax: contact.fax, fax: contact.fax,
email: contact.email, email: contact.email,
location: contact.locationid, //location: contact.locationid,
// defaultContact: contact.defaultContact // defaultContact: contact.defaultContact
}); });
@ -158,6 +159,8 @@ export class ContactsComponent {
this.contactReadOnlyFields.lastChangedBy = contact.lastUpdatedBy ?? contact.createdBy; this.contactReadOnlyFields.lastChangedBy = contact.lastUpdatedBy ?? contact.createdBy;
this.contactReadOnlyFields.isInactive = contact.isInactive; this.contactReadOnlyFields.isInactive = contact.isInactive;
this.contactReadOnlyFields.inactivatedDate = contact.inactivatedDate; this.contactReadOnlyFields.inactivatedDate = contact.inactivatedDate;
this.contactForm.get('locationid')?.setValidators([]);
} }
saveContact(): void { saveContact(): void {
@ -258,11 +261,6 @@ export class ContactsComponent {
}); });
} }
getLocationLabel(value: number): string {
const location = this.locations.find(l => l.locationid === value);
return location ? location.name : '';
}
createLogin(contact: Contact): void { createLogin(contact: Contact): void {
this.showForm = false; this.showForm = false;
this.showLoginForm = true; this.showLoginForm = true;