diff --git a/src/app/carnet/add/add-carnet.component.ts b/src/app/carnet/add/add-carnet.component.ts
index c2d6c9c..71cd598 100644
--- a/src/app/carnet/add/add-carnet.component.ts
+++ b/src/app/carnet/add/add-carnet.component.ts
@@ -1,5 +1,5 @@
import { Component, inject } from '@angular/core';
-import { FormBuilder, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
+import { ReactiveFormsModule } from '@angular/forms';
import { AngularMaterialModule } from '../../shared/module/angular-material.module';
import { CommonModule } from '@angular/common';
import { StepperSelectionEvent } from '@angular/cdk/stepper';
@@ -45,8 +45,6 @@ export class AddCarnetComponent {
}
onApplicationDetailCreated(data: { headerid: number, applicationName: string }): void {
- // this.store.headerid.set(data.headerid);
- // this.store.applicationName.set(data.applicationName);
this.headerid = data.headerid;
this.stepsCompleted.applicationDetail = true;
this.isLinear = false; // Disable linear mode after application detail is created
diff --git a/src/app/carnet/edit/edit-carnet.component.ts b/src/app/carnet/edit/edit-carnet.component.ts
index 13a32c2..e40730d 100644
--- a/src/app/carnet/edit/edit-carnet.component.ts
+++ b/src/app/carnet/edit/edit-carnet.component.ts
@@ -48,6 +48,12 @@ export class EditCarnetComponent {
this.headerid = idParam ? parseInt(idParam, 10) : 0;
this.applicationName = this.route.snapshot.queryParamMap.get('applicationname') || '';
+
+ let returnTo = this.route.snapshot.queryParamMap.get('return');
+
+ if (returnTo === 'holder') {
+ this.currentStep = 1;
+ }
}
onStepChange(event: StepperSelectionEvent): void {
diff --git a/src/app/carnet/shipping/contact-dialog.component.ts b/src/app/carnet/shipping/contact-dialog.component.ts
index 2618543..c6dbb1c 100644
--- a/src/app/carnet/shipping/contact-dialog.component.ts
+++ b/src/app/carnet/shipping/contact-dialog.component.ts
@@ -55,7 +55,30 @@ export class ContactDialogComponent {
}
getContactLabel(contact: any): string {
- return `${contact.firstName} ${contact.middleInitial} ${contact.lastName},
- ${contact.email}, ${contact.phone}`;
+
+ if (!contact) {
+ return 'No contact information available';
+ }
+
+ // Build name parts, filtering out null/undefined/empty strings
+ const nameParts = [
+ contact.firstName,
+ contact.middleInitial,
+ contact.lastName
+ ].filter(part => part != null && part.trim() !== '');
+
+ // Build contact info parts
+ const contactInfoParts = [
+ contact.email,
+ contact.phone
+ ].filter(part => part != null && part.trim() !== '');
+
+ // Combine all non-empty parts
+ const allParts = [
+ nameParts.join(' '), // Join name parts with single spaces
+ ...contactInfoParts // Add email and phone if they exist
+ ].filter(part => part.trim() !== '');
+
+ return allParts.join(', ') || '';
}
}
\ No newline at end of file
diff --git a/src/app/carnet/shipping/shipping.component.html b/src/app/carnet/shipping/shipping.component.html
index 3cbcee5..6cc05a9 100644
--- a/src/app/carnet/shipping/shipping.component.html
+++ b/src/app/carnet/shipping/shipping.component.html
@@ -17,9 +17,9 @@
Ship To
- Preparer
- Holder
- 3rd Party
+ Preparer
+ Holder
+ 3rd Party
@@ -30,10 +30,10 @@
{{getContactLabel()}}
-
-
@@ -241,7 +241,7 @@
-
diff --git a/src/app/carnet/shipping/shipping.component.ts b/src/app/carnet/shipping/shipping.component.ts
index a0e03c1..d0268ae 100644
--- a/src/app/carnet/shipping/shipping.component.ts
+++ b/src/app/carnet/shipping/shipping.component.ts
@@ -10,7 +10,7 @@ import { Shipping } from '../../core/models/carnet/shipping';
import { Country } from '../../core/models/country';
import { State } from '../../core/models/state';
import { ZipCodeValidator } from '../../shared/validators/zipcode-validator';
-import { Subject, takeUntil } from 'rxjs';
+import { finalize, forkJoin, map, Subject, switchMap, takeUntil, throwError } from 'rxjs';
import { DeliveryType } from '../../core/models/delivery-type';
import { DeliveryMethod } from '../../core/models/delivery-method';
import { PaymentType } from '../../core/models/payment-type';
@@ -19,6 +19,8 @@ import { MatDialog } from '@angular/material/dialog';
import { ShippingContact } from '../../core/models/carnet/shipping-contact';
import { ShippingAddress } from '../../core/models/carnet/shipping-address';
import { ContactDialogComponent } from './contact-dialog.component';
+import { HolderService } from '../../core/services/carnet/holder.service';
+import { Holder } from '../../core/models/carnet/holder';
@Component({
selector: 'app-shipping',
@@ -38,12 +40,14 @@ export class ShippingComponent {
private notificationService = inject(NotificationService);
private errorHandler = inject(ApiErrorHandlerService);
private commonService = inject(CommonService);
+ private holderService = inject(HolderService);
shippingForm: FormGroup;
isLoading = false;
showAddressForm = false;
showContactForm = false;
deliveryEstimate: string = '';
+ holderid: number = 0;
countriesHasStates = ['US', 'CA', 'MX'];
countries: Country[] = [];
@@ -54,89 +58,19 @@ export class ShippingComponent {
private destroy$ = new Subject();
- // preparer contact and address mock data
+ preparerAddress: ShippingAddress | null | undefined = null;
+ holderAddress: ShippingAddress | null | undefined = null;
preparerContact: ShippingContact | null | undefined = null;
-
- preparerContacts: ShippingContact[] = [
- {
- contactid: 1,
- firstName: 'John',
- lastName: 'Doe',
- middleInitial: 'A',
- title: 'Mr.',
- phone: '1234567890',
- mobile: '0987654321',
- fax: '1234567890',
- email: 'j@doe.com',
- defaultContact: true
- },
- {
- contactid: 2,
- firstName: 'Jane',
- lastName: 'Smith',
- middleInitial: 'B',
- title: 'Ms.',
- phone: '2345678901',
- mobile: '1098765432',
- fax: '2345678901',
- email: 'jan@sm.cm',
- defaultContact: false
- }];
-
- preparerAddress = {
- companyName: 'ABC Company',
- address1: '123 Main St',
- address2: 'Suite 100',
- city: 'Anytown',
- state: 'CA',
- zip: '12345',
- country: 'US'
- };
-
- holderAddress = {
- companyName: 'XYZ Company',
- address1: '456 Holder St',
- address2: 'Apt 200',
- city: 'Othertown',
- state: 'NY',
- zip: '67890',
- country: 'US'
- };
-
+ preparerContacts: ShippingContact[] = [];
holderContact: ShippingContact | null | undefined = null;
-
- holderContacts: ShippingContact[] = [
- {
- contactid: 1,
- firstName: 'John',
- lastName: 'Doe',
- middleInitial: 'A',
- title: 'Mr.',
- phone: '1234567890',
- mobile: '0987654321',
- fax: '1234567890',
- email: 'j@doe.com',
- defaultContact: false
- },
- {
- contactid: 2,
- firstName: 'Jane',
- lastName: 'Smith',
- middleInitial: 'B',
- title: 'Ms.',
- phone: '2345678901',
- mobile: '1098765432',
- fax: '2345678901',
- email: 'jan@sm.cm',
- defaultContact: true
- }];
+ holderContacts: ShippingContact[] = [];
constructor() {
this.shippingForm = this.fb.group({
needsBond: [false],
needsInsurance: [false],
needsLostDocProtection: [false],
- shipTo: ['preparer', Validators.required],
+ shipTo: ['PREPARER', Validators.required],
address: this.fb.group({
address1: [''],
address2: [''],
@@ -164,17 +98,10 @@ export class ShippingComponent {
paymentNotes: ['']
});
- this.shippingForm.get('deliveryMethod')?.valueChanges.subscribe(value => {
-
- });
-
this.shippingForm.get('deliveryType')?.valueChanges.subscribe(() => {
this.calculateDeliveryEstimate();
});
- // this.shippingForm.valueChanges.subscribe(() => {
- // this.completed.emit(this.shippingForm.valid);
- // });
}
ngOnInit(): void {
@@ -185,10 +112,6 @@ export class ShippingComponent {
if (this.headerid && this.isEditMode) {
this.loadShippingData();
-
- // TODO
- this.preparerContact = this.preparerContacts.find(pc => pc.defaultContact);
- this.holderContact = this.holderContacts.find(hc => hc.defaultContact);
}
}
@@ -204,7 +127,12 @@ export class ShippingComponent {
}
this.isLoading = true;
- const shippingData = this.shippingForm.value;
+ const shippingData: Shipping = this.shippingForm.value;
+
+ if (shippingData.shipTo !== '3RDPARTY') {
+ shippingData.address = shippingData.shipTo === 'PREPARER' ? this.preparerAddress ?? undefined : this.holderAddress ?? undefined;
+ shippingData.contact = shippingData.shipTo === 'PREPARER' ? this.preparerContact ?? undefined : this.holderContact ?? undefined;
+ }
this.shippingService.saveShippingDetails(this.headerid, shippingData).subscribe({
next: () => {
@@ -248,12 +176,12 @@ export class ShippingComponent {
this.showAddressForm = true;
let shipTo = this.shippingForm.get('shipTo')?.value;
- if (shipTo === 'preparer') {
+ if (shipTo === 'PREPARER' && this.preparerAddress) {
this.shippingForm.get('address')?.patchValue(this.preparerAddress);
this.loadStates(this.preparerAddress.country);
- } else if (shipTo === 'holder') {
+ } else if (shipTo === 'HOLDER' && this.holderAddress) {
this.shippingForm.get('address')?.patchValue(this.holderAddress);
- this.loadStates(this.preparerAddress.country);
+ this.loadStates(this.holderAddress.country);
}
}
@@ -269,7 +197,7 @@ export class ShippingComponent {
this.updateShippingValidation(shipTo);
- if (shipTo === 'thirdParty') {
+ if (shipTo === '3RDPARTY') {
this.shippingForm.get('contact')?.reset();
this.shippingForm.get('address')?.reset();
this.showAddressForm = true;
@@ -359,15 +287,52 @@ export class ShippingComponent {
loadShippingData(): void {
this.isLoading = true;
- this.shippingService.getShippingData(this.headerid).subscribe({
- next: (data: Shipping) => {
- this.patchShippingData(data);
- this.isLoading = false;
+ this.holderService.getHolder(this.headerid).pipe(
+ switchMap((holder: Holder) => {
+ if (!holder) {
+ return throwError(() => new Error('Holder not found'));
+ }
+
+ return forkJoin({
+ holderContacts: this.shippingService.getHolderContactsById(holder.holderid),
+ holderAddress: this.shippingService.getHolderAddressById(holder.holderid),
+ preparerAddress: this.shippingService.getPreparerAddress(),
+ preparerContacts: this.shippingService.getPreparerContacts(),
+ shippingData: this.shippingService.getShippingData(this.headerid)
+ }).pipe(
+ // Combine the forkJoin results with the original holder object
+ map((apiResults: any) => ({ ...apiResults, holder }))
+ );
+ }),
+ finalize(() => this.isLoading = false)
+ ).subscribe({
+ next: (results) => {
+ this.holderid = results.holder.holderid;
+ this.holderContacts = results.holderContacts;
+ this.holderAddress = results.holderAddress;
+ this.preparerContacts = results.preparerContacts;
+ this.preparerAddress = results.preparerAddress;
+
+ // Set holder contact
+ if (results.shippingData?.shipTo === 'HOLDER' && results.shippingData?.contact?.contactid) {
+ this.holderContact = this.holderContacts.find(hc => hc.contactid === results.shippingData?.contact?.contactid);
+ } else {
+ this.holderContact = this.holderContacts?.[0];
+ }
+
+ // Set preparer contact
+ if (results.shippingData?.shipTo === 'PREPARER' && results.shippingData?.contact?.contactid) {
+ this.preparerContact = this.preparerContacts.find(pc => pc.contactid === results.shippingData?.contact?.contactid);
+ } else {
+ this.preparerContact = this.preparerContacts.find(pc => pc.defaultContact);
+ }
+
+ this.patchShippingData(results.shippingData);
},
error: (error: any) => {
- let errorMessage = this.errorHandler.handleApiError(error, 'Failed to load shipping and payments data');
+ console.error('Error loading shipping data', error);
+ const errorMessage = this.errorHandler.handleApiError(error, 'Failed to load shipping data');
this.notificationService.showError(errorMessage);
- this.isLoading = false;
}
});
}
@@ -395,7 +360,7 @@ export class ShippingComponent {
this.calculateDeliveryEstimate();
this.updateShippingValidation(shipping.shipTo);
- if (shipping.shipTo === 'thirdParty') {
+ if (shipping.shipTo === '3RDPARTY') {
this.showAddressForm = true;
this.showContactForm = true;
@@ -428,69 +393,11 @@ export class ShippingComponent {
}
}
- loadPreparerContacts(): void {
- this.isLoading = true;
- this.shippingService.getPreparerContactsById().subscribe({
- next: (data: ShippingContact) => {
- // this.preparerContacts = data;
- this.preparerContact = this.preparerContacts.find(pc => pc.defaultContact);
- },
- error: (error: any) => {
- let errorMessage = this.errorHandler.handleApiError(error, 'Failed to load preparer contacts data');
- this.notificationService.showError(errorMessage);
- this.isLoading = false;
- }
- });
- }
-
- loadHolderContacts(): void {
- this.isLoading = true;
- this.shippingService.getHolderContactsById(0).subscribe({
- next: (data: ShippingContact) => {
- // this.holderContacts = data;
- this.holderContact = this.holderContacts.find(hc => hc.defaultContact);
- },
- error: (error: any) => {
- let errorMessage = this.errorHandler.handleApiError(error, 'Failed to load holder contacts data');
- this.notificationService.showError(errorMessage);
- this.isLoading = false;
- }
- });
- }
-
- loadPreparerAddress(): void {
- this.isLoading = true;
- this.shippingService.getPreparerAddress().subscribe({
- next: (data: ShippingAddress) => {
- // this.preparerAddress = data;
- },
- error: (error: any) => {
- let errorMessage = this.errorHandler.handleApiError(error, 'Failed to load preparer address data');
- this.notificationService.showError(errorMessage);
- this.isLoading = false;
- }
- });
- }
-
- loadHolderAddress(): void {
- this.isLoading = true;
- this.shippingService.getHolderAddressById(0).subscribe({
- next: (data: ShippingAddress) => {
- // this.holderAddress = data;
- },
- error: (error: any) => {
- let errorMessage = this.errorHandler.handleApiError(error, 'Failed to load holder address data');
- this.notificationService.showError(errorMessage);
- this.isLoading = false;
- }
- });
- }
-
updateShippingValidation(shipTo: string): void {
const addressGroup = this.shippingForm.get('address') as FormGroup;
const contactGroup = this.shippingForm.get('contact') as FormGroup;
- if (shipTo === 'thirdParty') {
+ if (shipTo === '3RDPARTY') {
Object.keys(addressGroup.controls).forEach(key => {
if (key === 'address1') {
addressGroup.get(key)?.setValidators([Validators.required, Validators.maxLength(100)]);
@@ -542,14 +449,14 @@ export class ShippingComponent {
getAddressLabel(): string {
let shipTo = this.shippingForm.get('shipTo')?.value;
- if (shipTo === 'preparer') {
- return `${this.preparerAddress.companyName}, ${this.preparerAddress.address1},
+ if (shipTo === 'PREPARER' && this.preparerAddress) {
+ return `${this.preparerAddress.address1},
${this.preparerAddress.city}, ${this.preparerAddress.state}, ${this.preparerAddress.zip},
${this.preparerAddress.country}`;
}
- if (shipTo === 'holder') {
- return `${this.holderAddress.companyName}, ${this.holderAddress.address1},
+ if (shipTo === 'HOLDER' && this.holderAddress) {
+ return `${this.holderAddress.address1},
${this.holderAddress.city}, ${this.holderAddress.state}, ${this.holderAddress.zip},
${this.holderAddress.country}`;
}
@@ -558,18 +465,34 @@ export class ShippingComponent {
}
getContactLabel(): string {
- let shipTo = this.shippingForm.get('shipTo')?.value;
+ const shipTo = this.shippingForm.get('shipTo')?.value;
+ const contact = shipTo === 'PREPARER' ? this.preparerContact :
+ shipTo === 'HOLDER' ? this.holderContact : null;
- if (shipTo === 'preparer' && this.preparerContact) {
- return `${this.preparerContact.firstName} ${this.preparerContact.middleInitial} ${this.preparerContact.lastName},
- ${this.preparerContact.email}, ${this.preparerContact.phone}`;
+ if (!contact) {
+ return 'No contact information available';
}
- if (shipTo === 'holder' && this.holderContact) {
- return `${this.holderContact.firstName} ${this.holderContact.middleInitial} ${this.holderContact.lastName},
- ${this.holderContact.email}, ${this.holderContact.phone}`;
- }
- return '';
+ // Build name parts, filtering out null/undefined/empty strings
+ const nameParts = [
+ contact.firstName,
+ contact.middleInitial,
+ contact.lastName
+ ].filter(part => part != null && part.trim() !== '');
+
+ // Build contact info parts
+ const contactInfoParts = [
+ contact.email,
+ contact.phone
+ ].filter(part => part != null && part.trim() !== '');
+
+ // Combine all non-empty parts
+ const allParts = [
+ nameParts.join(' '), // Join name parts with single spaces
+ ...contactInfoParts // Add email and phone if they exist
+ ].filter(part => part.trim() !== '');
+
+ return allParts.join(', ') || '';
}
calculateDeliveryEstimate(): void {
@@ -627,13 +550,7 @@ export class ShippingComponent {
selectContact(): void {
let shipTo = this.shippingForm.get('shipTo')?.value;
- if (shipTo === 'preparer') {
- this.preparerContact = this.preparerContacts.find(pc => pc.defaultContact);
- } else if (shipTo === 'holder') {
- this.holderContact = this.holderContacts.find(hc => hc.defaultContact);
- }
-
- const contacts = shipTo === 'preparer' ? this.preparerContacts : this.holderContacts;
+ const contacts = shipTo === 'PREPARER' ? this.preparerContacts : this.holderContacts;
const dialogRef = this.dialog.open(ContactDialogComponent, {
width: '500px',
@@ -643,7 +560,7 @@ export class ShippingComponent {
dialogRef.afterClosed().subscribe(selectedItem => {
if (selectedItem) {
const selectedContact = contacts.find(c => c.contactid === selectedItem.contactid);
- if (shipTo === 'preparer') {
+ if (shipTo === 'PREPARER') {
this.preparerContact = selectedContact;
} else {
this.holderContact = selectedContact;
diff --git a/src/app/core/services/carnet/shipping.service.ts b/src/app/core/services/carnet/shipping.service.ts
index 4143a56..3bc997c 100644
--- a/src/app/core/services/carnet/shipping.service.ts
+++ b/src/app/core/services/carnet/shipping.service.ts
@@ -79,7 +79,6 @@ export class ShippingService {
P_INSPROTECTION: shippingData.needsInsurance ? 'Y' : 'N',
P_LDIPROTECTION: shippingData.needsLostDocProtection ? 'Y' : 'N',
- P_SHIPCONTACTID: shippingData.address?.addressid || 0,
P_ADDRESS1: shippingData.address?.address1 || null,
P_ADDRESS2: shippingData.address?.address2 || null,
P_CITY: shippingData.address?.city || null,
@@ -87,6 +86,7 @@ export class ShippingService {
P_ZIP: shippingData.address?.zip || null,
P_COUNTRY: shippingData.address?.country || null,
+ P_SHIPCONTACTID: shippingData.contact?.contactid || 0,
P_FIRSTNAME: shippingData.contact?.firstName || '',
P_LASTNAME: shippingData.contact?.lastName || '',
P_MIDDLEINITIAL: shippingData.contact?.middleInitial || null,
@@ -103,7 +103,7 @@ export class ShippingService {
return this.http.patch(`${this.apiUrl}/${this.apiDb}/UpdateShippingDetails`, shippingDetails);
}
- getPreparerContactsById(): ShippingContact[] | any {
+ getPreparerContacts(): ShippingContact[] | any {
return this.http.get(`${this.apiUrl}/${this.apiDb}/GetPreparerContactsByClientid/${this.userService.getUserSpid()}/${this.userService.getUserClientid()}`).pipe(
map(response => this.mapToContacts(response)));
}
@@ -115,7 +115,7 @@ export class ShippingService {
private mapToContacts(data: any[]): ShippingContact[] {
return data.map(contact => ({
- contactid: contact.CLIENTCONTACTID,
+ contactid: contact.CLIENTCONTACTID ?? contact.HOLDERCONTACTID,
defaultContact: contact.DEFCONTACTFLAG === 'Y',
firstName: contact.FIRSTNAME,
lastName: contact.LASTNAME,
@@ -129,18 +129,19 @@ export class ShippingService {
}));
}
- getPreparerAddress(): ShippingAddress[] | any {
+ getPreparerAddress(): ShippingAddress | any {
return this.http.get(`${this.apiUrl}/${this.apiDb}/GetPreparerLocByClientid/${this.userService.getUserSpid()}/${this.userService.getUserClientid()}`).pipe(
- map(response => this.mapToAddress(response)));
+ filter(response => response.length > 0),
+ map(response => this.mapToAddress(response?.[0])));
}
- getHolderAddressById(id: number): ShippingContact[] | any {
+ getHolderAddressById(id: number): ShippingAddress | any {
return this.http.get(`${this.apiUrl}/${this.apiDb}/GetHolderRecord/${this.userService.getUserSpid()}/${id}`).pipe(
map(response => this.mapToAddress(response)));
}
- private mapToAddress(data: any[]): ShippingAddress[] {
- return data.map(address => ({
+ private mapToAddress(address: any): ShippingAddress {
+ return {
addressid: address.SHIPADDRESSID,
address1: address.ADDRESS1,
address2: address.ADDRESS2,
@@ -148,6 +149,6 @@ export class ShippingService {
state: address.STATE,
zip: address.ZIP,
country: address.COUNTRY
- }));
+ };
}
}
diff --git a/src/app/holder/add/add-holder.component.html b/src/app/holder/add/add-holder.component.html
index 904e1b3..00a6385 100644
--- a/src/app/holder/add/add-holder.component.html
+++ b/src/app/holder/add/add-holder.component.html
@@ -1,6 +1,3 @@
-
-
+
+
+
+ chevron_left Back to application
+
+
\ No newline at end of file
diff --git a/src/app/holder/add/add-holder.component.scss b/src/app/holder/add/add-holder.component.scss
index 8d7d2bb..800e8ad 100644
--- a/src/app/holder/add/add-holder.component.scss
+++ b/src/app/holder/add/add-holder.component.scss
@@ -1,4 +1,3 @@
-// .back-btn{
-// padding: 0 10px !important;
-// margin-bottom: 10px !important;
-// }
\ No newline at end of file
+.additional-actions {
+ margin: 12px 0;
+}
\ No newline at end of file
diff --git a/src/app/holder/add/add-holder.component.ts b/src/app/holder/add/add-holder.component.ts
index 4779a1b..8df9e92 100644
--- a/src/app/holder/add/add-holder.component.ts
+++ b/src/app/holder/add/add-holder.component.ts
@@ -11,6 +11,7 @@ import { ContactsComponent } from '../contacts/contacts.component';
import { UserPreferences } from '../../core/models/user-preference';
import { UserPreferencesService } from '../../core/services/user-preference.service';
import { NavigationService } from '../../core/services/common/navigation.service';
+import { StorageService } from '../../core/services/common/storage.service';
@Component({
selector: 'app-add-holder',
@@ -33,6 +34,7 @@ export class AddHolderComponent {
isEditMode = false;
holderid: number = 0;
userPreferences: UserPreferences;
+ currentApplicationDetails: { headerid: number, applicationName: string } | null = null;
stepsCompleted = {
holderDetails: false,
@@ -40,11 +42,13 @@ export class AddHolderComponent {
};
private navigationService = inject(NavigationService);
+ private storageService = inject(StorageService);
constructor(
userPrefenceService: UserPreferencesService
) {
this.userPreferences = userPrefenceService.getPreferences();
+ this.currentApplicationDetails = this.storageService.get<{ headerid: number, applicationName: string }>('currentapplication')
}
onStepChange(event: StepperSelectionEvent): void {
@@ -56,11 +60,15 @@ export class AddHolderComponent {
this.stepsCompleted.holderDetails = true;
}
- // goToEditCarnet(): void {
- // this.navigationService.navigate(["edit-carnet", this.store.headerid()],
- // {
- // state: { isEditMode: true },
- // queryParams: { applicationname: this.store.applicationName() }
- // })
- // }
+ goBackToCarnetApplication(): void {
+ this.storageService.removeItem('currentapplication')
+ this.navigationService.navigate(["edit-carnet", this.currentApplicationDetails?.headerid],
+ {
+ state: { isEditMode: true },
+ queryParams: {
+ applicationname: this.currentApplicationDetails?.applicationName,
+ return: 'holder'
+ }
+ })
+ }
}
diff --git a/src/app/holder/edit/edit-holder.component.html b/src/app/holder/edit/edit-holder.component.html
index 90986ab..ab2c3f8 100644
--- a/src/app/holder/edit/edit-holder.component.html
+++ b/src/app/holder/edit/edit-holder.component.html
@@ -21,4 +21,10 @@
-
\ No newline at end of file
+
+
+
+
+ chevron_left Back to application
+
+
\ No newline at end of file
diff --git a/src/app/holder/edit/edit-holder.component.scss b/src/app/holder/edit/edit-holder.component.scss
index abc9d06..adddce0 100644
--- a/src/app/holder/edit/edit-holder.component.scss
+++ b/src/app/holder/edit/edit-holder.component.scss
@@ -8,6 +8,10 @@
padding-bottom: 20px;
}
+.additional-actions {
+ margin: 12px 0;
+}
+
.holder-headers-align .mat-expansion-panel-header-description {
justify-content: space-between;
align-items: center;
diff --git a/src/app/holder/edit/edit-holder.component.ts b/src/app/holder/edit/edit-holder.component.ts
index 99bb944..0b5b927 100644
--- a/src/app/holder/edit/edit-holder.component.ts
+++ b/src/app/holder/edit/edit-holder.component.ts
@@ -7,6 +7,8 @@ import { ActivatedRoute } from '@angular/router';
import { UserPreferencesService } from '../../core/services/user-preference.service';
import { BasicDetailComponent } from '../basic-details/basic-details.component';
import { ContactsComponent } from '../contacts/contacts.component';
+import { StorageService } from '../../core/services/common/storage.service';
+import { NavigationService } from '../../core/services/common/navigation.service';
@Component({
selector: 'app-edit-holder',
@@ -20,11 +22,16 @@ export class EditHolderComponent {
holderid = 0;
holderName: string | null = null;
userPreferences: UserPreferences;
+ currentApplicationDetails: { headerid: number, applicationName: string } | null = null;
private route = inject(ActivatedRoute);
+ private navigationService = inject(NavigationService);
+ private storageService = inject(StorageService);
constructor(userPrefenceService: UserPreferencesService) {
this.userPreferences = userPrefenceService.getPreferences();
+ this.currentApplicationDetails = this.storageService.get<{ headerid: number, applicationName: string }>('currentapplication')
+
afterNextRender(() => {
this.accordion().openAll();
});
@@ -38,4 +45,16 @@ export class EditHolderComponent {
onHolderNameUpdate(event: string): void {
this.holderName = event;
}
+
+ goBackToCarnetApplication(): void {
+ this.storageService.removeItem('currentapplication')
+ this.navigationService.navigate(["edit-carnet", this.currentApplicationDetails?.headerid],
+ {
+ state: { isEditMode: true },
+ queryParams: {
+ applicationname: this.currentApplicationDetails?.applicationName,
+ return: 'holder'
+ }
+ })
+ }
}
diff --git a/src/app/holder/search/search-holder.component.ts b/src/app/holder/search/search-holder.component.ts
index 37e80cd..c48c2b0 100644
--- a/src/app/holder/search/search-holder.component.ts
+++ b/src/app/holder/search/search-holder.component.ts
@@ -17,6 +17,7 @@ import { BasicDetail } from '../../core/models/holder/basic-detail';
import { HolderFilter } from '../../core/models/holder/holder-filter';
import { ConfirmDialogComponent } from '../../shared/components/confirm-dialog/confirm-dialog.component';
import { MatDialog } from '@angular/material/dialog';
+import { StorageService } from '../../core/services/common/storage.service';
@Component({
selector: 'app-holder-search',
@@ -46,7 +47,6 @@ export class SearchHolderComponent {
showInactiveHolders: boolean = false;
holders: BasicDetail[] = []
isLoading: boolean = false;
-
userPreferences: UserPreferences;
searchForm: FormGroup;
@@ -56,6 +56,7 @@ export class SearchHolderComponent {
private carnetHolderService = inject(CarnetApplicationHolderService);
private errorHandler = inject(ApiErrorHandlerService);
private notificationService = inject(NotificationService);
+ private storageService = inject(StorageService);
private dialog = inject(MatDialog);
dataSource = new MatTableDataSource([]);
@@ -137,10 +138,20 @@ export class SearchHolderComponent {
}
addNewHolder(): void {
- this.navigationService.navigate(["add-holder"], { state: { isEditMode: false } })
+ if (this.headerid) {
+ let currentApplicationDetails = { headerid: this.headerid, applicationName: this.applicationName }
+ this.storageService.set("currentapplication", currentApplicationDetails);
+ }
+
+ this.navigationService.navigate(["add-holder"])
}
onEdit(id: string) {
+ if (this.headerid) {
+ let currentApplicationDetails = { headerid: this.headerid, applicationName: this.applicationName }
+ this.storageService.set("currentapplication", currentApplicationDetails);
+ }
+
this.navigationService.navigate(['edit-holder', id]);
}