Skip to content

Commit

Permalink
Add ability to go back to lead motion after amendment create (#2859)
Browse files Browse the repository at this point in the history
  • Loading branch information
bastianjoel authored Oct 17, 2023
1 parent 393f3e5 commit aed8fca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
this.router.navigate([this.activeMeetingId, `motions`, sequential_number], {
replaceUrl: true,
state: { canGoBack: true }
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { filter, pairwise, startWith } from 'rxjs';
providedIn: `root`
})
export class RoutingStateService {
private skipUnsafeRouteCheck = false;
/**
* Hold the previous URL
*/
Expand All @@ -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;
Expand Down Expand Up @@ -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`]) {
Expand Down

0 comments on commit aed8fca

Please sign in to comment.