@coolon/angular-ui-powerups 0.0.90 → 0.0.92

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/bundles/coolon-angular-ui-powerups.umd.js +432 -364
  2. package/bundles/coolon-angular-ui-powerups.umd.js.map +1 -1
  3. package/bundles/coolon-angular-ui-powerups.umd.min.js +1 -1
  4. package/bundles/coolon-angular-ui-powerups.umd.min.js.map +1 -1
  5. package/coolon-angular-ui-powerups.d.ts +7 -7
  6. package/coolon-angular-ui-powerups.metadata.json +1 -1
  7. package/esm2015/coolon-angular-ui-powerups.js +8 -8
  8. package/esm2015/lib/directives/command.directive.js +28 -5
  9. package/esm2015/lib/interaction/components/activity-container/activity-container.component.js +2 -7
  10. package/esm2015/lib/interaction/components/inplace-interaction-context/inplace-interaction-context.component.js +3 -8
  11. package/esm2015/lib/interaction/interaction-context.js +70 -14
  12. package/esm2015/lib/interaction/services/dialog-interaction.service.js +11 -19
  13. package/esm2015/lib/place/navigation-session.js +171 -39
  14. package/esm2015/lib/place/place-component.js +4 -19
  15. package/esm2015/lib/place/place-router.js +72 -31
  16. package/esm2015/lib/place/route/guards/enter-place-guard.service.js +2 -2
  17. package/esm2015/lib/place/route/guards/leave-place.guard.js +7 -177
  18. package/esm5/coolon-angular-ui-powerups.js +8 -8
  19. package/esm5/lib/directives/command.directive.js +32 -5
  20. package/esm5/lib/interaction/components/activity-container/activity-container.component.js +2 -11
  21. package/esm5/lib/interaction/components/inplace-interaction-context/inplace-interaction-context.component.js +3 -12
  22. package/esm5/lib/interaction/interaction-context.js +89 -27
  23. package/esm5/lib/interaction/services/dialog-interaction.service.js +11 -22
  24. package/esm5/lib/place/navigation-session.js +214 -54
  25. package/esm5/lib/place/place-component.js +4 -35
  26. package/esm5/lib/place/place-router.js +82 -37
  27. package/esm5/lib/place/route/guards/enter-place-guard.service.js +2 -2
  28. package/esm5/lib/place/route/guards/leave-place.guard.js +7 -176
  29. package/fesm2015/coolon-angular-ui-powerups.js +350 -299
  30. package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
  31. package/fesm5/coolon-angular-ui-powerups.js +427 -359
  32. package/fesm5/coolon-angular-ui-powerups.js.map +1 -1
  33. package/lib/directives/command.directive.d.ts +2 -0
  34. package/lib/interaction/components/activity-container/activity-container.component.d.ts +1 -2
  35. package/lib/interaction/components/inplace-interaction-context/inplace-interaction-context.component.d.ts +3 -4
  36. package/lib/interaction/interaction-context.d.ts +6 -3
  37. package/lib/interaction/services/dialog-interaction.service.d.ts +3 -5
  38. package/lib/place/navigation-session.d.ts +26 -9
  39. package/lib/place/place-component.d.ts +4 -9
  40. package/lib/place/place-router.d.ts +8 -3
  41. package/lib/place/route/guards/leave-place.guard.d.ts +2 -10
  42. package/package.json +1 -1
@@ -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')];
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
+ }
937
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;
2222
- };
2223
- /**
2224
- * @return {?}
2225
- */
2226
- DialogInteractionService.prototype.cancelActivity = /**
2227
- * @return {?}
2228
- */
2229
- function () {
2230
- this.currentActivity.cancel(null);
2290
+ return this._inActivityPromise.value;
2231
2291
  };
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,183 @@ 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(interactionContext) {
3699
+ this.interactionContext = interactionContext;
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.interactionContext);
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.interactionContext);
3722
+ };
3723
+ return Factory;
3724
+ }());
3725
+ NavigationSession.Factory = Factory;
3726
+ if (false) {
3727
+ /** @type {?} */
3728
+ Factory.prototype.interactionContext;
3676
3729
  }
3677
- NavigationSession.createInternal = createInternal;
3678
- /**
3679
- * @param {?} firstTimeRoute
3680
- * @return {?}
3681
- */
3682
- function createExternal(firstTimeRoute) {
3683
- return new External(firstTimeRoute);
3730
+ var ComponentDeactivationHandler = /** @class */ (function () {
3731
+ function ComponentDeactivationHandler(component, appModelInteractionContext, primary) {
3732
+ this.component = component;
3733
+ this.appModelInteractionContext = appModelInteractionContext;
3734
+ this.primary = primary;
3735
+ this.alreadyAccepted = false;
3736
+ // super();
3737
+ }
3738
+ /**
3739
+ * @param {?} nextState
3740
+ * @return {?}
3741
+ */
3742
+ ComponentDeactivationHandler.prototype.canDeactivate = /**
3743
+ * @param {?} nextState
3744
+ * @return {?}
3745
+ */
3746
+ function (nextState) {
3747
+ return __awaiter(this, void 0, void 0, function () {
3748
+ var _a;
3749
+ return __generator(this, function (_b) {
3750
+ switch (_b.label) {
3751
+ case 0:
3752
+ console.log(this.constructor.name + ".canDeactivate", { component: this.component });
3753
+ if (!this.alreadyAccepted) return [3 /*break*/, 1];
3754
+ // We'll get called multiple times if there's any parameter sanitisation so
3755
+ // we always return true if we accepted on a previous cycle of the current
3756
+ // navigation session.
3757
+ return [2 /*return*/, true];
3758
+ case 1:
3759
+ if (!(this.primary && this.appModelInteractionContext.isActive())) return [3 /*break*/, 3];
3760
+ // We check the global interaction first
3761
+ return [4 /*yield*/, this.cancelCurrentActivityOf(this.appModelInteractionContext)];
3762
+ case 2:
3763
+ // We check the global interaction first
3764
+ _b.sent();
3765
+ return [2 /*return*/, false];
3766
+ case 3:
3767
+ _a = this;
3768
+ return [4 /*yield*/, this.canDeactivateComponent(nextState)];
3769
+ case 4:
3770
+ _a.alreadyAccepted = _b.sent();
3771
+ return [2 /*return*/, this.alreadyAccepted];
3772
+ }
3773
+ });
3774
+ });
3775
+ };
3776
+ /**
3777
+ * @protected
3778
+ * @param {?} nextState
3779
+ * @return {?}
3780
+ */
3781
+ ComponentDeactivationHandler.prototype.canDeactivateComponent = /**
3782
+ * @protected
3783
+ * @param {?} nextState
3784
+ * @return {?}
3785
+ */
3786
+ function (nextState) {
3787
+ return __awaiter(this, void 0, void 0, function () {
3788
+ var hasCustomInteractionContext;
3789
+ return __generator(this, function (_a) {
3790
+ // check if the component has an active interaction. This will handle
3791
+ // an inplace interaction contexts
3792
+ hasCustomInteractionContext = this.component.interactionContext &&
3793
+ !this.isAppModalInteractionContext(this.component.interactionContext) &&
3794
+ this.component.interactionContext.isActive();
3795
+ if (hasCustomInteractionContext) {
3796
+ this.cancelCurrentActivityOf(this.component.interactionContext);
3797
+ return [2 /*return*/, false];
3798
+ }
3799
+ if (this.isLeavingCurrentPlace(nextState) && this.component.canDeactivate) {
3800
+ // No interaction in progress, so ask the component .
3801
+ // This may start an interaction, hence checking the interaction context before now. I.e. if the place pops up the dialog, and
3802
+ // the user clicks back again, we'll re-enter here and go bang when the component tries to open another dialog.
3803
+ return [2 /*return*/, this.component.canDeactivate()];
3804
+ }
3805
+ return [2 /*return*/, true];
3806
+ });
3807
+ });
3808
+ };
3809
+ /**
3810
+ * @param {?} interactionContext
3811
+ * @return {?}
3812
+ */
3813
+ ComponentDeactivationHandler.prototype.isAppModalInteractionContext = /**
3814
+ * @param {?} interactionContext
3815
+ * @return {?}
3816
+ */
3817
+ function (interactionContext) {
3818
+ return this.appModelInteractionContext === interactionContext;
3819
+ };
3820
+ /**
3821
+ * @protected
3822
+ * @param {?} interactionContext
3823
+ * @return {?}
3824
+ */
3825
+ ComponentDeactivationHandler.prototype.cancelCurrentActivityOf = /**
3826
+ * @protected
3827
+ * @param {?} interactionContext
3828
+ * @return {?}
3829
+ */
3830
+ function (interactionContext) {
3831
+ return __awaiter(this, void 0, void 0, function () {
3832
+ var activity;
3833
+ return __generator(this, function (_a) {
3834
+ switch (_a.label) {
3835
+ case 0: return [4 /*yield*/, interactionContext.getCurrentActivity()];
3836
+ case 1:
3837
+ activity = _a.sent();
3838
+ console.log('cancelling', { activity: activity });
3839
+ activity.cancel(null);
3840
+ return [2 /*return*/];
3841
+ }
3842
+ });
3843
+ });
3844
+ };
3845
+ /**
3846
+ * @protected
3847
+ * @param {?} nextState
3848
+ * @return {?}
3849
+ */
3850
+ ComponentDeactivationHandler.prototype.isLeavingCurrentPlace = /**
3851
+ * @protected
3852
+ * @param {?} nextState
3853
+ * @return {?}
3854
+ */
3855
+ function (nextState) {
3856
+ return !nextState.includesPathOf(this.component.placeDefinition);
3857
+ };
3858
+ return ComponentDeactivationHandler;
3859
+ }());
3860
+ NavigationSession.ComponentDeactivationHandler = ComponentDeactivationHandler;
3861
+ if (false) {
3862
+ /**
3863
+ * @type {?}
3864
+ * @private
3865
+ */
3866
+ ComponentDeactivationHandler.prototype.alreadyAccepted;
3867
+ /** @type {?} */
3868
+ ComponentDeactivationHandler.prototype.component;
3869
+ /** @type {?} */
3870
+ ComponentDeactivationHandler.prototype.appModelInteractionContext;
3871
+ /** @type {?} */
3872
+ ComponentDeactivationHandler.prototype.primary;
3684
3873
  }
3685
- NavigationSession.createExternal = createExternal;
3686
3874
  })(NavigationSession || (NavigationSession = {}));
3687
3875
 
3688
3876
  /**
@@ -3771,10 +3959,11 @@ if (false) {
3771
3959
  */
3772
3960
  var PlaceRouter = /** @class */ (function (_super) {
3773
3961
  __extends(PlaceRouter, _super);
3774
- function PlaceRouter(router, urlSerializer, angularLocation, placeHistory) {
3962
+ function PlaceRouter(router, urlSerializer, interactionContext, angularLocation, placeHistory) {
3775
3963
  var _this = _super.call(this) || this;
3776
3964
  _this.router = router;
3777
3965
  _this.urlSerializer = urlSerializer;
3966
+ _this.interactionContext = interactionContext;
3778
3967
  _this.angularLocation = angularLocation;
3779
3968
  _this.placeHistory = placeHistory;
3780
3969
  _this.firstRoute = true;
@@ -3782,6 +3971,7 @@ var PlaceRouter = /** @class */ (function (_super) {
3782
3971
  _this._activeVisits = new MutableListModel();
3783
3972
  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;
3784
3973
  _this.activeVisitIndex = chain(_this._activeVisits).indexBy('placeDefinition');
3974
+ _this.navigationSessionFactory = new NavigationSession.Factory(interactionContext);
3785
3975
  angularLocation.onUrlChange((/**
3786
3976
  * @param {?} url
3787
3977
  * @return {?}
@@ -3804,8 +3994,11 @@ var PlaceRouter = /** @class */ (function (_super) {
3804
3994
  if (event instanceof NavigationStart) {
3805
3995
  _this.onAngularRouterStarted(event);
3806
3996
  }
3807
- if (event instanceof NavigationEnd || event instanceof NavigationError) {
3808
- _this.onAngularRouterFinished();
3997
+ if (event instanceof NavigationEnd) {
3998
+ _this.onAngularRouterFinished(false);
3999
+ }
4000
+ if (event instanceof NavigationError) {
4001
+ _this.onAngularRouterFinished(true);
3809
4002
  }
3810
4003
  }));
3811
4004
  _this.navigationSessionActive = chain(_this.navigationSessionModel).isNotNil();
@@ -3926,7 +4119,7 @@ var PlaceRouter = /** @class */ (function (_super) {
3926
4119
  */
3927
4120
  function (router) {
3928
4121
  /** @type {?} */
3929
- var commands = _this.createUrlManipulator(_this.router.routerState.snapshot).createRedirectCommandsFor(next);
4122
+ var commands = _this.parseUrl(_this.router.routerState.snapshot).createRedirectCommandsFor(next);
3930
4123
  // // we have to to use the definition for route id as our redirection always includes
3931
4124
  // // the id in the url segements (but leaves it blank when there's no id). I.e. in the
3932
4125
  // // no id case we're doing the following redirect [<placePath>, ""] -> ["..", <id>]
@@ -3959,7 +4152,7 @@ var PlaceRouter = /** @class */ (function (_super) {
3959
4152
  return __generator(this, function (_a) {
3960
4153
  switch (_a.label) {
3961
4154
  case 0:
3962
- this._navigationSessionModel.value = NavigationSession.createInternal(visit);
4155
+ this._navigationSessionModel.value = this.navigationSessionFactory.createInternal(visit);
3963
4156
  _a.label = 1;
3964
4157
  case 1:
3965
4158
  _a.trys.push([1, , 3, 4]);
@@ -3968,8 +4161,10 @@ var PlaceRouter = /** @class */ (function (_super) {
3968
4161
  _a.sent();
3969
4162
  return [3 /*break*/, 4];
3970
4163
  case 3:
4164
+ // Router has finished (since there was no router change required) so we
4165
+ // need to end the navigation session.
3971
4166
  if (this.navigationSession && !this.router.getCurrentNavigation()) {
3972
- this.onAngularRouterFinished();
4167
+ this.onAngularRouterFinished(false);
3973
4168
  }
3974
4169
  return [7 /*endfinally*/];
3975
4170
  case 4: return [2 /*return*/];
@@ -4012,9 +4207,9 @@ var PlaceRouter = /** @class */ (function (_super) {
4012
4207
  if (!this.navigationSession) { // We been activated by an external route rather than placeRouter.go(visit)
4013
4208
  console.log('navigation started', { firstTime: this.firstRoute });
4014
4209
  /** @type {?} */
4015
- var session = NavigationSession.createExternal(this.firstRoute);
4210
+ var session = this.navigationSessionFactory.createExternal(this.firstRoute);
4016
4211
  if (event.navigationTrigger === 'popstate') {
4017
- session.setPopstateReturn(this.router.routerState.snapshot.url);
4212
+ session.setPopstateReturnUrl(this.router.routerState.snapshot.url);
4018
4213
  }
4019
4214
  this._navigationSessionModel.value = session;
4020
4215
  }
@@ -4024,30 +4219,40 @@ var PlaceRouter = /** @class */ (function (_super) {
4024
4219
  // @Trace()
4025
4220
  /**
4026
4221
  * @private
4222
+ * @param {?} cancelled
4027
4223
  * @return {?}
4028
4224
  */
4029
4225
  PlaceRouter.prototype.onAngularRouterFinished =
4030
4226
  // @Trace()
4031
4227
  /**
4032
4228
  * @private
4229
+ * @param {?} cancelled
4033
4230
  * @return {?}
4034
4231
  */
4035
- function () {
4232
+ function (cancelled) {
4036
4233
  var _this = this;
4037
4234
  /** @type {?} */
4038
4235
  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;
4236
+ if (!cancelled) {
4237
+ // Update visits before we end the navigation session. This allows the placeOutets to
4238
+ // ignore visit changes that occur while the navigation is in progress
4239
+ /** @type {?} */
4240
+ var visits = session.getVisits();
4241
+ visits.forEach((/**
4242
+ * @param {?} v
4243
+ * @return {?}
4244
+ */
4245
+ function (v) { return _this.placeHistory.add(v); }));
4246
+ this._activeVisits.value = visits;
4247
+ }
4248
+ else {
4249
+ // Angular doesn't preserve the url when a guard cancels the back button.
4250
+ // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
4251
+ if (session.isPopState) {
4252
+ console.log('cancelled during popstate');
4253
+ this.angularLocation.go(session.popStateReturnUrl);
4254
+ }
4255
+ }
4051
4256
  this._navigationSessionModel.value = null;
4052
4257
  };
4053
4258
  /**
@@ -4069,12 +4274,12 @@ var PlaceRouter = /** @class */ (function (_super) {
4069
4274
  * @param {?} snapshot
4070
4275
  * @return {?}
4071
4276
  */
4072
- PlaceRouter.prototype.createUrlManipulator = /**
4277
+ PlaceRouter.prototype.parseUrl = /**
4073
4278
  * @param {?} snapshot
4074
4279
  * @return {?}
4075
4280
  */
4076
4281
  function (snapshot) {
4077
- return new PlaceRouter.UrlManipulator(this.urlSerializer.parse(snapshot.url));
4282
+ return new PlaceRouter.UrlHelper(this.urlSerializer.parse(snapshot.url));
4078
4283
  };
4079
4284
  PlaceRouter.decorators = [
4080
4285
  { type: Injectable, args: [{
@@ -4085,10 +4290,11 @@ var PlaceRouter = /** @class */ (function (_super) {
4085
4290
  PlaceRouter.ctorParameters = function () { return [
4086
4291
  { type: Router },
4087
4292
  { type: UrlSerializer },
4293
+ { type: InteractionContext },
4088
4294
  { type: Location },
4089
4295
  { type: PlaceHistory }
4090
4296
  ]; };
4091
- /** @nocollapse */ PlaceRouter.ngInjectableDef = ɵɵdefineInjectable({ factory: function PlaceRouter_Factory() { return new PlaceRouter(ɵɵinject(Router), ɵɵinject(UrlSerializer), ɵɵinject(Location), ɵɵinject(PlaceHistory)); }, token: PlaceRouter, providedIn: "root" });
4297
+ /** @nocollapse */ PlaceRouter.ngInjectableDef = ɵɵdefineInjectable({ factory: function PlaceRouter_Factory() { return new PlaceRouter(ɵɵinject(Router), ɵɵinject(UrlSerializer), ɵɵinject(InteractionContext), ɵɵinject(Location), ɵɵinject(PlaceHistory)); }, token: PlaceRouter, providedIn: "root" });
4092
4298
  __decorate([
4093
4299
  Trace(),
4094
4300
  __metadata("design:type", Function),
@@ -4117,6 +4323,11 @@ if (false) {
4117
4323
  PlaceRouter.prototype.navigationSessionActive;
4118
4324
  /** @type {?} */
4119
4325
  PlaceRouter.prototype.activeVisitIndex;
4326
+ /**
4327
+ * @type {?}
4328
+ * @private
4329
+ */
4330
+ PlaceRouter.prototype.navigationSessionFactory;
4120
4331
  /**
4121
4332
  * @type {?}
4122
4333
  * @private
@@ -4127,21 +4338,26 @@ if (false) {
4127
4338
  * @private
4128
4339
  */
4129
4340
  PlaceRouter.prototype.urlSerializer;
4341
+ /**
4342
+ * @type {?}
4343
+ * @private
4344
+ */
4345
+ PlaceRouter.prototype.interactionContext;
4130
4346
  /** @type {?} */
4131
4347
  PlaceRouter.prototype.angularLocation;
4132
4348
  /** @type {?} */
4133
4349
  PlaceRouter.prototype.placeHistory;
4134
4350
  }
4135
4351
  (function (PlaceRouter) {
4136
- var UrlManipulator = /** @class */ (function () {
4137
- function UrlManipulator(urlTree) {
4352
+ var UrlHelper = /** @class */ (function () {
4353
+ function UrlHelper(urlTree) {
4138
4354
  this.urlTree = urlTree;
4139
4355
  console.log({ segments: this.urlTree.root.children.primary.segments });
4140
4356
  }
4141
4357
  /**
4142
4358
  * @return {?}
4143
4359
  */
4144
- UrlManipulator.prototype.cloneUrlSegmentList = /**
4360
+ UrlHelper.prototype.cloneUrlSegmentList = /**
4145
4361
  * @return {?}
4146
4362
  */
4147
4363
  function () {
@@ -4151,7 +4367,7 @@ if (false) {
4151
4367
  * @param {?} visit
4152
4368
  * @return {?}
4153
4369
  */
4154
- UrlManipulator.prototype.updateVisitSegments = /**
4370
+ UrlHelper.prototype.updateVisitSegments = /**
4155
4371
  * @param {?} visit
4156
4372
  * @return {?}
4157
4373
  */
@@ -4180,7 +4396,7 @@ if (false) {
4180
4396
  * @param {?} visit
4181
4397
  * @return {?}
4182
4398
  */
4183
- UrlManipulator.prototype.convertToUrlSegments = /**
4399
+ UrlHelper.prototype.convertToUrlSegments = /**
4184
4400
  * Converts the visit into segments. Please not that these segments are not e
4185
4401
  * @param {?} visit
4186
4402
  * @return {?}
@@ -4203,7 +4419,7 @@ if (false) {
4203
4419
  * @param {?} visit
4204
4420
  * @return {?}
4205
4421
  */
4206
- UrlManipulator.prototype.createRedirectCommandsFor = /**
4422
+ UrlHelper.prototype.createRedirectCommandsFor = /**
4207
4423
  * @param {?} visit
4208
4424
  * @return {?}
4209
4425
  */
@@ -4224,21 +4440,36 @@ if (false) {
4224
4440
  }));
4225
4441
  return commands;
4226
4442
  };
4443
+ /**
4444
+ * @param {?} placeDef
4445
+ * @return {?}
4446
+ */
4447
+ UrlHelper.prototype.includesPathOf = /**
4448
+ * @param {?} placeDef
4449
+ * @return {?}
4450
+ */
4451
+ function (placeDef) {
4452
+ return this.cloneUrlSegmentList().find((/**
4453
+ * @param {?} s
4454
+ * @return {?}
4455
+ */
4456
+ function (s) { return s.path === placeDef.path; }));
4457
+ };
4227
4458
  __decorate([
4228
4459
  Trace(),
4229
4460
  __metadata("design:type", Function),
4230
4461
  __metadata("design:paramtypes", [Visit]),
4231
4462
  __metadata("design:returntype", Array)
4232
- ], UrlManipulator.prototype, "createRedirectCommandsFor", null);
4233
- return UrlManipulator;
4463
+ ], UrlHelper.prototype, "createRedirectCommandsFor", null);
4464
+ return UrlHelper;
4234
4465
  }());
4235
- PlaceRouter.UrlManipulator = UrlManipulator;
4466
+ PlaceRouter.UrlHelper = UrlHelper;
4236
4467
  if (false) {
4237
4468
  /**
4238
4469
  * @type {?}
4239
4470
  * @private
4240
4471
  */
4241
- UrlManipulator.prototype.urlTree;
4472
+ UrlHelper.prototype.urlTree;
4242
4473
  }
4243
4474
  })(PlaceRouter || (PlaceRouter = {}));
4244
4475
 
@@ -6009,7 +6240,7 @@ var EnterPlaceGuard = /** @class */ (function () {
6009
6240
  this.placeRouter.navigationSession.storeVisit(sanitisedVisit);
6010
6241
  if (initialVisit.hasRoutingChangedFrom(sanitisedVisit)) {
6011
6242
  // Regenerate the url
6012
- commands = this.placeRouter.createUrlManipulator(state).createRedirectCommandsFor(sanitisedVisit);
6243
+ commands = this.placeRouter.parseUrl(state).createRedirectCommandsFor(sanitisedVisit);
6013
6244
  console.log('##### Place Guard Redirect', commands);
6014
6245
  return [2 /*return*/, this.router.createUrlTree(commands, {
6015
6246
  replaceUrl: true,
@@ -6231,90 +6462,9 @@ if (false) {
6231
6462
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
6232
6463
  */
6233
6464
  var LeavePlaceGuard = /** @class */ (function () {
6234
- function LeavePlaceGuard(router, injector, placeRouter, dialogInteractionContext, angularLocation) {
6235
- this.router = router;
6236
- this.injector = injector;
6465
+ function LeavePlaceGuard(placeRouter) {
6237
6466
  this.placeRouter = placeRouter;
6238
- this.dialogInteractionContext = dialogInteractionContext;
6239
- this.angularLocation = angularLocation;
6240
6467
  }
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
6468
  /**
6319
6469
  * @param {?} component
6320
6470
  * @param {?} currentRoute
@@ -6331,72 +6481,8 @@ var LeavePlaceGuard = /** @class */ (function () {
6331
6481
  */
6332
6482
  function (component, currentRoute, currentState, nextState) {
6333
6483
  return __awaiter(this, void 0, void 0, function () {
6334
- var self_1, canLeave;
6335
6484
  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
- }
6485
+ return [2 /*return*/, this.placeRouter.navigationSession.canDeactivate(component, this.placeRouter.parseUrl(nextState))];
6400
6486
  });
6401
6487
  });
6402
6488
  };
@@ -6407,35 +6493,17 @@ var LeavePlaceGuard = /** @class */ (function () {
6407
6493
  ];
6408
6494
  /** @nocollapse */
6409
6495
  LeavePlaceGuard.ctorParameters = function () { return [
6410
- { type: Router },
6411
- { type: Injector },
6412
- { type: PlaceRouter },
6413
- { type: InteractionContext },
6414
- { type: Location }
6496
+ { type: PlaceRouter }
6415
6497
  ]; };
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" });
6498
+ /** @nocollapse */ LeavePlaceGuard.ngInjectableDef = ɵɵdefineInjectable({ factory: function LeavePlaceGuard_Factory() { return new LeavePlaceGuard(ɵɵinject(PlaceRouter)); }, token: LeavePlaceGuard, providedIn: "root" });
6417
6499
  return LeavePlaceGuard;
6418
6500
  }());
6419
6501
  if (false) {
6420
- /**
6421
- * @type {?}
6422
- * @private
6423
- */
6424
- LeavePlaceGuard.prototype.router;
6425
- /**
6426
- * @type {?}
6427
- * @private
6428
- */
6429
- LeavePlaceGuard.prototype.injector;
6430
6502
  /**
6431
6503
  * @type {?}
6432
6504
  * @private
6433
6505
  */
6434
6506
  LeavePlaceGuard.prototype.placeRouter;
6435
- /** @type {?} */
6436
- LeavePlaceGuard.prototype.dialogInteractionContext;
6437
- /** @type {?} */
6438
- LeavePlaceGuard.prototype.angularLocation;
6439
6507
  }
6440
6508
 
6441
6509
  /**
@@ -6458,5 +6526,5 @@ if (false) {
6458
6526
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
6459
6527
  */
6460
6528
 
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 };
6529
+ 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, ActivityContainerComponent 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, InteractionContext as ɵu, PlaceHistory as ɵv, TabbedPlaceNavigationComponent as ɵw, AbstractPlaceNavigationComponent as ɵx, ListPlaceNavComponent as ɵy, InteractionModule as ɵz };
6462
6530
  //# sourceMappingURL=coolon-angular-ui-powerups.js.map