@coolon/angular-ui-powerups 0.0.90 → 0.0.91

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 +468 -396
  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 +19 -18
  6. package/coolon-angular-ui-powerups.metadata.json +1 -1
  7. package/esm2015/coolon-angular-ui-powerups.js +18 -17
  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 +182 -39
  14. package/esm2015/lib/place/place-component.js +4 -19
  15. package/esm2015/lib/place/place-router.js +65 -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 +18 -17
  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 +225 -54
  25. package/esm5/lib/place/place-component.js +4 -35
  26. package/esm5/lib/place/place-router.js +75 -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 +353 -299
  30. package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
  31. package/fesm5/coolon-angular-ui-powerups.js +430 -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 +6 -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')];
1121
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
+ }
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
@@ -1183,7 +1272,7 @@
1183
1272
  * @abstract
1184
1273
  * @template D, R, E
1185
1274
  */
1186
- exports.ɵbf = /** @class */ (function (_super) {
1275
+ exports.ɵbg = /** @class */ (function (_super) {
1187
1276
  __extends(Activity, _super);
1188
1277
  function Activity() {
1189
1278
  var _this = _super !== null && _super.apply(this, arguments) || this;
@@ -1273,12 +1362,12 @@
1273
1362
  * @type {?}
1274
1363
  * @private
1275
1364
  */
1276
- exports.ɵbf.prototype._busyModel;
1365
+ exports.ɵbg.prototype._busyModel;
1277
1366
  /**
1278
1367
  * @type {?}
1279
1368
  * @private
1280
1369
  */
1281
- exports.ɵbf.prototype._activityContext;
1370
+ exports.ɵbg.prototype._activityContext;
1282
1371
  }
1283
1372
  (function (Activity) {
1284
1373
  /**
@@ -1293,7 +1382,7 @@
1293
1382
  /** @type {?} */
1294
1383
  Callbacks.prototype.onCancel;
1295
1384
  }
1296
- })(exports.ɵbf || (exports.ɵbf = {}));
1385
+ })(exports.ɵbg || (exports.ɵbg = {}));
1297
1386
 
1298
1387
  /**
1299
1388
  * @fileoverview added by tsickle
@@ -1450,7 +1539,7 @@
1450
1539
  return _super !== null && _super.apply(this, arguments) || this;
1451
1540
  }
1452
1541
  return AbstractActivity;
1453
- }(exports.ɵbf));
1542
+ }(exports.ɵbg));
1454
1543
 
1455
1544
  /**
1456
1545
  * @fileoverview added by tsickle
@@ -1496,7 +1585,7 @@
1496
1585
  /**
1497
1586
  * @template D, R, E
1498
1587
  */
1499
- exports.ɵbh = /** @class */ (function (_super) {
1588
+ exports.ɵbi = /** @class */ (function (_super) {
1500
1589
  __extends(ConfirmThenDialogComponent, _super);
1501
1590
  function ConfirmThenDialogComponent(config, interactionContext) {
1502
1591
  var _this = _super.call(this) || this;
@@ -1568,9 +1657,9 @@
1568
1657
  }(AbstractActivity));
1569
1658
  if (false) {
1570
1659
  /** @type {?} */
1571
- exports.ɵbh.prototype.config;
1660
+ exports.ɵbi.prototype.config;
1572
1661
  /** @type {?} */
1573
- exports.ɵbh.prototype.interactionContext;
1662
+ exports.ɵbi.prototype.interactionContext;
1574
1663
  }
1575
1664
  (function (ConfirmThenDialogComponent) {
1576
1665
  /**
@@ -1587,7 +1676,7 @@
1587
1676
  /** @type {?} */
1588
1677
  Data.prototype.data;
1589
1678
  }
1590
- })(exports.ɵbh || (exports.ɵbh = {}));
1679
+ })(exports.ɵbi || (exports.ɵbi = {}));
1591
1680
 
1592
1681
  /**
1593
1682
  * @fileoverview added by tsickle
@@ -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 {?}
@@ -1960,7 +2040,7 @@
1960
2040
  * @return {?}
1961
2041
  */
1962
2042
  function (confirm, activityType, data) {
1963
- return this.startActivity(exports.ɵbh, {
2043
+ return this.startActivity(exports.ɵbi, {
1964
2044
  confirm: confirm,
1965
2045
  activityType: activityType,
1966
2046
  data: data
@@ -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
  */
@@ -2216,7 +2287,7 @@
2216
2287
  * @return {?}
2217
2288
  */
2218
2289
  function (confirm, activityType, data) {
2219
- return this._startActivity(exports.ɵbh, {
2290
+ return this._startActivity(exports.ɵbi, {
2220
2291
  confirm: confirm,
2221
2292
  activityType: activityType,
2222
2293
  data: data
@@ -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;
2474
+ return this._inActivityPromise.value;
2406
2475
  };
2407
- /**
2408
- * @return {?}
2409
- */
2410
- DialogInteractionService.prototype.cancelActivity = /**
2411
- * @return {?}
2412
- */
2413
- function () {
2414
- this.currentActivity.cancel(null);
2415
- };
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
@@ -2592,7 +2654,7 @@
2592
2654
  * @return {?}
2593
2655
  */
2594
2656
  function (confirm, activityType, data) {
2595
- return this._startActivity(exports.ɵbh, {
2657
+ return this._startActivity(exports.ɵbi, {
2596
2658
  confirm: confirm,
2597
2659
  activityType: activityType,
2598
2660
  data: data
@@ -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
@@ -2662,7 +2722,7 @@
2662
2722
  declarations: [
2663
2723
  ActivityContainerComponent,
2664
2724
  ConfirmationDialogComponent,
2665
- exports.ɵbh,
2725
+ exports.ɵbi,
2666
2726
  AlertDialogComponent,
2667
2727
  ActivityOutletComponent,
2668
2728
  InteractionOutletComponent,
@@ -2677,7 +2737,7 @@
2677
2737
  entryComponents: [
2678
2738
  ActivityContainerComponent,
2679
2739
  ConfirmationDialogComponent,
2680
- exports.ɵbh,
2740
+ exports.ɵbi,
2681
2741
  AlertDialogComponent
2682
2742
  ],
2683
2743
  providers: [
@@ -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 {?}
@@ -3691,11 +3719,14 @@
3691
3719
  /**
3692
3720
  * @abstract
3693
3721
  */
3694
- exports.NavigationSession = /** @class */ (function () {
3695
- function NavigationSession(firstNavigation) {
3722
+ exports.ɵu = /** @class */ (function () {
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
  */
@@ -3807,27 +3822,39 @@
3807
3822
  * @type {?}
3808
3823
  * @private
3809
3824
  */
3810
- exports.NavigationSession.prototype._alreadyAccepted;
3825
+ exports.ɵu.prototype._alreadyAccepted;
3811
3826
  /**
3812
3827
  * @type {?}
3813
3828
  * @private
3814
3829
  */
3815
- exports.NavigationSession.prototype._visits;
3830
+ exports.ɵu.prototype._visits;
3816
3831
  /**
3817
3832
  * @type {?}
3818
3833
  * @private
3819
3834
  */
3820
- exports.NavigationSession.prototype._popStateReturnUrl;
3835
+ exports.ɵu.prototype._popStateReturnUrl;
3836
+ /** @type {?} */
3837
+ exports.ɵu.prototype.isExternal;
3821
3838
  /** @type {?} */
3822
- exports.NavigationSession.prototype.isExternal;
3839
+ exports.ɵu.prototype.dialogOpenOnStart;
3840
+ /**
3841
+ * @type {?}
3842
+ * @private
3843
+ */
3844
+ exports.ɵu.prototype.componentDeactivationHandlers;
3823
3845
  /** @type {?} */
3824
- exports.NavigationSession.prototype.firstNavigation;
3846
+ exports.ɵu.prototype.firstNavigation;
3847
+ /**
3848
+ * @type {?}
3849
+ * @private
3850
+ */
3851
+ exports.ɵu.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,23 +3878,193 @@
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(appModelInteractionContext) {
3883
+ this.appModelInteractionContext = appModelInteractionContext;
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.appModelInteractionContext);
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.appModelInteractionContext);
3906
+ };
3907
+ Factory.decorators = [
3908
+ { type: core.Injectable, args: [{
3909
+ providedIn: 'root'
3910
+ },] },
3911
+ ];
3912
+ /** @nocollapse */
3913
+ Factory.ctorParameters = function () { return [
3914
+ { type: InteractionContext }
3915
+ ]; };
3916
+ return Factory;
3917
+ }());
3918
+ NavigationSession.Factory = Factory;
3919
+ if (false) {
3920
+ /** @type {?} */
3921
+ Factory.prototype.appModelInteractionContext;
3860
3922
  }
3861
- NavigationSession.createInternal = createInternal;
3862
- /**
3863
- * @param {?} firstTimeRoute
3864
- * @return {?}
3865
- */
3866
- function createExternal(firstTimeRoute) {
3867
- return new External(firstTimeRoute);
3923
+ var ComponentDeactivationHandler = /** @class */ (function () {
3924
+ function ComponentDeactivationHandler(component, appModelInteractionContext, primary) {
3925
+ this.component = component;
3926
+ this.appModelInteractionContext = appModelInteractionContext;
3927
+ this.primary = primary;
3928
+ this.alreadyAccepted = false;
3929
+ // super();
3930
+ }
3931
+ /**
3932
+ * @param {?} nextState
3933
+ * @return {?}
3934
+ */
3935
+ ComponentDeactivationHandler.prototype.canDeactivate = /**
3936
+ * @param {?} nextState
3937
+ * @return {?}
3938
+ */
3939
+ function (nextState) {
3940
+ return __awaiter(this, void 0, void 0, function () {
3941
+ var _a;
3942
+ return __generator(this, function (_b) {
3943
+ switch (_b.label) {
3944
+ case 0:
3945
+ console.log(this.constructor.name + ".canDeactivate", { component: this.component });
3946
+ if (!this.alreadyAccepted) return [3 /*break*/, 1];
3947
+ // We'll get called multiple times if there's any parameter sanitisation so
3948
+ // we always return true if we accepted on a previous cycle of the current
3949
+ // navigation session.
3950
+ return [2 /*return*/, true];
3951
+ case 1:
3952
+ if (!(this.primary && this.appModelInteractionContext.isActive())) return [3 /*break*/, 3];
3953
+ // We check the global interaction first
3954
+ return [4 /*yield*/, this.cancelCurrentActivityOf(this.appModelInteractionContext)];
3955
+ case 2:
3956
+ // We check the global interaction first
3957
+ _b.sent();
3958
+ return [2 /*return*/, false];
3959
+ case 3:
3960
+ _a = this;
3961
+ return [4 /*yield*/, this.canDeactivateComponent(nextState)];
3962
+ case 4:
3963
+ _a.alreadyAccepted = _b.sent();
3964
+ return [2 /*return*/, this.alreadyAccepted];
3965
+ }
3966
+ });
3967
+ });
3968
+ };
3969
+ /**
3970
+ * @protected
3971
+ * @param {?} nextState
3972
+ * @return {?}
3973
+ */
3974
+ ComponentDeactivationHandler.prototype.canDeactivateComponent = /**
3975
+ * @protected
3976
+ * @param {?} nextState
3977
+ * @return {?}
3978
+ */
3979
+ function (nextState) {
3980
+ return __awaiter(this, void 0, void 0, function () {
3981
+ var hasCustomInteractionContext;
3982
+ return __generator(this, function (_a) {
3983
+ // check if the component has an active interaction. This will handle
3984
+ // an inplace interaction contexts
3985
+ hasCustomInteractionContext = this.component.interactionContext &&
3986
+ !this.isAppModalInteractionContext(this.component.interactionContext) &&
3987
+ this.component.interactionContext.isActive();
3988
+ if (hasCustomInteractionContext) {
3989
+ this.cancelCurrentActivityOf(this.component.interactionContext);
3990
+ return [2 /*return*/, false];
3991
+ }
3992
+ if (this.isLeavingCurrentPlace(nextState) && this.component.canDeactivate) {
3993
+ // No interaction in progress, so ask the component .
3994
+ // This may start an interaction, hence checking the interaction context before now. I.e. if the place pops up the dialog, and
3995
+ // the user clicks back again, we'll re-enter here and go bang when the component tries to open another dialog.
3996
+ return [2 /*return*/, this.component.canDeactivate()];
3997
+ }
3998
+ return [2 /*return*/, true];
3999
+ });
4000
+ });
4001
+ };
4002
+ /**
4003
+ * @param {?} interactionContext
4004
+ * @return {?}
4005
+ */
4006
+ ComponentDeactivationHandler.prototype.isAppModalInteractionContext = /**
4007
+ * @param {?} interactionContext
4008
+ * @return {?}
4009
+ */
4010
+ function (interactionContext) {
4011
+ return this.appModelInteractionContext === interactionContext;
4012
+ };
4013
+ /**
4014
+ * @protected
4015
+ * @param {?} interactionContext
4016
+ * @return {?}
4017
+ */
4018
+ ComponentDeactivationHandler.prototype.cancelCurrentActivityOf = /**
4019
+ * @protected
4020
+ * @param {?} interactionContext
4021
+ * @return {?}
4022
+ */
4023
+ function (interactionContext) {
4024
+ return __awaiter(this, void 0, void 0, function () {
4025
+ var activity;
4026
+ return __generator(this, function (_a) {
4027
+ switch (_a.label) {
4028
+ case 0: return [4 /*yield*/, interactionContext.getCurrentActivity()];
4029
+ case 1:
4030
+ activity = _a.sent();
4031
+ console.log('cancelling', { activity: activity });
4032
+ activity.cancel(null);
4033
+ return [2 /*return*/];
4034
+ }
4035
+ });
4036
+ });
4037
+ };
4038
+ /**
4039
+ * @protected
4040
+ * @param {?} nextState
4041
+ * @return {?}
4042
+ */
4043
+ ComponentDeactivationHandler.prototype.isLeavingCurrentPlace = /**
4044
+ * @protected
4045
+ * @param {?} nextState
4046
+ * @return {?}
4047
+ */
4048
+ function (nextState) {
4049
+ return !nextState.includesPathOf(this.component.placeDefinition);
4050
+ };
4051
+ return ComponentDeactivationHandler;
4052
+ }());
4053
+ NavigationSession.ComponentDeactivationHandler = ComponentDeactivationHandler;
4054
+ if (false) {
4055
+ /**
4056
+ * @type {?}
4057
+ * @private
4058
+ */
4059
+ ComponentDeactivationHandler.prototype.alreadyAccepted;
4060
+ /** @type {?} */
4061
+ ComponentDeactivationHandler.prototype.component;
4062
+ /** @type {?} */
4063
+ ComponentDeactivationHandler.prototype.appModelInteractionContext;
4064
+ /** @type {?} */
4065
+ ComponentDeactivationHandler.prototype.primary;
3868
4066
  }
3869
- NavigationSession.createExternal = createExternal;
3870
- })(exports.NavigationSession || (exports.NavigationSession = {}));
4067
+ })(exports.ɵu || (exports.ɵu = {}));
3871
4068
 
3872
4069
  /**
3873
4070
  * @fileoverview added by tsickle
@@ -3955,10 +4152,11 @@
3955
4152
  */
3956
4153
  exports.ɵt = /** @class */ (function (_super) {
3957
4154
  __extends(PlaceRouter, _super);
3958
- function PlaceRouter(router$1, urlSerializer, angularLocation, placeHistory) {
4155
+ function PlaceRouter(router$1, urlSerializer, navigationSessionFactory, angularLocation, placeHistory) {
3959
4156
  var _this = _super.call(this) || this;
3960
4157
  _this.router = router$1;
3961
4158
  _this.urlSerializer = urlSerializer;
4159
+ _this.navigationSessionFactory = navigationSessionFactory;
3962
4160
  _this.angularLocation = angularLocation;
3963
4161
  _this.placeHistory = placeHistory;
3964
4162
  _this.firstRoute = true;
@@ -3988,8 +4186,11 @@
3988
4186
  if (event instanceof router.NavigationStart) {
3989
4187
  _this.onAngularRouterStarted(event);
3990
4188
  }
3991
- if (event instanceof router.NavigationEnd || event instanceof router.NavigationError) {
3992
- _this.onAngularRouterFinished();
4189
+ if (event instanceof router.NavigationEnd) {
4190
+ _this.onAngularRouterFinished(false);
4191
+ }
4192
+ if (event instanceof router.NavigationError) {
4193
+ _this.onAngularRouterFinished(true);
3993
4194
  }
3994
4195
  }));
3995
4196
  _this.navigationSessionActive = chain(_this.navigationSessionModel).isNotNil();
@@ -4110,7 +4311,7 @@
4110
4311
  */
4111
4312
  function (router) {
4112
4313
  /** @type {?} */
4113
- var commands = _this.createUrlManipulator(_this.router.routerState.snapshot).createRedirectCommandsFor(next);
4314
+ var commands = _this.parseUrl(_this.router.routerState.snapshot).createRedirectCommandsFor(next);
4114
4315
  // // we have to to use the definition for route id as our redirection always includes
4115
4316
  // // the id in the url segements (but leaves it blank when there's no id). I.e. in the
4116
4317
  // // no id case we're doing the following redirect [<placePath>, ""] -> ["..", <id>]
@@ -4143,7 +4344,7 @@
4143
4344
  return __generator(this, function (_a) {
4144
4345
  switch (_a.label) {
4145
4346
  case 0:
4146
- this._navigationSessionModel.value = exports.NavigationSession.createInternal(visit);
4347
+ this._navigationSessionModel.value = this.navigationSessionFactory.createInternal(visit);
4147
4348
  _a.label = 1;
4148
4349
  case 1:
4149
4350
  _a.trys.push([1, , 3, 4]);
@@ -4152,8 +4353,10 @@
4152
4353
  _a.sent();
4153
4354
  return [3 /*break*/, 4];
4154
4355
  case 3:
4356
+ // Router has finished (since there was no router change required) so we
4357
+ // need to end the navigation session.
4155
4358
  if (this.navigationSession && !this.router.getCurrentNavigation()) {
4156
- this.onAngularRouterFinished();
4359
+ this.onAngularRouterFinished(false);
4157
4360
  }
4158
4361
  return [7 /*endfinally*/];
4159
4362
  case 4: return [2 /*return*/];
@@ -4196,9 +4399,9 @@
4196
4399
  if (!this.navigationSession) { // We been activated by an external route rather than placeRouter.go(visit)
4197
4400
  console.log('navigation started', { firstTime: this.firstRoute });
4198
4401
  /** @type {?} */
4199
- var session = exports.NavigationSession.createExternal(this.firstRoute);
4402
+ var session = this.navigationSessionFactory.createExternal(this.firstRoute);
4200
4403
  if (event.navigationTrigger === 'popstate') {
4201
- session.setPopstateReturn(this.router.routerState.snapshot.url);
4404
+ session.setPopstateReturnUrl(this.router.routerState.snapshot.url);
4202
4405
  }
4203
4406
  this._navigationSessionModel.value = session;
4204
4407
  }
@@ -4208,30 +4411,40 @@
4208
4411
  // @Trace()
4209
4412
  /**
4210
4413
  * @private
4414
+ * @param {?} cancelled
4211
4415
  * @return {?}
4212
4416
  */
4213
4417
  PlaceRouter.prototype.onAngularRouterFinished =
4214
4418
  // @Trace()
4215
4419
  /**
4216
4420
  * @private
4421
+ * @param {?} cancelled
4217
4422
  * @return {?}
4218
4423
  */
4219
- function () {
4424
+ function (cancelled) {
4220
4425
  var _this = this;
4221
4426
  /** @type {?} */
4222
4427
  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;
4428
+ if (!cancelled) {
4429
+ // Update visits before we end the navigation session. This allows the placeOutets to
4430
+ // ignore visit changes that occur while the navigation is in progress
4431
+ /** @type {?} */
4432
+ var visits = session.getVisits();
4433
+ visits.forEach((/**
4434
+ * @param {?} v
4435
+ * @return {?}
4436
+ */
4437
+ function (v) { return _this.placeHistory.add(v); }));
4438
+ this._activeVisits.value = visits;
4439
+ }
4440
+ else {
4441
+ // Angular doesn't preserve the url when a guard cancels the back button.
4442
+ // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
4443
+ if (session.isPopState) {
4444
+ console.log('cancelled during popstate');
4445
+ this.angularLocation.go(session.popStateReturnUrl);
4446
+ }
4447
+ }
4235
4448
  this._navigationSessionModel.value = null;
4236
4449
  };
4237
4450
  /**
@@ -4253,12 +4466,12 @@
4253
4466
  * @param {?} snapshot
4254
4467
  * @return {?}
4255
4468
  */
4256
- PlaceRouter.prototype.createUrlManipulator = /**
4469
+ PlaceRouter.prototype.parseUrl = /**
4257
4470
  * @param {?} snapshot
4258
4471
  * @return {?}
4259
4472
  */
4260
4473
  function (snapshot) {
4261
- return new PlaceRouter.UrlManipulator(this.urlSerializer.parse(snapshot.url));
4474
+ return new PlaceRouter.UrlHelper(this.urlSerializer.parse(snapshot.url));
4262
4475
  };
4263
4476
  PlaceRouter.decorators = [
4264
4477
  { type: core.Injectable, args: [{
@@ -4269,10 +4482,11 @@
4269
4482
  PlaceRouter.ctorParameters = function () { return [
4270
4483
  { type: router.Router },
4271
4484
  { type: router.UrlSerializer },
4485
+ { type: exports.ɵu.Factory },
4272
4486
  { type: common.Location },
4273
4487
  { type: PlaceHistory }
4274
4488
  ]; };
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" });
4489
+ /** @nocollapse */ PlaceRouter.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function PlaceRouter_Factory() { return new PlaceRouter(core.ɵɵinject(router.Router), core.ɵɵinject(router.UrlSerializer), core.ɵɵinject(exports.ɵu.Factory), core.ɵɵinject(common.Location), core.ɵɵinject(PlaceHistory)); }, token: PlaceRouter, providedIn: "root" });
4276
4490
  __decorate([
4277
4491
  pectin.Trace(),
4278
4492
  __metadata("design:type", Function),
@@ -4311,21 +4525,26 @@
4311
4525
  * @private
4312
4526
  */
4313
4527
  exports.ɵt.prototype.urlSerializer;
4528
+ /**
4529
+ * @type {?}
4530
+ * @private
4531
+ */
4532
+ exports.ɵt.prototype.navigationSessionFactory;
4314
4533
  /** @type {?} */
4315
4534
  exports.ɵt.prototype.angularLocation;
4316
4535
  /** @type {?} */
4317
4536
  exports.ɵt.prototype.placeHistory;
4318
4537
  }
4319
4538
  (function (PlaceRouter) {
4320
- var UrlManipulator = /** @class */ (function () {
4321
- function UrlManipulator(urlTree) {
4539
+ var UrlHelper = /** @class */ (function () {
4540
+ function UrlHelper(urlTree) {
4322
4541
  this.urlTree = urlTree;
4323
4542
  console.log({ segments: this.urlTree.root.children.primary.segments });
4324
4543
  }
4325
4544
  /**
4326
4545
  * @return {?}
4327
4546
  */
4328
- UrlManipulator.prototype.cloneUrlSegmentList = /**
4547
+ UrlHelper.prototype.cloneUrlSegmentList = /**
4329
4548
  * @return {?}
4330
4549
  */
4331
4550
  function () {
@@ -4335,7 +4554,7 @@
4335
4554
  * @param {?} visit
4336
4555
  * @return {?}
4337
4556
  */
4338
- UrlManipulator.prototype.updateVisitSegments = /**
4557
+ UrlHelper.prototype.updateVisitSegments = /**
4339
4558
  * @param {?} visit
4340
4559
  * @return {?}
4341
4560
  */
@@ -4364,7 +4583,7 @@
4364
4583
  * @param {?} visit
4365
4584
  * @return {?}
4366
4585
  */
4367
- UrlManipulator.prototype.convertToUrlSegments = /**
4586
+ UrlHelper.prototype.convertToUrlSegments = /**
4368
4587
  * Converts the visit into segments. Please not that these segments are not e
4369
4588
  * @param {?} visit
4370
4589
  * @return {?}
@@ -4387,7 +4606,7 @@
4387
4606
  * @param {?} visit
4388
4607
  * @return {?}
4389
4608
  */
4390
- UrlManipulator.prototype.createRedirectCommandsFor = /**
4609
+ UrlHelper.prototype.createRedirectCommandsFor = /**
4391
4610
  * @param {?} visit
4392
4611
  * @return {?}
4393
4612
  */
@@ -4408,21 +4627,36 @@
4408
4627
  }));
4409
4628
  return commands;
4410
4629
  };
4630
+ /**
4631
+ * @param {?} placeDef
4632
+ * @return {?}
4633
+ */
4634
+ UrlHelper.prototype.includesPathOf = /**
4635
+ * @param {?} placeDef
4636
+ * @return {?}
4637
+ */
4638
+ function (placeDef) {
4639
+ return this.cloneUrlSegmentList().find((/**
4640
+ * @param {?} s
4641
+ * @return {?}
4642
+ */
4643
+ function (s) { return s.path === placeDef.path; }));
4644
+ };
4411
4645
  __decorate([
4412
4646
  pectin.Trace(),
4413
4647
  __metadata("design:type", Function),
4414
4648
  __metadata("design:paramtypes", [Visit]),
4415
4649
  __metadata("design:returntype", Array)
4416
- ], UrlManipulator.prototype, "createRedirectCommandsFor", null);
4417
- return UrlManipulator;
4650
+ ], UrlHelper.prototype, "createRedirectCommandsFor", null);
4651
+ return UrlHelper;
4418
4652
  }());
4419
- PlaceRouter.UrlManipulator = UrlManipulator;
4653
+ PlaceRouter.UrlHelper = UrlHelper;
4420
4654
  if (false) {
4421
4655
  /**
4422
4656
  * @type {?}
4423
4657
  * @private
4424
4658
  */
4425
- UrlManipulator.prototype.urlTree;
4659
+ UrlHelper.prototype.urlTree;
4426
4660
  }
4427
4661
  })(exports.ɵt || (exports.ɵt = {}));
4428
4662
 
@@ -6193,7 +6427,7 @@
6193
6427
  this.placeRouter.navigationSession.storeVisit(sanitisedVisit);
6194
6428
  if (initialVisit.hasRoutingChangedFrom(sanitisedVisit)) {
6195
6429
  // Regenerate the url
6196
- commands = this.placeRouter.createUrlManipulator(state).createRedirectCommandsFor(sanitisedVisit);
6430
+ commands = this.placeRouter.parseUrl(state).createRedirectCommandsFor(sanitisedVisit);
6197
6431
  console.log('##### Place Guard Redirect', commands);
6198
6432
  return [2 /*return*/, this.router.createUrlTree(commands, {
6199
6433
  replaceUrl: true,
@@ -6415,90 +6649,9 @@
6415
6649
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
6416
6650
  */
6417
6651
  var LeavePlaceGuard = /** @class */ (function () {
6418
- function LeavePlaceGuard(router, injector, placeRouter, dialogInteractionContext, angularLocation) {
6419
- this.router = router;
6420
- this.injector = injector;
6652
+ function LeavePlaceGuard(placeRouter) {
6421
6653
  this.placeRouter = placeRouter;
6422
- this.dialogInteractionContext = dialogInteractionContext;
6423
- this.angularLocation = angularLocation;
6424
6654
  }
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
6655
  /**
6503
6656
  * @param {?} component
6504
6657
  * @param {?} currentRoute
@@ -6515,72 +6668,8 @@
6515
6668
  */
6516
6669
  function (component, currentRoute, currentState, nextState) {
6517
6670
  return __awaiter(this, void 0, void 0, function () {
6518
- var self_1, canLeave;
6519
6671
  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
- }
6672
+ return [2 /*return*/, this.placeRouter.navigationSession.canDeactivate(component, this.placeRouter.parseUrl(nextState))];
6584
6673
  });
6585
6674
  });
6586
6675
  };
@@ -6591,35 +6680,17 @@
6591
6680
  ];
6592
6681
  /** @nocollapse */
6593
6682
  LeavePlaceGuard.ctorParameters = function () { return [
6594
- { type: router.Router },
6595
- { type: core.Injector },
6596
- { type: exports.ɵt },
6597
- { type: InteractionContext },
6598
- { type: common.Location }
6683
+ { type: exports.ɵt }
6599
6684
  ]; };
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" });
6685
+ /** @nocollapse */ LeavePlaceGuard.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function LeavePlaceGuard_Factory() { return new LeavePlaceGuard(core.ɵɵinject(exports.ɵt)); }, token: LeavePlaceGuard, providedIn: "root" });
6601
6686
  return LeavePlaceGuard;
6602
6687
  }());
6603
6688
  if (false) {
6604
- /**
6605
- * @type {?}
6606
- * @private
6607
- */
6608
- LeavePlaceGuard.prototype.router;
6609
- /**
6610
- * @type {?}
6611
- * @private
6612
- */
6613
- LeavePlaceGuard.prototype.injector;
6614
6689
  /**
6615
6690
  * @type {?}
6616
6691
  * @private
6617
6692
  */
6618
6693
  LeavePlaceGuard.prototype.placeRouter;
6619
- /** @type {?} */
6620
- LeavePlaceGuard.prototype.dialogInteractionContext;
6621
- /** @type {?} */
6622
- LeavePlaceGuard.prototype.angularLocation;
6623
6694
  }
6624
6695
 
6625
6696
  exports.ACTIVITY_DATA = ACTIVITY_DATA;
@@ -6627,7 +6698,7 @@
6627
6698
  exports.AbstractActivity = AbstractActivity;
6628
6699
  exports.AbstractInputComponent = AbstractInputComponent;
6629
6700
  exports.AbstractPlaceNavigationComponent = AbstractPlaceNavigationComponent;
6630
- exports.Activity = exports.ɵbf;
6701
+ exports.Activity = exports.ɵbg;
6631
6702
  exports.ActivityContainerComponent = ActivityContainerComponent;
6632
6703
  exports.ActivityOutletComponent = ActivityOutletComponent;
6633
6704
  exports.AlertDialogComponent = AlertDialogComponent;
@@ -6635,7 +6706,7 @@
6635
6706
  exports.BusyOverlayComponent = BusyOverlayComponent;
6636
6707
  exports.CommandDirective = CommandDirective;
6637
6708
  exports.ComponentsModule = ComponentsModule;
6638
- exports.ConfirmThenDialogComponent = exports.ɵbh;
6709
+ exports.ConfirmThenDialogComponent = exports.ɵbi;
6639
6710
  exports.ConfirmationDialogComponent = ConfirmationDialogComponent;
6640
6711
  exports.DEFINITION_META_DATA_KEY = DEFINITION_META_DATA_KEY;
6641
6712
  exports.DIALOG_INTERACTION_SERVICE_DEFAULTS = DIALOG_INTERACTION_SERVICE_DEFAULTS;
@@ -6653,6 +6724,7 @@
6653
6724
  exports.LEFT_RIGHT_PLACE_ANIMATION = LEFT_RIGHT_PLACE_ANIMATION;
6654
6725
  exports.LeavePlaceGuard = LeavePlaceGuard;
6655
6726
  exports.ListPlaceNavComponent = ListPlaceNavComponent;
6727
+ exports.NavigationSession = exports.ɵu;
6656
6728
  exports.NoopComponent = NoopComponent;
6657
6729
  exports.NumberInputComponent = NumberInputComponent;
6658
6730
  exports.PasswordInputComponent = PasswordInputComponent;
@@ -6676,16 +6748,17 @@
6676
6748
  exports.slideDownAndUpAnimation = slideDownAndUpAnimation;
6677
6749
  exports.ɵa = DirectivesModule;
6678
6750
  exports.ɵb = CommandDirective;
6679
- exports.ɵba = InteractionContext;
6680
- exports.ɵbb = ActivityOutletComponent;
6681
- exports.ɵbc = ConfirmationDialogComponent;
6682
- exports.ɵbd = AbstractActivity;
6683
- exports.ɵbe = ACTIVITY_DATA;
6684
- exports.ɵbi = AlertDialogComponent;
6685
- exports.ɵbk = InteractionOutletComponent;
6686
- exports.ɵbl = InplaceInteractionContextComponent;
6687
- exports.ɵbm = DIALOG_INTERACTION_SERVICE_DEFAULTS;
6688
- exports.ɵbn = DialogInteractionService;
6751
+ exports.ɵba = InteractionModule;
6752
+ exports.ɵbb = ActivityContainerComponent;
6753
+ exports.ɵbc = ActivityOutletComponent;
6754
+ exports.ɵbd = ConfirmationDialogComponent;
6755
+ exports.ɵbe = AbstractActivity;
6756
+ exports.ɵbf = ACTIVITY_DATA;
6757
+ exports.ɵbj = AlertDialogComponent;
6758
+ exports.ɵbl = InteractionOutletComponent;
6759
+ exports.ɵbm = InplaceInteractionContextComponent;
6760
+ exports.ɵbn = DIALOG_INTERACTION_SERVICE_DEFAULTS;
6761
+ exports.ɵbo = DialogInteractionService;
6689
6762
  exports.ɵc = FocusBindingDirective;
6690
6763
  exports.ɵd = DisposableComponent;
6691
6764
  exports.ɵe = ComponentsModule;
@@ -6702,12 +6775,11 @@
6702
6775
  exports.ɵp = leftRightPlaceAnimation;
6703
6776
  exports.ɵq = LEFT_RIGHT_PLACE_ANIMATION;
6704
6777
  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;
6778
+ exports.ɵv = InteractionContext;
6779
+ exports.ɵw = PlaceHistory;
6780
+ exports.ɵx = TabbedPlaceNavigationComponent;
6781
+ exports.ɵy = AbstractPlaceNavigationComponent;
6782
+ exports.ɵz = ListPlaceNavComponent;
6711
6783
 
6712
6784
  Object.defineProperty(exports, '__esModule', { value: true });
6713
6785