@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
@@ -5,7 +5,7 @@ import { MatInputModule, MatFormFieldModule, MatSelectModule, MatDialog, MatButt
5
5
  import { MatTabsModule } from '@angular/material/tabs';
6
6
  import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
7
7
  import { __extends, __decorate, __metadata, __awaiter, __generator, __assign, __spread } from 'tslib';
8
- import { assert, UnaryCommand, lang, Dsl, GarbageCollector, Logger, DelegatingFormValueModel, UseDelegate, ValueModel, ListModel, StoreInListModel, DelegatingValueModel, MutableStream, MutableListModel, DelegatingListModel, Binding, MutableValueModel, Trace, Guard as Guard$1, Command, StoreInValueModel, OptionsHelper, ValueHolder } from '@coolon/pectin';
8
+ import { DelegatingValueModel, assert, UnaryCommand, lang, Dsl, GarbageCollector, Logger, DelegatingFormValueModel, UseDelegate, ValueModel, ListModel, StoreInListModel, DelegatingListModel, Deferred, MutableStream, MutableListModel, MutableValueModel, Binding, Trace, Guard as Guard$1, Command, StoreInValueModel, OptionsHelper, ValueHolder } from '@coolon/pectin';
9
9
  import { PortalModule } from '@angular/cdk/portal';
10
10
  import { Router, RouterModule, NavigationStart, NavigationEnd, NavigationError, UrlSerializer, UrlSegment, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
11
11
  import ___default, { last, isNil, isEqual } from 'lodash';
@@ -32,9 +32,28 @@ var CommandDirective = /** @class */ (function (_super) {
32
32
  function CommandDirective(elementRef) {
33
33
  var _this = _super.call(this) || this;
34
34
  _this.elementRef = elementRef;
35
+ _this._commandEnabled = new DelegatingValueModel().withDefault(false);
35
36
  _this._commandParameterProvided = false;
36
37
  return _this;
37
38
  }
39
+ Object.defineProperty(CommandDirective.prototype, "pectinCommand", {
40
+ get: /**
41
+ * @return {?}
42
+ */
43
+ function () {
44
+ return this._command;
45
+ },
46
+ set: /**
47
+ * @param {?} command
48
+ * @return {?}
49
+ */
50
+ function (command) {
51
+ this._command = command;
52
+ this._commandEnabled.setDelegate(command ? command.enabled : null);
53
+ },
54
+ enumerable: true,
55
+ configurable: true
56
+ });
38
57
  Object.defineProperty(CommandDirective.prototype, "commandParameter", {
39
58
  get: /**
40
59
  * @return {?}
@@ -83,7 +102,7 @@ var CommandDirective = /** @class */ (function (_super) {
83
102
  // for some reason mat-buttons kills the disabled host binding. It works on a regular button but for now
84
103
  // we need to do this.
85
104
  var chain = Dsl.disposeWith(this).chain;
86
- chain(this.pectinCommand.enabled).subscribe((/**
105
+ chain(this._commandEnabled).subscribe((/**
87
106
  * @param {?} enabled
88
107
  * @return {?}
89
108
  */
@@ -152,8 +171,16 @@ var CommandDirective = /** @class */ (function (_super) {
152
171
  return CommandDirective;
153
172
  }(GarbageCollector));
154
173
  if (false) {
155
- /** @type {?} */
156
- CommandDirective.prototype.pectinCommand;
174
+ /**
175
+ * @type {?}
176
+ * @private
177
+ */
178
+ CommandDirective.prototype._command;
179
+ /**
180
+ * @type {?}
181
+ * @private
182
+ */
183
+ CommandDirective.prototype._commandEnabled;
157
184
  /**
158
185
  * @type {?}
159
186
  * @private
@@ -893,51 +920,107 @@ var /**
893
920
  InteractionContext = /** @class */ (function (_super) {
894
921
  __extends(InteractionContext, _super);
895
922
  function InteractionContext() {
896
- return _super.call(this) || this;
897
- }
898
- Object.defineProperty(InteractionContext.prototype, "currentActivity", {
923
+ var _this = _super.call(this) || this;
899
924
  /**
900
- * Returns the activity that is currently active.
925
+ * Returns the current list of activities that are in progress.
901
926
  * This model is only updated in the next tick after the view has been updated.
902
927
  */
928
+ _this._activityListDelegate = new DelegatingListModel();
929
+ var _a = Dsl.disposeWith(_this), chain = _a.chain, valueOf = _a.valueOf, before = _a.before, when = _a.when, after = _a.after, observe = _a.observe, switchOn = _a.switchOn;
930
+ when.listOf(_this.activityList).becomesPopulated((/**
931
+ * @param {?} activities
932
+ * @return {?}
933
+ */
934
+ function (activities) {
935
+ if (_this.deferredGetCurrentActivity) {
936
+ _this.deferredGetCurrentActivity.resolve(last(activities));
937
+ _this.deferredGetCurrentActivity = null;
938
+ }
939
+ }));
940
+ return _this;
941
+ }
942
+ /**
943
+ * @protected
944
+ * @param {?} activityList
945
+ * @return {?}
946
+ */
947
+ InteractionContext.prototype.setActivityList = /**
948
+ * @protected
949
+ * @param {?} activityList
950
+ * @return {?}
951
+ */
952
+ function (activityList) {
953
+ this._activityListDelegate.setDelegate(activityList);
954
+ };
955
+ Object.defineProperty(InteractionContext.prototype, "activityList", {
903
956
  get: /**
904
- * Returns the activity that is currently active.
905
- * This model is only updated in the next tick after the view has been updated.
906
957
  * @return {?}
907
958
  */
908
959
  function () {
909
- return last(this.activityList.value);
960
+ return this._activityListDelegate.readonly;
910
961
  },
911
962
  enumerable: true,
912
963
  configurable: true
913
964
  });
914
965
  /**
915
- * @param {?} confirm
966
+ * Returns the activity that is currently active.
967
+ * This model is only updated in the next tick after the view has been updated.
968
+ */
969
+ /**
970
+ * Returns the activity that is currently active.
971
+ * This model is only updated in the next tick after the view has been updated.
916
972
  * @return {?}
917
973
  */
918
- InteractionContext.prototype.confirm = /**
919
- * @param {?} confirm
974
+ InteractionContext.prototype.getCurrentActivity = /**
975
+ * Returns the activity that is currently active.
976
+ * This model is only updated in the next tick after the view has been updated.
920
977
  * @return {?}
921
978
  */
922
- function (confirm) {
979
+ function () {
923
980
  return __awaiter(this, void 0, void 0, function () {
924
- var _a;
925
- return __generator(this, function (_b) {
926
- switch (_b.label) {
927
- case 0:
928
- _b.trys.push([0, 2, , 3]);
929
- return [4 /*yield*/, this.confirmOrReject(confirm)];
930
- case 1:
931
- _b.sent();
932
- return [2 /*return*/, true];
933
- case 2:
934
- _a = _b.sent();
935
- return [2 /*return*/, false];
936
- case 3: return [2 /*return*/];
981
+ return __generator(this, function (_a) {
982
+ if (!this.isActive()) {
983
+ return [2 /*return*/, Promise.reject('no activity in progress')];
937
984
  }
985
+ else {
986
+ if (this.deferredGetCurrentActivity) {
987
+ // we're already waiting then just return the same promise
988
+ return [2 /*return*/, this.deferredGetCurrentActivity.promise];
989
+ }
990
+ else {
991
+ if (this.activityList.length < 1) {
992
+ this.deferredGetCurrentActivity = Deferred.defer();
993
+ return [2 /*return*/, this.deferredGetCurrentActivity.promise];
994
+ }
995
+ else {
996
+ return [2 /*return*/, last(this.activityList.value)];
997
+ }
998
+ }
999
+ }
1000
+ return [2 /*return*/];
938
1001
  });
939
1002
  });
940
1003
  };
1004
+ /**
1005
+ * @param {?} confirm
1006
+ * @return {?}
1007
+ */
1008
+ InteractionContext.prototype.confirm = /**
1009
+ * @param {?} confirm
1010
+ * @return {?}
1011
+ */
1012
+ function (confirm) {
1013
+ // Important: we have to implement confirmOrReject as the main entry point
1014
+ // as the canDeactivation guards need to be able to cancel an interaction
1015
+ // without caring about returning a value.
1016
+ return this.confirmOrReject(confirm).then((/**
1017
+ * @return {?}
1018
+ */
1019
+ function () { return true; })).catch((/**
1020
+ * @return {?}
1021
+ */
1022
+ function () { return false; }));
1023
+ };
941
1024
  return InteractionContext;
942
1025
  }(GarbageCollector));
943
1026
  if (false) {
@@ -945,8 +1028,14 @@ if (false) {
945
1028
  * Returns the current list of activities that are in progress.
946
1029
  * This model is only updated in the next tick after the view has been updated.
947
1030
  * @type {?}
1031
+ * @private
1032
+ */
1033
+ InteractionContext.prototype._activityListDelegate;
1034
+ /**
1035
+ * @type {?}
1036
+ * @private
948
1037
  */
949
- InteractionContext.prototype.activityList;
1038
+ InteractionContext.prototype.deferredGetCurrentActivity;
950
1039
  /**
951
1040
  * Returns true if an activity is currently running.
952
1041
  * @abstract
@@ -1588,6 +1677,7 @@ var ActivityContainerComponent = /** @class */ (function (_super) {
1588
1677
  * @return {?}
1589
1678
  */
1590
1679
  function () { return _this.onNestedActivityFinished(); }));
1680
+ _this.setActivityList(_this._activityList.readonly);
1591
1681
  return _this;
1592
1682
  }
1593
1683
  Object.defineProperty(ActivityContainerComponent.prototype, "initialActivityOutletContext", {
@@ -1643,16 +1733,6 @@ var ActivityContainerComponent = /** @class */ (function (_super) {
1643
1733
  function () {
1644
1734
  return !!this._initialActivityOutletContext;
1645
1735
  };
1646
- Object.defineProperty(ActivityContainerComponent.prototype, "activityList", {
1647
- get: /**
1648
- * @return {?}
1649
- */
1650
- function () {
1651
- return this._activityList.readonly;
1652
- },
1653
- enumerable: true,
1654
- configurable: true
1655
- });
1656
1736
  Object.defineProperty(ActivityContainerComponent.prototype, "isFinished", {
1657
1737
  get: /**
1658
1738
  * @return {?}
@@ -1970,21 +2050,12 @@ var InplaceInteractionContextComponent = /** @class */ (function (_super) {
1970
2050
  /**
1971
2051
  * @return {?}
1972
2052
  */
1973
- InplaceInteractionContextComponent.prototype.ngOnInit = /**
2053
+ InplaceInteractionContextComponent.prototype.ngAfterViewInit = /**
1974
2054
  * @return {?}
1975
2055
  */
1976
2056
  function () {
2057
+ this.setActivityList(this.interactionContext.activityList);
1977
2058
  };
1978
- Object.defineProperty(InplaceInteractionContextComponent.prototype, "activityList", {
1979
- get: /**
1980
- * @return {?}
1981
- */
1982
- function () {
1983
- return this.interactionContext.activityList;
1984
- },
1985
- enumerable: true,
1986
- configurable: true
1987
- });
1988
2059
  /**
1989
2060
  * @return {?}
1990
2061
  */
@@ -2204,11 +2275,9 @@ var DialogInteractionService = /** @class */ (function (_super) {
2204
2275
  _this.router = router;
2205
2276
  _this.dialogServiceDefaults = dialogServiceDefaults;
2206
2277
  _this.matDialogDefaultConfig = matDialogDefaultConfig;
2207
- _this._activityList = new DelegatingListModel();
2208
2278
  _this.startingGuard = new Guard();
2279
+ _this._inActivityPromise = new MutableValueModel(false);
2209
2280
  assert$1.notNil(dialogService);
2210
- var _a = Dsl.disposeWith(_this), chain = _a.chain, valueOf = _a.valueOf, before = _a.before, when = _a.when, after = _a.after, observe = _a.observe, switchOn = _a.switchOn;
2211
- _this.active = chain(_this._activityList).isNotEmpty();
2212
2281
  return _this;
2213
2282
  }
2214
2283
  /**
@@ -2218,23 +2287,14 @@ var DialogInteractionService = /** @class */ (function (_super) {
2218
2287
  * @return {?}
2219
2288
  */
2220
2289
  function () {
2221
- return this.active.value;
2290
+ return this._inActivityPromise.value;
2222
2291
  };
2223
- /**
2224
- * @return {?}
2225
- */
2226
- DialogInteractionService.prototype.cancelActivity = /**
2227
- * @return {?}
2228
- */
2229
- function () {
2230
- this.currentActivity.cancel(null);
2231
- };
2232
- Object.defineProperty(DialogInteractionService.prototype, "activityList", {
2292
+ Object.defineProperty(DialogInteractionService.prototype, "active", {
2233
2293
  get: /**
2234
2294
  * @return {?}
2235
2295
  */
2236
2296
  function () {
2237
- return this._activityList.readonly;
2297
+ return this._inActivityPromise.readonly;
2238
2298
  },
2239
2299
  enumerable: true,
2240
2300
  configurable: true
@@ -2285,6 +2345,7 @@ var DialogInteractionService = /** @class */ (function (_super) {
2285
2345
  */
2286
2346
  function () {
2287
2347
  console.log('###### STARTING');
2348
+ _this._inActivityPromise.value = true;
2288
2349
  // this.currentActivityId = uuid.v1();
2289
2350
  // this.location.go(this.router.routerState.snapshot.url, "aup");
2290
2351
  /** @type {?} */
@@ -2343,6 +2404,7 @@ var DialogInteractionService = /** @class */ (function (_super) {
2343
2404
  * @return {?}
2344
2405
  */
2345
2406
  function () {
2407
+ _this._inActivityPromise.value = false;
2346
2408
  console.log('###### FINISHED');
2347
2409
  // this.currentActivityId = null;
2348
2410
  self.safelyUpdateActivityListDelegate(null);
@@ -2368,7 +2430,7 @@ var DialogInteractionService = /** @class */ (function (_super) {
2368
2430
  setTimeout((/**
2369
2431
  * @return {?}
2370
2432
  */
2371
- function () { return _this._activityList.setDelegate(delegate); }));
2433
+ function () { return _this.setActivityList(delegate); }));
2372
2434
  };
2373
2435
  /**
2374
2436
  * @param {?} alert
@@ -2435,14 +2497,12 @@ if (false) {
2435
2497
  * @type {?}
2436
2498
  * @private
2437
2499
  */
2438
- DialogInteractionService.prototype._activityList;
2500
+ DialogInteractionService.prototype.startingGuard;
2439
2501
  /**
2440
2502
  * @type {?}
2441
2503
  * @private
2442
2504
  */
2443
- DialogInteractionService.prototype.startingGuard;
2444
- /** @type {?} */
2445
- DialogInteractionService.prototype.active;
2505
+ DialogInteractionService.prototype._inActivityPromise;
2446
2506
  /**
2447
2507
  * @type {?}
2448
2508
  * @private
@@ -3217,15 +3277,6 @@ var PlaceComponent = /** @class */ (function (_super) {
3217
3277
  enumerable: true,
3218
3278
  configurable: true
3219
3279
  });
3220
- /**
3221
- * @return {?}
3222
- */
3223
- PlaceComponent.prototype.canDeactivate = /**
3224
- * @return {?}
3225
- */
3226
- function () {
3227
- return true;
3228
- };
3229
3280
  /**
3230
3281
  * @return {?}
3231
3282
  */
@@ -3234,36 +3285,13 @@ var PlaceComponent = /** @class */ (function (_super) {
3234
3285
  */
3235
3286
  function () {
3236
3287
  };
3237
- /**
3238
- * Called by the place outlet after all animations have finished. We need this instead of ngOnDestroy
3239
- * to avoid the fact that the angular router calls it before the animations have run causing the component
3240
- * to loose any pectin bindings.
3241
- */
3242
- // @Trace()
3243
- /**
3244
- * Called by the place outlet after all animations have finished. We need this instead of ngOnDestroy
3245
- * to avoid the fact that the angular router calls it before the animations have run causing the component
3246
- * to loose any pectin bindings.
3247
- * @return {?}
3248
- */
3249
- // @Trace()
3250
- PlaceComponent.prototype.onPlaceDestroyed = /**
3251
- * Called by the place outlet after all animations have finished. We need this instead of ngOnDestroy
3252
- * to avoid the fact that the angular router calls it before the animations have run causing the component
3253
- * to loose any pectin bindings.
3254
- * @return {?}
3255
- */
3256
- // @Trace()
3257
- function () {
3258
- this.dispose();
3259
- };
3260
3288
  __decorate([
3261
3289
  Memoize$1(),
3262
3290
  __metadata("design:type", PlaceDefinition),
3263
3291
  __metadata("design:paramtypes", [])
3264
3292
  ], PlaceComponent.prototype, "placeDefinition", null);
3265
3293
  return PlaceComponent;
3266
- }(GarbageCollector));
3294
+ }(DisposableComponent));
3267
3295
  if (false) {
3268
3296
  /**
3269
3297
  * @type {?}
@@ -3508,10 +3536,13 @@ var /**
3508
3536
  * @abstract
3509
3537
  */
3510
3538
  NavigationSession = /** @class */ (function () {
3511
- function NavigationSession(firstNavigation) {
3539
+ function NavigationSession(firstNavigation, appModalInteractionContext) {
3512
3540
  this.firstNavigation = firstNavigation;
3541
+ this.appModalInteractionContext = appModalInteractionContext;
3513
3542
  this._alreadyAccepted = [];
3514
3543
  this._visits = new Map();
3544
+ this.componentDeactivationHandlers = new Map();
3545
+ this.dialogOpenOnStart = this.appModalInteractionContext.isActive();
3515
3546
  }
3516
3547
  /**
3517
3548
  * @param {?} visit
@@ -3535,52 +3566,36 @@ NavigationSession = /** @class */ (function () {
3535
3566
  function (placeDef) {
3536
3567
  return this._visits.get(placeDef);
3537
3568
  };
3538
- /**
3539
- * @param {?} params
3540
- * @return {?}
3541
- */
3542
- NavigationSession.prototype.mergePrivatePlaceParameters = /**
3543
- * @param {?} params
3544
- * @return {?}
3545
- */
3546
- function (params) {
3547
- return null;
3548
- };
3549
- // @Trace()
3550
- // @Trace()
3551
- /**
3552
- * @param {?} placeComponent
3553
- * @return {?}
3554
- */
3555
- NavigationSession.prototype.alreadyAccepted =
3556
- // @Trace()
3557
- /**
3558
- * @param {?} placeComponent
3559
- * @return {?}
3560
- */
3561
- function (placeComponent) {
3562
- return this._alreadyAccepted.includes(placeComponent);
3563
- };
3564
- // @Trace()
3565
- // @Trace()
3566
3569
  /**
3567
3570
  * @param {?} component
3571
+ * @param {?} nextState
3568
3572
  * @return {?}
3569
3573
  */
3570
- NavigationSession.prototype.rememberAcceptanceOf =
3571
- // @Trace()
3572
- /**
3574
+ NavigationSession.prototype.canDeactivate = /**
3573
3575
  * @param {?} component
3576
+ * @param {?} nextState
3574
3577
  * @return {?}
3575
3578
  */
3576
- function (component) {
3577
- this._alreadyAccepted.push(component);
3579
+ function (component, nextState) {
3580
+ return __awaiter(this, void 0, void 0, function () {
3581
+ var handler, isPrimaryHandler;
3582
+ return __generator(this, function (_a) {
3583
+ // lookup the handler and create it if we've not seen it yet
3584
+ handler = this.componentDeactivationHandlers.get(component);
3585
+ if (!handler) {
3586
+ isPrimaryHandler = this.componentDeactivationHandlers.size === 0;
3587
+ handler = new NavigationSession.ComponentDeactivationHandler(component, this.appModalInteractionContext, isPrimaryHandler);
3588
+ this.componentDeactivationHandlers.set(component, handler);
3589
+ }
3590
+ return [2 /*return*/, handler.canDeactivate(nextState)];
3591
+ });
3592
+ });
3578
3593
  };
3579
3594
  /**
3580
3595
  * @param {?} url
3581
3596
  * @return {?}
3582
3597
  */
3583
- NavigationSession.prototype.setPopstateReturn = /**
3598
+ NavigationSession.prototype.setPopstateReturnUrl = /**
3584
3599
  * @param {?} url
3585
3600
  * @return {?}
3586
3601
  */
@@ -3637,13 +3652,25 @@ if (false) {
3637
3652
  /** @type {?} */
3638
3653
  NavigationSession.prototype.isExternal;
3639
3654
  /** @type {?} */
3655
+ NavigationSession.prototype.dialogOpenOnStart;
3656
+ /**
3657
+ * @type {?}
3658
+ * @private
3659
+ */
3660
+ NavigationSession.prototype.componentDeactivationHandlers;
3661
+ /** @type {?} */
3640
3662
  NavigationSession.prototype.firstNavigation;
3663
+ /**
3664
+ * @type {?}
3665
+ * @private
3666
+ */
3667
+ NavigationSession.prototype.appModalInteractionContext;
3641
3668
  }
3642
3669
  (function (NavigationSession) {
3643
3670
  var External = /** @class */ (function (_super) {
3644
3671
  __extends(External, _super);
3645
- function External(isFirstTime) {
3646
- var _this = _super.call(this, isFirstTime) || this;
3672
+ function External(isFirstTime, appModelInteractionContext) {
3673
+ var _this = _super.call(this, isFirstTime, appModelInteractionContext) || this;
3647
3674
  _this.isExternal = true;
3648
3675
  return _this;
3649
3676
  }
@@ -3655,8 +3682,8 @@ if (false) {
3655
3682
  }
3656
3683
  var Internal = /** @class */ (function (_super) {
3657
3684
  __extends(Internal, _super);
3658
- function Internal(visit) {
3659
- var _this = _super.call(this, false) || this;
3685
+ function Internal(visit, appModelInteractionContext) {
3686
+ var _this = _super.call(this, false, appModelInteractionContext) || this;
3660
3687
  _this.isExternal = false;
3661
3688
  _this.storeVisit(visit);
3662
3689
  return _this;
@@ -3667,22 +3694,192 @@ if (false) {
3667
3694
  /** @type {?} */
3668
3695
  Internal.prototype.isExternal;
3669
3696
  }
3670
- /**
3671
- * @param {?} visit
3672
- * @return {?}
3673
- */
3674
- function createInternal(visit) {
3675
- return new Internal(visit);
3697
+ var Factory = /** @class */ (function () {
3698
+ function Factory(appModelInteractionContext) {
3699
+ this.appModelInteractionContext = appModelInteractionContext;
3700
+ }
3701
+ /**
3702
+ * @param {?} visit
3703
+ * @return {?}
3704
+ */
3705
+ Factory.prototype.createInternal = /**
3706
+ * @param {?} visit
3707
+ * @return {?}
3708
+ */
3709
+ function (visit) {
3710
+ return new Internal(visit, this.appModelInteractionContext);
3711
+ };
3712
+ /**
3713
+ * @param {?} firstTimeRoute
3714
+ * @return {?}
3715
+ */
3716
+ Factory.prototype.createExternal = /**
3717
+ * @param {?} firstTimeRoute
3718
+ * @return {?}
3719
+ */
3720
+ function (firstTimeRoute) {
3721
+ return new External(firstTimeRoute, this.appModelInteractionContext);
3722
+ };
3723
+ Factory.decorators = [
3724
+ { type: Injectable, args: [{
3725
+ providedIn: 'root'
3726
+ },] },
3727
+ ];
3728
+ /** @nocollapse */
3729
+ Factory.ctorParameters = function () { return [
3730
+ { type: InteractionContext }
3731
+ ]; };
3732
+ return Factory;
3733
+ }());
3734
+ NavigationSession.Factory = Factory;
3735
+ if (false) {
3736
+ /** @type {?} */
3737
+ Factory.prototype.appModelInteractionContext;
3676
3738
  }
3677
- NavigationSession.createInternal = createInternal;
3678
- /**
3679
- * @param {?} firstTimeRoute
3680
- * @return {?}
3681
- */
3682
- function createExternal(firstTimeRoute) {
3683
- return new External(firstTimeRoute);
3739
+ var ComponentDeactivationHandler = /** @class */ (function () {
3740
+ function ComponentDeactivationHandler(component, appModelInteractionContext, primary) {
3741
+ this.component = component;
3742
+ this.appModelInteractionContext = appModelInteractionContext;
3743
+ this.primary = primary;
3744
+ this.alreadyAccepted = false;
3745
+ // super();
3746
+ }
3747
+ /**
3748
+ * @param {?} nextState
3749
+ * @return {?}
3750
+ */
3751
+ ComponentDeactivationHandler.prototype.canDeactivate = /**
3752
+ * @param {?} nextState
3753
+ * @return {?}
3754
+ */
3755
+ function (nextState) {
3756
+ return __awaiter(this, void 0, void 0, function () {
3757
+ var _a;
3758
+ return __generator(this, function (_b) {
3759
+ switch (_b.label) {
3760
+ case 0:
3761
+ console.log(this.constructor.name + ".canDeactivate", { component: this.component });
3762
+ if (!this.alreadyAccepted) return [3 /*break*/, 1];
3763
+ // We'll get called multiple times if there's any parameter sanitisation so
3764
+ // we always return true if we accepted on a previous cycle of the current
3765
+ // navigation session.
3766
+ return [2 /*return*/, true];
3767
+ case 1:
3768
+ if (!(this.primary && this.appModelInteractionContext.isActive())) return [3 /*break*/, 3];
3769
+ // We check the global interaction first
3770
+ return [4 /*yield*/, this.cancelCurrentActivityOf(this.appModelInteractionContext)];
3771
+ case 2:
3772
+ // We check the global interaction first
3773
+ _b.sent();
3774
+ return [2 /*return*/, false];
3775
+ case 3:
3776
+ _a = this;
3777
+ return [4 /*yield*/, this.canDeactivateComponent(nextState)];
3778
+ case 4:
3779
+ _a.alreadyAccepted = _b.sent();
3780
+ return [2 /*return*/, this.alreadyAccepted];
3781
+ }
3782
+ });
3783
+ });
3784
+ };
3785
+ /**
3786
+ * @protected
3787
+ * @param {?} nextState
3788
+ * @return {?}
3789
+ */
3790
+ ComponentDeactivationHandler.prototype.canDeactivateComponent = /**
3791
+ * @protected
3792
+ * @param {?} nextState
3793
+ * @return {?}
3794
+ */
3795
+ function (nextState) {
3796
+ return __awaiter(this, void 0, void 0, function () {
3797
+ var hasCustomInteractionContext;
3798
+ return __generator(this, function (_a) {
3799
+ // check if the component has an active interaction. This will handle
3800
+ // an inplace interaction contexts
3801
+ hasCustomInteractionContext = this.component.interactionContext &&
3802
+ !this.isAppModalInteractionContext(this.component.interactionContext) &&
3803
+ this.component.interactionContext.isActive();
3804
+ if (hasCustomInteractionContext) {
3805
+ this.cancelCurrentActivityOf(this.component.interactionContext);
3806
+ return [2 /*return*/, false];
3807
+ }
3808
+ if (this.isLeavingCurrentPlace(nextState) && this.component.canDeactivate) {
3809
+ // No interaction in progress, so ask the component .
3810
+ // This may start an interaction, hence checking the interaction context before now. I.e. if the place pops up the dialog, and
3811
+ // the user clicks back again, we'll re-enter here and go bang when the component tries to open another dialog.
3812
+ return [2 /*return*/, this.component.canDeactivate()];
3813
+ }
3814
+ return [2 /*return*/, true];
3815
+ });
3816
+ });
3817
+ };
3818
+ /**
3819
+ * @param {?} interactionContext
3820
+ * @return {?}
3821
+ */
3822
+ ComponentDeactivationHandler.prototype.isAppModalInteractionContext = /**
3823
+ * @param {?} interactionContext
3824
+ * @return {?}
3825
+ */
3826
+ function (interactionContext) {
3827
+ return this.appModelInteractionContext === interactionContext;
3828
+ };
3829
+ /**
3830
+ * @protected
3831
+ * @param {?} interactionContext
3832
+ * @return {?}
3833
+ */
3834
+ ComponentDeactivationHandler.prototype.cancelCurrentActivityOf = /**
3835
+ * @protected
3836
+ * @param {?} interactionContext
3837
+ * @return {?}
3838
+ */
3839
+ function (interactionContext) {
3840
+ return __awaiter(this, void 0, void 0, function () {
3841
+ var activity;
3842
+ return __generator(this, function (_a) {
3843
+ switch (_a.label) {
3844
+ case 0: return [4 /*yield*/, interactionContext.getCurrentActivity()];
3845
+ case 1:
3846
+ activity = _a.sent();
3847
+ console.log('cancelling', { activity: activity });
3848
+ activity.cancel(null);
3849
+ return [2 /*return*/];
3850
+ }
3851
+ });
3852
+ });
3853
+ };
3854
+ /**
3855
+ * @protected
3856
+ * @param {?} nextState
3857
+ * @return {?}
3858
+ */
3859
+ ComponentDeactivationHandler.prototype.isLeavingCurrentPlace = /**
3860
+ * @protected
3861
+ * @param {?} nextState
3862
+ * @return {?}
3863
+ */
3864
+ function (nextState) {
3865
+ return !nextState.includesPathOf(this.component.placeDefinition);
3866
+ };
3867
+ return ComponentDeactivationHandler;
3868
+ }());
3869
+ NavigationSession.ComponentDeactivationHandler = ComponentDeactivationHandler;
3870
+ if (false) {
3871
+ /**
3872
+ * @type {?}
3873
+ * @private
3874
+ */
3875
+ ComponentDeactivationHandler.prototype.alreadyAccepted;
3876
+ /** @type {?} */
3877
+ ComponentDeactivationHandler.prototype.component;
3878
+ /** @type {?} */
3879
+ ComponentDeactivationHandler.prototype.appModelInteractionContext;
3880
+ /** @type {?} */
3881
+ ComponentDeactivationHandler.prototype.primary;
3684
3882
  }
3685
- NavigationSession.createExternal = createExternal;
3686
3883
  })(NavigationSession || (NavigationSession = {}));
3687
3884
 
3688
3885
  /**
@@ -3771,10 +3968,11 @@ if (false) {
3771
3968
  */
3772
3969
  var PlaceRouter = /** @class */ (function (_super) {
3773
3970
  __extends(PlaceRouter, _super);
3774
- function PlaceRouter(router, urlSerializer, angularLocation, placeHistory) {
3971
+ function PlaceRouter(router, urlSerializer, navigationSessionFactory, angularLocation, placeHistory) {
3775
3972
  var _this = _super.call(this) || this;
3776
3973
  _this.router = router;
3777
3974
  _this.urlSerializer = urlSerializer;
3975
+ _this.navigationSessionFactory = navigationSessionFactory;
3778
3976
  _this.angularLocation = angularLocation;
3779
3977
  _this.placeHistory = placeHistory;
3780
3978
  _this.firstRoute = true;
@@ -3804,8 +4002,11 @@ var PlaceRouter = /** @class */ (function (_super) {
3804
4002
  if (event instanceof NavigationStart) {
3805
4003
  _this.onAngularRouterStarted(event);
3806
4004
  }
3807
- if (event instanceof NavigationEnd || event instanceof NavigationError) {
3808
- _this.onAngularRouterFinished();
4005
+ if (event instanceof NavigationEnd) {
4006
+ _this.onAngularRouterFinished(false);
4007
+ }
4008
+ if (event instanceof NavigationError) {
4009
+ _this.onAngularRouterFinished(true);
3809
4010
  }
3810
4011
  }));
3811
4012
  _this.navigationSessionActive = chain(_this.navigationSessionModel).isNotNil();
@@ -3926,7 +4127,7 @@ var PlaceRouter = /** @class */ (function (_super) {
3926
4127
  */
3927
4128
  function (router) {
3928
4129
  /** @type {?} */
3929
- var commands = _this.createUrlManipulator(_this.router.routerState.snapshot).createRedirectCommandsFor(next);
4130
+ var commands = _this.parseUrl(_this.router.routerState.snapshot).createRedirectCommandsFor(next);
3930
4131
  // // we have to to use the definition for route id as our redirection always includes
3931
4132
  // // the id in the url segements (but leaves it blank when there's no id). I.e. in the
3932
4133
  // // no id case we're doing the following redirect [<placePath>, ""] -> ["..", <id>]
@@ -3959,7 +4160,7 @@ var PlaceRouter = /** @class */ (function (_super) {
3959
4160
  return __generator(this, function (_a) {
3960
4161
  switch (_a.label) {
3961
4162
  case 0:
3962
- this._navigationSessionModel.value = NavigationSession.createInternal(visit);
4163
+ this._navigationSessionModel.value = this.navigationSessionFactory.createInternal(visit);
3963
4164
  _a.label = 1;
3964
4165
  case 1:
3965
4166
  _a.trys.push([1, , 3, 4]);
@@ -3968,8 +4169,10 @@ var PlaceRouter = /** @class */ (function (_super) {
3968
4169
  _a.sent();
3969
4170
  return [3 /*break*/, 4];
3970
4171
  case 3:
4172
+ // Router has finished (since there was no router change required) so we
4173
+ // need to end the navigation session.
3971
4174
  if (this.navigationSession && !this.router.getCurrentNavigation()) {
3972
- this.onAngularRouterFinished();
4175
+ this.onAngularRouterFinished(false);
3973
4176
  }
3974
4177
  return [7 /*endfinally*/];
3975
4178
  case 4: return [2 /*return*/];
@@ -4012,9 +4215,9 @@ var PlaceRouter = /** @class */ (function (_super) {
4012
4215
  if (!this.navigationSession) { // We been activated by an external route rather than placeRouter.go(visit)
4013
4216
  console.log('navigation started', { firstTime: this.firstRoute });
4014
4217
  /** @type {?} */
4015
- var session = NavigationSession.createExternal(this.firstRoute);
4218
+ var session = this.navigationSessionFactory.createExternal(this.firstRoute);
4016
4219
  if (event.navigationTrigger === 'popstate') {
4017
- session.setPopstateReturn(this.router.routerState.snapshot.url);
4220
+ session.setPopstateReturnUrl(this.router.routerState.snapshot.url);
4018
4221
  }
4019
4222
  this._navigationSessionModel.value = session;
4020
4223
  }
@@ -4024,30 +4227,40 @@ var PlaceRouter = /** @class */ (function (_super) {
4024
4227
  // @Trace()
4025
4228
  /**
4026
4229
  * @private
4230
+ * @param {?} cancelled
4027
4231
  * @return {?}
4028
4232
  */
4029
4233
  PlaceRouter.prototype.onAngularRouterFinished =
4030
4234
  // @Trace()
4031
4235
  /**
4032
4236
  * @private
4237
+ * @param {?} cancelled
4033
4238
  * @return {?}
4034
4239
  */
4035
- function () {
4240
+ function (cancelled) {
4036
4241
  var _this = this;
4037
4242
  /** @type {?} */
4038
4243
  var session = this._navigationSessionModel.value;
4039
- // Update visits before we end the navigation session. This allows the place out let to
4040
- // gate ignore changes that occur while the visit is active
4041
- /** @type {?} */
4042
- var visits = session.getVisits();
4043
- visits.forEach((/**
4044
- * @param {?} v
4045
- * @return {?}
4046
- */
4047
- function (v) {
4048
- _this.placeHistory.add(v);
4049
- }));
4050
- this._activeVisits.value = visits;
4244
+ if (!cancelled) {
4245
+ // Update visits before we end the navigation session. This allows the placeOutets to
4246
+ // ignore visit changes that occur while the navigation is in progress
4247
+ /** @type {?} */
4248
+ var visits = session.getVisits();
4249
+ visits.forEach((/**
4250
+ * @param {?} v
4251
+ * @return {?}
4252
+ */
4253
+ function (v) { return _this.placeHistory.add(v); }));
4254
+ this._activeVisits.value = visits;
4255
+ }
4256
+ else {
4257
+ // Angular doesn't preserve the url when a guard cancels the back button.
4258
+ // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
4259
+ if (session.isPopState) {
4260
+ console.log('cancelled during popstate');
4261
+ this.angularLocation.go(session.popStateReturnUrl);
4262
+ }
4263
+ }
4051
4264
  this._navigationSessionModel.value = null;
4052
4265
  };
4053
4266
  /**
@@ -4069,12 +4282,12 @@ var PlaceRouter = /** @class */ (function (_super) {
4069
4282
  * @param {?} snapshot
4070
4283
  * @return {?}
4071
4284
  */
4072
- PlaceRouter.prototype.createUrlManipulator = /**
4285
+ PlaceRouter.prototype.parseUrl = /**
4073
4286
  * @param {?} snapshot
4074
4287
  * @return {?}
4075
4288
  */
4076
4289
  function (snapshot) {
4077
- return new PlaceRouter.UrlManipulator(this.urlSerializer.parse(snapshot.url));
4290
+ return new PlaceRouter.UrlHelper(this.urlSerializer.parse(snapshot.url));
4078
4291
  };
4079
4292
  PlaceRouter.decorators = [
4080
4293
  { type: Injectable, args: [{
@@ -4085,10 +4298,11 @@ var PlaceRouter = /** @class */ (function (_super) {
4085
4298
  PlaceRouter.ctorParameters = function () { return [
4086
4299
  { type: Router },
4087
4300
  { type: UrlSerializer },
4301
+ { type: NavigationSession.Factory },
4088
4302
  { type: Location },
4089
4303
  { type: PlaceHistory }
4090
4304
  ]; };
4091
- /** @nocollapse */ PlaceRouter.ngInjectableDef = ɵɵdefineInjectable({ factory: function PlaceRouter_Factory() { return new PlaceRouter(ɵɵinject(Router), ɵɵinject(UrlSerializer), ɵɵinject(Location), ɵɵinject(PlaceHistory)); }, token: PlaceRouter, providedIn: "root" });
4305
+ /** @nocollapse */ PlaceRouter.ngInjectableDef = ɵɵdefineInjectable({ factory: function PlaceRouter_Factory() { return new PlaceRouter(ɵɵinject(Router), ɵɵinject(UrlSerializer), ɵɵinject(NavigationSession.Factory), ɵɵinject(Location), ɵɵinject(PlaceHistory)); }, token: PlaceRouter, providedIn: "root" });
4092
4306
  __decorate([
4093
4307
  Trace(),
4094
4308
  __metadata("design:type", Function),
@@ -4127,21 +4341,26 @@ if (false) {
4127
4341
  * @private
4128
4342
  */
4129
4343
  PlaceRouter.prototype.urlSerializer;
4344
+ /**
4345
+ * @type {?}
4346
+ * @private
4347
+ */
4348
+ PlaceRouter.prototype.navigationSessionFactory;
4130
4349
  /** @type {?} */
4131
4350
  PlaceRouter.prototype.angularLocation;
4132
4351
  /** @type {?} */
4133
4352
  PlaceRouter.prototype.placeHistory;
4134
4353
  }
4135
4354
  (function (PlaceRouter) {
4136
- var UrlManipulator = /** @class */ (function () {
4137
- function UrlManipulator(urlTree) {
4355
+ var UrlHelper = /** @class */ (function () {
4356
+ function UrlHelper(urlTree) {
4138
4357
  this.urlTree = urlTree;
4139
4358
  console.log({ segments: this.urlTree.root.children.primary.segments });
4140
4359
  }
4141
4360
  /**
4142
4361
  * @return {?}
4143
4362
  */
4144
- UrlManipulator.prototype.cloneUrlSegmentList = /**
4363
+ UrlHelper.prototype.cloneUrlSegmentList = /**
4145
4364
  * @return {?}
4146
4365
  */
4147
4366
  function () {
@@ -4151,7 +4370,7 @@ if (false) {
4151
4370
  * @param {?} visit
4152
4371
  * @return {?}
4153
4372
  */
4154
- UrlManipulator.prototype.updateVisitSegments = /**
4373
+ UrlHelper.prototype.updateVisitSegments = /**
4155
4374
  * @param {?} visit
4156
4375
  * @return {?}
4157
4376
  */
@@ -4180,7 +4399,7 @@ if (false) {
4180
4399
  * @param {?} visit
4181
4400
  * @return {?}
4182
4401
  */
4183
- UrlManipulator.prototype.convertToUrlSegments = /**
4402
+ UrlHelper.prototype.convertToUrlSegments = /**
4184
4403
  * Converts the visit into segments. Please not that these segments are not e
4185
4404
  * @param {?} visit
4186
4405
  * @return {?}
@@ -4203,7 +4422,7 @@ if (false) {
4203
4422
  * @param {?} visit
4204
4423
  * @return {?}
4205
4424
  */
4206
- UrlManipulator.prototype.createRedirectCommandsFor = /**
4425
+ UrlHelper.prototype.createRedirectCommandsFor = /**
4207
4426
  * @param {?} visit
4208
4427
  * @return {?}
4209
4428
  */
@@ -4224,21 +4443,36 @@ if (false) {
4224
4443
  }));
4225
4444
  return commands;
4226
4445
  };
4446
+ /**
4447
+ * @param {?} placeDef
4448
+ * @return {?}
4449
+ */
4450
+ UrlHelper.prototype.includesPathOf = /**
4451
+ * @param {?} placeDef
4452
+ * @return {?}
4453
+ */
4454
+ function (placeDef) {
4455
+ return this.cloneUrlSegmentList().find((/**
4456
+ * @param {?} s
4457
+ * @return {?}
4458
+ */
4459
+ function (s) { return s.path === placeDef.path; }));
4460
+ };
4227
4461
  __decorate([
4228
4462
  Trace(),
4229
4463
  __metadata("design:type", Function),
4230
4464
  __metadata("design:paramtypes", [Visit]),
4231
4465
  __metadata("design:returntype", Array)
4232
- ], UrlManipulator.prototype, "createRedirectCommandsFor", null);
4233
- return UrlManipulator;
4466
+ ], UrlHelper.prototype, "createRedirectCommandsFor", null);
4467
+ return UrlHelper;
4234
4468
  }());
4235
- PlaceRouter.UrlManipulator = UrlManipulator;
4469
+ PlaceRouter.UrlHelper = UrlHelper;
4236
4470
  if (false) {
4237
4471
  /**
4238
4472
  * @type {?}
4239
4473
  * @private
4240
4474
  */
4241
- UrlManipulator.prototype.urlTree;
4475
+ UrlHelper.prototype.urlTree;
4242
4476
  }
4243
4477
  })(PlaceRouter || (PlaceRouter = {}));
4244
4478
 
@@ -6009,7 +6243,7 @@ var EnterPlaceGuard = /** @class */ (function () {
6009
6243
  this.placeRouter.navigationSession.storeVisit(sanitisedVisit);
6010
6244
  if (initialVisit.hasRoutingChangedFrom(sanitisedVisit)) {
6011
6245
  // Regenerate the url
6012
- commands = this.placeRouter.createUrlManipulator(state).createRedirectCommandsFor(sanitisedVisit);
6246
+ commands = this.placeRouter.parseUrl(state).createRedirectCommandsFor(sanitisedVisit);
6013
6247
  console.log('##### Place Guard Redirect', commands);
6014
6248
  return [2 /*return*/, this.router.createUrlTree(commands, {
6015
6249
  replaceUrl: true,
@@ -6231,90 +6465,9 @@ if (false) {
6231
6465
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
6232
6466
  */
6233
6467
  var LeavePlaceGuard = /** @class */ (function () {
6234
- function LeavePlaceGuard(router, injector, placeRouter, dialogInteractionContext, angularLocation) {
6235
- this.router = router;
6236
- this.injector = injector;
6468
+ function LeavePlaceGuard(placeRouter) {
6237
6469
  this.placeRouter = placeRouter;
6238
- this.dialogInteractionContext = dialogInteractionContext;
6239
- this.angularLocation = angularLocation;
6240
6470
  }
6241
- // @Trace()
6242
- // @Trace()
6243
- /**
6244
- * @private
6245
- * @param {?} nextState
6246
- * @param {?} placeDefinition
6247
- * @return {?}
6248
- */
6249
- LeavePlaceGuard.prototype.isLeavingTheCurrentPlace =
6250
- // @Trace()
6251
- /**
6252
- * @private
6253
- * @param {?} nextState
6254
- * @param {?} placeDefinition
6255
- * @return {?}
6256
- */
6257
- function (nextState, placeDefinition) {
6258
- // TODO: this will break with child routes... need to examine the router states properly.
6259
- // console.log('canDeactivate', {
6260
- // staticPath: placeDefinitionPath,
6261
- // currentStateUrl: currentState.url,
6262
- // nextStateUrl: nextState.url
6263
- // // alreadyDeclined: this._alreadyAccepted
6264
- // });
6265
- // Example of the above when navigating to a different child route.
6266
- // canDeactivate {staticPath: "/hero-details",
6267
- // currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-details",
6268
- // nextStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats"
6269
- // }
6270
- // TODO: this will break with child routes... need to examine the router states properly.
6271
- // console.log('canDeactivate', {
6272
- // staticPath: placeDefinitionPath,
6273
- // currentStateUrl: currentState.url,
6274
- // nextStateUrl: nextState.url
6275
- // // alreadyDeclined: this._alreadyAccepted
6276
- // });
6277
- // Example of the above when navigating to a different child route.
6278
- // canDeactivate {staticPath: "/hero-details",
6279
- // currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-details",
6280
- // nextStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats"
6281
- // }
6282
- // Example clicking on router tab of the parent component (de-activates the parent due to route param changes)
6283
- // canDeactivate {
6284
- // staticPath: "/hero-stats",
6285
- // currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats",
6286
- // nextStateUrl: "/route-parameters/"
6287
- // }
6288
- // canDeactivate {
6289
- // staticPath: "/route-parameters",
6290
- // currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats",
6291
- // nextStateUrl: "/route-parameters/"
6292
- // }
6293
- // logger.class.js:54 ParameterSnapshot.sanitise -> {idModel: -1, pv: undefined, pl: Array(0), dv: undefined, dl: Array(0), …}
6294
- // parameter-snapshot.ts:20 {name: "idModel", mine: -1, theirs: null}
6295
- // place-router.ts:28 redirect path (3) ["route-parameters", "-1", {…}]
6296
- // canDeactivate {
6297
- // staticPath: "/hero-stats",
6298
- // currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats",
6299
- // nextStateUrl: "/route-parameters/-1"
6300
- // }
6301
- // canDeactivate {
6302
- // staticPath: "/route-parameters",
6303
- // currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats",
6304
- // nextStateUrl: "/route-parameters/-1"
6305
- // }
6306
- // logger.class.js:54 ParameterSnapshot.sanitise -> {idModel: -1, pv: undefined, pl: Array(0), dv: "A", dl: Array(3), …}
6307
- // parameter-snapshot.ts:20 {name: "dv", mine: "A", theirs: undefined}
6308
- // place-router.ts:28 redirect path (3) ["route-parameters", "-1", {…}]
6309
- // canDeactivate {
6310
- // staticPath: "/hero-stats",
6311
- // currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats",
6312
- // nextStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c"
6313
- // }
6314
- /** @type {?} */
6315
- var placeDefinitionPath = "/" + placeDefinition.path;
6316
- return !nextState.url.startsWith(placeDefinitionPath);
6317
- };
6318
6471
  /**
6319
6472
  * @param {?} component
6320
6473
  * @param {?} currentRoute
@@ -6331,72 +6484,8 @@ var LeavePlaceGuard = /** @class */ (function () {
6331
6484
  */
6332
6485
  function (component, currentRoute, currentState, nextState) {
6333
6486
  return __awaiter(this, void 0, void 0, function () {
6334
- var self_1, canLeave;
6335
6487
  return __generator(this, function (_a) {
6336
- switch (_a.label) {
6337
- case 0:
6338
- if (!this.placeRouter.navigationSession.alreadyAccepted(component)) return [3 /*break*/, 1];
6339
- // We'll get called multiple times if there's any parameter sanitisation so
6340
- // we always return true if we accepted on a previous cycle of the current
6341
- // navigation session.
6342
- return [2 /*return*/, true];
6343
- case 1:
6344
- self_1 = this;
6345
- canLeave = true;
6346
- if (!this.isLeavingTheCurrentPlace(nextState, component.placeDefinition)) return [3 /*break*/, 4];
6347
- // we check the dialog interaction first, so that components that don't need to check if they're in an
6348
- // interaction during the canDeactivate cycle.
6349
- // TODO: Add tests: show dialog -> hit back -> same route
6350
- if (this.dialogInteractionContext.isActive()) {
6351
- console.log('cancelling', { activity: this.dialogInteractionContext.currentActivity });
6352
- this.dialogInteractionContext.currentActivity.cancel(null);
6353
- canLeave = false;
6354
- }
6355
- else {
6356
- canLeave = true;
6357
- }
6358
- if (canLeave) {
6359
- // now check if the component has an active interaction. This will handle
6360
- // an inplace interaction contexts
6361
- if (component.interactionContext && component.interactionContext.isActive()) {
6362
- canLeave = false;
6363
- console.log('cancelling', { activity: component.interactionContext.currentActivity });
6364
- component.interactionContext.currentActivity.cancel(null);
6365
- }
6366
- }
6367
- if (!canLeave) return [3 /*break*/, 3];
6368
- return [4 /*yield*/, component.canDeactivate()];
6369
- case 2:
6370
- // TODO: Add tests: hit back -> confirm leave dialog -> hit back -> close dialog -> hit back -> confirm leave dialog.
6371
- canLeave = _a.sent();
6372
- _a.label = 3;
6373
- case 3: return [3 /*break*/, 5];
6374
- case 4:
6375
- if (this.dialogInteractionContext.isActive()) {
6376
- console.log('cancelling', { activity: this.dialogInteractionContext.currentActivity });
6377
- this.dialogInteractionContext.currentActivity.cancel(null);
6378
- canLeave = false;
6379
- }
6380
- else {
6381
- canLeave = true;
6382
- }
6383
- _a.label = 5;
6384
- case 5:
6385
- if (canLeave) {
6386
- // We'll get called multiple times if there's any parameter sanitisation so
6387
- // we remember the acceptance for the duration of the current navigation session.
6388
- self_1.placeRouter.navigationSession.rememberAcceptanceOf(component);
6389
- }
6390
- else {
6391
- // Angular doesn't preserve the url when a guard cancels the back button.
6392
- // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
6393
- if (this.placeRouter.navigationSession.isPopState) {
6394
- console.log('cancelled during popstate');
6395
- this.angularLocation.go(this.placeRouter.navigationSession.popStateReturnUrl);
6396
- }
6397
- }
6398
- return [2 /*return*/, canLeave];
6399
- }
6488
+ return [2 /*return*/, this.placeRouter.navigationSession.canDeactivate(component, this.placeRouter.parseUrl(nextState))];
6400
6489
  });
6401
6490
  });
6402
6491
  };
@@ -6407,35 +6496,17 @@ var LeavePlaceGuard = /** @class */ (function () {
6407
6496
  ];
6408
6497
  /** @nocollapse */
6409
6498
  LeavePlaceGuard.ctorParameters = function () { return [
6410
- { type: Router },
6411
- { type: Injector },
6412
- { type: PlaceRouter },
6413
- { type: InteractionContext },
6414
- { type: Location }
6499
+ { type: PlaceRouter }
6415
6500
  ]; };
6416
- /** @nocollapse */ LeavePlaceGuard.ngInjectableDef = ɵɵdefineInjectable({ factory: function LeavePlaceGuard_Factory() { return new LeavePlaceGuard(ɵɵinject(Router), ɵɵinject(INJECTOR), ɵɵinject(PlaceRouter), ɵɵinject(InteractionContext), ɵɵinject(Location)); }, token: LeavePlaceGuard, providedIn: "root" });
6501
+ /** @nocollapse */ LeavePlaceGuard.ngInjectableDef = ɵɵdefineInjectable({ factory: function LeavePlaceGuard_Factory() { return new LeavePlaceGuard(ɵɵinject(PlaceRouter)); }, token: LeavePlaceGuard, providedIn: "root" });
6417
6502
  return LeavePlaceGuard;
6418
6503
  }());
6419
6504
  if (false) {
6420
- /**
6421
- * @type {?}
6422
- * @private
6423
- */
6424
- LeavePlaceGuard.prototype.router;
6425
- /**
6426
- * @type {?}
6427
- * @private
6428
- */
6429
- LeavePlaceGuard.prototype.injector;
6430
6505
  /**
6431
6506
  * @type {?}
6432
6507
  * @private
6433
6508
  */
6434
6509
  LeavePlaceGuard.prototype.placeRouter;
6435
- /** @type {?} */
6436
- LeavePlaceGuard.prototype.dialogInteractionContext;
6437
- /** @type {?} */
6438
- LeavePlaceGuard.prototype.angularLocation;
6439
6510
  }
6440
6511
 
6441
6512
  /**
@@ -6458,5 +6529,5 @@ if (false) {
6458
6529
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
6459
6530
  */
6460
6531
 
6461
- export { ACTIVITY_DATA, AUP_PLACE_CONFIG, AbstractActivity, AbstractInputComponent, AbstractPlaceNavigationComponent, Activity, ActivityContainerComponent, ActivityOutletComponent, AlertDialogComponent, AngularUiPowerupsModule, Bounds, BusyOverlayComponent, CommandDirective, ComponentsModule, ConfirmThenDialogComponent, ConfirmationDialogComponent, DEFINITION_META_DATA_KEY, DIALOG_INTERACTION_SERVICE_DEFAULTS, DialogInteractionService, Dimension, DirectivesModule, DisposableComponent, EmptyStateComponent, EnterPlaceGuard, FocusBindingDirective, Formatter, InplaceInteractionContextComponent, InteractionContext, InteractionGuard, InteractionModule, InteractionOutletComponent, LEFT_RIGHT_PLACE_ANIMATION, LeavePlaceGuard, ListPlaceNavComponent, NavigationSession, NoopComponent, NumberInputComponent, ParameterDefinition, PasswordInputComponent, Place, PlaceComponent, PlaceDefinition, PlaceHistory, PlaceModule, PlaceOutletComponent, PlaceRouter, Point, ROUTE_PARAMETER_LIST_KEY, ResizeAwareComponent, RouteId, SelectInputComponent, StringInputComponent, TabbedPlaceNavigationComponent, Visit, VisitParameter, VisitParameterList, VisitSanitiser, leftRightPlaceAnimation, slideDownAndUpAnimation, DirectivesModule as ɵa, CommandDirective as ɵb, InteractionContext as ɵba, ActivityOutletComponent as ɵbb, ConfirmationDialogComponent as ɵbc, AbstractActivity as ɵbd, ACTIVITY_DATA as ɵbe, Activity as ɵbf, ConfirmThenDialogComponent as ɵbh, AlertDialogComponent as ɵbi, InteractionOutletComponent as ɵbk, InplaceInteractionContextComponent as ɵbl, DIALOG_INTERACTION_SERVICE_DEFAULTS as ɵbm, DialogInteractionService as ɵbn, FocusBindingDirective as ɵc, DisposableComponent as ɵd, ComponentsModule as ɵe, NumberInputComponent as ɵf, AbstractInputComponent as ɵg, StringInputComponent as ɵh, PasswordInputComponent as ɵi, SelectInputComponent as ɵj, NoopComponent as ɵk, PlaceModule as ɵl, EmptyStateComponent as ɵm, BusyOverlayComponent as ɵn, PlaceOutletComponent as ɵo, leftRightPlaceAnimation as ɵp, LEFT_RIGHT_PLACE_ANIMATION as ɵq, AUP_PLACE_CONFIG as ɵr, PlaceRouter as ɵt, PlaceHistory as ɵu, TabbedPlaceNavigationComponent as ɵv, AbstractPlaceNavigationComponent as ɵw, ListPlaceNavComponent as ɵx, InteractionModule as ɵy, ActivityContainerComponent as ɵz };
6532
+ export { ACTIVITY_DATA, AUP_PLACE_CONFIG, AbstractActivity, AbstractInputComponent, AbstractPlaceNavigationComponent, Activity, ActivityContainerComponent, ActivityOutletComponent, AlertDialogComponent, AngularUiPowerupsModule, Bounds, BusyOverlayComponent, CommandDirective, ComponentsModule, ConfirmThenDialogComponent, ConfirmationDialogComponent, DEFINITION_META_DATA_KEY, DIALOG_INTERACTION_SERVICE_DEFAULTS, DialogInteractionService, Dimension, DirectivesModule, DisposableComponent, EmptyStateComponent, EnterPlaceGuard, FocusBindingDirective, Formatter, InplaceInteractionContextComponent, InteractionContext, InteractionGuard, InteractionModule, InteractionOutletComponent, LEFT_RIGHT_PLACE_ANIMATION, LeavePlaceGuard, ListPlaceNavComponent, NavigationSession, NoopComponent, NumberInputComponent, ParameterDefinition, PasswordInputComponent, Place, PlaceComponent, PlaceDefinition, PlaceHistory, PlaceModule, PlaceOutletComponent, PlaceRouter, Point, ROUTE_PARAMETER_LIST_KEY, ResizeAwareComponent, RouteId, SelectInputComponent, StringInputComponent, TabbedPlaceNavigationComponent, Visit, VisitParameter, VisitParameterList, VisitSanitiser, leftRightPlaceAnimation, slideDownAndUpAnimation, DirectivesModule as ɵa, CommandDirective as ɵb, InteractionModule as ɵba, ActivityContainerComponent as ɵbb, ActivityOutletComponent as ɵbc, ConfirmationDialogComponent as ɵbd, AbstractActivity as ɵbe, ACTIVITY_DATA as ɵbf, Activity as ɵbg, ConfirmThenDialogComponent as ɵbi, AlertDialogComponent as ɵbj, InteractionOutletComponent as ɵbl, InplaceInteractionContextComponent as ɵbm, DIALOG_INTERACTION_SERVICE_DEFAULTS as ɵbn, DialogInteractionService as ɵbo, FocusBindingDirective as ɵc, DisposableComponent as ɵd, ComponentsModule as ɵe, NumberInputComponent as ɵf, AbstractInputComponent as ɵg, StringInputComponent as ɵh, PasswordInputComponent as ɵi, SelectInputComponent as ɵj, NoopComponent as ɵk, PlaceModule as ɵl, EmptyStateComponent as ɵm, BusyOverlayComponent as ɵn, PlaceOutletComponent as ɵo, leftRightPlaceAnimation as ɵp, LEFT_RIGHT_PLACE_ANIMATION as ɵq, AUP_PLACE_CONFIG as ɵr, PlaceRouter as ɵt, NavigationSession as ɵu, InteractionContext as ɵv, PlaceHistory as ɵw, TabbedPlaceNavigationComponent as ɵx, AbstractPlaceNavigationComponent as ɵy, ListPlaceNavComponent as ɵz };
6462
6533
  //# sourceMappingURL=coolon-angular-ui-powerups.js.map