@coolon/angular-ui-powerups 16.1.0-alpha.272 → 16.1.0-alpha.274
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2022/lib/place/components/abstract-place-navigation.component.mjs +31 -2
- package/esm2022/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.mjs +4 -3
- package/esm2022/lib/place/guards/place.guard.mjs +31 -2
- package/esm2022/lib/place/navigation/session/interactions/navigating-during-interaction.mjs +11 -1
- package/esm2022/lib/place/navigation/session/interactions/pop-state-during-interaction-navigation.mjs +6 -1
- package/esm2022/lib/place/navigation/session/navigation-context.mjs +4 -2
- package/esm2022/lib/place/navigation/session/pop-state-navigation.mjs +11 -1
- package/esm2022/lib/place/place-router.mjs +15 -6
- package/esm2022/lib/place/visit.mjs +12 -3
- package/fesm2022/coolon-angular-ui-powerups.mjs +114 -11
- package/fesm2022/coolon-angular-ui-powerups.mjs.map +1 -1
- package/lib/place/components/abstract-place-navigation.component.d.ts +11 -2
- package/lib/place/guards/place.guard.d.ts +22 -0
- package/lib/place/navigation/session/navigation-context.d.ts +9 -1
- package/lib/place/place-router.d.ts +6 -0
- package/package.json +1 -1
|
@@ -9062,8 +9062,17 @@ class Visit {
|
|
|
9062
9062
|
return this.segments.find(v => v.placeDefinition === placeDefinition);
|
|
9063
9063
|
}
|
|
9064
9064
|
getRouterCommands() {
|
|
9065
|
-
return this.segments.reduce((result, v) => {
|
|
9065
|
+
return this.segments.reduce((result, v, index) => {
|
|
9066
9066
|
const path = v.placeDefinition.path;
|
|
9067
|
+
// A NON-terminal route-id segment must have a resolved id: createRouterCommands omits a nil
|
|
9068
|
+
// id, so the next place's path would silently bind into the id slot (e.g. groups/:g followed
|
|
9069
|
+
// by a child serialises as groups/<child>, navigating to a "circuit" called <child>). A
|
|
9070
|
+
// TERMINAL nil id is fine — the generated `<path> -> <path>/` redirect supplies the empty
|
|
9071
|
+
// slot and the guard's sanitiser takes it from there.
|
|
9072
|
+
if (index < this.segments.length - 1 && v.placeDefinition.hasRouteId() && !v.hasRouteId()) {
|
|
9073
|
+
lang$1.illegalState(`can't build a url for '${this.destinationPlaceDef.path}' while ancestor '${path}' has no route id — ` +
|
|
9074
|
+
`the child path would bind into the empty id slot`);
|
|
9075
|
+
}
|
|
9067
9076
|
return isEmpty(path) ?
|
|
9068
9077
|
[...result, path] : // Angular doesn't support route params on empty path segments
|
|
9069
9078
|
[...result, path, ...v.createRouterCommands()];
|
|
@@ -9589,6 +9598,11 @@ class NavigatingDuringInteraction extends NavigationSession {
|
|
|
9589
9598
|
isPopState = false;
|
|
9590
9599
|
// @Trace()
|
|
9591
9600
|
onRouterCancelled(event) {
|
|
9601
|
+
// A guard/sanitiser redirect is the navigation continuing — keep the session for the chain
|
|
9602
|
+
// (see Navigating / PopStateNavigation).
|
|
9603
|
+
if (event.code === 0 /* NavigationCancellationCode.Redirect */) {
|
|
9604
|
+
return;
|
|
9605
|
+
}
|
|
9592
9606
|
this.context.finishRoutingSession();
|
|
9593
9607
|
}
|
|
9594
9608
|
// @Trace()
|
|
@@ -9599,6 +9613,11 @@ class NavigatingDuringInteraction extends NavigationSession {
|
|
|
9599
9613
|
// @Trace()
|
|
9600
9614
|
onRouterEnd(event) {
|
|
9601
9615
|
if (this.context.routerInteractionAdapter.isActive()) {
|
|
9616
|
+
// The sync handover's own finish is deliberately visitless, so record the completed visit
|
|
9617
|
+
// HERE — dropping it left activeVisit$ (and remember/rememberLastChild history) stale, and a
|
|
9618
|
+
// later navigate() then built its url from an id-less groups-style segment, collapsing the
|
|
9619
|
+
// child path into the route-id slot.
|
|
9620
|
+
this.context.recordVisit(this.createUpdatedVisit(event.urlAfterRedirects));
|
|
9602
9621
|
this.context.transitionTo(new SynchroniseInteractionContextIdsWithRoute(this.context, this.startingUrl, false));
|
|
9603
9622
|
}
|
|
9604
9623
|
else {
|
|
@@ -9639,6 +9658,11 @@ class PopStateDuringInteractionNavigation extends AbstractPopStateNavigation {
|
|
|
9639
9658
|
*/
|
|
9640
9659
|
// @Trace()
|
|
9641
9660
|
onRouterCancelled(event) {
|
|
9661
|
+
// A guard/sanitiser redirect is the navigation continuing, not the refusal this handler was
|
|
9662
|
+
// written for — keep the session and let the redirect chain run (see PopStateNavigation).
|
|
9663
|
+
if (event.code === 0 /* NavigationCancellationCode.Redirect */) {
|
|
9664
|
+
return;
|
|
9665
|
+
}
|
|
9642
9666
|
this.repairBrowserHistoryAndUrlAfterGuardCancellation();
|
|
9643
9667
|
// NOTE: for now we need to wasTriggeredByPopState=false because we're resetting the url and history in the previous line.
|
|
9644
9668
|
this.context.transitionTo(new SynchroniseInteractionContextIdsWithRoute(this.context, this.poppedHistoryUrl, false));
|
|
@@ -9842,12 +9866,14 @@ var NavigationContext;
|
|
|
9842
9866
|
navigateByUrl;
|
|
9843
9867
|
transitionTo;
|
|
9844
9868
|
finishRoutingSession;
|
|
9845
|
-
|
|
9869
|
+
recordVisit;
|
|
9870
|
+
constructor(urlService, routerInteractionAdapter, navigateByUrl, transitionTo, finishRoutingSession, recordVisit) {
|
|
9846
9871
|
this.urlService = urlService;
|
|
9847
9872
|
this.routerInteractionAdapter = routerInteractionAdapter;
|
|
9848
9873
|
this.navigateByUrl = navigateByUrl;
|
|
9849
9874
|
this.transitionTo = transitionTo;
|
|
9850
9875
|
this.finishRoutingSession = finishRoutingSession;
|
|
9876
|
+
this.recordVisit = recordVisit;
|
|
9851
9877
|
}
|
|
9852
9878
|
}
|
|
9853
9879
|
NavigationContext.Impl = Impl;
|
|
@@ -9920,6 +9946,16 @@ class WaitUntilPopStateDuringCanDeactivateInteractionFinishes extends EventClean
|
|
|
9920
9946
|
|
|
9921
9947
|
class PopStateNavigation extends AbstractPopStateNavigation {
|
|
9922
9948
|
onRouterCancelled(event) {
|
|
9949
|
+
// A guard/sanitiser redirect is the navigation CONTINUING, not a rejection: keep the session
|
|
9950
|
+
// (as Navigating does) and repair nothing. Angular replaces the popped entry with the redirect
|
|
9951
|
+
// target for browser-triggered navigations, so history collapses correctly by itself — the
|
|
9952
|
+
// repair's replace+push here was what stranded the popped entry and made Back appear dead
|
|
9953
|
+
// (see the DEFECT PIN in place-router.spec.ts and async-sanitiser-back.cy.ts).
|
|
9954
|
+
if (event.code === 0 /* NavigationCancellationCode.Redirect */) {
|
|
9955
|
+
return;
|
|
9956
|
+
}
|
|
9957
|
+
// A genuine rejection (e.g. canDeactivate refusal): the browser has already moved even though
|
|
9958
|
+
// the app refused, so restore it — the angular #13586 workaround.
|
|
9923
9959
|
this.repairBrowserHistoryAndUrlAfterGuardCancellation();
|
|
9924
9960
|
this.context.finishRoutingSession();
|
|
9925
9961
|
}
|
|
@@ -10538,6 +10574,8 @@ class PlaceRouter extends GarbageCollector {
|
|
|
10538
10574
|
this.transitionTo(state);
|
|
10539
10575
|
}, (segments) => {
|
|
10540
10576
|
this.routingSessionFinished(segments);
|
|
10577
|
+
}, (visit) => {
|
|
10578
|
+
this.recordFinishedVisit(visit);
|
|
10541
10579
|
});
|
|
10542
10580
|
const { chain } = Dsl.disposeWith(this);
|
|
10543
10581
|
this.navigationInProgress$ = chain(this.navigationSession$).isNotNil();
|
|
@@ -10840,11 +10878,7 @@ class PlaceRouter extends GarbageCollector {
|
|
|
10840
10878
|
routingSessionFinished(visit) {
|
|
10841
10879
|
if (visit) {
|
|
10842
10880
|
assert.isTruthy(this.navigationInProgress$.value);
|
|
10843
|
-
this.
|
|
10844
|
-
// We update the active visits before we finish the session so the
|
|
10845
|
-
// place outlets can ignore the incoming changes until things are settled.
|
|
10846
|
-
this._activeVisit$.value = visit;
|
|
10847
|
-
// console.log(visit.toDebugString())
|
|
10881
|
+
this.recordFinishedVisit(visit);
|
|
10848
10882
|
}
|
|
10849
10883
|
const session = this.currentSession;
|
|
10850
10884
|
session.dispose();
|
|
@@ -10858,6 +10892,17 @@ class PlaceRouter extends GarbageCollector {
|
|
|
10858
10892
|
this.sessionFinishedJobs = [];
|
|
10859
10893
|
jobs.forEach((job) => job());
|
|
10860
10894
|
}
|
|
10895
|
+
/**
|
|
10896
|
+
* Records a completed navigation's visit without finishing the session. Shared by the normal
|
|
10897
|
+
* finish path and sessions that hand over to visitless housekeeping (see
|
|
10898
|
+
* NavigationContext.recordVisit).
|
|
10899
|
+
*/
|
|
10900
|
+
recordFinishedVisit(visit) {
|
|
10901
|
+
this.placeHistory.notifyNavigationFinished(visit);
|
|
10902
|
+
// We update the active visits before we finish the session so the
|
|
10903
|
+
// place outlets can ignore the incoming changes until things are settled.
|
|
10904
|
+
this._activeVisit$.value = visit;
|
|
10905
|
+
}
|
|
10861
10906
|
/**
|
|
10862
10907
|
* Runs `func` when the NEXT navigation session finishes — which may be a session that hasn't
|
|
10863
10908
|
* started yet (the interaction-id sync registers its completion job before starting the sync
|
|
@@ -13649,8 +13694,21 @@ class AbstractPlaceNavigationComponent extends DisposableComponent {
|
|
|
13649
13694
|
#placeOutlet$_accessor_storage = proxify((ValueModel));
|
|
13650
13695
|
get placeOutlet$() { return this.#placeOutlet$_accessor_storage; }
|
|
13651
13696
|
set placeOutlet$(value) { this.#placeOutlet$_accessor_storage = value; }
|
|
13697
|
+
#hideWhenSinglePlace$_accessor_storage = proxify((ValueModel));
|
|
13698
|
+
get hideWhenSinglePlace$() { return this.#hideWhenSinglePlace$_accessor_storage; }
|
|
13699
|
+
set hideWhenSinglePlace$(value) { this.#hideWhenSinglePlace$_accessor_storage = value; }
|
|
13700
|
+
#hideWhenSinglePlace_accessor_storage = false;
|
|
13701
|
+
/**
|
|
13702
|
+
* Hide the whole bar when it would render a single item: one tab is not a choice, so it reads as
|
|
13703
|
+
* chrome rather than navigation. Off by default - a bar that has always shown one item keeps
|
|
13704
|
+
* doing so until its consumer opts in.
|
|
13705
|
+
*/
|
|
13706
|
+
get hideWhenSinglePlace() { return this.#hideWhenSinglePlace_accessor_storage; }
|
|
13707
|
+
set hideWhenSinglePlace(value) { this.#hideWhenSinglePlace_accessor_storage = value; }
|
|
13652
13708
|
placeDefinitions;
|
|
13653
13709
|
menuItems;
|
|
13710
|
+
/** Whether the bar should render nothing at all - see {@link hideWhenSinglePlace}. */
|
|
13711
|
+
hidden$;
|
|
13654
13712
|
commandFactory;
|
|
13655
13713
|
_activePlaceComponent = this.registerDisposable(new DelegatingValueModel());
|
|
13656
13714
|
activePlaceDefinition;
|
|
@@ -13684,6 +13742,10 @@ class AbstractPlaceNavigationComponent extends DisposableComponent {
|
|
|
13684
13742
|
}, {
|
|
13685
13743
|
dependsOn: this.activePlaceDefinition
|
|
13686
13744
|
});
|
|
13745
|
+
// <= 1 rather than === 1: a bar filtered down to nothing is just as much noise as a bar showing
|
|
13746
|
+
// one item. menuItems is already authorisation-filtered, so this counts what would RENDER.
|
|
13747
|
+
this.hidden$ = valueOf.all(this.hideWhenSinglePlace$, this.menuItems.count().isLessThanOrEqualTo(1)).areTruthy();
|
|
13748
|
+
this.viewStateDependsOn(this.hidden$);
|
|
13687
13749
|
// const txo = new TransactionObserver({ verbose: true }).onEvent(e => console.log(e.name, e.payload));
|
|
13688
13750
|
// txo.observe('this.placesModel', this.placesModel);
|
|
13689
13751
|
// txo.observe('this.placeDefinitions', this.placeDefinitions);
|
|
@@ -13710,7 +13772,7 @@ class AbstractPlaceNavigationComponent extends DisposableComponent {
|
|
|
13710
13772
|
};
|
|
13711
13773
|
}
|
|
13712
13774
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: AbstractPlaceNavigationComponent, deps: [{ token: PlaceRouter }], target: i0.ɵɵFactoryTarget.Component });
|
|
13713
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.9", type: AbstractPlaceNavigationComponent, selector: "ng-component", inputs: { places: "places", places$: "places$", placeOutlet: "placeOutlet", placeOutlet$: "placeOutlet$" }, usesInheritance: true, ngImport: i0, template: '', isInline: true });
|
|
13775
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.9", type: AbstractPlaceNavigationComponent, selector: "ng-component", inputs: { places: "places", places$: "places$", placeOutlet: "placeOutlet", placeOutlet$: "placeOutlet$", hideWhenSinglePlace$: "hideWhenSinglePlace$", hideWhenSinglePlace: "hideWhenSinglePlace" }, usesInheritance: true, ngImport: i0, template: '', isInline: true });
|
|
13714
13776
|
}
|
|
13715
13777
|
__decorate([
|
|
13716
13778
|
StoreInListModel(),
|
|
@@ -13728,6 +13790,14 @@ __decorate([
|
|
|
13728
13790
|
Proxify(),
|
|
13729
13791
|
__metadata("design:type", Object)
|
|
13730
13792
|
], AbstractPlaceNavigationComponent.prototype, "placeOutlet$", null);
|
|
13793
|
+
__decorate([
|
|
13794
|
+
Proxify(),
|
|
13795
|
+
__metadata("design:type", Object)
|
|
13796
|
+
], AbstractPlaceNavigationComponent.prototype, "hideWhenSinglePlace$", null);
|
|
13797
|
+
__decorate([
|
|
13798
|
+
StoreInValueModel(),
|
|
13799
|
+
__metadata("design:type", Object)
|
|
13800
|
+
], AbstractPlaceNavigationComponent.prototype, "hideWhenSinglePlace", null);
|
|
13731
13801
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: AbstractPlaceNavigationComponent, decorators: [{
|
|
13732
13802
|
type: Component,
|
|
13733
13803
|
args: [{
|
|
@@ -13741,6 +13811,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.9", ngImpor
|
|
|
13741
13811
|
type: Input
|
|
13742
13812
|
}], placeOutlet$: [{
|
|
13743
13813
|
type: Input
|
|
13814
|
+
}], hideWhenSinglePlace$: [{
|
|
13815
|
+
type: Input
|
|
13816
|
+
}], hideWhenSinglePlace: [{
|
|
13817
|
+
type: Input
|
|
13744
13818
|
}] } });
|
|
13745
13819
|
|
|
13746
13820
|
class ListPlaceNavComponent extends AbstractPlaceNavigationComponent {
|
|
@@ -13856,11 +13930,11 @@ class TabbedPlaceNavigationComponent extends AbstractPlaceNavigationComponent {
|
|
|
13856
13930
|
super(router);
|
|
13857
13931
|
}
|
|
13858
13932
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: TabbedPlaceNavigationComponent, deps: [{ token: PlaceRouter }], target: i0.ɵɵFactoryTarget.Component });
|
|
13859
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.9", type: TabbedPlaceNavigationComponent, selector: "aup-tabbed-place-navigation", usesInheritance: true, ngImport: i0, template: "<!-- Tabs keep their natural width, packed to the left; Material stretches them to fill by default. -->\n<nav mat-tab-nav-bar [mat-stretch-tabs]=\"false\" [tabPanel]=\"tabPanel\">\n <ng-content select=\"[nav-start]\"></ng-content>\n <a mat-tab-link *ngFor=\"let item of menuItems.value; trackBy: trackByPlaceDef\"\n aup-gc #gc=\"aup-gc\"\n [pectinCommand]=\"commandFactory.create(item.place, {disposedWith: gc})\"\n [active]=\"item.active\"\n [matTooltip]=\"getNavigationFace(item.place).tooltip()\">\n <aup-command-face [faces]=\"[getNavigationFace(item.place)]\"></aup-command-face>\n </a>\n <ng-content select=\"[nav-end]\"></ng-content>\n</nav>\n
|
|
13933
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.9", type: TabbedPlaceNavigationComponent, selector: "aup-tabbed-place-navigation", usesInheritance: true, ngImport: i0, template: "<!-- Declared BEFORE the nav that references it: the nav lives in an *ngIf embedded view, and a\n template ref declared after it can be unresolved on that view's first render. -->\n<mat-tab-nav-panel #tabPanel></mat-tab-nav-panel>\n<!-- Tabs keep their natural width, packed to the left; Material stretches them to fill by default. -->\n<nav mat-tab-nav-bar [mat-stretch-tabs]=\"false\" [tabPanel]=\"tabPanel\"\n *ngIf=\"!hidden$.value\" [@slideDownOnEnter]>\n <ng-content select=\"[nav-start]\"></ng-content>\n <a mat-tab-link *ngFor=\"let item of menuItems.value; trackBy: trackByPlaceDef\"\n aup-gc #gc=\"aup-gc\"\n [pectinCommand]=\"commandFactory.create(item.place, {disposedWith: gc})\"\n [active]=\"item.active\"\n [matTooltip]=\"getNavigationFace(item.place).tooltip()\">\n <aup-command-face [faces]=\"[getNavigationFace(item.place)]\"></aup-command-face>\n </a>\n <ng-content select=\"[nav-end]\"></ng-content>\n</nav>\n", styles: [":host{display:block}nav{overflow:hidden}div.place-holder{border:1px solid green}\n"], dependencies: [{ kind: "directive", type: i1$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i3$2.MatTabNav, selector: "[mat-tab-nav-bar]", inputs: ["color", "fitInkBarToContent", "mat-stretch-tabs", "animationDuration"], exportAs: ["matTabNavBar", "matTabNav"] }, { kind: "component", type: i3$2.MatTabNavPanel, selector: "mat-tab-nav-panel", inputs: ["id"], exportAs: ["matTabNavPanel"] }, { kind: "component", type: i3$2.MatTabLink, selector: "[mat-tab-link], [matTabLink]", inputs: ["disabled", "disableRipple", "tabIndex", "active", "id"], exportAs: ["matTabLink"] }, { kind: "directive", type: i3.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }, { kind: "directive", type: CommandDirective, selector: "[pectinCommand]", inputs: ["pectinCommand", "commandParameter", "preventDefault"] }, { kind: "directive", type: GarbageCollectorDirective, selector: "[aup-gc]", exportAs: ["aup-gc"] }, { kind: "component", type: CommandFaceComponent, selector: "aup-command-face", inputs: ["faces", "face", "ignoreIcon", "ignoreText", "includeMissingIconInLayout"] }], animations: [slideDownOnEnterAnimation] });
|
|
13860
13934
|
}
|
|
13861
13935
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: TabbedPlaceNavigationComponent, decorators: [{
|
|
13862
13936
|
type: Component,
|
|
13863
|
-
args: [{ selector: 'aup-tabbed-place-navigation', template: "<!-- Tabs keep their natural width, packed to the left; Material stretches them to fill by default. -->\n<nav mat-tab-nav-bar [mat-stretch-tabs]=\"false\" [tabPanel]=\"tabPanel\">\n <ng-content select=\"[nav-start]\"></ng-content>\n <a mat-tab-link *ngFor=\"let item of menuItems.value; trackBy: trackByPlaceDef\"\n aup-gc #gc=\"aup-gc\"\n [pectinCommand]=\"commandFactory.create(item.place, {disposedWith: gc})\"\n [active]=\"item.active\"\n [matTooltip]=\"getNavigationFace(item.place).tooltip()\">\n <aup-command-face [faces]=\"[getNavigationFace(item.place)]\"></aup-command-face>\n </a>\n <ng-content select=\"[nav-end]\"></ng-content>\n</nav>\n
|
|
13937
|
+
args: [{ selector: 'aup-tabbed-place-navigation', animations: [slideDownOnEnterAnimation], template: "<!-- Declared BEFORE the nav that references it: the nav lives in an *ngIf embedded view, and a\n template ref declared after it can be unresolved on that view's first render. -->\n<mat-tab-nav-panel #tabPanel></mat-tab-nav-panel>\n<!-- Tabs keep their natural width, packed to the left; Material stretches them to fill by default. -->\n<nav mat-tab-nav-bar [mat-stretch-tabs]=\"false\" [tabPanel]=\"tabPanel\"\n *ngIf=\"!hidden$.value\" [@slideDownOnEnter]>\n <ng-content select=\"[nav-start]\"></ng-content>\n <a mat-tab-link *ngFor=\"let item of menuItems.value; trackBy: trackByPlaceDef\"\n aup-gc #gc=\"aup-gc\"\n [pectinCommand]=\"commandFactory.create(item.place, {disposedWith: gc})\"\n [active]=\"item.active\"\n [matTooltip]=\"getNavigationFace(item.place).tooltip()\">\n <aup-command-face [faces]=\"[getNavigationFace(item.place)]\"></aup-command-face>\n </a>\n <ng-content select=\"[nav-end]\"></ng-content>\n</nav>\n", styles: [":host{display:block}nav{overflow:hidden}div.place-holder{border:1px solid green}\n"] }]
|
|
13864
13938
|
}], ctorParameters: function () { return [{ type: PlaceRouter }]; } });
|
|
13865
13939
|
|
|
13866
13940
|
class PlaceModule {
|
|
@@ -14417,7 +14491,7 @@ class PlaceGuard {
|
|
|
14417
14491
|
currentPlace = currentPlace.parent;
|
|
14418
14492
|
const permittedChild = currentPlace.findChild(c => this.authService.isAuthorised(c));
|
|
14419
14493
|
if (permittedChild) {
|
|
14420
|
-
return
|
|
14494
|
+
return this.visitToAlternative(permittedChild);
|
|
14421
14495
|
}
|
|
14422
14496
|
}
|
|
14423
14497
|
// Couldn't find an authorised ancestor so we check if there are router level defined alternatives
|
|
@@ -14430,6 +14504,35 @@ class PlaceGuard {
|
|
|
14430
14504
|
return nextRedirect ?? lang.illegalState(`onAuthorisationFailure hook didn't return any authorised locations`);
|
|
14431
14505
|
}
|
|
14432
14506
|
}
|
|
14507
|
+
/**
|
|
14508
|
+
* A visit to the alternative place, carrying its ancestors' RESOLVED route parameters.
|
|
14509
|
+
*
|
|
14510
|
+
* `Visit.goto` builds a single, parameterless segment, and the url is then assembled from the
|
|
14511
|
+
* destination's ancestorsAndSelf — so an ancestor holding a route id contributes an EMPTY id
|
|
14512
|
+
* slot. That url is not merely wrong, it is unrepresentable: `groups//devices` collapses, and
|
|
14513
|
+
* `groups/devices` binds the child's path into the id slot, navigating to a "group" called
|
|
14514
|
+
* `devices` and eventually failing in `UrlSnapshot.appendSegment`. The user lands on `#/` with
|
|
14515
|
+
* nothing explaining why. (`Visit.getRouterCommands` guards this case explicitly; the
|
|
14516
|
+
* `createUrlSnapshot` path used for redirects does not, which is why it surfaced here.)
|
|
14517
|
+
*
|
|
14518
|
+
* The ancestors' ids are already resolved by the time we need them: guards run parent-first, so
|
|
14519
|
+
* each ancestor's own pass has already sanitised its segment into the navigation session. Any
|
|
14520
|
+
* ancestor without a stored segment falls back to a bare one, which is the pre-existing
|
|
14521
|
+
* behaviour for a parameterless chain.
|
|
14522
|
+
*
|
|
14523
|
+
* Reached whenever a place is refused while a parameterised ancestor stays authorised — most
|
|
14524
|
+
* often a DISABLED (`enablePlace`) child of a route-id parent, e.g. a feature-flagged tab
|
|
14525
|
+
* reached by a stale deep link. Pure role gating rarely hits it, because a role usually gates a
|
|
14526
|
+
* whole subtree rather than one child of a parameterised parent.
|
|
14527
|
+
*/
|
|
14528
|
+
visitToAlternative(alternative) {
|
|
14529
|
+
const session = this.placeRouter.navigationSession;
|
|
14530
|
+
const segments = alternative.ancestorsAndSelf()
|
|
14531
|
+
.map(place => place === alternative
|
|
14532
|
+
? new VisitSegment(alternative)
|
|
14533
|
+
: session?.getVisitSegmentFor(place) ?? new VisitSegment(place));
|
|
14534
|
+
return Visit.fromSegments(segments);
|
|
14535
|
+
}
|
|
14433
14536
|
// @Trace()
|
|
14434
14537
|
async canDeactivate(component, currentRoute, currentState, nextState) {
|
|
14435
14538
|
if (!component) {
|