preparer location updates
This commit is contained in:
parent
7c6a9996bc
commit
7bbb633cd7
@ -7,7 +7,7 @@
|
|||||||
<ng-template matStepLabel>Basic Details</ng-template>
|
<ng-template matStepLabel>Basic Details</ng-template>
|
||||||
|
|
||||||
<app-basic-details [isEditMode]="isEditMode" (clientidCreated)="onBasicDetailsSaved($event)"
|
<app-basic-details [isEditMode]="isEditMode" (clientidCreated)="onBasicDetailsSaved($event)"
|
||||||
(showLocations)="onShowLocations($event)">
|
(showLocations)="onShowLocations($event)"(locationAdded)="onLocationAdded($event)">
|
||||||
</app-basic-details>
|
</app-basic-details>
|
||||||
</mat-step>
|
</mat-step>
|
||||||
|
|
||||||
@ -16,7 +16,8 @@
|
|||||||
<ng-template matStepLabel>Locations</ng-template>
|
<ng-template matStepLabel>Locations</ng-template>
|
||||||
|
|
||||||
<app-location *ngIf="clientid" [clientid]="clientid" (hasLocations)="onLocationSaved($event)"
|
<app-location *ngIf="clientid" [clientid]="clientid" (hasLocations)="onLocationSaved($event)"
|
||||||
(updated)="onLocationUpdated($event)" [userPreferences]="userPreferences">
|
(updated)="onLocationUpdated($event)" [userPreferences]="userPreferences"
|
||||||
|
[refreshLocationData]="refreshLocationData">
|
||||||
</app-location>
|
</app-location>
|
||||||
</mat-step>
|
</mat-step>
|
||||||
|
|
||||||
|
|||||||
@ -44,14 +44,18 @@ export class AddPreparerComponent {
|
|||||||
this.locationCompleted = event;
|
this.locationCompleted = event;
|
||||||
}
|
}
|
||||||
|
|
||||||
onLocationUpdated(updated: boolean): void {
|
onLocationUpdated(event: boolean): void {
|
||||||
this.refreshLocationData = updated;
|
this.refreshLocationData = event;
|
||||||
}
|
}
|
||||||
|
|
||||||
onShowLocations(event: boolean): void {
|
onShowLocations(event: boolean): void {
|
||||||
this.showLocation = event;
|
this.showLocation = event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onLocationAdded(event: boolean): void {
|
||||||
|
this.refreshLocationData = event;
|
||||||
|
}
|
||||||
|
|
||||||
onStepChange(event: StepperSelectionEvent): void {
|
onStepChange(event: StepperSelectionEvent): void {
|
||||||
this.currentStep = event.selectedIndex;
|
this.currentStep = event.selectedIndex;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,6 +27,7 @@ export class BasicDetailsComponent implements OnInit, OnDestroy {
|
|||||||
@Output() clientidCreated = new EventEmitter<string>();
|
@Output() clientidCreated = new EventEmitter<string>();
|
||||||
@Output() clientName = new EventEmitter<string>();
|
@Output() clientName = new EventEmitter<string>();
|
||||||
@Output() showLocations = new EventEmitter<boolean>();
|
@Output() showLocations = new EventEmitter<boolean>();
|
||||||
|
@Output() locationAdded = new EventEmitter<boolean>();
|
||||||
|
|
||||||
basicDetailsForm: FormGroup;
|
basicDetailsForm: FormGroup;
|
||||||
countries: Country[] = [];
|
countries: Country[] = [];
|
||||||
@ -254,6 +255,7 @@ export class BasicDetailsComponent implements OnInit, OnDestroy {
|
|||||||
this.locationService.createLocation(clientid, locationData).subscribe({
|
this.locationService.createLocation(clientid, locationData).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
//this.notificationService.showSuccess('Location added successfully');
|
//this.notificationService.showSuccess('Location added successfully');
|
||||||
|
this.locationAdded.emit(true);
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to add location');
|
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to add location');
|
||||||
|
|||||||
@ -280,6 +280,7 @@
|
|||||||
<!-- Contact Login Form -->
|
<!-- Contact Login Form -->
|
||||||
<div class="form-container" *ngIf="showLoginForm">
|
<div class="form-container" *ngIf="showLoginForm">
|
||||||
<!-- <form [formGroup]="contactLoginForm" (ngSubmit)="saveLogin()"> -->
|
<!-- <form [formGroup]="contactLoginForm" (ngSubmit)="saveLogin()"> -->
|
||||||
|
<form>
|
||||||
<div class="form-header">
|
<div class="form-header">
|
||||||
<h3>Create Login</h3>
|
<h3>Create Login</h3>
|
||||||
</div>
|
</div>
|
||||||
@ -315,6 +316,6 @@
|
|||||||
</button>
|
</button>
|
||||||
<button mat-button type="button" (click)="cancelEdit()">Cancel</button>
|
<button mat-button type="button" (click)="cancelEdit()">Cancel</button>
|
||||||
</div>
|
</div>
|
||||||
<!-- </form> -->
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -1,4 +1,4 @@
|
|||||||
import { Component, EventEmitter, inject, Input, Output, ViewChild } from '@angular/core';
|
import { Component, EventEmitter, inject, Input, Output, SimpleChanges, ViewChild } from '@angular/core';
|
||||||
import { AngularMaterialModule } from '../../shared/module/angular-material.module';
|
import { AngularMaterialModule } from '../../shared/module/angular-material.module';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { FormBuilder, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
|
import { FormBuilder, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
|
||||||
@ -47,6 +47,7 @@ export class LocationComponent {
|
|||||||
|
|
||||||
@Input() clientid: number = 0;
|
@Input() clientid: number = 0;
|
||||||
@Input() userPreferences: UserPreferences = {};
|
@Input() userPreferences: UserPreferences = {};
|
||||||
|
@Input() refreshLocationData: boolean = false;
|
||||||
@Output() hasLocations = new EventEmitter<boolean>();
|
@Output() hasLocations = new EventEmitter<boolean>();
|
||||||
@Output() updated = new EventEmitter<boolean>();
|
@Output() updated = new EventEmitter<boolean>();
|
||||||
|
|
||||||
@ -67,7 +68,7 @@ export class LocationComponent {
|
|||||||
address2: ['', [Validators.maxLength(100)]],
|
address2: ['', [Validators.maxLength(100)]],
|
||||||
city: ['', [Validators.required, Validators.maxLength(50)]],
|
city: ['', [Validators.required, Validators.maxLength(50)]],
|
||||||
state: ['', Validators.required],
|
state: ['', Validators.required],
|
||||||
country: ['', Validators.required],
|
country: ['US', Validators.required],
|
||||||
zip: ['', [Validators.required, ZipCodeValidator('country')]],
|
zip: ['', [Validators.required, ZipCodeValidator('country')]],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -87,6 +88,12 @@ export class LocationComponent {
|
|||||||
this.destroy$.complete();
|
this.destroy$.complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
|
if (changes['refreshLocationData']) {
|
||||||
|
this.loadLocations();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
loadLocations(): void {
|
loadLocations(): void {
|
||||||
this.isLoading = true;
|
this.isLoading = true;
|
||||||
|
|
||||||
@ -119,6 +126,11 @@ export class LocationComponent {
|
|||||||
this.isEditing = false;
|
this.isEditing = false;
|
||||||
this.currentLocationId = null;
|
this.currentLocationId = null;
|
||||||
this.locationForm.reset();
|
this.locationForm.reset();
|
||||||
|
|
||||||
|
this.locationForm.patchValue({
|
||||||
|
country: 'US'
|
||||||
|
});
|
||||||
|
this.loadStates('US');
|
||||||
}
|
}
|
||||||
|
|
||||||
editLocation(location: Location): void {
|
editLocation(location: Location): void {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user