@coolon/angular-ui-powerups 0.0.61 → 0.0.63

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 +414 -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 +24 -5
  14. package/esm2015/lib/interaction/services/dialog-interaction.service.js +77 -4
  15. package/esm2015/lib/place/guards/leave-place.guard.js +144 -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 +25 -6
  25. package/esm5/lib/interaction/services/dialog-interaction.service.js +96 -4
  26. package/esm5/lib/place/guards/leave-place.guard.js +147 -20
  27. package/esm5/public_api.js +2 -2
  28. package/fesm2015/coolon-angular-ui-powerups.js +354 -82
  29. package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
  30. package/fesm5/coolon-angular-ui-powerups.js +401 -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 +15 -2
  39. package/lib/place/guards/leave-place.guard.d.ts +7 -1
  40. package/package.json +1 -1
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common'), require('@angular/core'), require('@angular/forms'), require('@angular/material'), require('@angular/material/tabs'), require('@angular/platform-browser/animations'), require('@coolon/pectin'), require('@angular/cdk/portal'), require('@coolon/typescript-utilities'), require('@angular/material/dialog'), require('@angular/material/icon'), require('@angular/material/list'), require('@angular/material/tooltip'), require('@angular/router'), require('@typescript-plus/fast-memoize-decorator/dist/src'), require('@typescript-plus/fast-memoize-decorator'), require('reflect-metadata'), require('lodash'), require('@angular/animations'), require('resize-observer-polyfill')) :
3
- typeof define === 'function' && define.amd ? define('@coolon/angular-ui-powerups', ['exports', '@angular/common', '@angular/core', '@angular/forms', '@angular/material', '@angular/material/tabs', '@angular/platform-browser/animations', '@coolon/pectin', '@angular/cdk/portal', '@coolon/typescript-utilities', '@angular/material/dialog', '@angular/material/icon', '@angular/material/list', '@angular/material/tooltip', '@angular/router', '@typescript-plus/fast-memoize-decorator/dist/src', '@typescript-plus/fast-memoize-decorator', 'reflect-metadata', 'lodash', '@angular/animations', 'resize-observer-polyfill'], factory) :
4
- (global = global || self, factory((global.coolon = global.coolon || {}, global.coolon['angular-ui-powerups'] = {}), global.ng.common, global.ng.core, global.ng.forms, global.ng.material, global.ng.material.tabs, global.ng.platformBrowser.animations, global.pectin, global.ng.cdk.portal, global.typescriptUtilities, global.ng.material.dialog, global.ng.material.icon, global.ng.material.list, global.ng.material.tooltip, global.ng.router, global.src, global.fastMemoizeDecorator, null, global.___default, global.ng.animations, global.ResizeObserver));
5
- }(this, function (exports, common, core, forms, material, tabs, animations, pectin, portal, typescriptUtilities, dialog, icon, list, tooltip, router, src, fastMemoizeDecorator, reflectMetadata, ___default, animations$1, ResizeObserver) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common'), require('@angular/core'), require('@angular/forms'), require('@angular/material'), require('@angular/material/tabs'), require('@angular/platform-browser/animations'), require('@coolon/pectin'), require('@angular/cdk/portal'), require('@coolon/typescript-utilities'), require('@angular/material/dialog'), require('@angular/router'), require('@angular/material/icon'), require('@angular/material/list'), require('@angular/material/tooltip'), require('@typescript-plus/fast-memoize-decorator/dist/src'), require('@typescript-plus/fast-memoize-decorator'), require('reflect-metadata'), require('lodash'), require('@angular/animations'), require('resize-observer-polyfill')) :
3
+ typeof define === 'function' && define.amd ? define('@coolon/angular-ui-powerups', ['exports', '@angular/common', '@angular/core', '@angular/forms', '@angular/material', '@angular/material/tabs', '@angular/platform-browser/animations', '@coolon/pectin', '@angular/cdk/portal', '@coolon/typescript-utilities', '@angular/material/dialog', '@angular/router', '@angular/material/icon', '@angular/material/list', '@angular/material/tooltip', '@typescript-plus/fast-memoize-decorator/dist/src', '@typescript-plus/fast-memoize-decorator', 'reflect-metadata', 'lodash', '@angular/animations', 'resize-observer-polyfill'], factory) :
4
+ (global = global || self, factory((global.coolon = global.coolon || {}, global.coolon['angular-ui-powerups'] = {}), global.ng.common, global.ng.core, global.ng.forms, global.ng.material, global.ng.material.tabs, global.ng.platformBrowser.animations, global.pectin, global.ng.cdk.portal, global.typescriptUtilities, global.ng.material.dialog, global.ng.router, global.ng.material.icon, global.ng.material.list, global.ng.material.tooltip, global.src, global.fastMemoizeDecorator, null, global.___default, global.ng.animations, global.ResizeObserver));
5
+ }(this, function (exports, common, core, forms, material, tabs, animations, pectin, portal, typescriptUtilities, dialog, router, icon, list, tooltip, src, fastMemoizeDecorator, reflectMetadata, ___default, animations$1, ResizeObserver) { 'use strict';
6
6
 
7
7
  var ___default__default = 'default' in ___default ? ___default['default'] : ___default;
8
8
  ResizeObserver = ResizeObserver && ResizeObserver.hasOwnProperty('default') ? ResizeObserver['default'] : ResizeObserver;
@@ -980,20 +980,38 @@
980
980
  * @fileoverview added by tsickle
981
981
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
982
982
  */
983
- /** @type {?} */
984
- var INTERACTION_CONTEXT = new core.InjectionToken('InteractionContext');
985
983
  /**
986
984
  * @abstract
987
985
  */
988
986
  var /**
989
987
  * @abstract
990
988
  */
991
- InteractionContext = /** @class */ (function () {
989
+ InteractionContext = /** @class */ (function (_super) {
990
+ __extends(InteractionContext, _super);
992
991
  function InteractionContext() {
992
+ return _super.call(this) || this;
993
993
  }
994
994
  return InteractionContext;
995
- }());
995
+ }(pectin.GarbageCollector));
996
996
  if (false) {
997
+ /**
998
+ * Returns the activity that is currently active.
999
+ * This model is only updated in the next tick after the view has been updated.
1000
+ * @type {?}
1001
+ */
1002
+ InteractionContext.prototype.currentActivity;
1003
+ /**
1004
+ * Returns the current list of activities that are in progress.
1005
+ * This model is only updated in the next tick after the view has been updated.
1006
+ * @type {?}
1007
+ */
1008
+ InteractionContext.prototype.activityList;
1009
+ /**
1010
+ * Returns true if an activity is currently running.
1011
+ * @abstract
1012
+ * @return {?}
1013
+ */
1014
+ InteractionContext.prototype.isActive = function () { };
997
1015
  /**
998
1016
  * @abstract
999
1017
  * @template D, R, E
@@ -1045,6 +1063,16 @@
1045
1063
  * @return {?}
1046
1064
  */
1047
1065
  Activity.prototype.initialise = function (activityContext) { };
1066
+ /**
1067
+ * @param {?} result
1068
+ * @return {?}
1069
+ */
1070
+ Activity.prototype.done = function (result) { };
1071
+ /**
1072
+ * @param {?} e
1073
+ * @return {?}
1074
+ */
1075
+ Activity.prototype.cancel = function (e) { };
1048
1076
  }
1049
1077
 
1050
1078
  /**
@@ -1059,7 +1087,7 @@
1059
1087
  * <activity-view [activityClass]="...", [activityData]="..." (done)=".." (cancel)="..."></activity-view>
1060
1088
  * @template D, R, E
1061
1089
  */
1062
- exports.ɵv = /** @class */ (function () {
1090
+ var ActivityOutletComponent = /** @class */ (function () {
1063
1091
  function ActivityOutletComponent(componentFactoryResolver, viewContainerRef, injector) {
1064
1092
  this.componentFactoryResolver = componentFactoryResolver;
1065
1093
  this.viewContainerRef = viewContainerRef;
@@ -1111,6 +1139,16 @@
1111
1139
  this.activityComponentRef = this.viewContainerRef.createComponent(componentFactory, 0, injector);
1112
1140
  this.activityComponentRef.instance.initialise(activityContext);
1113
1141
  };
1142
+ Object.defineProperty(ActivityOutletComponent.prototype, "component", {
1143
+ get: /**
1144
+ * @return {?}
1145
+ */
1146
+ function () {
1147
+ return this.activityComponentRef.instance;
1148
+ },
1149
+ enumerable: true,
1150
+ configurable: true
1151
+ });
1114
1152
  /**
1115
1153
  * @param {?} alert
1116
1154
  * @return {?}
@@ -1197,105 +1235,29 @@
1197
1235
  }());
1198
1236
  if (false) {
1199
1237
  /** @type {?} */
1200
- exports.ɵv.prototype.interactionContext;
1238
+ ActivityOutletComponent.prototype.interactionContext;
1201
1239
  /**
1202
1240
  * @type {?}
1203
1241
  * @private
1204
1242
  */
1205
- exports.ɵv.prototype.activityComponentRef;
1243
+ ActivityOutletComponent.prototype.activityComponentRef;
1206
1244
  /**
1207
1245
  * @type {?}
1208
1246
  * @private
1209
1247
  */
1210
- exports.ɵv.prototype.componentFactoryResolver;
1248
+ ActivityOutletComponent.prototype.componentFactoryResolver;
1211
1249
  /**
1212
1250
  * @type {?}
1213
1251
  * @private
1214
1252
  */
1215
- exports.ɵv.prototype.viewContainerRef;
1253
+ ActivityOutletComponent.prototype.viewContainerRef;
1216
1254
  /**
1217
1255
  * @type {?}
1218
1256
  * @private
1219
1257
  */
1220
- exports.ɵv.prototype.injector;
1258
+ ActivityOutletComponent.prototype.injector;
1221
1259
  /* Skipping unhandled member: ;*/
1222
1260
  }
1223
- (function (ActivityOutletComponent) {
1224
- /**
1225
- * @template D, R, E
1226
- */
1227
- var /**
1228
- * @template D, R, E
1229
- */
1230
- OutletInteractionContext = /** @class */ (function () {
1231
- function OutletInteractionContext(context) {
1232
- this.context = context;
1233
- }
1234
- /**
1235
- * @param {?} alert
1236
- * @return {?}
1237
- */
1238
- OutletInteractionContext.prototype.alert = /**
1239
- * @param {?} alert
1240
- * @return {?}
1241
- */
1242
- function (alert) {
1243
- return pectin.lang.notImplemented();
1244
- };
1245
- /**
1246
- * @param {?} confirm
1247
- * @return {?}
1248
- */
1249
- OutletInteractionContext.prototype.confirm = /**
1250
- * @param {?} confirm
1251
- * @return {?}
1252
- */
1253
- function (confirm) {
1254
- return pectin.lang.notImplemented();
1255
- };
1256
- /**
1257
- * @template D1, R1, E1
1258
- * @param {?} confirm
1259
- * @param {?} activityType
1260
- * @param {?=} data
1261
- * @return {?}
1262
- */
1263
- OutletInteractionContext.prototype.confirmThen = /**
1264
- * @template D1, R1, E1
1265
- * @param {?} confirm
1266
- * @param {?} activityType
1267
- * @param {?=} data
1268
- * @return {?}
1269
- */
1270
- function (confirm, activityType, data) {
1271
- return pectin.lang.notImplemented();
1272
- };
1273
- /**
1274
- * @template D1, R1, E1
1275
- * @param {?} activityType
1276
- * @param {?=} data
1277
- * @return {?}
1278
- */
1279
- OutletInteractionContext.prototype.startActivity = /**
1280
- * @template D1, R1, E1
1281
- * @param {?} activityType
1282
- * @param {?=} data
1283
- * @return {?}
1284
- */
1285
- function (activityType, data) {
1286
- return pectin.lang.notImplemented();
1287
- };
1288
- return OutletInteractionContext;
1289
- }());
1290
- ActivityOutletComponent.OutletInteractionContext = OutletInteractionContext;
1291
- if (false) {
1292
- /**
1293
- * @type {?}
1294
- * @private
1295
- */
1296
- OutletInteractionContext.prototype.context;
1297
- }
1298
- })(exports.ɵv || (exports.ɵv = {}));
1299
1261
 
1300
1262
  /**
1301
1263
  * @fileoverview added by tsickle
@@ -1600,8 +1562,28 @@
1600
1562
  _this.activityOutletTabs = new pectin.MutableListModel();
1601
1563
  _this.obsoleteTabs = [];
1602
1564
  _this.finished = false;
1565
+ _this._activityList = new pectin.MutableListModel();
1603
1566
  return _this;
1604
1567
  }
1568
+ /**
1569
+ * @return {?}
1570
+ */
1571
+ ActivityContainerComponent.prototype.isActive = /**
1572
+ * @return {?}
1573
+ */
1574
+ function () {
1575
+ return this.parentInteractionContext.isActive();
1576
+ };
1577
+ Object.defineProperty(ActivityContainerComponent.prototype, "activityList", {
1578
+ get: /**
1579
+ * @return {?}
1580
+ */
1581
+ function () {
1582
+ return this._activityList.readonly;
1583
+ },
1584
+ enumerable: true,
1585
+ configurable: true
1586
+ });
1605
1587
  /**
1606
1588
  * @return {?}
1607
1589
  */
@@ -1619,11 +1601,50 @@
1619
1601
  function () {
1620
1602
  var _this = this;
1621
1603
  var observe = pectin.Dsl.disposeWith(this).observe;
1604
+ this._activityList.value = this.outlets.toArray().map((/**
1605
+ * @param {?} c
1606
+ * @return {?}
1607
+ */
1608
+ function (c) { return c.component; }));
1609
+ observe.valuesFrom(this.outlets.changes).subscribe((/**
1610
+ * @param {?} change
1611
+ * @return {?}
1612
+ */
1613
+ function (change) {
1614
+ _this.safelyUpdateActivityList(change.map((/**
1615
+ * @param {?} c
1616
+ * @return {?}
1617
+ */
1618
+ function (c) { return c.component; })));
1619
+ }));
1622
1620
  observe.valuesFrom(this.tabs.animationDone).subscribe((/**
1623
1621
  * @return {?}
1624
1622
  */
1625
1623
  function () { return _this.onAnimationFinished(); }));
1626
1624
  };
1625
+ /**
1626
+ * Update in the next tick to avoid changing state in the current change detection cycle.
1627
+ * @param activities
1628
+ */
1629
+ /**
1630
+ * Update in the next tick to avoid changing state in the current change detection cycle.
1631
+ * @private
1632
+ * @param {?} activities
1633
+ * @return {?}
1634
+ */
1635
+ ActivityContainerComponent.prototype.safelyUpdateActivityList = /**
1636
+ * Update in the next tick to avoid changing state in the current change detection cycle.
1637
+ * @private
1638
+ * @param {?} activities
1639
+ * @return {?}
1640
+ */
1641
+ function (activities) {
1642
+ var _this = this;
1643
+ setTimeout((/**
1644
+ * @return {?}
1645
+ */
1646
+ function () { return _this._activityList.value = activities; }));
1647
+ };
1627
1648
  /**
1628
1649
  * @template D, R, E
1629
1650
  * @param {?} initialContext
@@ -1808,7 +1829,7 @@
1808
1829
  parentInteractionContext: [{ type: core.Input }],
1809
1830
  initialActivityOutletContext: [{ type: core.Input }],
1810
1831
  tabs: [{ type: core.ViewChild, args: ['tabs', { static: true },] }],
1811
- outlets: [{ type: core.ViewChildren, args: [exports.ɵv,] }]
1832
+ outlets: [{ type: core.ViewChildren, args: [ActivityOutletComponent,] }]
1812
1833
  };
1813
1834
  return ActivityContainerComponent;
1814
1835
  }(DisposableComponent));
@@ -1818,6 +1839,8 @@
1818
1839
  /** @type {?} */
1819
1840
  exports.ɵu.prototype.initialActivityOutletContext;
1820
1841
  /** @type {?} */
1842
+ exports.ɵu.prototype.currentActivity;
1843
+ /** @type {?} */
1821
1844
  exports.ɵu.prototype.tabs;
1822
1845
  /** @type {?} */
1823
1846
  exports.ɵu.prototype.outlets;
@@ -1833,6 +1856,11 @@
1833
1856
  * @private
1834
1857
  */
1835
1858
  exports.ɵu.prototype.finished;
1859
+ /**
1860
+ * @type {?}
1861
+ * @private
1862
+ */
1863
+ exports.ɵu.prototype._activityList;
1836
1864
  }
1837
1865
  (function (ActivityContainerComponent) {
1838
1866
  /**
@@ -1861,14 +1889,47 @@
1861
1889
  var DIALOG_INTERACTION_SERVICE_DEFAULTS = new core.InjectionToken('DIALOG_INTERACTION_SERVICE_DEFAULTS');
1862
1890
  var DialogInteractionService = /** @class */ (function (_super) {
1863
1891
  __extends(DialogInteractionService, _super);
1864
- function DialogInteractionService(dialogService, dialogServiceDefaults, matDialogDefaultConfig) {
1892
+ function DialogInteractionService(dialogService, router, dialogServiceDefaults, matDialogDefaultConfig) {
1865
1893
  var _this = _super.call(this) || this;
1866
1894
  _this.dialogService = dialogService;
1895
+ _this.router = router;
1867
1896
  _this.dialogServiceDefaults = dialogServiceDefaults;
1868
1897
  _this.matDialogDefaultConfig = matDialogDefaultConfig;
1898
+ _this._activityList = new pectin.DelegatingListModel();
1899
+ _this._active = false;
1869
1900
  typescriptUtilities.assert.notNil(dialogService);
1901
+ var _a = pectin.Dsl.disposeWith(_this), chain = _a.chain, observe = _a.observe;
1902
+ _this.currentActivity = chain(_this.activityList).last();
1870
1903
  return _this;
1871
1904
  }
1905
+ /**
1906
+ * @return {?}
1907
+ */
1908
+ DialogInteractionService.prototype.isActive = /**
1909
+ * @return {?}
1910
+ */
1911
+ function () {
1912
+ return this._active;
1913
+ };
1914
+ /**
1915
+ * @return {?}
1916
+ */
1917
+ DialogInteractionService.prototype.cancelActivity = /**
1918
+ * @return {?}
1919
+ */
1920
+ function () {
1921
+ this.currentActivity.value.cancel(null);
1922
+ };
1923
+ Object.defineProperty(DialogInteractionService.prototype, "activityList", {
1924
+ get: /**
1925
+ * @return {?}
1926
+ */
1927
+ function () {
1928
+ return this._activityList.readonly;
1929
+ },
1930
+ enumerable: true,
1931
+ configurable: true
1932
+ });
1872
1933
  /**
1873
1934
  * @template D, R, E
1874
1935
  * @param {?} activityType
@@ -1903,8 +1964,18 @@
1903
1964
  function (activityType, data, disableClose) {
1904
1965
  var _this = this;
1905
1966
  if (disableClose === void 0) { disableClose = true; }
1967
+ if (this.isActive()) {
1968
+ pectin.lang.illegalState("Activity already in progress: " + this.activityList.value.map((/**
1969
+ * @param {?} a
1970
+ * @return {?}
1971
+ */
1972
+ function (a) { return a.constructor.name; })).join(', '));
1973
+ }
1974
+ this._active = true;
1975
+ /** @type {?} */
1976
+ var self = this;
1906
1977
  /** @type {?} */
1907
- var config = __assign({ autoFocus: false, hasBackdrop: true }, this.matDialogDefaultConfig, this.dialogServiceDefaults, {
1978
+ var config = __assign({ autoFocus: false, hasBackdrop: true, closeOnNavigation: false }, this.matDialogDefaultConfig, this.dialogServiceDefaults, {
1908
1979
  data: data,
1909
1980
  disableClose: disableClose,
1910
1981
  panelClass: 'dialog-interaction-service'
@@ -1920,6 +1991,7 @@
1920
1991
  /** @type {?} */
1921
1992
  var activityContainer = matDialogRef.componentInstance;
1922
1993
  activityContainer.parentInteractionContext = _this;
1994
+ self.safelyUpdateActivityListDelegate(activityContainer.activityList);
1923
1995
  activityContainer.initialise({
1924
1996
  activityClass: activityType,
1925
1997
  activityData: data,
@@ -1943,8 +2015,35 @@
1943
2015
  }
1944
2016
  });
1945
2017
  matDialogRef.updateSize();
2018
+ })).finally((/**
2019
+ * @return {?}
2020
+ */
2021
+ function () {
2022
+ self.safelyUpdateActivityListDelegate(null);
2023
+ self._active = false;
1946
2024
  }));
1947
2025
  };
2026
+ /**
2027
+ * Updates teh delegate on the next tick to avoid modifying state during the current change detection cycle.
2028
+ * @param delegate
2029
+ */
2030
+ /**
2031
+ * Updates teh delegate on the next tick to avoid modifying state during the current change detection cycle.
2032
+ * @param {?} delegate
2033
+ * @return {?}
2034
+ */
2035
+ DialogInteractionService.prototype.safelyUpdateActivityListDelegate = /**
2036
+ * Updates teh delegate on the next tick to avoid modifying state during the current change detection cycle.
2037
+ * @param {?} delegate
2038
+ * @return {?}
2039
+ */
2040
+ function (delegate) {
2041
+ var _this = this;
2042
+ setTimeout((/**
2043
+ * @return {?}
2044
+ */
2045
+ function () { return _this._activityList.setDelegate(delegate); }));
2046
+ };
1948
2047
  /**
1949
2048
  * @param {?} alert
1950
2049
  * @return {?}
@@ -1996,18 +2095,36 @@
1996
2095
  /** @nocollapse */
1997
2096
  DialogInteractionService.ctorParameters = function () { return [
1998
2097
  { type: material.MatDialog },
2098
+ { type: router.Router },
1999
2099
  { type: dialog.MatDialogConfig, decorators: [{ type: core.Optional }, { type: core.Inject, args: [DIALOG_INTERACTION_SERVICE_DEFAULTS,] }] },
2000
2100
  { type: dialog.MatDialogConfig, decorators: [{ type: core.Optional }, { type: core.Inject, args: [dialog.MAT_DIALOG_DEFAULT_OPTIONS,] }] }
2001
2101
  ]; };
2002
- /** @nocollapse */ DialogInteractionService.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function DialogInteractionService_Factory() { return new DialogInteractionService(core.ɵɵinject(dialog.MatDialog), core.ɵɵinject(DIALOG_INTERACTION_SERVICE_DEFAULTS, 8), core.ɵɵinject(dialog.MAT_DIALOG_DEFAULT_OPTIONS, 8)); }, token: DialogInteractionService, providedIn: "root" });
2102
+ /** @nocollapse */ DialogInteractionService.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function DialogInteractionService_Factory() { return new DialogInteractionService(core.ɵɵinject(dialog.MatDialog), core.ɵɵinject(router.Router), core.ɵɵinject(DIALOG_INTERACTION_SERVICE_DEFAULTS, 8), core.ɵɵinject(dialog.MAT_DIALOG_DEFAULT_OPTIONS, 8)); }, token: DialogInteractionService, providedIn: "root" });
2003
2103
  return DialogInteractionService;
2004
2104
  }(InteractionContext));
2005
2105
  if (false) {
2106
+ /** @type {?} */
2107
+ DialogInteractionService.prototype.currentActivity;
2108
+ /**
2109
+ * @type {?}
2110
+ * @private
2111
+ */
2112
+ DialogInteractionService.prototype._activityList;
2113
+ /**
2114
+ * @type {?}
2115
+ * @private
2116
+ */
2117
+ DialogInteractionService.prototype._active;
2006
2118
  /**
2007
2119
  * @type {?}
2008
2120
  * @private
2009
2121
  */
2010
2122
  DialogInteractionService.prototype.dialogService;
2123
+ /**
2124
+ * @type {?}
2125
+ * @private
2126
+ */
2127
+ DialogInteractionService.prototype.router;
2011
2128
  /** @type {?} */
2012
2129
  DialogInteractionService.prototype.dialogServiceDefaults;
2013
2130
  /** @type {?} */
@@ -2035,11 +2152,11 @@
2035
2152
  ConfirmationDialogComponent,
2036
2153
  exports.ɵba,
2037
2154
  AlertDialogComponent,
2038
- exports.ɵv
2155
+ ActivityOutletComponent
2039
2156
  ],
2040
2157
  exports: [
2041
2158
  exports.ɵu,
2042
- exports.ɵv,
2159
+ ActivityOutletComponent,
2043
2160
  ],
2044
2161
  entryComponents: [
2045
2162
  exports.ɵu,
@@ -4488,6 +4605,65 @@
4488
4605
  ActivityOutletContext.prototype.onCancel;
4489
4606
  }
4490
4607
 
4608
+ /**
4609
+ * @fileoverview added by tsickle
4610
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4611
+ */
4612
+ var CloseInteractionGuard = /** @class */ (function () {
4613
+ function CloseInteractionGuard(router, injector, interactionContext) {
4614
+ this.router = router;
4615
+ this.injector = injector;
4616
+ this.interactionContext = interactionContext;
4617
+ }
4618
+ /**
4619
+ * @param {?} component
4620
+ * @param {?} currentRoute
4621
+ * @param {?} currentState
4622
+ * @param {?=} nextState
4623
+ * @return {?}
4624
+ */
4625
+ CloseInteractionGuard.prototype.canDeactivate = /**
4626
+ * @param {?} component
4627
+ * @param {?} currentRoute
4628
+ * @param {?} currentState
4629
+ * @param {?=} nextState
4630
+ * @return {?}
4631
+ */
4632
+ function (component, currentRoute, currentState, nextState) {
4633
+ return !this.interactionContext.isActive();
4634
+ };
4635
+ CloseInteractionGuard.decorators = [
4636
+ { type: core.Injectable, args: [{
4637
+ providedIn: 'root'
4638
+ },] }
4639
+ ];
4640
+ /** @nocollapse */
4641
+ CloseInteractionGuard.ctorParameters = function () { return [
4642
+ { type: router.Router },
4643
+ { type: core.Injector },
4644
+ { type: InteractionContext }
4645
+ ]; };
4646
+ /** @nocollapse */ CloseInteractionGuard.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function CloseInteractionGuard_Factory() { return new CloseInteractionGuard(core.ɵɵinject(router.Router), core.ɵɵinject(core.INJECTOR), core.ɵɵinject(InteractionContext)); }, token: CloseInteractionGuard, providedIn: "root" });
4647
+ return CloseInteractionGuard;
4648
+ }());
4649
+ if (false) {
4650
+ /**
4651
+ * @type {?}
4652
+ * @private
4653
+ */
4654
+ CloseInteractionGuard.prototype.router;
4655
+ /**
4656
+ * @type {?}
4657
+ * @private
4658
+ */
4659
+ CloseInteractionGuard.prototype.injector;
4660
+ /**
4661
+ * @type {?}
4662
+ * @private
4663
+ */
4664
+ CloseInteractionGuard.prototype.interactionContext;
4665
+ }
4666
+
4491
4667
  /**
4492
4668
  * @fileoverview added by tsickle
4493
4669
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -4589,9 +4765,33 @@
4589
4765
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4590
4766
  */
4591
4767
  var LeavePlaceGuard = /** @class */ (function () {
4592
- function LeavePlaceGuard(router, injector) {
4593
- this.router = router;
4768
+ function LeavePlaceGuard(router$1, injector, interactionContext, location) {
4769
+ this.router = router$1;
4594
4770
  this.injector = injector;
4771
+ this.interactionContext = interactionContext;
4772
+ this.location = location;
4773
+ // TODO: should probably replace this with a RouteTracker thingy.
4774
+ this._alreadyAccepted = [];
4775
+ console.log('***** Created new guard ******');
4776
+ /** @type {?} */
4777
+ var self = this;
4778
+ this.router.events.subscribe((/**
4779
+ * @param {?} event
4780
+ * @return {?}
4781
+ */
4782
+ function (event) {
4783
+ // NavigationStart -> .... -> NavigationCancel === redirect (so don't ask again)
4784
+ // NavigationStart -> .... -> NavigationEnd === navigated (so ask next time)
4785
+ // NavigationStart -> .... -> NavigationError === canceled (guard cancelled so ask next time)
4786
+ if (event instanceof router.NavigationEnd) {
4787
+ console.log('navigation ended');
4788
+ self._alreadyAccepted = [];
4789
+ }
4790
+ if (event instanceof router.NavigationError) {
4791
+ console.log('navigation errored');
4792
+ self._alreadyAccepted = [];
4793
+ }
4794
+ }));
4595
4795
  }
4596
4796
  /**
4597
4797
  * @param {?} component
@@ -4608,27 +4808,106 @@
4608
4808
  * @return {?}
4609
4809
  */
4610
4810
  function (component, currentRoute, currentState, nextState) {
4611
- // HACK: this will break with child routes...
4811
+ var _this = this;
4612
4812
  /** @type {?} */
4613
- var path = "/" + component.placeDefinition.path;
4614
- // let thisTree = this.router.parseUrl(currentState.url);
4615
- // let nextTree = this.router.parseUrl(nextState.url);
4616
- // console.log({
4617
- // placePath: path,
4618
- // currentRoute: currentRoute.toString(),
4619
- // currentStateUrl: currentState.url,
4620
- // nextStateUrl: nextState.url,
4621
- // currentStateUrlTree: thisTree.root.children[PRIMARY_OUTLET].segments,
4622
- // nextStateUrlTree: nextTree.root.children[PRIMARY_OUTLET].segments
4623
- // });
4624
- // nextState is the full path...
4625
- if (!nextState.url.startsWith(path)) {
4626
- return component.canDeactivate();
4813
+ var placeDefinitionPath = "/" + component.placeDefinition.path;
4814
+ console.log('canDeactivate', {
4815
+ staticPath: placeDefinitionPath,
4816
+ currentStateUrl: currentState.url,
4817
+ nextStateUrl: nextState.url,
4818
+ alreadyDeclined: this._alreadyAccepted
4819
+ });
4820
+ // Example of the above when navigating to a different child route.
4821
+ // canDeactivate {staticPath: "/hero-details",
4822
+ // currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-details",
4823
+ // nextStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats"
4824
+ // }
4825
+ // Example clicking on router tab of the parent component (de-activates the parent due to route param changes)
4826
+ // canDeactivate {
4827
+ // staticPath: "/hero-stats",
4828
+ // currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats",
4829
+ // nextStateUrl: "/route-parameters/"
4830
+ // }
4831
+ // canDeactivate {
4832
+ // staticPath: "/route-parameters",
4833
+ // currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats",
4834
+ // nextStateUrl: "/route-parameters/"
4835
+ // }
4836
+ // logger.class.js:54 ParameterSnapshot.sanitise -> {idModel: -1, pv: undefined, pl: Array(0), dv: undefined, dl: Array(0), …}
4837
+ // parameter-snapshot.ts:20 {name: "idModel", mine: -1, theirs: null}
4838
+ // place-router.ts:28 redirect path (3) ["route-parameters", "-1", {…}]
4839
+ // canDeactivate {
4840
+ // staticPath: "/hero-stats",
4841
+ // currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats",
4842
+ // nextStateUrl: "/route-parameters/-1"
4843
+ // }
4844
+ // canDeactivate {
4845
+ // staticPath: "/route-parameters",
4846
+ // currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats",
4847
+ // nextStateUrl: "/route-parameters/-1"
4848
+ // }
4849
+ // logger.class.js:54 ParameterSnapshot.sanitise -> {idModel: -1, pv: undefined, pl: Array(0), dv: "A", dl: Array(3), …}
4850
+ // parameter-snapshot.ts:20 {name: "dv", mine: "A", theirs: undefined}
4851
+ // place-router.ts:28 redirect path (3) ["route-parameters", "-1", {…}]
4852
+ // canDeactivate {
4853
+ // staticPath: "/hero-stats",
4854
+ // currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats",
4855
+ // nextStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c"
4856
+ // }
4857
+ // HACK: this will break with child routes...
4858
+ if (this.alreadyAccepted(component)) {
4859
+ return true;
4627
4860
  }
4628
4861
  else {
4862
+ if (!nextState.url.startsWith(placeDefinitionPath)) {
4863
+ /** @type {?} */
4864
+ var self_1 = this;
4865
+ return Promise.resolve(component.canDeactivate())
4866
+ .then((/**
4867
+ * @param {?} canLeave
4868
+ * @return {?}
4869
+ */
4870
+ function (canLeave) {
4871
+ if (!canLeave) {
4872
+ // Angular doesn't preserve the url when a guard cancels the back button.
4873
+ // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
4874
+ _this.location.go(currentState.url);
4875
+ return false;
4876
+ }
4877
+ else {
4878
+ if (_this.interactionContext.isActive()) {
4879
+ _this.interactionContext.currentActivity.value.cancel(null);
4880
+ return false;
4881
+ }
4882
+ else {
4883
+ return true;
4884
+ }
4885
+ }
4886
+ })).then((/**
4887
+ * @param {?} canDeactivate
4888
+ * @return {?}
4889
+ */
4890
+ function (canDeactivate) {
4891
+ if (canDeactivate) {
4892
+ self_1._alreadyAccepted.push(component);
4893
+ }
4894
+ return canDeactivate;
4895
+ }));
4896
+ }
4629
4897
  return true;
4630
4898
  }
4631
4899
  };
4900
+ /**
4901
+ * @param {?} placeComponent
4902
+ * @return {?}
4903
+ */
4904
+ LeavePlaceGuard.prototype.alreadyAccepted = /**
4905
+ * @param {?} placeComponent
4906
+ * @return {?}
4907
+ */
4908
+ function (placeComponent) {
4909
+ return this._alreadyAccepted.includes(placeComponent);
4910
+ };
4632
4911
  LeavePlaceGuard.decorators = [
4633
4912
  { type: core.Injectable, args: [{
4634
4913
  providedIn: 'root'
@@ -4637,12 +4916,25 @@
4637
4916
  /** @nocollapse */
4638
4917
  LeavePlaceGuard.ctorParameters = function () { return [
4639
4918
  { type: router.Router },
4640
- { type: core.Injector }
4919
+ { type: core.Injector },
4920
+ { type: InteractionContext },
4921
+ { type: common.Location }
4641
4922
  ]; };
4642
- /** @nocollapse */ LeavePlaceGuard.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function LeavePlaceGuard_Factory() { return new LeavePlaceGuard(core.ɵɵinject(router.Router), core.ɵɵinject(core.INJECTOR)); }, token: LeavePlaceGuard, providedIn: "root" });
4923
+ /** @nocollapse */ LeavePlaceGuard.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function LeavePlaceGuard_Factory() { return new LeavePlaceGuard(core.ɵɵinject(router.Router), core.ɵɵinject(core.INJECTOR), core.ɵɵinject(InteractionContext), core.ɵɵinject(common.Location)); }, token: LeavePlaceGuard, providedIn: "root" });
4924
+ __decorate([
4925
+ pectin.Trace(),
4926
+ __metadata("design:type", Function),
4927
+ __metadata("design:paramtypes", [exports.PlaceComponent]),
4928
+ __metadata("design:returntype", Boolean)
4929
+ ], LeavePlaceGuard.prototype, "alreadyAccepted", null);
4643
4930
  return LeavePlaceGuard;
4644
4931
  }());
4645
4932
  if (false) {
4933
+ /**
4934
+ * @type {?}
4935
+ * @private
4936
+ */
4937
+ LeavePlaceGuard.prototype._alreadyAccepted;
4646
4938
  /**
4647
4939
  * @type {?}
4648
4940
  * @private
@@ -4653,6 +4945,10 @@
4653
4945
  * @private
4654
4946
  */
4655
4947
  LeavePlaceGuard.prototype.injector;
4948
+ /** @type {?} */
4949
+ LeavePlaceGuard.prototype.interactionContext;
4950
+ /** @type {?} */
4951
+ LeavePlaceGuard.prototype.location;
4656
4952
  }
4657
4953
 
4658
4954
  /**
@@ -4946,10 +5242,11 @@
4946
5242
  exports.AbstractInputComponent = AbstractInputComponent;
4947
5243
  exports.AbstractPlaceNavigationComponent = AbstractPlaceNavigationComponent;
4948
5244
  exports.ActivityContainerComponent = exports.ɵu;
4949
- exports.ActivityOutletComponent = exports.ɵv;
5245
+ exports.ActivityOutletComponent = ActivityOutletComponent;
4950
5246
  exports.AlertDialogComponent = AlertDialogComponent;
4951
5247
  exports.AngularUiPowerupsModule = AngularUiPowerupsModule;
4952
5248
  exports.BusyOverlayComponent = BusyOverlayComponent;
5249
+ exports.CloseInteractionGuard = CloseInteractionGuard;
4953
5250
  exports.CommandDirective = CommandDirective;
4954
5251
  exports.ConfirmThenDialogComponent = exports.ɵba;
4955
5252
  exports.ConfirmationDialogComponent = ConfirmationDialogComponent;
@@ -4960,7 +5257,6 @@
4960
5257
  exports.DisposableComponent = DisposableComponent;
4961
5258
  exports.EmptyStateComponent = EmptyStateComponent;
4962
5259
  exports.FocusBindingDirective = FocusBindingDirective;
4963
- exports.INTERACTION_CONTEXT = INTERACTION_CONTEXT;
4964
5260
  exports.InteractionContext = InteractionContext;
4965
5261
  exports.InteractionModule = InteractionModule;
4966
5262
  exports.LEFT_RIGHT_PLACE_ANIMATION = LEFT_RIGHT_PLACE_ANIMATION;
@@ -5010,6 +5306,7 @@
5010
5306
  exports.ɵr = AbstractPlaceNavigationComponent;
5011
5307
  exports.ɵs = ListPlaceNavComponent;
5012
5308
  exports.ɵt = InteractionModule;
5309
+ exports.ɵv = ActivityOutletComponent;
5013
5310
  exports.ɵw = ConfirmationDialogComponent;
5014
5311
  exports.ɵx = AbstractActivity;
5015
5312
  exports.ɵy = ACTIVITY_DATA;