@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.
- package/bundles/coolon-angular-ui-powerups.umd.js +419 -117
- package/bundles/coolon-angular-ui-powerups.umd.js.map +1 -1
- package/bundles/coolon-angular-ui-powerups.umd.min.js +1 -1
- package/bundles/coolon-angular-ui-powerups.umd.min.js.map +1 -1
- package/coolon-angular-ui-powerups.metadata.json +1 -1
- package/esm2015/coolon-angular-ui-powerups.js +2 -2
- package/esm2015/index.js +2 -2
- package/esm2015/lib/interaction/activity.js +11 -1
- package/esm2015/lib/interaction/components/activity-container/activity-container.component.js +49 -1
- package/esm2015/lib/interaction/components/activity-outlet/activity-outlet.component.js +7 -56
- package/esm2015/lib/interaction/guards/close-interaction.guard.js +62 -0
- package/esm2015/lib/interaction/index.js +3 -2
- package/esm2015/lib/interaction/interaction-context.js +25 -5
- package/esm2015/lib/interaction/services/dialog-interaction.service.js +93 -4
- package/esm2015/lib/place/guards/leave-place.guard.js +128 -20
- package/esm2015/public_api.js +2 -2
- package/esm5/coolon-angular-ui-powerups.js +2 -2
- package/esm5/index.js +2 -2
- package/esm5/lib/interaction/activity.js +11 -1
- package/esm5/lib/interaction/components/activity-container/activity-container.component.js +67 -1
- package/esm5/lib/interaction/components/activity-outlet/activity-outlet.component.js +11 -78
- package/esm5/lib/interaction/guards/close-interaction.guard.js +66 -0
- package/esm5/lib/interaction/index.js +3 -2
- package/esm5/lib/interaction/interaction-context.js +33 -6
- package/esm5/lib/interaction/services/dialog-interaction.service.js +109 -4
- package/esm5/lib/place/guards/leave-place.guard.js +131 -20
- package/esm5/public_api.js +2 -2
- package/fesm2015/coolon-angular-ui-powerups.js +355 -82
- package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
- package/fesm5/coolon-angular-ui-powerups.js +406 -105
- package/fesm5/coolon-angular-ui-powerups.js.map +1 -1
- package/lib/interaction/activity.d.ts +2 -0
- package/lib/interaction/components/activity-container/activity-container.component.d.ts +10 -1
- package/lib/interaction/components/activity-outlet/activity-outlet.component.d.ts +2 -9
- package/lib/interaction/guards/close-interaction.guard.d.ts +12 -0
- package/lib/interaction/index.d.ts +1 -0
- package/lib/interaction/interaction-context.d.ts +17 -4
- package/lib/interaction/services/dialog-interaction.service.d.ts +14 -2
- package/lib/place/guards/leave-place.guard.d.ts +7 -1
- 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 { __decorate, __metadata, __awaiter } 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';
|
|
@@ -651,14 +651,34 @@ if (false) {
|
|
|
651
651
|
* @fileoverview added by tsickle
|
|
652
652
|
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
653
653
|
*/
|
|
654
|
-
/** @type {?} */
|
|
655
|
-
const INTERACTION_CONTEXT = new InjectionToken('InteractionContext');
|
|
656
654
|
/**
|
|
657
655
|
* @abstract
|
|
658
656
|
*/
|
|
659
|
-
class InteractionContext {
|
|
657
|
+
class InteractionContext extends GarbageCollector {
|
|
658
|
+
constructor() {
|
|
659
|
+
super();
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* Returns true if an activity is currently running.
|
|
663
|
+
* @return {?}
|
|
664
|
+
*/
|
|
665
|
+
isActive() {
|
|
666
|
+
return this.activityList.length > 0;
|
|
667
|
+
}
|
|
660
668
|
}
|
|
661
669
|
if (false) {
|
|
670
|
+
/**
|
|
671
|
+
* Returns the activity that is currently active.
|
|
672
|
+
* This model is only updated in the next tick after the view has been updated.
|
|
673
|
+
* @type {?}
|
|
674
|
+
*/
|
|
675
|
+
InteractionContext.prototype.currentActivity;
|
|
676
|
+
/**
|
|
677
|
+
* Returns the current list of activities that are in progress.
|
|
678
|
+
* This model is only updated in the next tick after the view has been updated.
|
|
679
|
+
* @type {?}
|
|
680
|
+
*/
|
|
681
|
+
InteractionContext.prototype.activityList;
|
|
662
682
|
/**
|
|
663
683
|
* @abstract
|
|
664
684
|
* @template D, R, E
|
|
@@ -710,6 +730,16 @@ if (false) {
|
|
|
710
730
|
* @return {?}
|
|
711
731
|
*/
|
|
712
732
|
Activity.prototype.initialise = function (activityContext) { };
|
|
733
|
+
/**
|
|
734
|
+
* @param {?} result
|
|
735
|
+
* @return {?}
|
|
736
|
+
*/
|
|
737
|
+
Activity.prototype.done = function (result) { };
|
|
738
|
+
/**
|
|
739
|
+
* @param {?} e
|
|
740
|
+
* @return {?}
|
|
741
|
+
*/
|
|
742
|
+
Activity.prototype.cancel = function (e) { };
|
|
713
743
|
}
|
|
714
744
|
|
|
715
745
|
/**
|
|
@@ -770,6 +800,12 @@ class ActivityOutletComponent {
|
|
|
770
800
|
this.activityComponentRef = this.viewContainerRef.createComponent(componentFactory, 0, injector);
|
|
771
801
|
this.activityComponentRef.instance.initialise(activityContext);
|
|
772
802
|
}
|
|
803
|
+
/**
|
|
804
|
+
* @return {?}
|
|
805
|
+
*/
|
|
806
|
+
get component() {
|
|
807
|
+
return this.activityComponentRef.instance;
|
|
808
|
+
}
|
|
773
809
|
/**
|
|
774
810
|
* @param {?} alert
|
|
775
811
|
* @return {?}
|
|
@@ -854,60 +890,6 @@ if (false) {
|
|
|
854
890
|
ActivityOutletComponent.prototype.injector;
|
|
855
891
|
/* Skipping unhandled member: ;*/
|
|
856
892
|
}
|
|
857
|
-
(function (ActivityOutletComponent) {
|
|
858
|
-
/**
|
|
859
|
-
* @template D, R, E
|
|
860
|
-
*/
|
|
861
|
-
class OutletInteractionContext {
|
|
862
|
-
/**
|
|
863
|
-
* @param {?} context
|
|
864
|
-
*/
|
|
865
|
-
constructor(context) {
|
|
866
|
-
this.context = context;
|
|
867
|
-
}
|
|
868
|
-
/**
|
|
869
|
-
* @param {?} alert
|
|
870
|
-
* @return {?}
|
|
871
|
-
*/
|
|
872
|
-
alert(alert) {
|
|
873
|
-
return lang.notImplemented();
|
|
874
|
-
}
|
|
875
|
-
/**
|
|
876
|
-
* @param {?} confirm
|
|
877
|
-
* @return {?}
|
|
878
|
-
*/
|
|
879
|
-
confirm(confirm) {
|
|
880
|
-
return lang.notImplemented();
|
|
881
|
-
}
|
|
882
|
-
/**
|
|
883
|
-
* @template D1, R1, E1
|
|
884
|
-
* @param {?} confirm
|
|
885
|
-
* @param {?} activityType
|
|
886
|
-
* @param {?=} data
|
|
887
|
-
* @return {?}
|
|
888
|
-
*/
|
|
889
|
-
confirmThen(confirm, activityType, data) {
|
|
890
|
-
return lang.notImplemented();
|
|
891
|
-
}
|
|
892
|
-
/**
|
|
893
|
-
* @template D1, R1, E1
|
|
894
|
-
* @param {?} activityType
|
|
895
|
-
* @param {?=} data
|
|
896
|
-
* @return {?}
|
|
897
|
-
*/
|
|
898
|
-
startActivity(activityType, data) {
|
|
899
|
-
return lang.notImplemented();
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
ActivityOutletComponent.OutletInteractionContext = OutletInteractionContext;
|
|
903
|
-
if (false) {
|
|
904
|
-
/**
|
|
905
|
-
* @type {?}
|
|
906
|
-
* @private
|
|
907
|
-
*/
|
|
908
|
-
OutletInteractionContext.prototype.context;
|
|
909
|
-
}
|
|
910
|
-
})(ActivityOutletComponent || (ActivityOutletComponent = {}));
|
|
911
893
|
|
|
912
894
|
/**
|
|
913
895
|
* @fileoverview added by tsickle
|
|
@@ -1154,6 +1136,19 @@ class ActivityContainerComponent extends DisposableComponent {
|
|
|
1154
1136
|
this.activityOutletTabs = new MutableListModel();
|
|
1155
1137
|
this.obsoleteTabs = [];
|
|
1156
1138
|
this.finished = false;
|
|
1139
|
+
this._activityList = new MutableListModel();
|
|
1140
|
+
}
|
|
1141
|
+
/**
|
|
1142
|
+
* @return {?}
|
|
1143
|
+
*/
|
|
1144
|
+
isActive() {
|
|
1145
|
+
return this.parentInteractionContext.isActive();
|
|
1146
|
+
}
|
|
1147
|
+
/**
|
|
1148
|
+
* @return {?}
|
|
1149
|
+
*/
|
|
1150
|
+
get activityList() {
|
|
1151
|
+
return this._activityList.readonly;
|
|
1157
1152
|
}
|
|
1158
1153
|
/**
|
|
1159
1154
|
* @return {?}
|
|
@@ -1165,11 +1160,39 @@ class ActivityContainerComponent extends DisposableComponent {
|
|
|
1165
1160
|
*/
|
|
1166
1161
|
ngAfterViewInit() {
|
|
1167
1162
|
const { observe } = Dsl.disposeWith(this);
|
|
1163
|
+
this._activityList.value = this.outlets.toArray().map((/**
|
|
1164
|
+
* @param {?} c
|
|
1165
|
+
* @return {?}
|
|
1166
|
+
*/
|
|
1167
|
+
c => c.component));
|
|
1168
|
+
observe.valuesFrom(this.outlets.changes).subscribe((/**
|
|
1169
|
+
* @param {?} change
|
|
1170
|
+
* @return {?}
|
|
1171
|
+
*/
|
|
1172
|
+
(change) => {
|
|
1173
|
+
this.safelyUpdateActivityList(change.map((/**
|
|
1174
|
+
* @param {?} c
|
|
1175
|
+
* @return {?}
|
|
1176
|
+
*/
|
|
1177
|
+
c => c.component)));
|
|
1178
|
+
}));
|
|
1168
1179
|
observe.valuesFrom(this.tabs.animationDone).subscribe((/**
|
|
1169
1180
|
* @return {?}
|
|
1170
1181
|
*/
|
|
1171
1182
|
() => this.onAnimationFinished()));
|
|
1172
1183
|
}
|
|
1184
|
+
/**
|
|
1185
|
+
* Update in the next tick to avoid changing state in the current change detection cycle.
|
|
1186
|
+
* @private
|
|
1187
|
+
* @param {?} activities
|
|
1188
|
+
* @return {?}
|
|
1189
|
+
*/
|
|
1190
|
+
safelyUpdateActivityList(activities) {
|
|
1191
|
+
setTimeout((/**
|
|
1192
|
+
* @return {?}
|
|
1193
|
+
*/
|
|
1194
|
+
() => this._activityList.value = activities));
|
|
1195
|
+
}
|
|
1173
1196
|
/**
|
|
1174
1197
|
* @template D, R, E
|
|
1175
1198
|
* @param {?} initialContext
|
|
@@ -1327,6 +1350,8 @@ if (false) {
|
|
|
1327
1350
|
/** @type {?} */
|
|
1328
1351
|
ActivityContainerComponent.prototype.initialActivityOutletContext;
|
|
1329
1352
|
/** @type {?} */
|
|
1353
|
+
ActivityContainerComponent.prototype.currentActivity;
|
|
1354
|
+
/** @type {?} */
|
|
1330
1355
|
ActivityContainerComponent.prototype.tabs;
|
|
1331
1356
|
/** @type {?} */
|
|
1332
1357
|
ActivityContainerComponent.prototype.outlets;
|
|
@@ -1342,6 +1367,11 @@ if (false) {
|
|
|
1342
1367
|
* @private
|
|
1343
1368
|
*/
|
|
1344
1369
|
ActivityContainerComponent.prototype.finished;
|
|
1370
|
+
/**
|
|
1371
|
+
* @type {?}
|
|
1372
|
+
* @private
|
|
1373
|
+
*/
|
|
1374
|
+
ActivityContainerComponent.prototype._activityList;
|
|
1345
1375
|
}
|
|
1346
1376
|
(function (ActivityContainerComponent) {
|
|
1347
1377
|
/**
|
|
@@ -1371,15 +1401,55 @@ const DIALOG_INTERACTION_SERVICE_DEFAULTS = new InjectionToken('DIALOG_INTERACTI
|
|
|
1371
1401
|
class DialogInteractionService extends InteractionContext {
|
|
1372
1402
|
/**
|
|
1373
1403
|
* @param {?} dialogService
|
|
1404
|
+
* @param {?} router
|
|
1374
1405
|
* @param {?} dialogServiceDefaults
|
|
1375
1406
|
* @param {?} matDialogDefaultConfig
|
|
1376
1407
|
*/
|
|
1377
|
-
constructor(dialogService, dialogServiceDefaults, matDialogDefaultConfig) {
|
|
1408
|
+
constructor(dialogService, router, dialogServiceDefaults, matDialogDefaultConfig) {
|
|
1378
1409
|
super();
|
|
1379
1410
|
this.dialogService = dialogService;
|
|
1411
|
+
this.router = router;
|
|
1380
1412
|
this.dialogServiceDefaults = dialogServiceDefaults;
|
|
1381
1413
|
this.matDialogDefaultConfig = matDialogDefaultConfig;
|
|
1414
|
+
this._activityList = new DelegatingListModel();
|
|
1415
|
+
this._active = false;
|
|
1382
1416
|
assert$1.notNil(dialogService);
|
|
1417
|
+
const { chain, observe } = Dsl.disposeWith(this);
|
|
1418
|
+
this.currentActivity = chain(this.activityList).last();
|
|
1419
|
+
// observe.valuesFrom(this.router.events)
|
|
1420
|
+
// .tap((event:RouterEvent) => {
|
|
1421
|
+
// const nav = router.getCurrentNavigation();
|
|
1422
|
+
// console.log({
|
|
1423
|
+
// previousUrl: nav.previousNavigation && nav.previousNavigation.finalUrl,
|
|
1424
|
+
// initialUrl: nav.initialUrl,
|
|
1425
|
+
// finalUrl: nav.finalUrl,
|
|
1426
|
+
// });
|
|
1427
|
+
//
|
|
1428
|
+
// })
|
|
1429
|
+
// .filter(event => event instanceof NavigationStart)
|
|
1430
|
+
// .subscribe((event: NavigationStart) => {
|
|
1431
|
+
// console.log(event.navigationTrigger);
|
|
1432
|
+
// if (event.navigationTrigger === 'popstate' && this.isActive()) {
|
|
1433
|
+
// const prev = router.getCurrentNavigation().previousNavigation.finalUrl;
|
|
1434
|
+
// // this.router.navigateByUrl(prev.toString(), {
|
|
1435
|
+
// // replaceUrl: true,
|
|
1436
|
+
// // skipLocationChange: false
|
|
1437
|
+
// // });
|
|
1438
|
+
// // this.cancelActivity();
|
|
1439
|
+
// }
|
|
1440
|
+
// });
|
|
1441
|
+
}
|
|
1442
|
+
/**
|
|
1443
|
+
* @return {?}
|
|
1444
|
+
*/
|
|
1445
|
+
cancelActivity() {
|
|
1446
|
+
this.currentActivity.value.cancel(null);
|
|
1447
|
+
}
|
|
1448
|
+
/**
|
|
1449
|
+
* @return {?}
|
|
1450
|
+
*/
|
|
1451
|
+
get activityList() {
|
|
1452
|
+
return this._activityList.readonly;
|
|
1383
1453
|
}
|
|
1384
1454
|
/**
|
|
1385
1455
|
* @template D, R, E
|
|
@@ -1399,8 +1469,18 @@ class DialogInteractionService extends InteractionContext {
|
|
|
1399
1469
|
* @return {?}
|
|
1400
1470
|
*/
|
|
1401
1471
|
_startActivity(activityType, data, disableClose = true) {
|
|
1472
|
+
if (this.isActive()) {
|
|
1473
|
+
lang.illegalState(`Activity already in progress: ${this.activityList.value.map((/**
|
|
1474
|
+
* @param {?} a
|
|
1475
|
+
* @return {?}
|
|
1476
|
+
*/
|
|
1477
|
+
a => a.constructor.name)).join(', ')}`);
|
|
1478
|
+
}
|
|
1479
|
+
this._active = true;
|
|
1402
1480
|
/** @type {?} */
|
|
1403
|
-
const
|
|
1481
|
+
const self = this;
|
|
1482
|
+
/** @type {?} */
|
|
1483
|
+
const config = Object.assign({ autoFocus: false, hasBackdrop: true, closeOnNavigation: false }, this.matDialogDefaultConfig, this.dialogServiceDefaults, {
|
|
1404
1484
|
data,
|
|
1405
1485
|
disableClose,
|
|
1406
1486
|
panelClass: 'dialog-interaction-service'
|
|
@@ -1416,6 +1496,7 @@ class DialogInteractionService extends InteractionContext {
|
|
|
1416
1496
|
/** @type {?} */
|
|
1417
1497
|
const activityContainer = matDialogRef.componentInstance;
|
|
1418
1498
|
activityContainer.parentInteractionContext = this;
|
|
1499
|
+
self.safelyUpdateActivityListDelegate(activityContainer.activityList);
|
|
1419
1500
|
activityContainer.initialise({
|
|
1420
1501
|
activityClass: activityType,
|
|
1421
1502
|
activityData: data,
|
|
@@ -1439,8 +1520,25 @@ class DialogInteractionService extends InteractionContext {
|
|
|
1439
1520
|
}
|
|
1440
1521
|
});
|
|
1441
1522
|
matDialogRef.updateSize();
|
|
1523
|
+
})).finally((/**
|
|
1524
|
+
* @return {?}
|
|
1525
|
+
*/
|
|
1526
|
+
() => {
|
|
1527
|
+
self.safelyUpdateActivityListDelegate(null);
|
|
1528
|
+
self._active = false;
|
|
1442
1529
|
}));
|
|
1443
1530
|
}
|
|
1531
|
+
/**
|
|
1532
|
+
* Updates teh delegate on the next tick to avoid modifying state during the current change detection cycle.
|
|
1533
|
+
* @param {?} delegate
|
|
1534
|
+
* @return {?}
|
|
1535
|
+
*/
|
|
1536
|
+
safelyUpdateActivityListDelegate(delegate) {
|
|
1537
|
+
setTimeout((/**
|
|
1538
|
+
* @return {?}
|
|
1539
|
+
*/
|
|
1540
|
+
() => this._activityList.setDelegate(delegate)));
|
|
1541
|
+
}
|
|
1444
1542
|
/**
|
|
1445
1543
|
* @param {?} alert
|
|
1446
1544
|
* @return {?}
|
|
@@ -1478,16 +1576,34 @@ DialogInteractionService.decorators = [
|
|
|
1478
1576
|
/** @nocollapse */
|
|
1479
1577
|
DialogInteractionService.ctorParameters = () => [
|
|
1480
1578
|
{ type: MatDialog },
|
|
1579
|
+
{ type: Router },
|
|
1481
1580
|
{ type: MatDialogConfig, decorators: [{ type: Optional }, { type: Inject, args: [DIALOG_INTERACTION_SERVICE_DEFAULTS,] }] },
|
|
1482
1581
|
{ type: MatDialogConfig, decorators: [{ type: Optional }, { type: Inject, args: [MAT_DIALOG_DEFAULT_OPTIONS,] }] }
|
|
1483
1582
|
];
|
|
1484
|
-
/** @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" });
|
|
1583
|
+
/** @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" });
|
|
1485
1584
|
if (false) {
|
|
1585
|
+
/** @type {?} */
|
|
1586
|
+
DialogInteractionService.prototype.currentActivity;
|
|
1587
|
+
/**
|
|
1588
|
+
* @type {?}
|
|
1589
|
+
* @private
|
|
1590
|
+
*/
|
|
1591
|
+
DialogInteractionService.prototype._activityList;
|
|
1592
|
+
/**
|
|
1593
|
+
* @type {?}
|
|
1594
|
+
* @private
|
|
1595
|
+
*/
|
|
1596
|
+
DialogInteractionService.prototype._active;
|
|
1486
1597
|
/**
|
|
1487
1598
|
* @type {?}
|
|
1488
1599
|
* @private
|
|
1489
1600
|
*/
|
|
1490
1601
|
DialogInteractionService.prototype.dialogService;
|
|
1602
|
+
/**
|
|
1603
|
+
* @type {?}
|
|
1604
|
+
* @private
|
|
1605
|
+
*/
|
|
1606
|
+
DialogInteractionService.prototype.router;
|
|
1491
1607
|
/** @type {?} */
|
|
1492
1608
|
DialogInteractionService.prototype.dialogServiceDefaults;
|
|
1493
1609
|
/** @type {?} */
|
|
@@ -3591,6 +3707,62 @@ if (false) {
|
|
|
3591
3707
|
ActivityOutletContext.prototype.onCancel;
|
|
3592
3708
|
}
|
|
3593
3709
|
|
|
3710
|
+
/**
|
|
3711
|
+
* @fileoverview added by tsickle
|
|
3712
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3713
|
+
*/
|
|
3714
|
+
class CloseInteractionGuard {
|
|
3715
|
+
/**
|
|
3716
|
+
* @param {?} router
|
|
3717
|
+
* @param {?} injector
|
|
3718
|
+
* @param {?} interactionContext
|
|
3719
|
+
*/
|
|
3720
|
+
constructor(router, injector, interactionContext) {
|
|
3721
|
+
this.router = router;
|
|
3722
|
+
this.injector = injector;
|
|
3723
|
+
this.interactionContext = interactionContext;
|
|
3724
|
+
}
|
|
3725
|
+
/**
|
|
3726
|
+
* @param {?} component
|
|
3727
|
+
* @param {?} currentRoute
|
|
3728
|
+
* @param {?} currentState
|
|
3729
|
+
* @param {?=} nextState
|
|
3730
|
+
* @return {?}
|
|
3731
|
+
*/
|
|
3732
|
+
canDeactivate(component, currentRoute, currentState, nextState) {
|
|
3733
|
+
return !this.interactionContext.isActive();
|
|
3734
|
+
}
|
|
3735
|
+
}
|
|
3736
|
+
CloseInteractionGuard.decorators = [
|
|
3737
|
+
{ type: Injectable, args: [{
|
|
3738
|
+
providedIn: 'root'
|
|
3739
|
+
},] }
|
|
3740
|
+
];
|
|
3741
|
+
/** @nocollapse */
|
|
3742
|
+
CloseInteractionGuard.ctorParameters = () => [
|
|
3743
|
+
{ type: Router },
|
|
3744
|
+
{ type: Injector },
|
|
3745
|
+
{ type: InteractionContext }
|
|
3746
|
+
];
|
|
3747
|
+
/** @nocollapse */ CloseInteractionGuard.ngInjectableDef = ɵɵdefineInjectable({ factory: function CloseInteractionGuard_Factory() { return new CloseInteractionGuard(ɵɵinject(Router), ɵɵinject(INJECTOR), ɵɵinject(InteractionContext)); }, token: CloseInteractionGuard, providedIn: "root" });
|
|
3748
|
+
if (false) {
|
|
3749
|
+
/**
|
|
3750
|
+
* @type {?}
|
|
3751
|
+
* @private
|
|
3752
|
+
*/
|
|
3753
|
+
CloseInteractionGuard.prototype.router;
|
|
3754
|
+
/**
|
|
3755
|
+
* @type {?}
|
|
3756
|
+
* @private
|
|
3757
|
+
*/
|
|
3758
|
+
CloseInteractionGuard.prototype.injector;
|
|
3759
|
+
/**
|
|
3760
|
+
* @type {?}
|
|
3761
|
+
* @private
|
|
3762
|
+
*/
|
|
3763
|
+
CloseInteractionGuard.prototype.interactionContext;
|
|
3764
|
+
}
|
|
3765
|
+
|
|
3594
3766
|
/**
|
|
3595
3767
|
* @fileoverview added by tsickle
|
|
3596
3768
|
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
@@ -3695,10 +3867,36 @@ class LeavePlaceGuard {
|
|
|
3695
3867
|
/**
|
|
3696
3868
|
* @param {?} router
|
|
3697
3869
|
* @param {?} injector
|
|
3870
|
+
* @param {?} interactionContext
|
|
3871
|
+
* @param {?} location
|
|
3698
3872
|
*/
|
|
3699
|
-
constructor(router, injector) {
|
|
3873
|
+
constructor(router, injector, interactionContext, location) {
|
|
3700
3874
|
this.router = router;
|
|
3701
3875
|
this.injector = injector;
|
|
3876
|
+
this.interactionContext = interactionContext;
|
|
3877
|
+
this.location = location;
|
|
3878
|
+
// TODO: should probably replace this with a RouteTracker thingy.
|
|
3879
|
+
this._alreadyAccepted = [];
|
|
3880
|
+
console.log('***** Created new guard ******');
|
|
3881
|
+
/** @type {?} */
|
|
3882
|
+
const self = this;
|
|
3883
|
+
this.router.events.subscribe((/**
|
|
3884
|
+
* @param {?} event
|
|
3885
|
+
* @return {?}
|
|
3886
|
+
*/
|
|
3887
|
+
event => {
|
|
3888
|
+
// NavigationStart -> .... -> NavigationCancel === redirect (so don't ask again)
|
|
3889
|
+
// NavigationStart -> .... -> NavigationEnd === navigated (so ask next time)
|
|
3890
|
+
// NavigationStart -> .... -> NavigationError === canceled (guard cancelled so ask next time)
|
|
3891
|
+
if (event instanceof NavigationEnd) {
|
|
3892
|
+
console.log("navigation ended");
|
|
3893
|
+
self._alreadyAccepted = [];
|
|
3894
|
+
}
|
|
3895
|
+
if (event instanceof NavigationError) {
|
|
3896
|
+
console.log("navigation errored");
|
|
3897
|
+
self._alreadyAccepted = [];
|
|
3898
|
+
}
|
|
3899
|
+
}));
|
|
3702
3900
|
}
|
|
3703
3901
|
/**
|
|
3704
3902
|
* @param {?} component
|
|
@@ -3708,27 +3906,85 @@ class LeavePlaceGuard {
|
|
|
3708
3906
|
* @return {?}
|
|
3709
3907
|
*/
|
|
3710
3908
|
canDeactivate(component, currentRoute, currentState, nextState) {
|
|
3711
|
-
// HACK: this will break with child routes...
|
|
3712
3909
|
/** @type {?} */
|
|
3713
|
-
const
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
//
|
|
3721
|
-
//
|
|
3722
|
-
//
|
|
3723
|
-
//
|
|
3724
|
-
//
|
|
3725
|
-
|
|
3726
|
-
|
|
3910
|
+
const placeDefinitionPath = `/${component.placeDefinition.path}`;
|
|
3911
|
+
console.log('canDeactivate', {
|
|
3912
|
+
staticPath: placeDefinitionPath,
|
|
3913
|
+
currentStateUrl: currentState.url,
|
|
3914
|
+
nextStateUrl: nextState.url,
|
|
3915
|
+
alreadyDeclined: this._alreadyAccepted
|
|
3916
|
+
});
|
|
3917
|
+
// Example of the above when navigating to a different child route.
|
|
3918
|
+
// canDeactivate {staticPath: "/hero-details",
|
|
3919
|
+
// currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-details",
|
|
3920
|
+
// nextStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats"
|
|
3921
|
+
// }
|
|
3922
|
+
// Example clicking on router tab of the parent component (de-activates the parent due to route param changes)
|
|
3923
|
+
// canDeactivate {
|
|
3924
|
+
// staticPath: "/hero-stats",
|
|
3925
|
+
// currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats",
|
|
3926
|
+
// nextStateUrl: "/route-parameters/"
|
|
3927
|
+
// }
|
|
3928
|
+
// canDeactivate {
|
|
3929
|
+
// staticPath: "/route-parameters",
|
|
3930
|
+
// currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats",
|
|
3931
|
+
// nextStateUrl: "/route-parameters/"
|
|
3932
|
+
// }
|
|
3933
|
+
// logger.class.js:54 ParameterSnapshot.sanitise -> {idModel: -1, pv: undefined, pl: Array(0), dv: undefined, dl: Array(0), …}
|
|
3934
|
+
// parameter-snapshot.ts:20 {name: "idModel", mine: -1, theirs: null}
|
|
3935
|
+
// place-router.ts:28 redirect path (3) ["route-parameters", "-1", {…}]
|
|
3936
|
+
// canDeactivate {
|
|
3937
|
+
// staticPath: "/hero-stats",
|
|
3938
|
+
// currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats",
|
|
3939
|
+
// nextStateUrl: "/route-parameters/-1"
|
|
3940
|
+
// }
|
|
3941
|
+
// canDeactivate {
|
|
3942
|
+
// staticPath: "/route-parameters",
|
|
3943
|
+
// currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats",
|
|
3944
|
+
// nextStateUrl: "/route-parameters/-1"
|
|
3945
|
+
// }
|
|
3946
|
+
// logger.class.js:54 ParameterSnapshot.sanitise -> {idModel: -1, pv: undefined, pl: Array(0), dv: "A", dl: Array(3), …}
|
|
3947
|
+
// parameter-snapshot.ts:20 {name: "dv", mine: "A", theirs: undefined}
|
|
3948
|
+
// place-router.ts:28 redirect path (3) ["route-parameters", "-1", {…}]
|
|
3949
|
+
// canDeactivate {
|
|
3950
|
+
// staticPath: "/hero-stats",
|
|
3951
|
+
// currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats",
|
|
3952
|
+
// nextStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c"
|
|
3953
|
+
// }
|
|
3954
|
+
// HACK: this will break with child routes...
|
|
3955
|
+
if (this.alreadyAccepted(component)) {
|
|
3956
|
+
return true;
|
|
3727
3957
|
}
|
|
3728
3958
|
else {
|
|
3959
|
+
if (!nextState.url.startsWith(placeDefinitionPath)) {
|
|
3960
|
+
/** @type {?} */
|
|
3961
|
+
const self = this;
|
|
3962
|
+
return Promise.resolve(component.canDeactivate()).then((/**
|
|
3963
|
+
* @param {?} canLeave
|
|
3964
|
+
* @return {?}
|
|
3965
|
+
*/
|
|
3966
|
+
canLeave => {
|
|
3967
|
+
if (!canLeave) {
|
|
3968
|
+
// Angular doesn't preserve the url when a guard cancels the back button.
|
|
3969
|
+
// See https://github.com/angular/angular/issues/13586#issuecomment-432795720
|
|
3970
|
+
this.location.go(currentState.url);
|
|
3971
|
+
}
|
|
3972
|
+
else {
|
|
3973
|
+
self._alreadyAccepted.push(component);
|
|
3974
|
+
}
|
|
3975
|
+
return canLeave;
|
|
3976
|
+
}));
|
|
3977
|
+
}
|
|
3729
3978
|
return true;
|
|
3730
3979
|
}
|
|
3731
3980
|
}
|
|
3981
|
+
/**
|
|
3982
|
+
* @param {?} placeComponent
|
|
3983
|
+
* @return {?}
|
|
3984
|
+
*/
|
|
3985
|
+
alreadyAccepted(placeComponent) {
|
|
3986
|
+
return this._alreadyAccepted.includes(placeComponent);
|
|
3987
|
+
}
|
|
3732
3988
|
}
|
|
3733
3989
|
LeavePlaceGuard.decorators = [
|
|
3734
3990
|
{ type: Injectable, args: [{
|
|
@@ -3738,10 +3994,23 @@ LeavePlaceGuard.decorators = [
|
|
|
3738
3994
|
/** @nocollapse */
|
|
3739
3995
|
LeavePlaceGuard.ctorParameters = () => [
|
|
3740
3996
|
{ type: Router },
|
|
3741
|
-
{ type: Injector }
|
|
3997
|
+
{ type: Injector },
|
|
3998
|
+
{ type: InteractionContext },
|
|
3999
|
+
{ type: Location }
|
|
3742
4000
|
];
|
|
3743
|
-
/** @nocollapse */ LeavePlaceGuard.ngInjectableDef = ɵɵdefineInjectable({ factory: function LeavePlaceGuard_Factory() { return new LeavePlaceGuard(ɵɵinject(Router), ɵɵinject(INJECTOR)); }, token: LeavePlaceGuard, providedIn: "root" });
|
|
4001
|
+
/** @nocollapse */ LeavePlaceGuard.ngInjectableDef = ɵɵdefineInjectable({ factory: function LeavePlaceGuard_Factory() { return new LeavePlaceGuard(ɵɵinject(Router), ɵɵinject(INJECTOR), ɵɵinject(InteractionContext), ɵɵinject(Location)); }, token: LeavePlaceGuard, providedIn: "root" });
|
|
4002
|
+
__decorate([
|
|
4003
|
+
Trace(),
|
|
4004
|
+
__metadata("design:type", Function),
|
|
4005
|
+
__metadata("design:paramtypes", [PlaceComponent]),
|
|
4006
|
+
__metadata("design:returntype", Boolean)
|
|
4007
|
+
], LeavePlaceGuard.prototype, "alreadyAccepted", null);
|
|
3744
4008
|
if (false) {
|
|
4009
|
+
/**
|
|
4010
|
+
* @type {?}
|
|
4011
|
+
* @private
|
|
4012
|
+
*/
|
|
4013
|
+
LeavePlaceGuard.prototype._alreadyAccepted;
|
|
3745
4014
|
/**
|
|
3746
4015
|
* @type {?}
|
|
3747
4016
|
* @private
|
|
@@ -3752,6 +4021,10 @@ if (false) {
|
|
|
3752
4021
|
* @private
|
|
3753
4022
|
*/
|
|
3754
4023
|
LeavePlaceGuard.prototype.injector;
|
|
4024
|
+
/** @type {?} */
|
|
4025
|
+
LeavePlaceGuard.prototype.interactionContext;
|
|
4026
|
+
/** @type {?} */
|
|
4027
|
+
LeavePlaceGuard.prototype.location;
|
|
3755
4028
|
}
|
|
3756
4029
|
|
|
3757
4030
|
/**
|
|
@@ -4024,5 +4297,5 @@ var ParameterType;
|
|
|
4024
4297
|
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
4025
4298
|
*/
|
|
4026
4299
|
|
|
4027
|
-
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,
|
|
4300
|
+
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 };
|
|
4028
4301
|
//# sourceMappingURL=coolon-angular-ui-powerups.js.map
|