@coolon/angular-ui-powerups 0.0.90 → 0.0.92

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.
Files changed (42) hide show
  1. package/bundles/coolon-angular-ui-powerups.umd.js +432 -364
  2. package/bundles/coolon-angular-ui-powerups.umd.js.map +1 -1
  3. package/bundles/coolon-angular-ui-powerups.umd.min.js +1 -1
  4. package/bundles/coolon-angular-ui-powerups.umd.min.js.map +1 -1
  5. package/coolon-angular-ui-powerups.d.ts +7 -7
  6. package/coolon-angular-ui-powerups.metadata.json +1 -1
  7. package/esm2015/coolon-angular-ui-powerups.js +8 -8
  8. package/esm2015/lib/directives/command.directive.js +28 -5
  9. package/esm2015/lib/interaction/components/activity-container/activity-container.component.js +2 -7
  10. package/esm2015/lib/interaction/components/inplace-interaction-context/inplace-interaction-context.component.js +3 -8
  11. package/esm2015/lib/interaction/interaction-context.js +70 -14
  12. package/esm2015/lib/interaction/services/dialog-interaction.service.js +11 -19
  13. package/esm2015/lib/place/navigation-session.js +171 -39
  14. package/esm2015/lib/place/place-component.js +4 -19
  15. package/esm2015/lib/place/place-router.js +72 -31
  16. package/esm2015/lib/place/route/guards/enter-place-guard.service.js +2 -2
  17. package/esm2015/lib/place/route/guards/leave-place.guard.js +7 -177
  18. package/esm5/coolon-angular-ui-powerups.js +8 -8
  19. package/esm5/lib/directives/command.directive.js +32 -5
  20. package/esm5/lib/interaction/components/activity-container/activity-container.component.js +2 -11
  21. package/esm5/lib/interaction/components/inplace-interaction-context/inplace-interaction-context.component.js +3 -12
  22. package/esm5/lib/interaction/interaction-context.js +89 -27
  23. package/esm5/lib/interaction/services/dialog-interaction.service.js +11 -22
  24. package/esm5/lib/place/navigation-session.js +214 -54
  25. package/esm5/lib/place/place-component.js +4 -35
  26. package/esm5/lib/place/place-router.js +82 -37
  27. package/esm5/lib/place/route/guards/enter-place-guard.service.js +2 -2
  28. package/esm5/lib/place/route/guards/leave-place.guard.js +7 -176
  29. package/fesm2015/coolon-angular-ui-powerups.js +350 -299
  30. package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
  31. package/fesm5/coolon-angular-ui-powerups.js +427 -359
  32. package/fesm5/coolon-angular-ui-powerups.js.map +1 -1
  33. package/lib/directives/command.directive.d.ts +2 -0
  34. package/lib/interaction/components/activity-container/activity-container.component.d.ts +1 -2
  35. package/lib/interaction/components/inplace-interaction-context/inplace-interaction-context.component.d.ts +3 -4
  36. package/lib/interaction/interaction-context.d.ts +6 -3
  37. package/lib/interaction/services/dialog-interaction.service.d.ts +3 -5
  38. package/lib/place/navigation-session.d.ts +26 -9
  39. package/lib/place/place-component.d.ts +4 -9
  40. package/lib/place/place-router.d.ts +8 -3
  41. package/lib/place/route/guards/leave-place.guard.d.ts +2 -10
  42. package/package.json +1 -1
@@ -216,9 +216,28 @@
216
216
  function CommandDirective(elementRef) {
217
217
  var _this = _super.call(this) || this;
218
218
  _this.elementRef = elementRef;
219
+ _this._commandEnabled = new pectin.DelegatingValueModel().withDefault(false);
219
220
  _this._commandParameterProvided = false;
220
221
  return _this;
221
222
  }
223
+ Object.defineProperty(CommandDirective.prototype, "pectinCommand", {
224
+ get: /**
225
+ * @return {?}
226
+ */
227
+ function () {
228
+ return this._command;
229
+ },
230
+ set: /**
231
+ * @param {?} command
232
+ * @return {?}
233
+ */
234
+ function (command) {
235
+ this._command = command;
236
+ this._commandEnabled.setDelegate(command ? command.enabled : null);
237
+ },
238
+ enumerable: true,
239
+ configurable: true
240
+ });
222
241
  Object.defineProperty(CommandDirective.prototype, "commandParameter", {
223
242
  get: /**
224
243
  * @return {?}
@@ -267,7 +286,7 @@
267
286
  // for some reason mat-buttons kills the disabled host binding. It works on a regular button but for now
268
287
  // we need to do this.
269
288
  var chain = pectin.Dsl.disposeWith(this).chain;
270
- chain(this.pectinCommand.enabled).subscribe((/**
289
+ chain(this._commandEnabled).subscribe((/**
271
290
  * @param {?} enabled
272
291
  * @return {?}
273
292
  */
@@ -336,8 +355,16 @@
336
355
  return CommandDirective;
337
356
  }(pectin.GarbageCollector));
338
357
  if (false) {
339
- /** @type {?} */
340
- CommandDirective.prototype.pectinCommand;
358
+ /**
359
+ * @type {?}
360
+ * @private
361
+ */
362
+ CommandDirective.prototype._command;
363
+ /**
364
+ * @type {?}
365
+ * @private
366
+ */
367
+ CommandDirective.prototype._commandEnabled;
341
368
  /**
342
369
  * @type {?}
343
370
  * @private
@@ -1077,51 +1104,107 @@
1077
1104
  InteractionContext = /** @class */ (function (_super) {
1078
1105
  __extends(InteractionContext, _super);
1079
1106
  function InteractionContext() {
1080
- return _super.call(this) || this;
1081
- }
1082
- Object.defineProperty(InteractionContext.prototype, "currentActivity", {
1107
+ var _this = _super.call(this) || this;
1083
1108
  /**
1084
- * Returns the activity that is currently active.
1109
+ * Returns the current list of activities that are in progress.
1085
1110
  * This model is only updated in the next tick after the view has been updated.
1086
1111
  */
1112
+ _this._activityListDelegate = new pectin.DelegatingListModel();
1113
+ var _a = pectin.Dsl.disposeWith(_this), chain = _a.chain, valueOf = _a.valueOf, before = _a.before, when = _a.when, after = _a.after, observe = _a.observe, switchOn = _a.switchOn;
1114
+ when.listOf(_this.activityList).becomesPopulated((/**
1115
+ * @param {?} activities
1116
+ * @return {?}
1117
+ */
1118
+ function (activities) {
1119
+ if (_this.deferredGetCurrentActivity) {
1120
+ _this.deferredGetCurrentActivity.resolve(___default.last(activities));
1121
+ _this.deferredGetCurrentActivity = null;
1122
+ }
1123
+ }));
1124
+ return _this;
1125
+ }
1126
+ /**
1127
+ * @protected
1128
+ * @param {?} activityList
1129
+ * @return {?}
1130
+ */
1131
+ InteractionContext.prototype.setActivityList = /**
1132
+ * @protected
1133
+ * @param {?} activityList
1134
+ * @return {?}
1135
+ */
1136
+ function (activityList) {
1137
+ this._activityListDelegate.setDelegate(activityList);
1138
+ };
1139
+ Object.defineProperty(InteractionContext.prototype, "activityList", {
1087
1140
  get: /**
1088
- * Returns the activity that is currently active.
1089
- * This model is only updated in the next tick after the view has been updated.
1090
1141
  * @return {?}
1091
1142
  */
1092
1143
  function () {
1093
- return ___default.last(this.activityList.value);
1144
+ return this._activityListDelegate.readonly;
1094
1145
  },
1095
1146
  enumerable: true,
1096
1147
  configurable: true
1097
1148
  });
1098
1149
  /**
1099
- * @param {?} confirm
1150
+ * Returns the activity that is currently active.
1151
+ * This model is only updated in the next tick after the view has been updated.
1152
+ */
1153
+ /**
1154
+ * Returns the activity that is currently active.
1155
+ * This model is only updated in the next tick after the view has been updated.
1100
1156
  * @return {?}
1101
1157
  */
1102
- InteractionContext.prototype.confirm = /**
1103
- * @param {?} confirm
1158
+ InteractionContext.prototype.getCurrentActivity = /**
1159
+ * Returns the activity that is currently active.
1160
+ * This model is only updated in the next tick after the view has been updated.
1104
1161
  * @return {?}
1105
1162
  */
1106
- function (confirm) {
1163
+ function () {
1107
1164
  return __awaiter(this, void 0, void 0, function () {
1108
- var _a;
1109
- return __generator(this, function (_b) {
1110
- switch (_b.label) {
1111
- case 0:
1112
- _b.trys.push([0, 2, , 3]);
1113
- return [4 /*yield*/, this.confirmOrReject(confirm)];
1114
- case 1:
1115
- _b.sent();
1116
- return [2 /*return*/, true];
1117
- case 2:
1118
- _a = _b.sent();
1119
- return [2 /*return*/, false];
1120
- case 3: return [2 /*return*/];
1165
+ return __generator(this, function (_a) {
1166
+ if (!this.isActive()) {
1167
+ return [2 /*return*/, Promise.reject('no activity in progress')];
1168
+ }
1169
+ else {
1170
+ if (this.deferredGetCurrentActivity) {
1171
+ // we're already waiting then just return the same promise
1172
+ return [2 /*return*/, this.deferredGetCurrentActivity.promise];
1173
+ }
1174
+ else {
1175
+ if (this.activityList.length < 1) {
1176
+ this.deferredGetCurrentActivity = pectin.Deferred.defer();
1177
+ return [2 /*return*/, this.deferredGetCurrentActivity.promise];
1178
+ }
1179
+ else {
1180
+ return [2 /*return*/, ___default.last(this.activityList.value)];
1181
+ }
1182
+ }
1121
1183
  }
1184
+ return [2 /*return*/];
1122
1185
  });
1123
1186
  });
1124
1187
  };
1188
+ /**
1189
+ * @param {?} confirm
1190
+ * @return {?}
1191
+ */
1192
+ InteractionContext.prototype.confirm = /**
1193
+ * @param {?} confirm
1194
+ * @return {?}
1195
+ */
1196
+ function (confirm) {
1197
+ // Important: we have to implement confirmOrReject as the main entry point
1198
+ // as the canDeactivation guards need to be able to cancel an interaction
1199
+ // without caring about returning a value.
1200
+ return this.confirmOrReject(confirm).then((/**
1201
+ * @return {?}
1202
+ */
1203
+ function () { return true; })).catch((/**
1204
+ * @return {?}
1205
+ */
1206
+ function () { return false; }));
1207
+ };
1125
1208
  return InteractionContext;
1126
1209
  }(pectin.GarbageCollector));
1127
1210
  if (false) {
@@ -1129,8 +1212,14 @@
1129
1212
  * Returns the current list of activities that are in progress.
1130
1213
  * This model is only updated in the next tick after the view has been updated.
1131
1214
  * @type {?}
1215
+ * @private
1216
+ */
1217
+ InteractionContext.prototype._activityListDelegate;
1218
+ /**
1219
+ * @type {?}
1220
+ * @private
1132
1221
  */
1133
- InteractionContext.prototype.activityList;
1222
+ InteractionContext.prototype.deferredGetCurrentActivity;
1134
1223
  /**
1135
1224
  * Returns true if an activity is currently running.
1136
1225
  * @abstract
@@ -1772,6 +1861,7 @@
1772
1861
  * @return {?}
1773
1862
  */
1774
1863
  function () { return _this.onNestedActivityFinished(); }));
1864
+ _this.setActivityList(_this._activityList.readonly);
1775
1865
  return _this;
1776
1866
  }
1777
1867
  Object.defineProperty(ActivityContainerComponent.prototype, "initialActivityOutletContext", {
@@ -1827,16 +1917,6 @@
1827
1917
  function () {
1828
1918
  return !!this._initialActivityOutletContext;
1829
1919
  };
1830
- Object.defineProperty(ActivityContainerComponent.prototype, "activityList", {
1831
- get: /**
1832
- * @return {?}
1833
- */
1834
- function () {
1835
- return this._activityList.readonly;
1836
- },
1837
- enumerable: true,
1838
- configurable: true
1839
- });
1840
1920
  Object.defineProperty(ActivityContainerComponent.prototype, "isFinished", {
1841
1921
  get: /**
1842
1922
  * @return {?}
@@ -2154,21 +2234,12 @@
2154
2234
  /**
2155
2235
  * @return {?}
2156
2236
  */
2157
- InplaceInteractionContextComponent.prototype.ngOnInit = /**
2237
+ InplaceInteractionContextComponent.prototype.ngAfterViewInit = /**
2158
2238
  * @return {?}
2159
2239
  */
2160
2240
  function () {
2241
+ this.setActivityList(this.interactionContext.activityList);
2161
2242
  };
2162
- Object.defineProperty(InplaceInteractionContextComponent.prototype, "activityList", {
2163
- get: /**
2164
- * @return {?}
2165
- */
2166
- function () {
2167
- return this.interactionContext.activityList;
2168
- },
2169
- enumerable: true,
2170
- configurable: true
2171
- });
2172
2243
  /**
2173
2244
  * @return {?}
2174
2245
  */
@@ -2388,11 +2459,9 @@
2388
2459
  _this.router = router;
2389
2460
  _this.dialogServiceDefaults = dialogServiceDefaults;
2390
2461
  _this.matDialogDefaultConfig = matDialogDefaultConfig;
2391
- _this._activityList = new pectin.DelegatingListModel();
2392
2462
  _this.startingGuard = new Guard();
2463
+ _this._inActivityPromise = new pectin.MutableValueModel(false);
2393
2464
  typescriptUtilities.assert.notNil(dialogService);
2394
- var _a = pectin.Dsl.disposeWith(_this), chain = _a.chain, valueOf = _a.valueOf, before = _a.before, when = _a.when, after = _a.after, observe = _a.observe, switchOn = _a.switchOn;
2395
- _this.active = chain(_this._activityList).isNotEmpty();
2396
2465
  return _this;
2397
2466
  }
2398
2467
  /**
@@ -2402,23 +2471,14 @@
2402
2471
  * @return {?}
2403
2472
  */
2404
2473
  function () {
2405
- return this.active.value;
2406
- };
2407
- /**
2408
- * @return {?}
2409
- */
2410
- DialogInteractionService.prototype.cancelActivity = /**
2411
- * @return {?}
2412
- */
2413
- function () {
2414
- this.currentActivity.cancel(null);
2474
+ return this._inActivityPromise.value;
2415
2475
  };
2416
- Object.defineProperty(DialogInteractionService.prototype, "activityList", {
2476
+ Object.defineProperty(DialogInteractionService.prototype, "active", {
2417
2477
  get: /**
2418
2478
  * @return {?}
2419
2479
  */
2420
2480
  function () {
2421
- return this._activityList.readonly;
2481
+ return this._inActivityPromise.readonly;
2422
2482
  },
2423
2483
  enumerable: true,
2424
2484
  configurable: true
@@ -2469,6 +2529,7 @@
2469
2529
  */
2470
2530
  function () {
2471
2531
  console.log('###### STARTING');
2532
+ _this._inActivityPromise.value = true;
2472
2533
  // this.currentActivityId = uuid.v1();
2473
2534
  // this.location.go(this.router.routerState.snapshot.url, "aup");
2474
2535
  /** @type {?} */
@@ -2527,6 +2588,7 @@
2527
2588
  * @return {?}
2528
2589
  */
2529
2590
  function () {
2591
+ _this._inActivityPromise.value = false;
2530
2592
  console.log('###### FINISHED');
2531
2593
  // this.currentActivityId = null;
2532
2594
  self.safelyUpdateActivityListDelegate(null);
@@ -2552,7 +2614,7 @@
2552
2614
  setTimeout((/**
2553
2615
  * @return {?}
2554
2616
  */
2555
- function () { return _this._activityList.setDelegate(delegate); }));
2617
+ function () { return _this.setActivityList(delegate); }));
2556
2618
  };
2557
2619
  /**
2558
2620
  * @param {?} alert
@@ -2619,14 +2681,12 @@
2619
2681
  * @type {?}
2620
2682
  * @private
2621
2683
  */
2622
- DialogInteractionService.prototype._activityList;
2684
+ DialogInteractionService.prototype.startingGuard;
2623
2685
  /**
2624
2686
  * @type {?}
2625
2687
  * @private
2626
2688
  */
2627
- DialogInteractionService.prototype.startingGuard;
2628
- /** @type {?} */
2629
- DialogInteractionService.prototype.active;
2689
+ DialogInteractionService.prototype._inActivityPromise;
2630
2690
  /**
2631
2691
  * @type {?}
2632
2692
  * @private
@@ -3401,15 +3461,6 @@
3401
3461
  enumerable: true,
3402
3462
  configurable: true
3403
3463
  });
3404
- /**
3405
- * @return {?}
3406
- */
3407
- PlaceComponent.prototype.canDeactivate = /**
3408
- * @return {?}
3409
- */
3410
- function () {
3411
- return true;
3412
- };
3413
3464
  /**
3414
3465
  * @return {?}
3415
3466
  */
@@ -3418,36 +3469,13 @@
3418
3469
  */
3419
3470
  function () {
3420
3471
  };
3421
- /**
3422
- * Called by the place outlet after all animations have finished. We need this instead of ngOnDestroy
3423
- * to avoid the fact that the angular router calls it before the animations have run causing the component
3424
- * to loose any pectin bindings.
3425
- */
3426
- // @Trace()
3427
- /**
3428
- * Called by the place outlet after all animations have finished. We need this instead of ngOnDestroy
3429
- * to avoid the fact that the angular router calls it before the animations have run causing the component
3430
- * to loose any pectin bindings.
3431
- * @return {?}
3432
- */
3433
- // @Trace()
3434
- PlaceComponent.prototype.onPlaceDestroyed = /**
3435
- * Called by the place outlet after all animations have finished. We need this instead of ngOnDestroy
3436
- * to avoid the fact that the angular router calls it before the animations have run causing the component
3437
- * to loose any pectin bindings.
3438
- * @return {?}
3439
- */
3440
- // @Trace()
3441
- function () {
3442
- this.dispose();
3443
- };
3444
3472
  __decorate([
3445
3473
  fastMemoizeDecorator.Memoize(),
3446
3474
  __metadata("design:type", exports.PlaceDefinition),
3447
3475
  __metadata("design:paramtypes", [])
3448
3476
  ], PlaceComponent.prototype, "placeDefinition", null);
3449
3477
  return PlaceComponent;
3450
- }(pectin.GarbageCollector));
3478
+ }(DisposableComponent));
3451
3479
  if (false) {
3452
3480
  /**
3453
3481
  * @type {?}
@@ -3692,10 +3720,13 @@
3692
3720
  * @abstract
3693
3721
  */
3694
3722
  exports.NavigationSession = /** @class */ (function () {
3695
- function NavigationSession(firstNavigation) {
3723
+ function NavigationSession(firstNavigation, appModalInteractionContext) {
3696
3724
  this.firstNavigation = firstNavigation;
3725
+ this.appModalInteractionContext = appModalInteractionContext;
3697
3726
  this._alreadyAccepted = [];
3698
3727
  this._visits = new Map();
3728
+ this.componentDeactivationHandlers = new Map();
3729
+ this.dialogOpenOnStart = this.appModalInteractionContext.isActive();
3699
3730
  }
3700
3731
  /**
3701
3732
  * @param {?} visit
@@ -3719,52 +3750,36 @@
3719
3750
  function (placeDef) {
3720
3751
  return this._visits.get(placeDef);
3721
3752
  };
3722
- /**
3723
- * @param {?} params
3724
- * @return {?}
3725
- */
3726
- NavigationSession.prototype.mergePrivatePlaceParameters = /**
3727
- * @param {?} params
3728
- * @return {?}
3729
- */
3730
- function (params) {
3731
- return null;
3732
- };
3733
- // @Trace()
3734
- // @Trace()
3735
- /**
3736
- * @param {?} placeComponent
3737
- * @return {?}
3738
- */
3739
- NavigationSession.prototype.alreadyAccepted =
3740
- // @Trace()
3741
- /**
3742
- * @param {?} placeComponent
3743
- * @return {?}
3744
- */
3745
- function (placeComponent) {
3746
- return this._alreadyAccepted.includes(placeComponent);
3747
- };
3748
- // @Trace()
3749
- // @Trace()
3750
3753
  /**
3751
3754
  * @param {?} component
3755
+ * @param {?} nextState
3752
3756
  * @return {?}
3753
3757
  */
3754
- NavigationSession.prototype.rememberAcceptanceOf =
3755
- // @Trace()
3756
- /**
3758
+ NavigationSession.prototype.canDeactivate = /**
3757
3759
  * @param {?} component
3760
+ * @param {?} nextState
3758
3761
  * @return {?}
3759
3762
  */
3760
- function (component) {
3761
- this._alreadyAccepted.push(component);
3763
+ function (component, nextState) {
3764
+ return __awaiter(this, void 0, void 0, function () {
3765
+ var handler, isPrimaryHandler;
3766
+ return __generator(this, function (_a) {
3767
+ // lookup the handler and create it if we've not seen it yet
3768
+ handler = this.componentDeactivationHandlers.get(component);
3769
+ if (!handler) {
3770
+ isPrimaryHandler = this.componentDeactivationHandlers.size === 0;
3771
+ handler = new NavigationSession.ComponentDeactivationHandler(component, this.appModalInteractionContext, isPrimaryHandler);
3772
+ this.componentDeactivationHandlers.set(component, handler);
3773
+ }
3774
+ return [2 /*return*/, handler.canDeactivate(nextState)];
3775
+ });
3776
+ });
3762
3777
  };
3763
3778
  /**
3764
3779
  * @param {?} url
3765
3780
  * @return {?}
3766
3781
  */
3767
- NavigationSession.prototype.setPopstateReturn = /**
3782
+ NavigationSession.prototype.setPopstateReturnUrl = /**
3768
3783
  * @param {?} url
3769
3784
  * @return {?}
3770
3785
  */
@@ -3821,13 +3836,25 @@
3821
3836
  /** @type {?} */
3822
3837
  exports.NavigationSession.prototype.isExternal;
3823
3838
  /** @type {?} */
3839
+ exports.NavigationSession.prototype.dialogOpenOnStart;
3840
+ /**
3841
+ * @type {?}
3842
+ * @private
3843
+ */
3844
+ exports.NavigationSession.prototype.componentDeactivationHandlers;
3845
+ /** @type {?} */
3824
3846
  exports.NavigationSession.prototype.firstNavigation;
3847
+ /**
3848
+ * @type {?}
3849
+ * @private
3850
+ */
3851
+ exports.NavigationSession.prototype.appModalInteractionContext;
3825
3852
  }
3826
3853
  (function (NavigationSession) {
3827
3854
  var External = /** @class */ (function (_super) {
3828
3855
  __extends(External, _super);
3829
- function External(isFirstTime) {
3830
- var _this = _super.call(this, isFirstTime) || this;
3856
+ function External(isFirstTime, appModelInteractionContext) {
3857
+ var _this = _super.call(this, isFirstTime, appModelInteractionContext) || this;
3831
3858
  _this.isExternal = true;
3832
3859
  return _this;
3833
3860
  }
@@ -3839,8 +3866,8 @@
3839
3866
  }
3840
3867
  var Internal = /** @class */ (function (_super) {
3841
3868
  __extends(Internal, _super);
3842
- function Internal(visit) {
3843
- var _this = _super.call(this, false) || this;
3869
+ function Internal(visit, appModelInteractionContext) {
3870
+ var _this = _super.call(this, false, appModelInteractionContext) || this;
3844
3871
  _this.isExternal = false;
3845
3872
  _this.storeVisit(visit);
3846
3873
  return _this;
@@ -3851,22 +3878,183 @@
3851
3878
  /** @type {?} */
3852
3879
  Internal.prototype.isExternal;
3853
3880
  }
3854
- /**
3855
- * @param {?} visit
3856
- * @return {?}
3857
- */
3858
- function createInternal(visit) {
3859
- return new Internal(visit);
3881
+ var Factory = /** @class */ (function () {
3882
+ function Factory(interactionContext) {
3883
+ this.interactionContext = interactionContext;
3884
+ }
3885
+ /**
3886
+ * @param {?} visit
3887
+ * @return {?}
3888
+ */
3889
+ Factory.prototype.createInternal = /**
3890
+ * @param {?} visit
3891
+ * @return {?}
3892
+ */
3893
+ function (visit) {
3894
+ return new Internal(visit, this.interactionContext);
3895
+ };
3896
+ /**
3897
+ * @param {?} firstTimeRoute
3898
+ * @return {?}
3899
+ */
3900
+ Factory.prototype.createExternal = /**
3901
+ * @param {?} firstTimeRoute
3902
+ * @return {?}
3903
+ */
3904
+ function (firstTimeRoute) {
3905
+ return new External(firstTimeRoute, this.interactionContext);
3906
+ };
3907
+ return Factory;
3908
+ }());
3909
+ NavigationSession.Factory = Factory;
3910
+ if (false) {
3911
+ /** @type {?} */
3912
+ Factory.prototype.interactionContext;
3860
3913
  }
3861
- NavigationSession.createInternal = createInternal;
3862
- /**
3863
- * @param {?} firstTimeRoute
3864
- * @return {?}
3865
- */
3866
- function createExternal(firstTimeRoute) {
3867
- return new External(firstTimeRoute);
3914
+ var ComponentDeactivationHandler = /** @class */ (function () {
3915
+ function ComponentDeactivationHandler(component, appModelInteractionContext, primary) {
3916
+ this.component = component;
3917
+ this.appModelInteractionContext = appModelInteractionContext;
3918
+ this.primary = primary;
3919
+ this.alreadyAccepted = false;
3920
+ // super();
3921
+ }
3922
+ /**
3923
+ * @param {?} nextState
3924
+ * @return {?}
3925
+ */
3926
+ ComponentDeactivationHandler.prototype.canDeactivate = /**
3927
+ * @param {?} nextState
3928
+ * @return {?}
3929
+ */
3930
+ function (nextState) {
3931
+ return __awaiter(this, void 0, void 0, function () {
3932
+ var _a;
3933
+ return __generator(this, function (_b) {
3934
+ switch (_b.label) {
3935
+ case 0:
3936
+ console.log(this.constructor.name + ".canDeactivate", { component: this.component });
3937
+ if (!this.alreadyAccepted) return [3 /*break*/, 1];
3938
+ // We'll get called multiple times if there's any parameter sanitisation so
3939
+ // we always return true if we accepted on a previous cycle of the current
3940
+ // navigation session.
3941
+ return [2 /*return*/, true];
3942
+ case 1:
3943
+ if (!(this.primary && this.appModelInteractionContext.isActive())) return [3 /*break*/, 3];
3944
+ // We check the global interaction first
3945
+ return [4 /*yield*/, this.cancelCurrentActivityOf(this.appModelInteractionContext)];
3946
+ case 2:
3947
+ // We check the global interaction first
3948
+ _b.sent();
3949
+ return [2 /*return*/, false];
3950
+ case 3:
3951
+ _a = this;
3952
+ return [4 /*yield*/, this.canDeactivateComponent(nextState)];
3953
+ case 4:
3954
+ _a.alreadyAccepted = _b.sent();
3955
+ return [2 /*return*/, this.alreadyAccepted];
3956
+ }
3957
+ });
3958
+ });
3959
+ };
3960
+ /**
3961
+ * @protected
3962
+ * @param {?} nextState
3963
+ * @return {?}
3964
+ */
3965
+ ComponentDeactivationHandler.prototype.canDeactivateComponent = /**
3966
+ * @protected
3967
+ * @param {?} nextState
3968
+ * @return {?}
3969
+ */
3970
+ function (nextState) {
3971
+ return __awaiter(this, void 0, void 0, function () {
3972
+ var hasCustomInteractionContext;
3973
+ return __generator(this, function (_a) {
3974
+ // check if the component has an active interaction. This will handle
3975
+ // an inplace interaction contexts
3976
+ hasCustomInteractionContext = this.component.interactionContext &&
3977
+ !this.isAppModalInteractionContext(this.component.interactionContext) &&
3978
+ this.component.interactionContext.isActive();
3979
+ if (hasCustomInteractionContext) {
3980
+ this.cancelCurrentActivityOf(this.component.interactionContext);
3981
+ return [2 /*return*/, false];
3982
+ }
3983
+ if (this.isLeavingCurrentPlace(nextState) && this.component.canDeactivate) {
3984
+ // No interaction in progress, so ask the component .
3985
+ // This may start an interaction, hence checking the interaction context before now. I.e. if the place pops up the dialog, and
3986
+ // the user clicks back again, we'll re-enter here and go bang when the component tries to open another dialog.
3987
+ return [2 /*return*/, this.component.canDeactivate()];
3988
+ }
3989
+ return [2 /*return*/, true];
3990
+ });
3991
+ });
3992
+ };
3993
+ /**
3994
+ * @param {?} interactionContext
3995
+ * @return {?}
3996
+ */
3997
+ ComponentDeactivationHandler.prototype.isAppModalInteractionContext = /**
3998
+ * @param {?} interactionContext
3999
+ * @return {?}
4000
+ */
4001
+ function (interactionContext) {
4002
+ return this.appModelInteractionContext === interactionContext;
4003
+ };
4004
+ /**
4005
+ * @protected
4006
+ * @param {?} interactionContext
4007
+ * @return {?}
4008
+ */
4009
+ ComponentDeactivationHandler.prototype.cancelCurrentActivityOf = /**
4010
+ * @protected
4011
+ * @param {?} interactionContext
4012
+ * @return {?}
4013
+ */
4014
+ function (interactionContext) {
4015
+ return __awaiter(this, void 0, void 0, function () {
4016
+ var activity;
4017
+ return __generator(this, function (_a) {
4018
+ switch (_a.label) {
4019
+ case 0: return [4 /*yield*/, interactionContext.getCurrentActivity()];
4020
+ case 1:
4021
+ activity = _a.sent();
4022
+ console.log('cancelling', { activity: activity });
4023
+ activity.cancel(null);
4024
+ return [2 /*return*/];
4025
+ }
4026
+ });
4027
+ });
4028
+ };
4029
+ /**
4030
+ * @protected
4031
+ * @param {?} nextState
4032
+ * @return {?}
4033
+ */
4034
+ ComponentDeactivationHandler.prototype.isLeavingCurrentPlace = /**
4035
+ * @protected
4036
+ * @param {?} nextState
4037
+ * @return {?}
4038
+ */
4039
+ function (nextState) {
4040
+ return !nextState.includesPathOf(this.component.placeDefinition);
4041
+ };
4042
+ return ComponentDeactivationHandler;
4043
+ }());
4044
+ NavigationSession.ComponentDeactivationHandler = ComponentDeactivationHandler;
4045
+ if (false) {
4046
+ /**
4047
+ * @type {?}
4048
+ * @private
4049
+ */
4050
+ ComponentDeactivationHandler.prototype.alreadyAccepted;
4051
+ /** @type {?} */
4052
+ ComponentDeactivationHandler.prototype.component;
4053
+ /** @type {?} */
4054
+ ComponentDeactivationHandler.prototype.appModelInteractionContext;
4055
+ /** @type {?} */
4056
+ ComponentDeactivationHandler.prototype.primary;
3868
4057
  }
3869
- NavigationSession.createExternal = createExternal;
3870
4058
  })(exports.NavigationSession || (exports.NavigationSession = {}));
3871
4059
 
3872
4060
  /**
@@ -3955,10 +4143,11 @@
3955
4143
  */
3956
4144
  exports.ɵt = /** @class */ (function (_super) {
3957
4145
  __extends(PlaceRouter, _super);
3958
- function PlaceRouter(router$1, urlSerializer, angularLocation, placeHistory) {
4146
+ function PlaceRouter(router$1, urlSerializer, interactionContext, angularLocation, placeHistory) {
3959
4147
  var _this = _super.call(this) || this;
3960
4148
  _this.router = router$1;
3961
4149
  _this.urlSerializer = urlSerializer;
4150
+ _this.interactionContext = interactionContext;
3962
4151
  _this.angularLocation = angularLocation;
3963
4152
  _this.placeHistory = placeHistory;
3964
4153
  _this.firstRoute = true;
@@ -3966,6 +4155,7 @@
3966
4155
  _this._activeVisits = new pectin.MutableListModel();
3967
4156
  var _a = pectin.Dsl.disposeWith(_this), chain = _a.chain, valueOf = _a.valueOf, before = _a.before, when = _a.when, after = _a.after, observe = _a.observe, switchOn = _a.switchOn;
3968
4157
  _this.activeVisitIndex = chain(_this._activeVisits).indexBy('placeDefinition');
4158
+ _this.navigationSessionFactory = new exports.NavigationSession.Factory(interactionContext);
3969
4159
  angularLocation.onUrlChange((/**
3970
4160
  * @param {?} url
3971
4161
  * @return {?}
@@ -3988,8 +4178,11 @@
3988
4178
  if (event instanceof router.NavigationStart) {
3989
4179
  _this.onAngularRouterStarted(event);
3990
4180
  }
3991
- if (event instanceof router.NavigationEnd || event instanceof router.NavigationError) {
3992
- _this.onAngularRouterFinished();
4181
+ if (event instanceof router.NavigationEnd) {
4182
+ _this.onAngularRouterFinished(false);
4183
+ }
4184
+ if (event instanceof router.NavigationError) {
4185
+ _this.onAngularRouterFinished(true);
3993
4186
  }
3994
4187
  }));
3995
4188
  _this.navigationSessionActive = chain(_this.navigationSessionModel).isNotNil();
@@ -4110,7 +4303,7 @@
4110
4303
  */
4111
4304
  function (router) {
4112
4305
  /** @type {?} */
4113
- var commands = _this.createUrlManipulator(_this.router.routerState.snapshot).createRedirectCommandsFor(next);
4306
+ var commands = _this.parseUrl(_this.router.routerState.snapshot).createRedirectCommandsFor(next);
4114
4307
  // // we have to to use the definition for route id as our redirection always includes
4115
4308
  // // the id in the url segements (but leaves it blank when there's no id). I.e. in the
4116
4309
  // // no id case we're doing the following redirect [<placePath>, ""] -> ["..", <id>]
@@ -4143,7 +4336,7 @@
4143
4336
  return __generator(this, function (_a) {
4144
4337
  switch (_a.label) {
4145
4338
  case 0:
4146
- this._navigationSessionModel.value = exports.NavigationSession.createInternal(visit);
4339
+ this._navigationSessionModel.value = this.navigationSessionFactory.createInternal(visit);
4147
4340
  _a.label = 1;
4148
4341
  case 1:
4149
4342
  _a.trys.push([1, , 3, 4]);
@@ -4152,8 +4345,10 @@
4152
4345
  _a.sent();
4153
4346
  return [3 /*break*/, 4];
4154
4347
  case 3:
4348
+ // Router has finished (since there was no router change required) so we
4349
+ // need to end the navigation session.
4155
4350
  if (this.navigationSession && !this.router.getCurrentNavigation()) {
4156
- this.onAngularRouterFinished();
4351
+ this.onAngularRouterFinished(false);
4157
4352
  }
4158
4353
  return [7 /*endfinally*/];
4159
4354
  case 4: return [2 /*return*/];
@@ -4196,9 +4391,9 @@
4196
4391
  if (!this.navigationSession) { // We been activated by an external route rather than placeRouter.go(visit)
4197
4392
  console.log('navigation started', { firstTime: this.firstRoute });
4198
4393
  /** @type {?} */
4199
- var session = exports.NavigationSession.createExternal(this.firstRoute);
4394
+ var session = this.navigationSessionFactory.createExternal(this.firstRoute);
4200
4395
  if (event.navigationTrigger === 'popstate') {
4201
- session.setPopstateReturn(this.router.routerState.snapshot.url);
4396
+ session.setPopstateReturnUrl(this.router.routerState.snapshot.url);
4202
4397
  }
4203
4398
  this._navigationSessionModel.value = session;
4204
4399
  }
@@ -4208,30 +4403,40 @@
4208
4403
  // @Trace()
4209
4404
  /**
4210
4405
  * @private
4406
+ * @param {?} cancelled
4211
4407
  * @return {?}
4212
4408
  */
4213
4409
  PlaceRouter.prototype.onAngularRouterFinished =
4214
4410
  // @Trace()
4215
4411
  /**
4216
4412
  * @private
4413
+ * @param {?} cancelled
4217
4414
  * @return {?}
4218
4415
  */
4219
- function () {
4416
+ function (cancelled) {
4220
4417
  var _this = this;
4221
4418
  /** @type {?} */
4222
4419
  var session = this._navigationSessionModel.value;
4223
- // Update visits before we end the navigation session. This allows the place out let to
4224
- // gate ignore changes that occur while the visit is active
4225
- /** @type {?} */
4226
- var visits = session.getVisits();
4227
- visits.forEach((/**
4228
- * @param {?} v
4229
- * @return {?}
4230
- */
4231
- function (v) {
4232
- _this.placeHistory.add(v);
4233
- }));
4234
- this._activeVisits.value = visits;
4420
+ if (!cancelled) {
4421
+ // Update visits before we end the navigation session. This allows the placeOutets to
4422
+ // ignore visit changes that occur while the navigation is in progress
4423
+ /** @type {?} */
4424
+ var visits = session.getVisits();
4425
+ visits.forEach((/**
4426
+ * @param {?} v
4427
+ * @return {?}
4428
+ */
4429
+ function (v) { return _this.placeHistory.add(v); }));
4430
+ this._activeVisits.value = visits;
4431
+ }
4432
+ else {
4433
+ // Angular doesn't preserve the url when a guard cancels the back button.
4434
+ // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
4435
+ if (session.isPopState) {
4436
+ console.log('cancelled during popstate');
4437
+ this.angularLocation.go(session.popStateReturnUrl);
4438
+ }
4439
+ }
4235
4440
  this._navigationSessionModel.value = null;
4236
4441
  };
4237
4442
  /**
@@ -4253,12 +4458,12 @@
4253
4458
  * @param {?} snapshot
4254
4459
  * @return {?}
4255
4460
  */
4256
- PlaceRouter.prototype.createUrlManipulator = /**
4461
+ PlaceRouter.prototype.parseUrl = /**
4257
4462
  * @param {?} snapshot
4258
4463
  * @return {?}
4259
4464
  */
4260
4465
  function (snapshot) {
4261
- return new PlaceRouter.UrlManipulator(this.urlSerializer.parse(snapshot.url));
4466
+ return new PlaceRouter.UrlHelper(this.urlSerializer.parse(snapshot.url));
4262
4467
  };
4263
4468
  PlaceRouter.decorators = [
4264
4469
  { type: core.Injectable, args: [{
@@ -4269,10 +4474,11 @@
4269
4474
  PlaceRouter.ctorParameters = function () { return [
4270
4475
  { type: router.Router },
4271
4476
  { type: router.UrlSerializer },
4477
+ { type: InteractionContext },
4272
4478
  { type: common.Location },
4273
4479
  { type: PlaceHistory }
4274
4480
  ]; };
4275
- /** @nocollapse */ PlaceRouter.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function PlaceRouter_Factory() { return new PlaceRouter(core.ɵɵinject(router.Router), core.ɵɵinject(router.UrlSerializer), core.ɵɵinject(common.Location), core.ɵɵinject(PlaceHistory)); }, token: PlaceRouter, providedIn: "root" });
4481
+ /** @nocollapse */ PlaceRouter.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function PlaceRouter_Factory() { return new PlaceRouter(core.ɵɵinject(router.Router), core.ɵɵinject(router.UrlSerializer), core.ɵɵinject(InteractionContext), core.ɵɵinject(common.Location), core.ɵɵinject(PlaceHistory)); }, token: PlaceRouter, providedIn: "root" });
4276
4482
  __decorate([
4277
4483
  pectin.Trace(),
4278
4484
  __metadata("design:type", Function),
@@ -4301,6 +4507,11 @@
4301
4507
  exports.ɵt.prototype.navigationSessionActive;
4302
4508
  /** @type {?} */
4303
4509
  exports.ɵt.prototype.activeVisitIndex;
4510
+ /**
4511
+ * @type {?}
4512
+ * @private
4513
+ */
4514
+ exports.ɵt.prototype.navigationSessionFactory;
4304
4515
  /**
4305
4516
  * @type {?}
4306
4517
  * @private
@@ -4311,21 +4522,26 @@
4311
4522
  * @private
4312
4523
  */
4313
4524
  exports.ɵt.prototype.urlSerializer;
4525
+ /**
4526
+ * @type {?}
4527
+ * @private
4528
+ */
4529
+ exports.ɵt.prototype.interactionContext;
4314
4530
  /** @type {?} */
4315
4531
  exports.ɵt.prototype.angularLocation;
4316
4532
  /** @type {?} */
4317
4533
  exports.ɵt.prototype.placeHistory;
4318
4534
  }
4319
4535
  (function (PlaceRouter) {
4320
- var UrlManipulator = /** @class */ (function () {
4321
- function UrlManipulator(urlTree) {
4536
+ var UrlHelper = /** @class */ (function () {
4537
+ function UrlHelper(urlTree) {
4322
4538
  this.urlTree = urlTree;
4323
4539
  console.log({ segments: this.urlTree.root.children.primary.segments });
4324
4540
  }
4325
4541
  /**
4326
4542
  * @return {?}
4327
4543
  */
4328
- UrlManipulator.prototype.cloneUrlSegmentList = /**
4544
+ UrlHelper.prototype.cloneUrlSegmentList = /**
4329
4545
  * @return {?}
4330
4546
  */
4331
4547
  function () {
@@ -4335,7 +4551,7 @@
4335
4551
  * @param {?} visit
4336
4552
  * @return {?}
4337
4553
  */
4338
- UrlManipulator.prototype.updateVisitSegments = /**
4554
+ UrlHelper.prototype.updateVisitSegments = /**
4339
4555
  * @param {?} visit
4340
4556
  * @return {?}
4341
4557
  */
@@ -4364,7 +4580,7 @@
4364
4580
  * @param {?} visit
4365
4581
  * @return {?}
4366
4582
  */
4367
- UrlManipulator.prototype.convertToUrlSegments = /**
4583
+ UrlHelper.prototype.convertToUrlSegments = /**
4368
4584
  * Converts the visit into segments. Please not that these segments are not e
4369
4585
  * @param {?} visit
4370
4586
  * @return {?}
@@ -4387,7 +4603,7 @@
4387
4603
  * @param {?} visit
4388
4604
  * @return {?}
4389
4605
  */
4390
- UrlManipulator.prototype.createRedirectCommandsFor = /**
4606
+ UrlHelper.prototype.createRedirectCommandsFor = /**
4391
4607
  * @param {?} visit
4392
4608
  * @return {?}
4393
4609
  */
@@ -4408,21 +4624,36 @@
4408
4624
  }));
4409
4625
  return commands;
4410
4626
  };
4627
+ /**
4628
+ * @param {?} placeDef
4629
+ * @return {?}
4630
+ */
4631
+ UrlHelper.prototype.includesPathOf = /**
4632
+ * @param {?} placeDef
4633
+ * @return {?}
4634
+ */
4635
+ function (placeDef) {
4636
+ return this.cloneUrlSegmentList().find((/**
4637
+ * @param {?} s
4638
+ * @return {?}
4639
+ */
4640
+ function (s) { return s.path === placeDef.path; }));
4641
+ };
4411
4642
  __decorate([
4412
4643
  pectin.Trace(),
4413
4644
  __metadata("design:type", Function),
4414
4645
  __metadata("design:paramtypes", [Visit]),
4415
4646
  __metadata("design:returntype", Array)
4416
- ], UrlManipulator.prototype, "createRedirectCommandsFor", null);
4417
- return UrlManipulator;
4647
+ ], UrlHelper.prototype, "createRedirectCommandsFor", null);
4648
+ return UrlHelper;
4418
4649
  }());
4419
- PlaceRouter.UrlManipulator = UrlManipulator;
4650
+ PlaceRouter.UrlHelper = UrlHelper;
4420
4651
  if (false) {
4421
4652
  /**
4422
4653
  * @type {?}
4423
4654
  * @private
4424
4655
  */
4425
- UrlManipulator.prototype.urlTree;
4656
+ UrlHelper.prototype.urlTree;
4426
4657
  }
4427
4658
  })(exports.ɵt || (exports.ɵt = {}));
4428
4659
 
@@ -6193,7 +6424,7 @@
6193
6424
  this.placeRouter.navigationSession.storeVisit(sanitisedVisit);
6194
6425
  if (initialVisit.hasRoutingChangedFrom(sanitisedVisit)) {
6195
6426
  // Regenerate the url
6196
- commands = this.placeRouter.createUrlManipulator(state).createRedirectCommandsFor(sanitisedVisit);
6427
+ commands = this.placeRouter.parseUrl(state).createRedirectCommandsFor(sanitisedVisit);
6197
6428
  console.log('##### Place Guard Redirect', commands);
6198
6429
  return [2 /*return*/, this.router.createUrlTree(commands, {
6199
6430
  replaceUrl: true,
@@ -6415,90 +6646,9 @@
6415
6646
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
6416
6647
  */
6417
6648
  var LeavePlaceGuard = /** @class */ (function () {
6418
- function LeavePlaceGuard(router, injector, placeRouter, dialogInteractionContext, angularLocation) {
6419
- this.router = router;
6420
- this.injector = injector;
6649
+ function LeavePlaceGuard(placeRouter) {
6421
6650
  this.placeRouter = placeRouter;
6422
- this.dialogInteractionContext = dialogInteractionContext;
6423
- this.angularLocation = angularLocation;
6424
6651
  }
6425
- // @Trace()
6426
- // @Trace()
6427
- /**
6428
- * @private
6429
- * @param {?} nextState
6430
- * @param {?} placeDefinition
6431
- * @return {?}
6432
- */
6433
- LeavePlaceGuard.prototype.isLeavingTheCurrentPlace =
6434
- // @Trace()
6435
- /**
6436
- * @private
6437
- * @param {?} nextState
6438
- * @param {?} placeDefinition
6439
- * @return {?}
6440
- */
6441
- function (nextState, placeDefinition) {
6442
- // TODO: this will break with child routes... need to examine the router states properly.
6443
- // console.log('canDeactivate', {
6444
- // staticPath: placeDefinitionPath,
6445
- // currentStateUrl: currentState.url,
6446
- // nextStateUrl: nextState.url
6447
- // // alreadyDeclined: this._alreadyAccepted
6448
- // });
6449
- // Example of the above when navigating to a different child route.
6450
- // canDeactivate {staticPath: "/hero-details",
6451
- // currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-details",
6452
- // nextStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats"
6453
- // }
6454
- // TODO: this will break with child routes... need to examine the router states properly.
6455
- // console.log('canDeactivate', {
6456
- // staticPath: placeDefinitionPath,
6457
- // currentStateUrl: currentState.url,
6458
- // nextStateUrl: nextState.url
6459
- // // alreadyDeclined: this._alreadyAccepted
6460
- // });
6461
- // Example of the above when navigating to a different child route.
6462
- // canDeactivate {staticPath: "/hero-details",
6463
- // currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-details",
6464
- // nextStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats"
6465
- // }
6466
- // Example clicking on router tab of the parent component (de-activates the parent due to route param changes)
6467
- // canDeactivate {
6468
- // staticPath: "/hero-stats",
6469
- // currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats",
6470
- // nextStateUrl: "/route-parameters/"
6471
- // }
6472
- // canDeactivate {
6473
- // staticPath: "/route-parameters",
6474
- // currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats",
6475
- // nextStateUrl: "/route-parameters/"
6476
- // }
6477
- // logger.class.js:54 ParameterSnapshot.sanitise -> {idModel: -1, pv: undefined, pl: Array(0), dv: undefined, dl: Array(0), …}
6478
- // parameter-snapshot.ts:20 {name: "idModel", mine: -1, theirs: null}
6479
- // place-router.ts:28 redirect path (3) ["route-parameters", "-1", {…}]
6480
- // canDeactivate {
6481
- // staticPath: "/hero-stats",
6482
- // currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats",
6483
- // nextStateUrl: "/route-parameters/-1"
6484
- // }
6485
- // canDeactivate {
6486
- // staticPath: "/route-parameters",
6487
- // currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats",
6488
- // nextStateUrl: "/route-parameters/-1"
6489
- // }
6490
- // logger.class.js:54 ParameterSnapshot.sanitise -> {idModel: -1, pv: undefined, pl: Array(0), dv: "A", dl: Array(3), …}
6491
- // parameter-snapshot.ts:20 {name: "dv", mine: "A", theirs: undefined}
6492
- // place-router.ts:28 redirect path (3) ["route-parameters", "-1", {…}]
6493
- // canDeactivate {
6494
- // staticPath: "/hero-stats",
6495
- // currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats",
6496
- // nextStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c"
6497
- // }
6498
- /** @type {?} */
6499
- var placeDefinitionPath = "/" + placeDefinition.path;
6500
- return !nextState.url.startsWith(placeDefinitionPath);
6501
- };
6502
6652
  /**
6503
6653
  * @param {?} component
6504
6654
  * @param {?} currentRoute
@@ -6515,72 +6665,8 @@
6515
6665
  */
6516
6666
  function (component, currentRoute, currentState, nextState) {
6517
6667
  return __awaiter(this, void 0, void 0, function () {
6518
- var self_1, canLeave;
6519
6668
  return __generator(this, function (_a) {
6520
- switch (_a.label) {
6521
- case 0:
6522
- if (!this.placeRouter.navigationSession.alreadyAccepted(component)) return [3 /*break*/, 1];
6523
- // We'll get called multiple times if there's any parameter sanitisation so
6524
- // we always return true if we accepted on a previous cycle of the current
6525
- // navigation session.
6526
- return [2 /*return*/, true];
6527
- case 1:
6528
- self_1 = this;
6529
- canLeave = true;
6530
- if (!this.isLeavingTheCurrentPlace(nextState, component.placeDefinition)) return [3 /*break*/, 4];
6531
- // we check the dialog interaction first, so that components that don't need to check if they're in an
6532
- // interaction during the canDeactivate cycle.
6533
- // TODO: Add tests: show dialog -> hit back -> same route
6534
- if (this.dialogInteractionContext.isActive()) {
6535
- console.log('cancelling', { activity: this.dialogInteractionContext.currentActivity });
6536
- this.dialogInteractionContext.currentActivity.cancel(null);
6537
- canLeave = false;
6538
- }
6539
- else {
6540
- canLeave = true;
6541
- }
6542
- if (canLeave) {
6543
- // now check if the component has an active interaction. This will handle
6544
- // an inplace interaction contexts
6545
- if (component.interactionContext && component.interactionContext.isActive()) {
6546
- canLeave = false;
6547
- console.log('cancelling', { activity: component.interactionContext.currentActivity });
6548
- component.interactionContext.currentActivity.cancel(null);
6549
- }
6550
- }
6551
- if (!canLeave) return [3 /*break*/, 3];
6552
- return [4 /*yield*/, component.canDeactivate()];
6553
- case 2:
6554
- // TODO: Add tests: hit back -> confirm leave dialog -> hit back -> close dialog -> hit back -> confirm leave dialog.
6555
- canLeave = _a.sent();
6556
- _a.label = 3;
6557
- case 3: return [3 /*break*/, 5];
6558
- case 4:
6559
- if (this.dialogInteractionContext.isActive()) {
6560
- console.log('cancelling', { activity: this.dialogInteractionContext.currentActivity });
6561
- this.dialogInteractionContext.currentActivity.cancel(null);
6562
- canLeave = false;
6563
- }
6564
- else {
6565
- canLeave = true;
6566
- }
6567
- _a.label = 5;
6568
- case 5:
6569
- if (canLeave) {
6570
- // We'll get called multiple times if there's any parameter sanitisation so
6571
- // we remember the acceptance for the duration of the current navigation session.
6572
- self_1.placeRouter.navigationSession.rememberAcceptanceOf(component);
6573
- }
6574
- else {
6575
- // Angular doesn't preserve the url when a guard cancels the back button.
6576
- // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
6577
- if (this.placeRouter.navigationSession.isPopState) {
6578
- console.log('cancelled during popstate');
6579
- this.angularLocation.go(this.placeRouter.navigationSession.popStateReturnUrl);
6580
- }
6581
- }
6582
- return [2 /*return*/, canLeave];
6583
- }
6669
+ return [2 /*return*/, this.placeRouter.navigationSession.canDeactivate(component, this.placeRouter.parseUrl(nextState))];
6584
6670
  });
6585
6671
  });
6586
6672
  };
@@ -6591,35 +6677,17 @@
6591
6677
  ];
6592
6678
  /** @nocollapse */
6593
6679
  LeavePlaceGuard.ctorParameters = function () { return [
6594
- { type: router.Router },
6595
- { type: core.Injector },
6596
- { type: exports.ɵt },
6597
- { type: InteractionContext },
6598
- { type: common.Location }
6680
+ { type: exports.ɵt }
6599
6681
  ]; };
6600
- /** @nocollapse */ LeavePlaceGuard.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function LeavePlaceGuard_Factory() { return new LeavePlaceGuard(core.ɵɵinject(router.Router), core.ɵɵinject(core.INJECTOR), core.ɵɵinject(exports.ɵt), core.ɵɵinject(InteractionContext), core.ɵɵinject(common.Location)); }, token: LeavePlaceGuard, providedIn: "root" });
6682
+ /** @nocollapse */ LeavePlaceGuard.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function LeavePlaceGuard_Factory() { return new LeavePlaceGuard(core.ɵɵinject(exports.ɵt)); }, token: LeavePlaceGuard, providedIn: "root" });
6601
6683
  return LeavePlaceGuard;
6602
6684
  }());
6603
6685
  if (false) {
6604
- /**
6605
- * @type {?}
6606
- * @private
6607
- */
6608
- LeavePlaceGuard.prototype.router;
6609
- /**
6610
- * @type {?}
6611
- * @private
6612
- */
6613
- LeavePlaceGuard.prototype.injector;
6614
6686
  /**
6615
6687
  * @type {?}
6616
6688
  * @private
6617
6689
  */
6618
6690
  LeavePlaceGuard.prototype.placeRouter;
6619
- /** @type {?} */
6620
- LeavePlaceGuard.prototype.dialogInteractionContext;
6621
- /** @type {?} */
6622
- LeavePlaceGuard.prototype.angularLocation;
6623
6691
  }
6624
6692
 
6625
6693
  exports.ACTIVITY_DATA = ACTIVITY_DATA;
@@ -6676,7 +6744,7 @@
6676
6744
  exports.slideDownAndUpAnimation = slideDownAndUpAnimation;
6677
6745
  exports.ɵa = DirectivesModule;
6678
6746
  exports.ɵb = CommandDirective;
6679
- exports.ɵba = InteractionContext;
6747
+ exports.ɵba = ActivityContainerComponent;
6680
6748
  exports.ɵbb = ActivityOutletComponent;
6681
6749
  exports.ɵbc = ConfirmationDialogComponent;
6682
6750
  exports.ɵbd = AbstractActivity;
@@ -6702,12 +6770,12 @@
6702
6770
  exports.ɵp = leftRightPlaceAnimation;
6703
6771
  exports.ɵq = LEFT_RIGHT_PLACE_ANIMATION;
6704
6772
  exports.ɵr = AUP_PLACE_CONFIG;
6705
- exports.ɵu = PlaceHistory;
6706
- exports.ɵv = TabbedPlaceNavigationComponent;
6707
- exports.ɵw = AbstractPlaceNavigationComponent;
6708
- exports.ɵx = ListPlaceNavComponent;
6709
- exports.ɵy = InteractionModule;
6710
- exports.ɵz = ActivityContainerComponent;
6773
+ exports.ɵu = InteractionContext;
6774
+ exports.ɵv = PlaceHistory;
6775
+ exports.ɵw = TabbedPlaceNavigationComponent;
6776
+ exports.ɵx = AbstractPlaceNavigationComponent;
6777
+ exports.ɵy = ListPlaceNavComponent;
6778
+ exports.ɵz = InteractionModule;
6711
6779
 
6712
6780
  Object.defineProperty(exports, '__esModule', { value: true });
6713
6781