@coolon/angular-ui-powerups 0.0.61 → 0.0.62

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 (40) hide show
  1. package/bundles/coolon-angular-ui-powerups.umd.js +419 -117
  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.metadata.json +1 -1
  6. package/esm2015/coolon-angular-ui-powerups.js +2 -2
  7. package/esm2015/index.js +2 -2
  8. package/esm2015/lib/interaction/activity.js +11 -1
  9. package/esm2015/lib/interaction/components/activity-container/activity-container.component.js +49 -1
  10. package/esm2015/lib/interaction/components/activity-outlet/activity-outlet.component.js +7 -56
  11. package/esm2015/lib/interaction/guards/close-interaction.guard.js +62 -0
  12. package/esm2015/lib/interaction/index.js +3 -2
  13. package/esm2015/lib/interaction/interaction-context.js +25 -5
  14. package/esm2015/lib/interaction/services/dialog-interaction.service.js +93 -4
  15. package/esm2015/lib/place/guards/leave-place.guard.js +128 -20
  16. package/esm2015/public_api.js +2 -2
  17. package/esm5/coolon-angular-ui-powerups.js +2 -2
  18. package/esm5/index.js +2 -2
  19. package/esm5/lib/interaction/activity.js +11 -1
  20. package/esm5/lib/interaction/components/activity-container/activity-container.component.js +67 -1
  21. package/esm5/lib/interaction/components/activity-outlet/activity-outlet.component.js +11 -78
  22. package/esm5/lib/interaction/guards/close-interaction.guard.js +66 -0
  23. package/esm5/lib/interaction/index.js +3 -2
  24. package/esm5/lib/interaction/interaction-context.js +33 -6
  25. package/esm5/lib/interaction/services/dialog-interaction.service.js +109 -4
  26. package/esm5/lib/place/guards/leave-place.guard.js +131 -20
  27. package/esm5/public_api.js +2 -2
  28. package/fesm2015/coolon-angular-ui-powerups.js +355 -82
  29. package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
  30. package/fesm5/coolon-angular-ui-powerups.js +406 -105
  31. package/fesm5/coolon-angular-ui-powerups.js.map +1 -1
  32. package/lib/interaction/activity.d.ts +2 -0
  33. package/lib/interaction/components/activity-container/activity-container.component.d.ts +10 -1
  34. package/lib/interaction/components/activity-outlet/activity-outlet.component.d.ts +2 -9
  35. package/lib/interaction/guards/close-interaction.guard.d.ts +12 -0
  36. package/lib/interaction/index.d.ts +1 -0
  37. package/lib/interaction/interaction-context.d.ts +17 -4
  38. package/lib/interaction/services/dialog-interaction.service.d.ts +14 -2
  39. package/lib/place/guards/leave-place.guard.d.ts +7 -1
  40. package/package.json +1 -1
@@ -1,18 +1,18 @@
1
- import { DOCUMENT, CommonModule } from '@angular/common';
1
+ import { DOCUMENT, CommonModule, Location } from '@angular/common';
2
2
  import { EventEmitter, Input, Output, HostListener, Component, Directive, ElementRef, Inject, NgZone, InjectionToken, Injector, ComponentFactoryResolver, ViewContainerRef, ViewChild, ViewChildren, Injectable, Optional, ɵɵdefineInjectable, ɵɵinject, NgModule, HostBinding, INJECTOR } from '@angular/core';
3
3
  import { FormsModule } from '@angular/forms';
4
4
  import { MatDialog, MatButtonModule, MatDialogModule, MatTabsModule, MatProgressSpinnerModule, MatInputModule, MatFormFieldModule, MatSelectModule } from '@angular/material';
5
5
  import { MatTabsModule as MatTabsModule$1 } from '@angular/material/tabs';
6
6
  import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
7
7
  import { __extends, __decorate, __metadata, __assign, __awaiter, __generator } from 'tslib';
8
- import { GarbageCollector, DelegatingFormValueModel, UseDelegate, ValueModel, ListModel, StoreInListModel, assert, UnaryCommand, lang, Dsl, Logger, DelegatingValueModel, MutableListModel, StoreInValueModel, Binding, MutableValueModel, Guard, OptionsHelper, ValueHolder } from '@coolon/pectin';
8
+ import { GarbageCollector, DelegatingFormValueModel, UseDelegate, ValueModel, ListModel, StoreInListModel, assert, UnaryCommand, lang, Dsl, Logger, DelegatingValueModel, MutableListModel, DelegatingListModel, StoreInValueModel, Binding, MutableValueModel, Guard, OptionsHelper, ValueHolder, Trace } from '@coolon/pectin';
9
9
  import { PortalModule } from '@angular/cdk/portal';
10
10
  import { assert as assert$1, Klass, Opts } from '@coolon/typescript-utilities';
11
11
  import { MatDialogConfig, MAT_DIALOG_DEFAULT_OPTIONS, MatDialog as MatDialog$1 } from '@angular/material/dialog';
12
+ import { Router, RouterModule, NavigationEnd, NavigationError } from '@angular/router';
12
13
  import { MatIconModule } from '@angular/material/icon';
13
14
  import { MatListModule } from '@angular/material/list';
14
15
  import { MatTooltipModule } from '@angular/material/tooltip';
15
- import { Router, RouterModule } from '@angular/router';
16
16
  import { Memoize as Memoize$1 } from '@typescript-plus/fast-memoize-decorator/dist/src';
17
17
  import { Memoize } from '@typescript-plus/fast-memoize-decorator';
18
18
  import 'reflect-metadata';
@@ -796,20 +796,46 @@ if (false) {
796
796
  * @fileoverview added by tsickle
797
797
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
798
798
  */
799
- /** @type {?} */
800
- var INTERACTION_CONTEXT = new InjectionToken('InteractionContext');
801
799
  /**
802
800
  * @abstract
803
801
  */
804
802
  var /**
805
803
  * @abstract
806
804
  */
807
- InteractionContext = /** @class */ (function () {
805
+ InteractionContext = /** @class */ (function (_super) {
806
+ __extends(InteractionContext, _super);
808
807
  function InteractionContext() {
808
+ return _super.call(this) || this;
809
809
  }
810
+ /**
811
+ * Returns true if an activity is currently running.
812
+ */
813
+ /**
814
+ * Returns true if an activity is currently running.
815
+ * @return {?}
816
+ */
817
+ InteractionContext.prototype.isActive = /**
818
+ * Returns true if an activity is currently running.
819
+ * @return {?}
820
+ */
821
+ function () {
822
+ return this.activityList.length > 0;
823
+ };
810
824
  return InteractionContext;
811
- }());
825
+ }(GarbageCollector));
812
826
  if (false) {
827
+ /**
828
+ * Returns the activity that is currently active.
829
+ * This model is only updated in the next tick after the view has been updated.
830
+ * @type {?}
831
+ */
832
+ InteractionContext.prototype.currentActivity;
833
+ /**
834
+ * Returns the current list of activities that are in progress.
835
+ * This model is only updated in the next tick after the view has been updated.
836
+ * @type {?}
837
+ */
838
+ InteractionContext.prototype.activityList;
813
839
  /**
814
840
  * @abstract
815
841
  * @template D, R, E
@@ -861,6 +887,16 @@ if (false) {
861
887
  * @return {?}
862
888
  */
863
889
  Activity.prototype.initialise = function (activityContext) { };
890
+ /**
891
+ * @param {?} result
892
+ * @return {?}
893
+ */
894
+ Activity.prototype.done = function (result) { };
895
+ /**
896
+ * @param {?} e
897
+ * @return {?}
898
+ */
899
+ Activity.prototype.cancel = function (e) { };
864
900
  }
865
901
 
866
902
  /**
@@ -927,6 +963,16 @@ var ActivityOutletComponent = /** @class */ (function () {
927
963
  this.activityComponentRef = this.viewContainerRef.createComponent(componentFactory, 0, injector);
928
964
  this.activityComponentRef.instance.initialise(activityContext);
929
965
  };
966
+ Object.defineProperty(ActivityOutletComponent.prototype, "component", {
967
+ get: /**
968
+ * @return {?}
969
+ */
970
+ function () {
971
+ return this.activityComponentRef.instance;
972
+ },
973
+ enumerable: true,
974
+ configurable: true
975
+ });
930
976
  /**
931
977
  * @param {?} alert
932
978
  * @return {?}
@@ -1036,82 +1082,6 @@ if (false) {
1036
1082
  ActivityOutletComponent.prototype.injector;
1037
1083
  /* Skipping unhandled member: ;*/
1038
1084
  }
1039
- (function (ActivityOutletComponent) {
1040
- /**
1041
- * @template D, R, E
1042
- */
1043
- var /**
1044
- * @template D, R, E
1045
- */
1046
- OutletInteractionContext = /** @class */ (function () {
1047
- function OutletInteractionContext(context) {
1048
- this.context = context;
1049
- }
1050
- /**
1051
- * @param {?} alert
1052
- * @return {?}
1053
- */
1054
- OutletInteractionContext.prototype.alert = /**
1055
- * @param {?} alert
1056
- * @return {?}
1057
- */
1058
- function (alert) {
1059
- return lang.notImplemented();
1060
- };
1061
- /**
1062
- * @param {?} confirm
1063
- * @return {?}
1064
- */
1065
- OutletInteractionContext.prototype.confirm = /**
1066
- * @param {?} confirm
1067
- * @return {?}
1068
- */
1069
- function (confirm) {
1070
- return lang.notImplemented();
1071
- };
1072
- /**
1073
- * @template D1, R1, E1
1074
- * @param {?} confirm
1075
- * @param {?} activityType
1076
- * @param {?=} data
1077
- * @return {?}
1078
- */
1079
- OutletInteractionContext.prototype.confirmThen = /**
1080
- * @template D1, R1, E1
1081
- * @param {?} confirm
1082
- * @param {?} activityType
1083
- * @param {?=} data
1084
- * @return {?}
1085
- */
1086
- function (confirm, activityType, data) {
1087
- return lang.notImplemented();
1088
- };
1089
- /**
1090
- * @template D1, R1, E1
1091
- * @param {?} activityType
1092
- * @param {?=} data
1093
- * @return {?}
1094
- */
1095
- OutletInteractionContext.prototype.startActivity = /**
1096
- * @template D1, R1, E1
1097
- * @param {?} activityType
1098
- * @param {?=} data
1099
- * @return {?}
1100
- */
1101
- function (activityType, data) {
1102
- return lang.notImplemented();
1103
- };
1104
- return OutletInteractionContext;
1105
- }());
1106
- ActivityOutletComponent.OutletInteractionContext = OutletInteractionContext;
1107
- if (false) {
1108
- /**
1109
- * @type {?}
1110
- * @private
1111
- */
1112
- OutletInteractionContext.prototype.context;
1113
- }
1114
- })(ActivityOutletComponent || (ActivityOutletComponent = {}));
1115
1085
 
1116
1086
  /**
1117
1087
  * @fileoverview added by tsickle
@@ -1416,8 +1386,28 @@ var ActivityContainerComponent = /** @class */ (function (_super) {
1416
1386
  _this.activityOutletTabs = new MutableListModel();
1417
1387
  _this.obsoleteTabs = [];
1418
1388
  _this.finished = false;
1389
+ _this._activityList = new MutableListModel();
1419
1390
  return _this;
1420
1391
  }
1392
+ /**
1393
+ * @return {?}
1394
+ */
1395
+ ActivityContainerComponent.prototype.isActive = /**
1396
+ * @return {?}
1397
+ */
1398
+ function () {
1399
+ return this.parentInteractionContext.isActive();
1400
+ };
1401
+ Object.defineProperty(ActivityContainerComponent.prototype, "activityList", {
1402
+ get: /**
1403
+ * @return {?}
1404
+ */
1405
+ function () {
1406
+ return this._activityList.readonly;
1407
+ },
1408
+ enumerable: true,
1409
+ configurable: true
1410
+ });
1421
1411
  /**
1422
1412
  * @return {?}
1423
1413
  */
@@ -1435,11 +1425,50 @@ var ActivityContainerComponent = /** @class */ (function (_super) {
1435
1425
  function () {
1436
1426
  var _this = this;
1437
1427
  var observe = Dsl.disposeWith(this).observe;
1428
+ this._activityList.value = this.outlets.toArray().map((/**
1429
+ * @param {?} c
1430
+ * @return {?}
1431
+ */
1432
+ function (c) { return c.component; }));
1433
+ observe.valuesFrom(this.outlets.changes).subscribe((/**
1434
+ * @param {?} change
1435
+ * @return {?}
1436
+ */
1437
+ function (change) {
1438
+ _this.safelyUpdateActivityList(change.map((/**
1439
+ * @param {?} c
1440
+ * @return {?}
1441
+ */
1442
+ function (c) { return c.component; })));
1443
+ }));
1438
1444
  observe.valuesFrom(this.tabs.animationDone).subscribe((/**
1439
1445
  * @return {?}
1440
1446
  */
1441
1447
  function () { return _this.onAnimationFinished(); }));
1442
1448
  };
1449
+ /**
1450
+ * Update in the next tick to avoid changing state in the current change detection cycle.
1451
+ * @param activities
1452
+ */
1453
+ /**
1454
+ * Update in the next tick to avoid changing state in the current change detection cycle.
1455
+ * @private
1456
+ * @param {?} activities
1457
+ * @return {?}
1458
+ */
1459
+ ActivityContainerComponent.prototype.safelyUpdateActivityList = /**
1460
+ * Update in the next tick to avoid changing state in the current change detection cycle.
1461
+ * @private
1462
+ * @param {?} activities
1463
+ * @return {?}
1464
+ */
1465
+ function (activities) {
1466
+ var _this = this;
1467
+ setTimeout((/**
1468
+ * @return {?}
1469
+ */
1470
+ function () { return _this._activityList.value = activities; }));
1471
+ };
1443
1472
  /**
1444
1473
  * @template D, R, E
1445
1474
  * @param {?} initialContext
@@ -1634,6 +1663,8 @@ if (false) {
1634
1663
  /** @type {?} */
1635
1664
  ActivityContainerComponent.prototype.initialActivityOutletContext;
1636
1665
  /** @type {?} */
1666
+ ActivityContainerComponent.prototype.currentActivity;
1667
+ /** @type {?} */
1637
1668
  ActivityContainerComponent.prototype.tabs;
1638
1669
  /** @type {?} */
1639
1670
  ActivityContainerComponent.prototype.outlets;
@@ -1649,6 +1680,11 @@ if (false) {
1649
1680
  * @private
1650
1681
  */
1651
1682
  ActivityContainerComponent.prototype.finished;
1683
+ /**
1684
+ * @type {?}
1685
+ * @private
1686
+ */
1687
+ ActivityContainerComponent.prototype._activityList;
1652
1688
  }
1653
1689
  (function (ActivityContainerComponent) {
1654
1690
  /**
@@ -1677,14 +1713,60 @@ if (false) {
1677
1713
  var DIALOG_INTERACTION_SERVICE_DEFAULTS = new InjectionToken('DIALOG_INTERACTION_SERVICE_DEFAULTS');
1678
1714
  var DialogInteractionService = /** @class */ (function (_super) {
1679
1715
  __extends(DialogInteractionService, _super);
1680
- function DialogInteractionService(dialogService, dialogServiceDefaults, matDialogDefaultConfig) {
1716
+ function DialogInteractionService(dialogService, router, dialogServiceDefaults, matDialogDefaultConfig) {
1681
1717
  var _this = _super.call(this) || this;
1682
1718
  _this.dialogService = dialogService;
1719
+ _this.router = router;
1683
1720
  _this.dialogServiceDefaults = dialogServiceDefaults;
1684
1721
  _this.matDialogDefaultConfig = matDialogDefaultConfig;
1722
+ _this._activityList = new DelegatingListModel();
1723
+ _this._active = false;
1685
1724
  assert$1.notNil(dialogService);
1725
+ var _a = Dsl.disposeWith(_this), chain = _a.chain, observe = _a.observe;
1726
+ _this.currentActivity = chain(_this.activityList).last();
1686
1727
  return _this;
1728
+ // observe.valuesFrom(this.router.events)
1729
+ // .tap((event:RouterEvent) => {
1730
+ // const nav = router.getCurrentNavigation();
1731
+ // console.log({
1732
+ // previousUrl: nav.previousNavigation && nav.previousNavigation.finalUrl,
1733
+ // initialUrl: nav.initialUrl,
1734
+ // finalUrl: nav.finalUrl,
1735
+ // });
1736
+ //
1737
+ // })
1738
+ // .filter(event => event instanceof NavigationStart)
1739
+ // .subscribe((event: NavigationStart) => {
1740
+ // console.log(event.navigationTrigger);
1741
+ // if (event.navigationTrigger === 'popstate' && this.isActive()) {
1742
+ // const prev = router.getCurrentNavigation().previousNavigation.finalUrl;
1743
+ // // this.router.navigateByUrl(prev.toString(), {
1744
+ // // replaceUrl: true,
1745
+ // // skipLocationChange: false
1746
+ // // });
1747
+ // // this.cancelActivity();
1748
+ // }
1749
+ // });
1687
1750
  }
1751
+ /**
1752
+ * @return {?}
1753
+ */
1754
+ DialogInteractionService.prototype.cancelActivity = /**
1755
+ * @return {?}
1756
+ */
1757
+ function () {
1758
+ this.currentActivity.value.cancel(null);
1759
+ };
1760
+ Object.defineProperty(DialogInteractionService.prototype, "activityList", {
1761
+ get: /**
1762
+ * @return {?}
1763
+ */
1764
+ function () {
1765
+ return this._activityList.readonly;
1766
+ },
1767
+ enumerable: true,
1768
+ configurable: true
1769
+ });
1688
1770
  /**
1689
1771
  * @template D, R, E
1690
1772
  * @param {?} activityType
@@ -1719,8 +1801,18 @@ var DialogInteractionService = /** @class */ (function (_super) {
1719
1801
  function (activityType, data, disableClose) {
1720
1802
  var _this = this;
1721
1803
  if (disableClose === void 0) { disableClose = true; }
1804
+ if (this.isActive()) {
1805
+ lang.illegalState("Activity already in progress: " + this.activityList.value.map((/**
1806
+ * @param {?} a
1807
+ * @return {?}
1808
+ */
1809
+ function (a) { return a.constructor.name; })).join(', '));
1810
+ }
1811
+ this._active = true;
1722
1812
  /** @type {?} */
1723
- var config = __assign({ autoFocus: false, hasBackdrop: true }, this.matDialogDefaultConfig, this.dialogServiceDefaults, {
1813
+ var self = this;
1814
+ /** @type {?} */
1815
+ var config = __assign({ autoFocus: false, hasBackdrop: true, closeOnNavigation: false }, this.matDialogDefaultConfig, this.dialogServiceDefaults, {
1724
1816
  data: data,
1725
1817
  disableClose: disableClose,
1726
1818
  panelClass: 'dialog-interaction-service'
@@ -1736,6 +1828,7 @@ var DialogInteractionService = /** @class */ (function (_super) {
1736
1828
  /** @type {?} */
1737
1829
  var activityContainer = matDialogRef.componentInstance;
1738
1830
  activityContainer.parentInteractionContext = _this;
1831
+ self.safelyUpdateActivityListDelegate(activityContainer.activityList);
1739
1832
  activityContainer.initialise({
1740
1833
  activityClass: activityType,
1741
1834
  activityData: data,
@@ -1759,8 +1852,35 @@ var DialogInteractionService = /** @class */ (function (_super) {
1759
1852
  }
1760
1853
  });
1761
1854
  matDialogRef.updateSize();
1855
+ })).finally((/**
1856
+ * @return {?}
1857
+ */
1858
+ function () {
1859
+ self.safelyUpdateActivityListDelegate(null);
1860
+ self._active = false;
1762
1861
  }));
1763
1862
  };
1863
+ /**
1864
+ * Updates teh delegate on the next tick to avoid modifying state during the current change detection cycle.
1865
+ * @param delegate
1866
+ */
1867
+ /**
1868
+ * Updates teh delegate on the next tick to avoid modifying state during the current change detection cycle.
1869
+ * @param {?} delegate
1870
+ * @return {?}
1871
+ */
1872
+ DialogInteractionService.prototype.safelyUpdateActivityListDelegate = /**
1873
+ * Updates teh delegate on the next tick to avoid modifying state during the current change detection cycle.
1874
+ * @param {?} delegate
1875
+ * @return {?}
1876
+ */
1877
+ function (delegate) {
1878
+ var _this = this;
1879
+ setTimeout((/**
1880
+ * @return {?}
1881
+ */
1882
+ function () { return _this._activityList.setDelegate(delegate); }));
1883
+ };
1764
1884
  /**
1765
1885
  * @param {?} alert
1766
1886
  * @return {?}
@@ -1812,18 +1932,36 @@ var DialogInteractionService = /** @class */ (function (_super) {
1812
1932
  /** @nocollapse */
1813
1933
  DialogInteractionService.ctorParameters = function () { return [
1814
1934
  { type: MatDialog },
1935
+ { type: Router },
1815
1936
  { type: MatDialogConfig, decorators: [{ type: Optional }, { type: Inject, args: [DIALOG_INTERACTION_SERVICE_DEFAULTS,] }] },
1816
1937
  { type: MatDialogConfig, decorators: [{ type: Optional }, { type: Inject, args: [MAT_DIALOG_DEFAULT_OPTIONS,] }] }
1817
1938
  ]; };
1818
- /** @nocollapse */ DialogInteractionService.ngInjectableDef = ɵɵdefineInjectable({ factory: function DialogInteractionService_Factory() { return new DialogInteractionService(ɵɵinject(MatDialog$1), ɵɵinject(DIALOG_INTERACTION_SERVICE_DEFAULTS, 8), ɵɵinject(MAT_DIALOG_DEFAULT_OPTIONS, 8)); }, token: DialogInteractionService, providedIn: "root" });
1939
+ /** @nocollapse */ DialogInteractionService.ngInjectableDef = ɵɵdefineInjectable({ factory: function DialogInteractionService_Factory() { return new DialogInteractionService(ɵɵinject(MatDialog$1), ɵɵinject(Router), ɵɵinject(DIALOG_INTERACTION_SERVICE_DEFAULTS, 8), ɵɵinject(MAT_DIALOG_DEFAULT_OPTIONS, 8)); }, token: DialogInteractionService, providedIn: "root" });
1819
1940
  return DialogInteractionService;
1820
1941
  }(InteractionContext));
1821
1942
  if (false) {
1943
+ /** @type {?} */
1944
+ DialogInteractionService.prototype.currentActivity;
1945
+ /**
1946
+ * @type {?}
1947
+ * @private
1948
+ */
1949
+ DialogInteractionService.prototype._activityList;
1950
+ /**
1951
+ * @type {?}
1952
+ * @private
1953
+ */
1954
+ DialogInteractionService.prototype._active;
1822
1955
  /**
1823
1956
  * @type {?}
1824
1957
  * @private
1825
1958
  */
1826
1959
  DialogInteractionService.prototype.dialogService;
1960
+ /**
1961
+ * @type {?}
1962
+ * @private
1963
+ */
1964
+ DialogInteractionService.prototype.router;
1827
1965
  /** @type {?} */
1828
1966
  DialogInteractionService.prototype.dialogServiceDefaults;
1829
1967
  /** @type {?} */
@@ -4304,6 +4442,65 @@ if (false) {
4304
4442
  ActivityOutletContext.prototype.onCancel;
4305
4443
  }
4306
4444
 
4445
+ /**
4446
+ * @fileoverview added by tsickle
4447
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4448
+ */
4449
+ var CloseInteractionGuard = /** @class */ (function () {
4450
+ function CloseInteractionGuard(router, injector, interactionContext) {
4451
+ this.router = router;
4452
+ this.injector = injector;
4453
+ this.interactionContext = interactionContext;
4454
+ }
4455
+ /**
4456
+ * @param {?} component
4457
+ * @param {?} currentRoute
4458
+ * @param {?} currentState
4459
+ * @param {?=} nextState
4460
+ * @return {?}
4461
+ */
4462
+ CloseInteractionGuard.prototype.canDeactivate = /**
4463
+ * @param {?} component
4464
+ * @param {?} currentRoute
4465
+ * @param {?} currentState
4466
+ * @param {?=} nextState
4467
+ * @return {?}
4468
+ */
4469
+ function (component, currentRoute, currentState, nextState) {
4470
+ return !this.interactionContext.isActive();
4471
+ };
4472
+ CloseInteractionGuard.decorators = [
4473
+ { type: Injectable, args: [{
4474
+ providedIn: 'root'
4475
+ },] }
4476
+ ];
4477
+ /** @nocollapse */
4478
+ CloseInteractionGuard.ctorParameters = function () { return [
4479
+ { type: Router },
4480
+ { type: Injector },
4481
+ { type: InteractionContext }
4482
+ ]; };
4483
+ /** @nocollapse */ CloseInteractionGuard.ngInjectableDef = ɵɵdefineInjectable({ factory: function CloseInteractionGuard_Factory() { return new CloseInteractionGuard(ɵɵinject(Router), ɵɵinject(INJECTOR), ɵɵinject(InteractionContext)); }, token: CloseInteractionGuard, providedIn: "root" });
4484
+ return CloseInteractionGuard;
4485
+ }());
4486
+ if (false) {
4487
+ /**
4488
+ * @type {?}
4489
+ * @private
4490
+ */
4491
+ CloseInteractionGuard.prototype.router;
4492
+ /**
4493
+ * @type {?}
4494
+ * @private
4495
+ */
4496
+ CloseInteractionGuard.prototype.injector;
4497
+ /**
4498
+ * @type {?}
4499
+ * @private
4500
+ */
4501
+ CloseInteractionGuard.prototype.interactionContext;
4502
+ }
4503
+
4307
4504
  /**
4308
4505
  * @fileoverview added by tsickle
4309
4506
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -4405,9 +4602,33 @@ if (false) {
4405
4602
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4406
4603
  */
4407
4604
  var LeavePlaceGuard = /** @class */ (function () {
4408
- function LeavePlaceGuard(router, injector) {
4605
+ function LeavePlaceGuard(router, injector, interactionContext, location) {
4409
4606
  this.router = router;
4410
4607
  this.injector = injector;
4608
+ this.interactionContext = interactionContext;
4609
+ this.location = location;
4610
+ // TODO: should probably replace this with a RouteTracker thingy.
4611
+ this._alreadyAccepted = [];
4612
+ console.log('***** Created new guard ******');
4613
+ /** @type {?} */
4614
+ var self = this;
4615
+ this.router.events.subscribe((/**
4616
+ * @param {?} event
4617
+ * @return {?}
4618
+ */
4619
+ function (event) {
4620
+ // NavigationStart -> .... -> NavigationCancel === redirect (so don't ask again)
4621
+ // NavigationStart -> .... -> NavigationEnd === navigated (so ask next time)
4622
+ // NavigationStart -> .... -> NavigationError === canceled (guard cancelled so ask next time)
4623
+ if (event instanceof NavigationEnd) {
4624
+ console.log("navigation ended");
4625
+ self._alreadyAccepted = [];
4626
+ }
4627
+ if (event instanceof NavigationError) {
4628
+ console.log("navigation errored");
4629
+ self._alreadyAccepted = [];
4630
+ }
4631
+ }));
4411
4632
  }
4412
4633
  /**
4413
4634
  * @param {?} component
@@ -4424,27 +4645,90 @@ var LeavePlaceGuard = /** @class */ (function () {
4424
4645
  * @return {?}
4425
4646
  */
4426
4647
  function (component, currentRoute, currentState, nextState) {
4427
- // HACK: this will break with child routes...
4648
+ var _this = this;
4428
4649
  /** @type {?} */
4429
- var path = "/" + component.placeDefinition.path;
4430
- // let thisTree = this.router.parseUrl(currentState.url);
4431
- // let nextTree = this.router.parseUrl(nextState.url);
4432
- // console.log({
4433
- // placePath: path,
4434
- // currentRoute: currentRoute.toString(),
4435
- // currentStateUrl: currentState.url,
4436
- // nextStateUrl: nextState.url,
4437
- // currentStateUrlTree: thisTree.root.children[PRIMARY_OUTLET].segments,
4438
- // nextStateUrlTree: nextTree.root.children[PRIMARY_OUTLET].segments
4439
- // });
4440
- // nextState is the full path...
4441
- if (!nextState.url.startsWith(path)) {
4442
- return component.canDeactivate();
4650
+ var placeDefinitionPath = "/" + component.placeDefinition.path;
4651
+ console.log('canDeactivate', {
4652
+ staticPath: placeDefinitionPath,
4653
+ currentStateUrl: currentState.url,
4654
+ nextStateUrl: nextState.url,
4655
+ alreadyDeclined: this._alreadyAccepted
4656
+ });
4657
+ // Example of the above when navigating to a different child route.
4658
+ // canDeactivate {staticPath: "/hero-details",
4659
+ // currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-details",
4660
+ // nextStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats"
4661
+ // }
4662
+ // Example clicking on router tab of the parent component (de-activates the parent due to route param changes)
4663
+ // canDeactivate {
4664
+ // staticPath: "/hero-stats",
4665
+ // currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats",
4666
+ // nextStateUrl: "/route-parameters/"
4667
+ // }
4668
+ // canDeactivate {
4669
+ // staticPath: "/route-parameters",
4670
+ // currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats",
4671
+ // nextStateUrl: "/route-parameters/"
4672
+ // }
4673
+ // logger.class.js:54 ParameterSnapshot.sanitise -> {idModel: -1, pv: undefined, pl: Array(0), dv: undefined, dl: Array(0), …}
4674
+ // parameter-snapshot.ts:20 {name: "idModel", mine: -1, theirs: null}
4675
+ // place-router.ts:28 redirect path (3) ["route-parameters", "-1", {…}]
4676
+ // canDeactivate {
4677
+ // staticPath: "/hero-stats",
4678
+ // currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats",
4679
+ // nextStateUrl: "/route-parameters/-1"
4680
+ // }
4681
+ // canDeactivate {
4682
+ // staticPath: "/route-parameters",
4683
+ // currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats",
4684
+ // nextStateUrl: "/route-parameters/-1"
4685
+ // }
4686
+ // logger.class.js:54 ParameterSnapshot.sanitise -> {idModel: -1, pv: undefined, pl: Array(0), dv: "A", dl: Array(3), …}
4687
+ // parameter-snapshot.ts:20 {name: "dv", mine: "A", theirs: undefined}
4688
+ // place-router.ts:28 redirect path (3) ["route-parameters", "-1", {…}]
4689
+ // canDeactivate {
4690
+ // staticPath: "/hero-stats",
4691
+ // currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats",
4692
+ // nextStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c"
4693
+ // }
4694
+ // HACK: this will break with child routes...
4695
+ if (this.alreadyAccepted(component)) {
4696
+ return true;
4443
4697
  }
4444
4698
  else {
4699
+ if (!nextState.url.startsWith(placeDefinitionPath)) {
4700
+ /** @type {?} */
4701
+ var self_1 = this;
4702
+ return Promise.resolve(component.canDeactivate()).then((/**
4703
+ * @param {?} canLeave
4704
+ * @return {?}
4705
+ */
4706
+ function (canLeave) {
4707
+ if (!canLeave) {
4708
+ // Angular doesn't preserve the url when a guard cancels the back button.
4709
+ // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
4710
+ _this.location.go(currentState.url);
4711
+ }
4712
+ else {
4713
+ self_1._alreadyAccepted.push(component);
4714
+ }
4715
+ return canLeave;
4716
+ }));
4717
+ }
4445
4718
  return true;
4446
4719
  }
4447
4720
  };
4721
+ /**
4722
+ * @param {?} placeComponent
4723
+ * @return {?}
4724
+ */
4725
+ LeavePlaceGuard.prototype.alreadyAccepted = /**
4726
+ * @param {?} placeComponent
4727
+ * @return {?}
4728
+ */
4729
+ function (placeComponent) {
4730
+ return this._alreadyAccepted.includes(placeComponent);
4731
+ };
4448
4732
  LeavePlaceGuard.decorators = [
4449
4733
  { type: Injectable, args: [{
4450
4734
  providedIn: 'root'
@@ -4453,12 +4737,25 @@ var LeavePlaceGuard = /** @class */ (function () {
4453
4737
  /** @nocollapse */
4454
4738
  LeavePlaceGuard.ctorParameters = function () { return [
4455
4739
  { type: Router },
4456
- { type: Injector }
4740
+ { type: Injector },
4741
+ { type: InteractionContext },
4742
+ { type: Location }
4457
4743
  ]; };
4458
- /** @nocollapse */ LeavePlaceGuard.ngInjectableDef = ɵɵdefineInjectable({ factory: function LeavePlaceGuard_Factory() { return new LeavePlaceGuard(ɵɵinject(Router), ɵɵinject(INJECTOR)); }, token: LeavePlaceGuard, providedIn: "root" });
4744
+ /** @nocollapse */ LeavePlaceGuard.ngInjectableDef = ɵɵdefineInjectable({ factory: function LeavePlaceGuard_Factory() { return new LeavePlaceGuard(ɵɵinject(Router), ɵɵinject(INJECTOR), ɵɵinject(InteractionContext), ɵɵinject(Location)); }, token: LeavePlaceGuard, providedIn: "root" });
4745
+ __decorate([
4746
+ Trace(),
4747
+ __metadata("design:type", Function),
4748
+ __metadata("design:paramtypes", [PlaceComponent]),
4749
+ __metadata("design:returntype", Boolean)
4750
+ ], LeavePlaceGuard.prototype, "alreadyAccepted", null);
4459
4751
  return LeavePlaceGuard;
4460
4752
  }());
4461
4753
  if (false) {
4754
+ /**
4755
+ * @type {?}
4756
+ * @private
4757
+ */
4758
+ LeavePlaceGuard.prototype._alreadyAccepted;
4462
4759
  /**
4463
4760
  * @type {?}
4464
4761
  * @private
@@ -4469,6 +4766,10 @@ if (false) {
4469
4766
  * @private
4470
4767
  */
4471
4768
  LeavePlaceGuard.prototype.injector;
4769
+ /** @type {?} */
4770
+ LeavePlaceGuard.prototype.interactionContext;
4771
+ /** @type {?} */
4772
+ LeavePlaceGuard.prototype.location;
4472
4773
  }
4473
4774
 
4474
4775
  /**
@@ -4777,5 +5078,5 @@ var ParameterType;
4777
5078
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4778
5079
  */
4779
5080
 
4780
- export { ACTIVITY_DATA, AbstractActivity, AbstractInputComponent, AbstractPlaceNavigationComponent, ActivityContainerComponent, ActivityOutletComponent, AlertDialogComponent, AngularUiPowerupsModule, Bounds, BusyOverlayComponent, CommandDirective, ConfirmThenDialogComponent, ConfirmationDialogComponent, DEFINITION_META_DATA_KEY, DIALOG_INTERACTION_SERVICE_DEFAULTS, DialogInteractionService, Dimension, DisposableComponent, EmptyStateComponent, FocusBindingDirective, INTERACTION_CONTEXT, InteractionContext, InteractionModule, LEFT_RIGHT_PLACE_ANIMATION, LeavePlaceGuard, ListPlaceNavComponent, NumberInputComponent, ParameterDefinition, ParameterSnapshot, ParameterType, PasswordInputComponent, Place, PlaceComponent, PlaceDefinition, PlaceHistory, PlaceModule, PlaceOutletComponent, PlaceRouteGuard, PlaceRouter, Point, ROUTE_PARAMETER_LIST_KEY, ResizeAwareComponent, RouteId, RouteParameter, RouteParameterList, RouteParameterValue, SelectInputComponent, StringInputComponent, TabbedPlaceNavigationComponent, leftRightPlaceAnimation, slideDownAndUpAnimation, CommandDirective as ɵa, FocusBindingDirective as ɵb, ConfirmThenDialogComponent as ɵba, InteractionContext as ɵbb, AlertDialogComponent as ɵbc, DIALOG_INTERACTION_SERVICE_DEFAULTS as ɵbe, DialogInteractionService as ɵbf, DisposableComponent as ɵc, NumberInputComponent as ɵd, AbstractInputComponent as ɵe, StringInputComponent as ɵf, PasswordInputComponent as ɵg, SelectInputComponent as ɵh, PlaceModule as ɵi, EmptyStateComponent as ɵj, BusyOverlayComponent as ɵk, PlaceOutletComponent as ɵl, leftRightPlaceAnimation as ɵm, LEFT_RIGHT_PLACE_ANIMATION as ɵn, PlaceRouter as ɵo, PlaceHistory as ɵp, TabbedPlaceNavigationComponent as ɵq, AbstractPlaceNavigationComponent as ɵr, ListPlaceNavComponent as ɵs, InteractionModule as ɵt, ActivityContainerComponent as ɵu, ActivityOutletComponent as ɵv, ConfirmationDialogComponent as ɵw, AbstractActivity as ɵx, ACTIVITY_DATA as ɵy };
5081
+ export { ACTIVITY_DATA, AbstractActivity, AbstractInputComponent, AbstractPlaceNavigationComponent, ActivityContainerComponent, ActivityOutletComponent, AlertDialogComponent, AngularUiPowerupsModule, Bounds, BusyOverlayComponent, CloseInteractionGuard, CommandDirective, ConfirmThenDialogComponent, ConfirmationDialogComponent, DEFINITION_META_DATA_KEY, DIALOG_INTERACTION_SERVICE_DEFAULTS, DialogInteractionService, Dimension, DisposableComponent, EmptyStateComponent, FocusBindingDirective, InteractionContext, InteractionModule, LEFT_RIGHT_PLACE_ANIMATION, LeavePlaceGuard, ListPlaceNavComponent, NumberInputComponent, ParameterDefinition, ParameterSnapshot, ParameterType, PasswordInputComponent, Place, PlaceComponent, PlaceDefinition, PlaceHistory, PlaceModule, PlaceOutletComponent, PlaceRouteGuard, PlaceRouter, Point, ROUTE_PARAMETER_LIST_KEY, ResizeAwareComponent, RouteId, RouteParameter, RouteParameterList, RouteParameterValue, SelectInputComponent, StringInputComponent, TabbedPlaceNavigationComponent, leftRightPlaceAnimation, slideDownAndUpAnimation, CommandDirective as ɵa, FocusBindingDirective as ɵb, ConfirmThenDialogComponent as ɵba, InteractionContext as ɵbb, AlertDialogComponent as ɵbc, DIALOG_INTERACTION_SERVICE_DEFAULTS as ɵbe, DialogInteractionService as ɵbf, DisposableComponent as ɵc, NumberInputComponent as ɵd, AbstractInputComponent as ɵe, StringInputComponent as ɵf, PasswordInputComponent as ɵg, SelectInputComponent as ɵh, PlaceModule as ɵi, EmptyStateComponent as ɵj, BusyOverlayComponent as ɵk, PlaceOutletComponent as ɵl, leftRightPlaceAnimation as ɵm, LEFT_RIGHT_PLACE_ANIMATION as ɵn, PlaceRouter as ɵo, PlaceHistory as ɵp, TabbedPlaceNavigationComponent as ɵq, AbstractPlaceNavigationComponent as ɵr, ListPlaceNavComponent as ɵs, InteractionModule as ɵt, ActivityContainerComponent as ɵu, ActivityOutletComponent as ɵv, ConfirmationDialogComponent as ɵw, AbstractActivity as ɵx, ACTIVITY_DATA as ɵy };
4781
5082
  //# sourceMappingURL=coolon-angular-ui-powerups.js.map