Skip to content

Commit

Permalink
Add fix for case details back button not working (#1280)
Browse files Browse the repository at this point in the history
  • Loading branch information
teodor-ritense authored Nov 21, 2024
1 parent e44be02 commit ca4e80c
Showing 1 changed file with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
ViewChild,
ViewContainerRef,
} from '@angular/core';
import {ActivatedRoute, ParamMap, Params, Router} from '@angular/router';
import {ActivatedRoute, NavigationStart, ParamMap, Params, Router} from '@angular/router';
import {ChevronDown16} from '@carbon/icons';
import {TranslateService} from '@ngx-translate/core';
import {PermissionService} from '@valtimo/access-control';
Expand All @@ -47,8 +47,9 @@ import {
InternalCaseStatusUtils,
ProcessDocumentDefinition,
} from '@valtimo/document';
import {TaskWithProcessLink} from '@valtimo/process-link';
import {UserProviderService} from '@valtimo/security';
import {IntermediateSubmission, TaskService} from '@valtimo/task';
import {IntermediateSubmission} from '@valtimo/task';
import {IconService, NotificationService} from 'carbon-components-angular';
import {KeycloakService} from 'keycloak-angular';
import moment from 'moment';
Expand Down Expand Up @@ -79,7 +80,6 @@ import {
} from '../../permissions';
import {DossierDetailLayoutService, DossierService, DossierTabService} from '../../services';
import {DossierSupportingProcessStartModalComponent} from '../dossier-supporting-process-start-modal/dossier-supporting-process-start-modal.component';
import {TaskWithProcessLink} from '@valtimo/process-link';

@Component({
selector: 'valtimo-dossier-detail',
Expand Down Expand Up @@ -261,6 +261,7 @@ export class DossierDetailComponent
private _pendingTab: TabImpl;
private _observer!: ResizeObserver;
private _tabsInit = false;
private _prevQueryParams: Params | undefined | null;

constructor(
private readonly breadcrumbService: BreadcrumbService,
Expand All @@ -283,7 +284,6 @@ export class DossierDetailComponent
private readonly renderer: Renderer2,
private readonly route: ActivatedRoute,
private readonly router: Router,
private readonly taskService: TaskService,
private readonly userProviderService: UserProviderService,
@Inject(DOCUMENT) private readonly htmlDocument: Document
) {
Expand All @@ -301,6 +301,7 @@ export class DossierDetailComponent
this.pageTitleService.disableReset();
this.iconService.registerAll([ChevronDown16]);
this.setDocumentStyle();
this.handleBackNavigation();
}

public ngOnDestroy(): void {
Expand Down Expand Up @@ -557,6 +558,26 @@ export class DossierDetailComponent
this.renderer.removeClass(this.htmlDocument.getElementsByTagName('html')[0], 'html--fixed');
}

private handleBackNavigation(): void {
this._prevQueryParams =
this.router.lastSuccessfulNavigation?.previousNavigation?.extras.queryParams;

this.router.events
.pipe(
filter(event => event instanceof NavigationStart && event.navigationTrigger === 'popstate'),
take(1)
)
.subscribe(() => {
this.pageTitleService.enableReset();

if (!this._prevQueryParams) return;

this.router.navigate([`dossiers/${this.documentDefinitionName}`], {
queryParams: this._prevQueryParams,
});
});
}

private handleNoTaskProcessLink(isAdmin: boolean): void {
this.notificationService.showActionable({
type: 'warning',
Expand Down

0 comments on commit ca4e80c

Please sign in to comment.