From 8b22d87658a84bfb3a37187727690fb0fdd4d390 Mon Sep 17 00:00:00 2001 From: Bastian Date: Fri, 6 Oct 2023 11:13:24 +0200 Subject: [PATCH 1/2] Add ability to go back to lead motion after amendment create --- .../amendment-create-wizard.component.ts | 2 +- .../app/ui/modules/head-bar/services/routing-state.service.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/client/src/app/site/pages/meetings/pages/motions/pages/motion-detail/components/amendment-create-wizard/amendment-create-wizard.component.ts b/client/src/app/site/pages/meetings/pages/motions/pages/motion-detail/components/amendment-create-wizard/amendment-create-wizard.component.ts index f2cac30d59..036e131088 100644 --- a/client/src/app/site/pages/meetings/pages/motions/pages/motion-detail/components/amendment-create-wizard/amendment-create-wizard.component.ts +++ b/client/src/app/site/pages/meetings/pages/motions/pages/motion-detail/components/amendment-create-wizard/amendment-create-wizard.component.ts @@ -181,7 +181,7 @@ export class AmendmentCreateWizardComponent extends BaseMeetingComponent impleme }; const { sequential_number } = await this.repo.createParagraphBased(motionCreate); - this.router.navigate([this.activeMeetingId, `motions`, sequential_number]); + this.router.navigate([this.activeMeetingId, `motions`, sequential_number], { replaceUrl: true, state: { canGoBack: true } }); } /** diff --git a/client/src/app/ui/modules/head-bar/services/routing-state.service.ts b/client/src/app/ui/modules/head-bar/services/routing-state.service.ts index 0717d34d78..fa2d2c2136 100644 --- a/client/src/app/ui/modules/head-bar/services/routing-state.service.ts +++ b/client/src/app/ui/modules/head-bar/services/routing-state.service.ts @@ -11,6 +11,7 @@ import { filter, pairwise, startWith } from 'rxjs'; providedIn: `root` }) export class RoutingStateService { + private skipUnsafeRouteCheck = false; /** * Hold the previous URL */ @@ -32,7 +33,7 @@ export class RoutingStateService { * If this fails, the open nav button should be shown */ public get isSafePrevUrl(): boolean { - if (this._previousUrl) { + if (this._previousUrl && !this.skipUnsafeRouteCheck) { return !this.unsafeUrls.some(unsafeUrl => this._previousUrl?.includes(unsafeUrl)); } else { return true; @@ -62,6 +63,7 @@ export class RoutingStateService { pairwise() ) .subscribe((event: any[]) => { + this.skipUnsafeRouteCheck = router.getCurrentNavigation()?.extras?.state[`canGoBack`] ?? false; this._previousUrl = event[0]?.urlAfterRedirects ?? this._currentUrl; const currentNavigationExtras = router.getCurrentNavigation()?.extras; if (currentNavigationExtras && currentNavigationExtras.state && currentNavigationExtras.state[`back`]) { From 1250cbca303e510e0f3070e4e791cf3e38cf90c2 Mon Sep 17 00:00:00 2001 From: Bastian Date: Fri, 6 Oct 2023 14:37:23 +0200 Subject: [PATCH 2/2] Cleanup --- .../amendment-create-wizard.component.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client/src/app/site/pages/meetings/pages/motions/pages/motion-detail/components/amendment-create-wizard/amendment-create-wizard.component.ts b/client/src/app/site/pages/meetings/pages/motions/pages/motion-detail/components/amendment-create-wizard/amendment-create-wizard.component.ts index 036e131088..30df9d84f3 100644 --- a/client/src/app/site/pages/meetings/pages/motions/pages/motion-detail/components/amendment-create-wizard/amendment-create-wizard.component.ts +++ b/client/src/app/site/pages/meetings/pages/motions/pages/motion-detail/components/amendment-create-wizard/amendment-create-wizard.component.ts @@ -181,7 +181,10 @@ export class AmendmentCreateWizardComponent extends BaseMeetingComponent impleme }; const { sequential_number } = await this.repo.createParagraphBased(motionCreate); - this.router.navigate([this.activeMeetingId, `motions`, sequential_number], { replaceUrl: true, state: { canGoBack: true } }); + this.router.navigate([this.activeMeetingId, `motions`, sequential_number], { + replaceUrl: true, + state: { canGoBack: true } + }); } /**