preparer contact updates
This commit is contained in:
parent
e67aa9a9cd
commit
4d81b0d97e
@ -2,7 +2,7 @@ export interface Contact {
|
||||
clientContactId: number;
|
||||
spid: number
|
||||
clientid: number;
|
||||
locationid: number;
|
||||
locationid?: number;
|
||||
defaultContact: boolean;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
|
||||
@ -26,7 +26,6 @@ export class ContactService {
|
||||
clientContactId: contact.CLIENTCONTACTID,
|
||||
spid: contact.SPID,
|
||||
clientid: contact.CLIENTID,
|
||||
locationid: contact.LOCATIONID,
|
||||
defaultContact: contact.DEFCONTACTFLAG === 'Y',
|
||||
firstName: contact.FIRSTNAME,
|
||||
lastName: contact.LASTNAME,
|
||||
@ -71,7 +70,6 @@ export class ContactService {
|
||||
const contact = {
|
||||
P_SPID: this.userService.getUserSpid(),
|
||||
P_CLIENTCONTACTID: spContactId,
|
||||
P_LOCATIONID: data.locationid,
|
||||
P_FIRSTNAME: data.firstName,
|
||||
P_LASTNAME: data.lastName,
|
||||
P_MIDDLEINITIAL: data.middleInitial,
|
||||
|
||||
@ -15,12 +15,6 @@
|
||||
</div>
|
||||
|
||||
<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 -->
|
||||
<ng-container matColumnDef="firstName">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>First Name</th>
|
||||
@ -117,6 +111,20 @@
|
||||
<h3>{{ isEditing ? 'Edit Contact' : 'Add New Contact' }}</h3>
|
||||
</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">
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>First Name</mat-label>
|
||||
@ -164,18 +172,6 @@
|
||||
Maximum 100 characters allowed
|
||||
</mat-error>
|
||||
</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 class="form-row">
|
||||
|
||||
@ -29,7 +29,7 @@ export class ContactsComponent {
|
||||
@ViewChild(MatPaginator) paginator!: MatPaginator;
|
||||
@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>();
|
||||
contactForm: FormGroup;
|
||||
contactLoginForm: FormGroup;
|
||||
@ -74,7 +74,7 @@ export class ContactsComponent {
|
||||
mobile: ['', [Validators.required, Validators.pattern(/^[0-9]{10,15}$/)]],
|
||||
fax: ['', [Validators.pattern(/^[0-9]{10,15}$/)]],
|
||||
email: ['', [Validators.required, Validators.email, Validators.maxLength(100)]],
|
||||
location: ['', [Validators.required]],
|
||||
locationid: [''],
|
||||
defaultContact: [false]
|
||||
});
|
||||
|
||||
@ -134,6 +134,7 @@ export class ContactsComponent {
|
||||
this.currentContactId = null;
|
||||
this.contactForm.reset();
|
||||
// this.contactForm.patchValue({ defaultContact: false });
|
||||
this.contactForm.get('locationid')?.setValidators([Validators.required]);
|
||||
}
|
||||
|
||||
editContact(contact: Contact): void {
|
||||
@ -150,7 +151,7 @@ export class ContactsComponent {
|
||||
mobile: contact.mobile,
|
||||
fax: contact.fax,
|
||||
email: contact.email,
|
||||
location: contact.locationid,
|
||||
//location: contact.locationid,
|
||||
// defaultContact: contact.defaultContact
|
||||
});
|
||||
|
||||
@ -158,6 +159,8 @@ export class ContactsComponent {
|
||||
this.contactReadOnlyFields.lastChangedBy = contact.lastUpdatedBy ?? contact.createdBy;
|
||||
this.contactReadOnlyFields.isInactive = contact.isInactive;
|
||||
this.contactReadOnlyFields.inactivatedDate = contact.inactivatedDate;
|
||||
|
||||
this.contactForm.get('locationid')?.setValidators([]);
|
||||
}
|
||||
|
||||
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 {
|
||||
this.showForm = false;
|
||||
this.showLoginForm = true;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user