From 5e81edb846a1463e86d03cb99f716d28ba5d030a Mon Sep 17 00:00:00 2001 From: stdevman91 Date: Mon, 24 Aug 2026 19:36:34 +0300 Subject: [PATCH] Delete remove filters value after action --- .../create-default-payment-reference.component.ts | 7 +++++-- .../create-payment-reference.component.ts | 7 +++++-- .../template/edit-template/edit-template.component.ts | 7 ++++++- .../default-payment-references.component.ts | 11 ++++++++--- .../payment-references.component.ts | 10 +++++++--- 5 files changed, 31 insertions(+), 11 deletions(-) diff --git a/src/app/sections/default-reference/create-default-reference/components/create-default-payment-reference/create-default-payment-reference.component.ts b/src/app/sections/default-reference/create-default-reference/components/create-default-payment-reference/create-default-payment-reference.component.ts index dc8da84b..4a5cdea2 100644 --- a/src/app/sections/default-reference/create-default-reference/components/create-default-payment-reference/create-default-payment-reference.component.ts +++ b/src/app/sections/default-reference/create-default-reference/components/create-default-payment-reference/create-default-payment-reference.component.ts @@ -1,5 +1,5 @@ import { Component, Inject } from '@angular/core'; -import { Router } from '@angular/router'; +import { ActivatedRoute, Router } from '@angular/router'; import { LAYOUT_GAP_M } from '../../../../../tokens'; import { CreateDefaultPaymentReferenceService } from '../../services/create-default-payment-reference.service'; @@ -14,11 +14,14 @@ export class CreateDefaultPaymentReferenceComponent { constructor( private createDefaultPaymentReferenceService: CreateDefaultPaymentReferenceService, + private route: ActivatedRoute, private router: Router, @Inject(LAYOUT_GAP_M) public layoutGapM: string ) { this.createDefaultPaymentReferenceService.created$.subscribe(() => { - this.router.navigate(['/templates/default-references']); + void this.router.navigateByUrl( + this.route.snapshot.queryParamMap.get('returnUrl') || '/templates/default-references' + ); }); } diff --git a/src/app/sections/reference/create-reference/components/create-payment-reference/create-payment-reference.component.ts b/src/app/sections/reference/create-reference/components/create-payment-reference/create-payment-reference.component.ts index dbd76b1f..8ab53211 100644 --- a/src/app/sections/reference/create-reference/components/create-payment-reference/create-payment-reference.component.ts +++ b/src/app/sections/reference/create-reference/components/create-payment-reference/create-payment-reference.component.ts @@ -1,5 +1,5 @@ import { Component, Inject } from '@angular/core'; -import { Router } from '@angular/router'; +import { ActivatedRoute, Router } from '@angular/router'; import { OperationType } from '../../../../../shared/constants/operation-type'; import { CsvUtilsService } from '../../../../../shared/services/utils/csv-utils.service'; @@ -17,11 +17,14 @@ export class CreatePaymentReferenceComponent { constructor( private createPaymentReferenceService: CreatePaymentReferenceService, + private route: ActivatedRoute, private router: Router, @Inject(LAYOUT_GAP_M) public layoutGapM: string ) { this.createPaymentReferenceService.created$.subscribe(() => { - this.router.navigate(['/templates/references']); + void this.router.navigateByUrl( + this.route.snapshot.queryParamMap.get('returnUrl') || '/templates/references' + ); }); } diff --git a/src/app/sections/template/edit-template/edit-template.component.ts b/src/app/sections/template/edit-template/edit-template.component.ts index 4e2100b4..f2707879 100644 --- a/src/app/sections/template/edit-template/edit-template.component.ts +++ b/src/app/sections/template/edit-template/edit-template.component.ts @@ -31,6 +31,11 @@ export class EditTemplateComponent { ) {} back() { - this.router.navigate([`../templates`]); + const returnUrl = this.route.snapshot.queryParamMap.get('returnUrl'); + if (returnUrl) { + void this.router.navigateByUrl(returnUrl); + } else { + void this.router.navigate([`../templates`]); + } } } diff --git a/src/app/sections/templates/components/payment-dafeult-references/default-payment-references.component.ts b/src/app/sections/templates/components/payment-dafeult-references/default-payment-references.component.ts index 9fbc8c55..ee2627cd 100644 --- a/src/app/sections/templates/components/payment-dafeult-references/default-payment-references.component.ts +++ b/src/app/sections/templates/components/payment-dafeult-references/default-payment-references.component.ts @@ -24,12 +24,14 @@ export class DefaultPaymentReferencesComponent { @Inject(LAYOUT_GAP_M) public layoutGapM: string ) { this.removeDefaultReferenceService.removed$.subscribe(() => { - this.fetchDefaultReferencesService.search({ isGlobal: false, isDefault: false }); + this.fetchDefaultReferencesService.refresh(); }); } createReference() { - this.router.navigate(['/default-references/new/payment']); + void this.router.navigate(['/default-references/new/payment'], { + queryParams: { returnUrl: this.router.url }, + }); } search(searchValue: string) { @@ -49,7 +51,10 @@ export class DefaultPaymentReferencesComponent { } goToTemplate(id: string) { - this.router.navigate([`/template/${id}`], { fragment: OperationType.Payment }); + void this.router.navigate([`/template/${id}`], { + fragment: OperationType.Payment, + queryParams: { returnUrl: this.router.url }, + }); } removeReference(reference: PaymentReference) { diff --git a/src/app/sections/templates/components/payment-references/payment-references.component.ts b/src/app/sections/templates/components/payment-references/payment-references.component.ts index 29a4bb54..3f2e0666 100644 --- a/src/app/sections/templates/components/payment-references/payment-references.component.ts +++ b/src/app/sections/templates/components/payment-references/payment-references.component.ts @@ -24,12 +24,14 @@ export class PaymentReferencesComponent { @Inject(LAYOUT_GAP_M) public layoutGapM: string ) { this.removeReferenceService.removed$.subscribe(() => { - this.fetchReferencesService.search({ isGlobal: false, isDefault: false }); + this.fetchReferencesService.refresh(); }); } createReference() { - this.router.navigate(['/reference/new/payment']); + void this.router.navigate(['/reference/new/payment'], { + queryParams: { returnUrl: this.router.url }, + }); } search(searchValue: string) { @@ -49,7 +51,9 @@ export class PaymentReferencesComponent { } goToTemplate(id: string) { - this.router.navigate([`/template/${id}`]); + void this.router.navigate([`/template/${id}`], { + queryParams: { returnUrl: this.router.url }, + }); } removeReference(reference: PaymentReference) {