@coolon/angular-ui-powerups 0.0.66 → 0.0.67
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/bundles/coolon-angular-ui-powerups.umd.js +51 -8
- package/bundles/coolon-angular-ui-powerups.umd.js.map +1 -1
- package/bundles/coolon-angular-ui-powerups.umd.min.js +1 -1
- package/bundles/coolon-angular-ui-powerups.umd.min.js.map +1 -1
- package/coolon-angular-ui-powerups.metadata.json +1 -1
- package/esm2015/lib/place/guards/leave-place.guard.js +57 -22
- package/esm2015/lib/place/place-router.js +4 -1
- package/esm5/lib/place/guards/leave-place.guard.js +52 -10
- package/esm5/lib/place/place-router.js +4 -1
- package/fesm2015/coolon-angular-ui-powerups.js +58 -22
- package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
- package/fesm5/coolon-angular-ui-powerups.js +53 -10
- package/fesm5/coolon-angular-ui-powerups.js.map +1 -1
- package/lib/place/guards/leave-place.guard.d.ts +1 -0
- package/lib/place/place-router.d.ts +1 -0
- package/package.json +1 -1
|
@@ -2922,6 +2922,7 @@
|
|
|
2922
2922
|
function PlaceRouter(router$1, angularLocation) {
|
|
2923
2923
|
var _this = this;
|
|
2924
2924
|
this.router = router$1;
|
|
2925
|
+
this.angularLocation = angularLocation;
|
|
2925
2926
|
this._navigationSession = new pectin.MutableValueModel();
|
|
2926
2927
|
angularLocation.onUrlChange((/**
|
|
2927
2928
|
* @param {?} url
|
|
@@ -3064,6 +3065,8 @@
|
|
|
3064
3065
|
* @private
|
|
3065
3066
|
*/
|
|
3066
3067
|
PlaceRouter.prototype.router;
|
|
3068
|
+
/** @type {?} */
|
|
3069
|
+
PlaceRouter.prototype.angularLocation;
|
|
3067
3070
|
}
|
|
3068
3071
|
|
|
3069
3072
|
/**
|
|
@@ -5020,6 +5023,22 @@
|
|
|
5020
5023
|
this.interactionContext = interactionContext;
|
|
5021
5024
|
this.angularLocation = angularLocation;
|
|
5022
5025
|
}
|
|
5026
|
+
/**
|
|
5027
|
+
* @private
|
|
5028
|
+
* @param {?} nextState
|
|
5029
|
+
* @param {?} placeDefinitionPath
|
|
5030
|
+
* @return {?}
|
|
5031
|
+
*/
|
|
5032
|
+
LeavePlaceGuard.prototype.isLeavingTheCurrentPlace = /**
|
|
5033
|
+
* @private
|
|
5034
|
+
* @param {?} nextState
|
|
5035
|
+
* @param {?} placeDefinitionPath
|
|
5036
|
+
* @return {?}
|
|
5037
|
+
*/
|
|
5038
|
+
function (nextState, placeDefinitionPath) {
|
|
5039
|
+
// TODO: this will break with child routes... need to examine the router states properly.
|
|
5040
|
+
return !nextState.url.startsWith(placeDefinitionPath);
|
|
5041
|
+
};
|
|
5023
5042
|
/**
|
|
5024
5043
|
* @param {?} component
|
|
5025
5044
|
* @param {?} currentRoute
|
|
@@ -5042,23 +5061,42 @@
|
|
|
5042
5061
|
case 0:
|
|
5043
5062
|
placeDefinitionPath = "/" + component.placeDefinition.path;
|
|
5044
5063
|
if (!this.placeRouter.navigationSession.alreadyAccepted(component)) return [3 /*break*/, 1];
|
|
5064
|
+
// We'll get called multiple times if there's any parameter sanitisation so
|
|
5065
|
+
// we always return true if we accepted on a previous cycle of the current
|
|
5066
|
+
// navigation session.
|
|
5045
5067
|
return [2 /*return*/, true];
|
|
5046
5068
|
case 1:
|
|
5047
|
-
if (!!nextState.url.startsWith(placeDefinitionPath)) return [3 /*break*/, 3];
|
|
5048
5069
|
self_1 = this;
|
|
5070
|
+
canLeave = true;
|
|
5071
|
+
if (!this.isLeavingTheCurrentPlace(nextState, placeDefinitionPath)) return [3 /*break*/, 4];
|
|
5072
|
+
// we check the interaction first, so that components that don't need to check if they're in an
|
|
5073
|
+
// interaction during the canDeactivate cycle.
|
|
5074
|
+
if (this.interactionContext.isActive()) {
|
|
5075
|
+
canLeave = false;
|
|
5076
|
+
console.log("cancelling", { activity: this.interactionContext.currentActivity });
|
|
5077
|
+
this.interactionContext.currentActivity.cancel(null);
|
|
5078
|
+
}
|
|
5079
|
+
if (!canLeave) return [3 /*break*/, 3];
|
|
5049
5080
|
return [4 /*yield*/, component.canDeactivate()];
|
|
5050
5081
|
case 2:
|
|
5051
5082
|
canLeave = _a.sent();
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5083
|
+
_a.label = 3;
|
|
5084
|
+
case 3: return [3 /*break*/, 5];
|
|
5085
|
+
case 4:
|
|
5086
|
+
// this is a parameter change.
|
|
5087
|
+
if (this.interactionContext.isActive()) {
|
|
5056
5088
|
console.log("cancelling", { activity: this.interactionContext.currentActivity });
|
|
5057
5089
|
this.interactionContext.currentActivity.cancel(null);
|
|
5090
|
+
canLeave = false;
|
|
5058
5091
|
}
|
|
5059
|
-
|
|
5060
|
-
|
|
5092
|
+
else {
|
|
5093
|
+
canLeave = true;
|
|
5094
|
+
}
|
|
5095
|
+
_a.label = 5;
|
|
5096
|
+
case 5:
|
|
5061
5097
|
if (canLeave) {
|
|
5098
|
+
// We'll get called multiple times if there's any parameter sanitisation so
|
|
5099
|
+
// we remember the acceptance for the duration of the current routing session.
|
|
5062
5100
|
self_1.placeRouter.navigationSession.rememberAcceptanceOf(component);
|
|
5063
5101
|
}
|
|
5064
5102
|
else {
|
|
@@ -5070,7 +5108,6 @@
|
|
|
5070
5108
|
}
|
|
5071
5109
|
}
|
|
5072
5110
|
return [2 /*return*/, canLeave];
|
|
5073
|
-
case 3: return [2 /*return*/, true];
|
|
5074
5111
|
}
|
|
5075
5112
|
});
|
|
5076
5113
|
});
|
|
@@ -5089,6 +5126,12 @@
|
|
|
5089
5126
|
{ type: common.Location }
|
|
5090
5127
|
]; };
|
|
5091
5128
|
/** @nocollapse */ LeavePlaceGuard.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function LeavePlaceGuard_Factory() { return new LeavePlaceGuard(core.ɵɵinject(router.Router), core.ɵɵinject(core.INJECTOR), core.ɵɵinject(PlaceRouter), core.ɵɵinject(InteractionContext), core.ɵɵinject(common.Location)); }, token: LeavePlaceGuard, providedIn: "root" });
|
|
5129
|
+
__decorate([
|
|
5130
|
+
pectin.Trace(),
|
|
5131
|
+
__metadata("design:type", Function),
|
|
5132
|
+
__metadata("design:paramtypes", [exports.PlaceComponent, router.ActivatedRouteSnapshot, router.RouterStateSnapshot, router.RouterStateSnapshot]),
|
|
5133
|
+
__metadata("design:returntype", Promise)
|
|
5134
|
+
], LeavePlaceGuard.prototype, "canDeactivate", null);
|
|
5092
5135
|
return LeavePlaceGuard;
|
|
5093
5136
|
}());
|
|
5094
5137
|
if (false) {
|