@coolon/angular-ui-powerups 0.0.90 → 0.0.92
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/coolon-angular-ui-powerups.umd.js +432 -364
- 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.d.ts +7 -7
- package/coolon-angular-ui-powerups.metadata.json +1 -1
- package/esm2015/coolon-angular-ui-powerups.js +8 -8
- package/esm2015/lib/directives/command.directive.js +28 -5
- package/esm2015/lib/interaction/components/activity-container/activity-container.component.js +2 -7
- package/esm2015/lib/interaction/components/inplace-interaction-context/inplace-interaction-context.component.js +3 -8
- package/esm2015/lib/interaction/interaction-context.js +70 -14
- package/esm2015/lib/interaction/services/dialog-interaction.service.js +11 -19
- package/esm2015/lib/place/navigation-session.js +171 -39
- package/esm2015/lib/place/place-component.js +4 -19
- package/esm2015/lib/place/place-router.js +72 -31
- package/esm2015/lib/place/route/guards/enter-place-guard.service.js +2 -2
- package/esm2015/lib/place/route/guards/leave-place.guard.js +7 -177
- package/esm5/coolon-angular-ui-powerups.js +8 -8
- package/esm5/lib/directives/command.directive.js +32 -5
- package/esm5/lib/interaction/components/activity-container/activity-container.component.js +2 -11
- package/esm5/lib/interaction/components/inplace-interaction-context/inplace-interaction-context.component.js +3 -12
- package/esm5/lib/interaction/interaction-context.js +89 -27
- package/esm5/lib/interaction/services/dialog-interaction.service.js +11 -22
- package/esm5/lib/place/navigation-session.js +214 -54
- package/esm5/lib/place/place-component.js +4 -35
- package/esm5/lib/place/place-router.js +82 -37
- package/esm5/lib/place/route/guards/enter-place-guard.service.js +2 -2
- package/esm5/lib/place/route/guards/leave-place.guard.js +7 -176
- package/fesm2015/coolon-angular-ui-powerups.js +350 -299
- package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
- package/fesm5/coolon-angular-ui-powerups.js +427 -359
- package/fesm5/coolon-angular-ui-powerups.js.map +1 -1
- package/lib/directives/command.directive.d.ts +2 -0
- package/lib/interaction/components/activity-container/activity-container.component.d.ts +1 -2
- package/lib/interaction/components/inplace-interaction-context/inplace-interaction-context.component.d.ts +3 -4
- package/lib/interaction/interaction-context.d.ts +6 -3
- package/lib/interaction/services/dialog-interaction.service.d.ts +3 -5
- package/lib/place/navigation-session.d.ts +26 -9
- package/lib/place/place-component.d.ts +4 -9
- package/lib/place/place-router.d.ts +8 -3
- package/lib/place/route/guards/leave-place.guard.d.ts +2 -10
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ import { FormsModule } from '@angular/forms';
|
|
|
4
4
|
import { MatInputModule, MatFormFieldModule, MatSelectModule, MatDialog, MatButtonModule, MatDialogModule, MatTabsModule as MatTabsModule$1, MatProgressSpinnerModule } from '@angular/material';
|
|
5
5
|
import { MatTabsModule } from '@angular/material/tabs';
|
|
6
6
|
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
|
7
|
-
import { GarbageCollector, assert, UnaryCommand, lang, Dsl, Logger, DelegatingFormValueModel, UseDelegate, ValueModel, ListModel, StoreInListModel,
|
|
7
|
+
import { GarbageCollector, DelegatingValueModel, assert, UnaryCommand, lang, Dsl, Logger, DelegatingFormValueModel, UseDelegate, ValueModel, ListModel, StoreInListModel, DelegatingListModel, Deferred, MutableStream, MutableListModel, MutableValueModel, Binding, Trace, Guard as Guard$1, Command, StoreInValueModel, OptionsHelper, ValueHolder } from '@coolon/pectin';
|
|
8
8
|
import { __decorate, __metadata, __awaiter } from 'tslib';
|
|
9
9
|
import { PortalModule } from '@angular/cdk/portal';
|
|
10
10
|
import { Router, RouterModule, NavigationStart, NavigationEnd, NavigationError, UrlSerializer, UrlSegment, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
|
|
@@ -34,8 +34,23 @@ class CommandDirective extends GarbageCollector {
|
|
|
34
34
|
constructor(elementRef) {
|
|
35
35
|
super();
|
|
36
36
|
this.elementRef = elementRef;
|
|
37
|
+
this._commandEnabled = new DelegatingValueModel().withDefault(false);
|
|
37
38
|
this._commandParameterProvided = false;
|
|
38
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* @param {?} command
|
|
42
|
+
* @return {?}
|
|
43
|
+
*/
|
|
44
|
+
set pectinCommand(command) {
|
|
45
|
+
this._command = command;
|
|
46
|
+
this._commandEnabled.setDelegate(command ? command.enabled : null);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* @return {?}
|
|
50
|
+
*/
|
|
51
|
+
get pectinCommand() {
|
|
52
|
+
return this._command;
|
|
53
|
+
}
|
|
39
54
|
/**
|
|
40
55
|
* @param {?} value
|
|
41
56
|
* @return {?}
|
|
@@ -73,7 +88,7 @@ class CommandDirective extends GarbageCollector {
|
|
|
73
88
|
// for some reason mat-buttons kills the disabled host binding. It works on a regular button but for now
|
|
74
89
|
// we need to do this.
|
|
75
90
|
const { chain } = Dsl.disposeWith(this);
|
|
76
|
-
chain(this.
|
|
91
|
+
chain(this._commandEnabled).subscribe((/**
|
|
77
92
|
* @param {?} enabled
|
|
78
93
|
* @return {?}
|
|
79
94
|
*/
|
|
@@ -134,8 +149,16 @@ CommandDirective.propDecorators = {
|
|
|
134
149
|
notifyClick: [{ type: HostListener, args: ['click', ['$event'],] }]
|
|
135
150
|
};
|
|
136
151
|
if (false) {
|
|
137
|
-
/**
|
|
138
|
-
|
|
152
|
+
/**
|
|
153
|
+
* @type {?}
|
|
154
|
+
* @private
|
|
155
|
+
*/
|
|
156
|
+
CommandDirective.prototype._command;
|
|
157
|
+
/**
|
|
158
|
+
* @type {?}
|
|
159
|
+
* @private
|
|
160
|
+
*/
|
|
161
|
+
CommandDirective.prototype._commandEnabled;
|
|
139
162
|
/**
|
|
140
163
|
* @type {?}
|
|
141
164
|
* @private
|
|
@@ -741,38 +764,94 @@ class InteractionContext extends GarbageCollector {
|
|
|
741
764
|
*/
|
|
742
765
|
constructor() {
|
|
743
766
|
super();
|
|
767
|
+
/**
|
|
768
|
+
* Returns the current list of activities that are in progress.
|
|
769
|
+
* This model is only updated in the next tick after the view has been updated.
|
|
770
|
+
*/
|
|
771
|
+
this._activityListDelegate = new DelegatingListModel();
|
|
772
|
+
const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);
|
|
773
|
+
when.listOf(this.activityList).becomesPopulated((/**
|
|
774
|
+
* @param {?} activities
|
|
775
|
+
* @return {?}
|
|
776
|
+
*/
|
|
777
|
+
(activities) => {
|
|
778
|
+
if (this.deferredGetCurrentActivity) {
|
|
779
|
+
this.deferredGetCurrentActivity.resolve(last(activities));
|
|
780
|
+
this.deferredGetCurrentActivity = null;
|
|
781
|
+
}
|
|
782
|
+
}));
|
|
744
783
|
}
|
|
745
784
|
/**
|
|
746
|
-
*
|
|
747
|
-
*
|
|
785
|
+
* @protected
|
|
786
|
+
* @param {?} activityList
|
|
748
787
|
* @return {?}
|
|
749
788
|
*/
|
|
750
|
-
|
|
751
|
-
|
|
789
|
+
setActivityList(activityList) {
|
|
790
|
+
this._activityListDelegate.setDelegate(activityList);
|
|
752
791
|
}
|
|
753
792
|
/**
|
|
754
|
-
* @param {?} confirm
|
|
755
793
|
* @return {?}
|
|
756
794
|
*/
|
|
757
|
-
|
|
795
|
+
get activityList() {
|
|
796
|
+
return this._activityListDelegate.readonly;
|
|
797
|
+
}
|
|
798
|
+
/**
|
|
799
|
+
* Returns the activity that is currently active.
|
|
800
|
+
* This model is only updated in the next tick after the view has been updated.
|
|
801
|
+
* @return {?}
|
|
802
|
+
*/
|
|
803
|
+
getCurrentActivity() {
|
|
758
804
|
return __awaiter(this, void 0, void 0, function* () {
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
return true;
|
|
805
|
+
if (!this.isActive()) {
|
|
806
|
+
return Promise.reject('no activity in progress');
|
|
762
807
|
}
|
|
763
|
-
|
|
764
|
-
|
|
808
|
+
else {
|
|
809
|
+
if (this.deferredGetCurrentActivity) {
|
|
810
|
+
// we're already waiting then just return the same promise
|
|
811
|
+
return this.deferredGetCurrentActivity.promise;
|
|
812
|
+
}
|
|
813
|
+
else {
|
|
814
|
+
if (this.activityList.length < 1) {
|
|
815
|
+
this.deferredGetCurrentActivity = Deferred.defer();
|
|
816
|
+
return this.deferredGetCurrentActivity.promise;
|
|
817
|
+
}
|
|
818
|
+
else {
|
|
819
|
+
return last(this.activityList.value);
|
|
820
|
+
}
|
|
821
|
+
}
|
|
765
822
|
}
|
|
766
823
|
});
|
|
767
824
|
}
|
|
825
|
+
/**
|
|
826
|
+
* @param {?} confirm
|
|
827
|
+
* @return {?}
|
|
828
|
+
*/
|
|
829
|
+
confirm(confirm) {
|
|
830
|
+
// Important: we have to implement confirmOrReject as the main entry point
|
|
831
|
+
// as the canDeactivation guards need to be able to cancel an interaction
|
|
832
|
+
// without caring about returning a value.
|
|
833
|
+
return this.confirmOrReject(confirm).then((/**
|
|
834
|
+
* @return {?}
|
|
835
|
+
*/
|
|
836
|
+
() => true)).catch((/**
|
|
837
|
+
* @return {?}
|
|
838
|
+
*/
|
|
839
|
+
() => false));
|
|
840
|
+
}
|
|
768
841
|
}
|
|
769
842
|
if (false) {
|
|
770
843
|
/**
|
|
771
844
|
* Returns the current list of activities that are in progress.
|
|
772
845
|
* This model is only updated in the next tick after the view has been updated.
|
|
773
846
|
* @type {?}
|
|
847
|
+
* @private
|
|
848
|
+
*/
|
|
849
|
+
InteractionContext.prototype._activityListDelegate;
|
|
850
|
+
/**
|
|
851
|
+
* @type {?}
|
|
852
|
+
* @private
|
|
774
853
|
*/
|
|
775
|
-
InteractionContext.prototype.
|
|
854
|
+
InteractionContext.prototype.deferredGetCurrentActivity;
|
|
776
855
|
/**
|
|
777
856
|
* Returns true if an activity is currently running.
|
|
778
857
|
* @abstract
|
|
@@ -1305,6 +1384,7 @@ class ActivityContainerComponent extends InteractionContext {
|
|
|
1305
1384
|
* @return {?}
|
|
1306
1385
|
*/
|
|
1307
1386
|
() => this.onNestedActivityFinished()));
|
|
1387
|
+
this.setActivityList(this._activityList.readonly);
|
|
1308
1388
|
}
|
|
1309
1389
|
/**
|
|
1310
1390
|
* @param {?} initialContext
|
|
@@ -1352,12 +1432,6 @@ class ActivityContainerComponent extends InteractionContext {
|
|
|
1352
1432
|
isActive() {
|
|
1353
1433
|
return !!this._initialActivityOutletContext;
|
|
1354
1434
|
}
|
|
1355
|
-
/**
|
|
1356
|
-
* @return {?}
|
|
1357
|
-
*/
|
|
1358
|
-
get activityList() {
|
|
1359
|
-
return this._activityList.readonly;
|
|
1360
|
-
}
|
|
1361
1435
|
/**
|
|
1362
1436
|
* @return {?}
|
|
1363
1437
|
*/
|
|
@@ -1596,13 +1670,8 @@ class InplaceInteractionContextComponent extends InteractionContext {
|
|
|
1596
1670
|
/**
|
|
1597
1671
|
* @return {?}
|
|
1598
1672
|
*/
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
/**
|
|
1602
|
-
* @return {?}
|
|
1603
|
-
*/
|
|
1604
|
-
get activityList() {
|
|
1605
|
-
return this.interactionContext.activityList;
|
|
1673
|
+
ngAfterViewInit() {
|
|
1674
|
+
this.setActivityList(this.interactionContext.activityList);
|
|
1606
1675
|
}
|
|
1607
1676
|
/**
|
|
1608
1677
|
* @return {?}
|
|
@@ -1777,29 +1846,21 @@ class DialogInteractionService extends InteractionContext {
|
|
|
1777
1846
|
this.router = router;
|
|
1778
1847
|
this.dialogServiceDefaults = dialogServiceDefaults;
|
|
1779
1848
|
this.matDialogDefaultConfig = matDialogDefaultConfig;
|
|
1780
|
-
this._activityList = new DelegatingListModel();
|
|
1781
1849
|
this.startingGuard = new Guard();
|
|
1850
|
+
this._inActivityPromise = new MutableValueModel(false);
|
|
1782
1851
|
assert$1.notNil(dialogService);
|
|
1783
|
-
const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);
|
|
1784
|
-
this.active = chain(this._activityList).isNotEmpty();
|
|
1785
1852
|
}
|
|
1786
1853
|
/**
|
|
1787
1854
|
* @return {?}
|
|
1788
1855
|
*/
|
|
1789
1856
|
isActive() {
|
|
1790
|
-
return this.
|
|
1857
|
+
return this._inActivityPromise.value;
|
|
1791
1858
|
}
|
|
1792
1859
|
/**
|
|
1793
1860
|
* @return {?}
|
|
1794
1861
|
*/
|
|
1795
|
-
|
|
1796
|
-
this.
|
|
1797
|
-
}
|
|
1798
|
-
/**
|
|
1799
|
-
* @return {?}
|
|
1800
|
-
*/
|
|
1801
|
-
get activityList() {
|
|
1802
|
-
return this._activityList.readonly;
|
|
1862
|
+
get active() {
|
|
1863
|
+
return this._inActivityPromise.readonly;
|
|
1803
1864
|
}
|
|
1804
1865
|
/**
|
|
1805
1866
|
* @template D, R, E
|
|
@@ -1831,6 +1892,7 @@ class DialogInteractionService extends InteractionContext {
|
|
|
1831
1892
|
*/
|
|
1832
1893
|
() => {
|
|
1833
1894
|
console.log('###### STARTING');
|
|
1895
|
+
this._inActivityPromise.value = true;
|
|
1834
1896
|
// this.currentActivityId = uuid.v1();
|
|
1835
1897
|
// this.location.go(this.router.routerState.snapshot.url, "aup");
|
|
1836
1898
|
/** @type {?} */
|
|
@@ -1889,6 +1951,7 @@ class DialogInteractionService extends InteractionContext {
|
|
|
1889
1951
|
* @return {?}
|
|
1890
1952
|
*/
|
|
1891
1953
|
() => {
|
|
1954
|
+
this._inActivityPromise.value = false;
|
|
1892
1955
|
console.log('###### FINISHED');
|
|
1893
1956
|
// this.currentActivityId = null;
|
|
1894
1957
|
self.safelyUpdateActivityListDelegate(null);
|
|
@@ -1904,7 +1967,7 @@ class DialogInteractionService extends InteractionContext {
|
|
|
1904
1967
|
setTimeout((/**
|
|
1905
1968
|
* @return {?}
|
|
1906
1969
|
*/
|
|
1907
|
-
() => this.
|
|
1970
|
+
() => this.setActivityList(delegate)));
|
|
1908
1971
|
}
|
|
1909
1972
|
/**
|
|
1910
1973
|
* @param {?} alert
|
|
@@ -1955,14 +2018,12 @@ if (false) {
|
|
|
1955
2018
|
* @type {?}
|
|
1956
2019
|
* @private
|
|
1957
2020
|
*/
|
|
1958
|
-
DialogInteractionService.prototype.
|
|
2021
|
+
DialogInteractionService.prototype.startingGuard;
|
|
1959
2022
|
/**
|
|
1960
2023
|
* @type {?}
|
|
1961
2024
|
* @private
|
|
1962
2025
|
*/
|
|
1963
|
-
DialogInteractionService.prototype.
|
|
1964
|
-
/** @type {?} */
|
|
1965
|
-
DialogInteractionService.prototype.active;
|
|
2026
|
+
DialogInteractionService.prototype._inActivityPromise;
|
|
1966
2027
|
/**
|
|
1967
2028
|
* @type {?}
|
|
1968
2029
|
* @private
|
|
@@ -2527,7 +2588,7 @@ const DEFINITION_META_DATA_KEY = 'PLACE_DEFINITION_OPTIONS';
|
|
|
2527
2588
|
// this one seems ok.
|
|
2528
2589
|
/** @type {?} */
|
|
2529
2590
|
const ROUTE_PARAMETER_LIST_KEY = Symbol('place:route:parameters');
|
|
2530
|
-
class PlaceComponent extends
|
|
2591
|
+
class PlaceComponent extends DisposableComponent {
|
|
2531
2592
|
constructor() {
|
|
2532
2593
|
super();
|
|
2533
2594
|
}
|
|
@@ -2594,27 +2655,11 @@ class PlaceComponent extends GarbageCollector {
|
|
|
2594
2655
|
*/
|
|
2595
2656
|
d => d.component));
|
|
2596
2657
|
}
|
|
2597
|
-
/**
|
|
2598
|
-
* @return {?}
|
|
2599
|
-
*/
|
|
2600
|
-
canDeactivate() {
|
|
2601
|
-
return true;
|
|
2602
|
-
}
|
|
2603
2658
|
/**
|
|
2604
2659
|
* @return {?}
|
|
2605
2660
|
*/
|
|
2606
2661
|
onPlaceReady() {
|
|
2607
2662
|
}
|
|
2608
|
-
/**
|
|
2609
|
-
* Called by the place outlet after all animations have finished. We need this instead of ngOnDestroy
|
|
2610
|
-
* to avoid the fact that the angular router calls it before the animations have run causing the component
|
|
2611
|
-
* to loose any pectin bindings.
|
|
2612
|
-
* @return {?}
|
|
2613
|
-
*/
|
|
2614
|
-
// @Trace()
|
|
2615
|
-
onPlaceDestroyed() {
|
|
2616
|
-
this.dispose();
|
|
2617
|
-
}
|
|
2618
2663
|
}
|
|
2619
2664
|
__decorate([
|
|
2620
2665
|
Memoize$1(),
|
|
@@ -2814,11 +2859,15 @@ class NavigationSession {
|
|
|
2814
2859
|
/**
|
|
2815
2860
|
* @protected
|
|
2816
2861
|
* @param {?} firstNavigation
|
|
2862
|
+
* @param {?} appModalInteractionContext
|
|
2817
2863
|
*/
|
|
2818
|
-
constructor(firstNavigation) {
|
|
2864
|
+
constructor(firstNavigation, appModalInteractionContext) {
|
|
2819
2865
|
this.firstNavigation = firstNavigation;
|
|
2866
|
+
this.appModalInteractionContext = appModalInteractionContext;
|
|
2820
2867
|
this._alreadyAccepted = [];
|
|
2821
2868
|
this._visits = new Map();
|
|
2869
|
+
this.componentDeactivationHandlers = new Map();
|
|
2870
|
+
this.dialogOpenOnStart = this.appModalInteractionContext.isActive();
|
|
2822
2871
|
}
|
|
2823
2872
|
/**
|
|
2824
2873
|
* @param {?} visit
|
|
@@ -2834,34 +2883,30 @@ class NavigationSession {
|
|
|
2834
2883
|
getVisitFor(placeDef) {
|
|
2835
2884
|
return this._visits.get(placeDef);
|
|
2836
2885
|
}
|
|
2837
|
-
/**
|
|
2838
|
-
* @param {?} params
|
|
2839
|
-
* @return {?}
|
|
2840
|
-
*/
|
|
2841
|
-
mergePrivatePlaceParameters(params) {
|
|
2842
|
-
return null;
|
|
2843
|
-
}
|
|
2844
|
-
// @Trace()
|
|
2845
|
-
/**
|
|
2846
|
-
* @param {?} placeComponent
|
|
2847
|
-
* @return {?}
|
|
2848
|
-
*/
|
|
2849
|
-
alreadyAccepted(placeComponent) {
|
|
2850
|
-
return this._alreadyAccepted.includes(placeComponent);
|
|
2851
|
-
}
|
|
2852
|
-
// @Trace()
|
|
2853
2886
|
/**
|
|
2854
2887
|
* @param {?} component
|
|
2888
|
+
* @param {?} nextState
|
|
2855
2889
|
* @return {?}
|
|
2856
2890
|
*/
|
|
2857
|
-
|
|
2858
|
-
this
|
|
2891
|
+
canDeactivate(component, nextState) {
|
|
2892
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2893
|
+
// lookup the handler and create it if we've not seen it yet
|
|
2894
|
+
/** @type {?} */
|
|
2895
|
+
let handler = this.componentDeactivationHandlers.get(component);
|
|
2896
|
+
if (!handler) {
|
|
2897
|
+
/** @type {?} */
|
|
2898
|
+
const isPrimaryHandler = this.componentDeactivationHandlers.size === 0;
|
|
2899
|
+
handler = new NavigationSession.ComponentDeactivationHandler(component, this.appModalInteractionContext, isPrimaryHandler);
|
|
2900
|
+
this.componentDeactivationHandlers.set(component, handler);
|
|
2901
|
+
}
|
|
2902
|
+
return handler.canDeactivate(nextState);
|
|
2903
|
+
});
|
|
2859
2904
|
}
|
|
2860
2905
|
/**
|
|
2861
2906
|
* @param {?} url
|
|
2862
2907
|
* @return {?}
|
|
2863
2908
|
*/
|
|
2864
|
-
|
|
2909
|
+
setPopstateReturnUrl(url) {
|
|
2865
2910
|
this._popStateReturnUrl = url;
|
|
2866
2911
|
}
|
|
2867
2912
|
/**
|
|
@@ -2902,15 +2947,28 @@ if (false) {
|
|
|
2902
2947
|
/** @type {?} */
|
|
2903
2948
|
NavigationSession.prototype.isExternal;
|
|
2904
2949
|
/** @type {?} */
|
|
2950
|
+
NavigationSession.prototype.dialogOpenOnStart;
|
|
2951
|
+
/**
|
|
2952
|
+
* @type {?}
|
|
2953
|
+
* @private
|
|
2954
|
+
*/
|
|
2955
|
+
NavigationSession.prototype.componentDeactivationHandlers;
|
|
2956
|
+
/** @type {?} */
|
|
2905
2957
|
NavigationSession.prototype.firstNavigation;
|
|
2958
|
+
/**
|
|
2959
|
+
* @type {?}
|
|
2960
|
+
* @private
|
|
2961
|
+
*/
|
|
2962
|
+
NavigationSession.prototype.appModalInteractionContext;
|
|
2906
2963
|
}
|
|
2907
2964
|
(function (NavigationSession) {
|
|
2908
2965
|
class External extends NavigationSession {
|
|
2909
2966
|
/**
|
|
2910
2967
|
* @param {?} isFirstTime
|
|
2968
|
+
* @param {?} appModelInteractionContext
|
|
2911
2969
|
*/
|
|
2912
|
-
constructor(isFirstTime) {
|
|
2913
|
-
super(isFirstTime);
|
|
2970
|
+
constructor(isFirstTime, appModelInteractionContext) {
|
|
2971
|
+
super(isFirstTime, appModelInteractionContext);
|
|
2914
2972
|
this.isExternal = true;
|
|
2915
2973
|
}
|
|
2916
2974
|
}
|
|
@@ -2921,9 +2979,10 @@ if (false) {
|
|
|
2921
2979
|
class Internal extends NavigationSession {
|
|
2922
2980
|
/**
|
|
2923
2981
|
* @param {?} visit
|
|
2982
|
+
* @param {?} appModelInteractionContext
|
|
2924
2983
|
*/
|
|
2925
|
-
constructor(visit) {
|
|
2926
|
-
super(false);
|
|
2984
|
+
constructor(visit, appModelInteractionContext) {
|
|
2985
|
+
super(false, appModelInteractionContext);
|
|
2927
2986
|
this.isExternal = false;
|
|
2928
2987
|
this.storeVisit(visit);
|
|
2929
2988
|
}
|
|
@@ -2932,22 +2991,139 @@ if (false) {
|
|
|
2932
2991
|
/** @type {?} */
|
|
2933
2992
|
Internal.prototype.isExternal;
|
|
2934
2993
|
}
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2994
|
+
class Factory {
|
|
2995
|
+
/**
|
|
2996
|
+
* @param {?} interactionContext
|
|
2997
|
+
*/
|
|
2998
|
+
constructor(interactionContext) {
|
|
2999
|
+
this.interactionContext = interactionContext;
|
|
3000
|
+
}
|
|
3001
|
+
/**
|
|
3002
|
+
* @param {?} visit
|
|
3003
|
+
* @return {?}
|
|
3004
|
+
*/
|
|
3005
|
+
createInternal(visit) {
|
|
3006
|
+
return new Internal(visit, this.interactionContext);
|
|
3007
|
+
}
|
|
3008
|
+
/**
|
|
3009
|
+
* @param {?} firstTimeRoute
|
|
3010
|
+
* @return {?}
|
|
3011
|
+
*/
|
|
3012
|
+
createExternal(firstTimeRoute) {
|
|
3013
|
+
return new External(firstTimeRoute, this.interactionContext);
|
|
3014
|
+
}
|
|
2941
3015
|
}
|
|
2942
|
-
NavigationSession.
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
3016
|
+
NavigationSession.Factory = Factory;
|
|
3017
|
+
if (false) {
|
|
3018
|
+
/** @type {?} */
|
|
3019
|
+
Factory.prototype.interactionContext;
|
|
3020
|
+
}
|
|
3021
|
+
class ComponentDeactivationHandler {
|
|
3022
|
+
/**
|
|
3023
|
+
* @param {?} component
|
|
3024
|
+
* @param {?} appModelInteractionContext
|
|
3025
|
+
* @param {?} primary
|
|
3026
|
+
*/
|
|
3027
|
+
constructor(component, appModelInteractionContext, primary) {
|
|
3028
|
+
this.component = component;
|
|
3029
|
+
this.appModelInteractionContext = appModelInteractionContext;
|
|
3030
|
+
this.primary = primary;
|
|
3031
|
+
this.alreadyAccepted = false;
|
|
3032
|
+
// super();
|
|
3033
|
+
}
|
|
3034
|
+
/**
|
|
3035
|
+
* @param {?} nextState
|
|
3036
|
+
* @return {?}
|
|
3037
|
+
*/
|
|
3038
|
+
canDeactivate(nextState) {
|
|
3039
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3040
|
+
console.log(`${this.constructor.name}.canDeactivate`, { component: this.component });
|
|
3041
|
+
if (this.alreadyAccepted) {
|
|
3042
|
+
// We'll get called multiple times if there's any parameter sanitisation so
|
|
3043
|
+
// we always return true if we accepted on a previous cycle of the current
|
|
3044
|
+
// navigation session.
|
|
3045
|
+
return true;
|
|
3046
|
+
}
|
|
3047
|
+
else {
|
|
3048
|
+
if (this.primary && this.appModelInteractionContext.isActive()) {
|
|
3049
|
+
// We check the global interaction first
|
|
3050
|
+
yield this.cancelCurrentActivityOf(this.appModelInteractionContext);
|
|
3051
|
+
return false;
|
|
3052
|
+
}
|
|
3053
|
+
this.alreadyAccepted = yield this.canDeactivateComponent(nextState);
|
|
3054
|
+
return this.alreadyAccepted;
|
|
3055
|
+
}
|
|
3056
|
+
});
|
|
3057
|
+
}
|
|
3058
|
+
/**
|
|
3059
|
+
* @protected
|
|
3060
|
+
* @param {?} nextState
|
|
3061
|
+
* @return {?}
|
|
3062
|
+
*/
|
|
3063
|
+
canDeactivateComponent(nextState) {
|
|
3064
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3065
|
+
// check if the component has an active interaction. This will handle
|
|
3066
|
+
// an inplace interaction contexts
|
|
3067
|
+
/** @type {?} */
|
|
3068
|
+
const hasCustomInteractionContext = this.component.interactionContext &&
|
|
3069
|
+
!this.isAppModalInteractionContext(this.component.interactionContext) &&
|
|
3070
|
+
this.component.interactionContext.isActive();
|
|
3071
|
+
if (hasCustomInteractionContext) {
|
|
3072
|
+
this.cancelCurrentActivityOf(this.component.interactionContext);
|
|
3073
|
+
return false;
|
|
3074
|
+
}
|
|
3075
|
+
if (this.isLeavingCurrentPlace(nextState) && this.component.canDeactivate) {
|
|
3076
|
+
// No interaction in progress, so ask the component .
|
|
3077
|
+
// This may start an interaction, hence checking the interaction context before now. I.e. if the place pops up the dialog, and
|
|
3078
|
+
// the user clicks back again, we'll re-enter here and go bang when the component tries to open another dialog.
|
|
3079
|
+
return this.component.canDeactivate();
|
|
3080
|
+
}
|
|
3081
|
+
return true;
|
|
3082
|
+
});
|
|
3083
|
+
}
|
|
3084
|
+
/**
|
|
3085
|
+
* @param {?} interactionContext
|
|
3086
|
+
* @return {?}
|
|
3087
|
+
*/
|
|
3088
|
+
isAppModalInteractionContext(interactionContext) {
|
|
3089
|
+
return this.appModelInteractionContext === interactionContext;
|
|
3090
|
+
}
|
|
3091
|
+
/**
|
|
3092
|
+
* @protected
|
|
3093
|
+
* @param {?} interactionContext
|
|
3094
|
+
* @return {?}
|
|
3095
|
+
*/
|
|
3096
|
+
cancelCurrentActivityOf(interactionContext) {
|
|
3097
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3098
|
+
/** @type {?} */
|
|
3099
|
+
const activity = yield interactionContext.getCurrentActivity();
|
|
3100
|
+
console.log('cancelling', { activity });
|
|
3101
|
+
activity.cancel(null);
|
|
3102
|
+
});
|
|
3103
|
+
}
|
|
3104
|
+
/**
|
|
3105
|
+
* @protected
|
|
3106
|
+
* @param {?} nextState
|
|
3107
|
+
* @return {?}
|
|
3108
|
+
*/
|
|
3109
|
+
isLeavingCurrentPlace(nextState) {
|
|
3110
|
+
return !nextState.includesPathOf(this.component.placeDefinition);
|
|
3111
|
+
}
|
|
3112
|
+
}
|
|
3113
|
+
NavigationSession.ComponentDeactivationHandler = ComponentDeactivationHandler;
|
|
3114
|
+
if (false) {
|
|
3115
|
+
/**
|
|
3116
|
+
* @type {?}
|
|
3117
|
+
* @private
|
|
3118
|
+
*/
|
|
3119
|
+
ComponentDeactivationHandler.prototype.alreadyAccepted;
|
|
3120
|
+
/** @type {?} */
|
|
3121
|
+
ComponentDeactivationHandler.prototype.component;
|
|
3122
|
+
/** @type {?} */
|
|
3123
|
+
ComponentDeactivationHandler.prototype.appModelInteractionContext;
|
|
3124
|
+
/** @type {?} */
|
|
3125
|
+
ComponentDeactivationHandler.prototype.primary;
|
|
2949
3126
|
}
|
|
2950
|
-
NavigationSession.createExternal = createExternal;
|
|
2951
3127
|
})(NavigationSession || (NavigationSession = {}));
|
|
2952
3128
|
|
|
2953
3129
|
/**
|
|
@@ -3020,13 +3196,15 @@ class PlaceRouter extends GarbageCollector {
|
|
|
3020
3196
|
/**
|
|
3021
3197
|
* @param {?} router
|
|
3022
3198
|
* @param {?} urlSerializer
|
|
3199
|
+
* @param {?} interactionContext
|
|
3023
3200
|
* @param {?} angularLocation
|
|
3024
3201
|
* @param {?} placeHistory
|
|
3025
3202
|
*/
|
|
3026
|
-
constructor(router, urlSerializer, angularLocation, placeHistory) {
|
|
3203
|
+
constructor(router, urlSerializer, interactionContext, angularLocation, placeHistory) {
|
|
3027
3204
|
super();
|
|
3028
3205
|
this.router = router;
|
|
3029
3206
|
this.urlSerializer = urlSerializer;
|
|
3207
|
+
this.interactionContext = interactionContext;
|
|
3030
3208
|
this.angularLocation = angularLocation;
|
|
3031
3209
|
this.placeHistory = placeHistory;
|
|
3032
3210
|
this.firstRoute = true;
|
|
@@ -3034,6 +3212,7 @@ class PlaceRouter extends GarbageCollector {
|
|
|
3034
3212
|
this._activeVisits = new MutableListModel();
|
|
3035
3213
|
const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);
|
|
3036
3214
|
this.activeVisitIndex = chain(this._activeVisits).indexBy('placeDefinition');
|
|
3215
|
+
this.navigationSessionFactory = new NavigationSession.Factory(interactionContext);
|
|
3037
3216
|
angularLocation.onUrlChange((/**
|
|
3038
3217
|
* @param {?} url
|
|
3039
3218
|
* @return {?}
|
|
@@ -3056,8 +3235,11 @@ class PlaceRouter extends GarbageCollector {
|
|
|
3056
3235
|
if (event instanceof NavigationStart) {
|
|
3057
3236
|
this.onAngularRouterStarted(event);
|
|
3058
3237
|
}
|
|
3059
|
-
if (event instanceof NavigationEnd
|
|
3060
|
-
this.onAngularRouterFinished();
|
|
3238
|
+
if (event instanceof NavigationEnd) {
|
|
3239
|
+
this.onAngularRouterFinished(false);
|
|
3240
|
+
}
|
|
3241
|
+
if (event instanceof NavigationError) {
|
|
3242
|
+
this.onAngularRouterFinished(true);
|
|
3061
3243
|
}
|
|
3062
3244
|
}));
|
|
3063
3245
|
this.navigationSessionActive = chain(this.navigationSessionModel).isNotNil();
|
|
@@ -3133,7 +3315,7 @@ class PlaceRouter extends GarbageCollector {
|
|
|
3133
3315
|
*/
|
|
3134
3316
|
router => {
|
|
3135
3317
|
/** @type {?} */
|
|
3136
|
-
const commands = this.
|
|
3318
|
+
const commands = this.parseUrl(this.router.routerState.snapshot).createRedirectCommandsFor(next);
|
|
3137
3319
|
// // we have to to use the definition for route id as our redirection always includes
|
|
3138
3320
|
// // the id in the url segements (but leaves it blank when there's no id). I.e. in the
|
|
3139
3321
|
// // no id case we're doing the following redirect [<placePath>, ""] -> ["..", <id>]
|
|
@@ -3156,13 +3338,15 @@ class PlaceRouter extends GarbageCollector {
|
|
|
3156
3338
|
*/
|
|
3157
3339
|
doNavigation(visit, customNavigation) {
|
|
3158
3340
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3159
|
-
this._navigationSessionModel.value =
|
|
3341
|
+
this._navigationSessionModel.value = this.navigationSessionFactory.createInternal(visit);
|
|
3160
3342
|
try {
|
|
3161
3343
|
yield customNavigation(this.router);
|
|
3162
3344
|
}
|
|
3163
3345
|
finally {
|
|
3346
|
+
// Router has finished (since there was no router change required) so we
|
|
3347
|
+
// need to end the navigation session.
|
|
3164
3348
|
if (this.navigationSession && !this.router.getCurrentNavigation()) {
|
|
3165
|
-
this.onAngularRouterFinished();
|
|
3349
|
+
this.onAngularRouterFinished(false);
|
|
3166
3350
|
}
|
|
3167
3351
|
}
|
|
3168
3352
|
});
|
|
@@ -3189,9 +3373,9 @@ class PlaceRouter extends GarbageCollector {
|
|
|
3189
3373
|
if (!this.navigationSession) { // We been activated by an external route rather than placeRouter.go(visit)
|
|
3190
3374
|
console.log('navigation started', { firstTime: this.firstRoute });
|
|
3191
3375
|
/** @type {?} */
|
|
3192
|
-
const session =
|
|
3376
|
+
const session = this.navigationSessionFactory.createExternal(this.firstRoute);
|
|
3193
3377
|
if (event.navigationTrigger === 'popstate') {
|
|
3194
|
-
session.
|
|
3378
|
+
session.setPopstateReturnUrl(this.router.routerState.snapshot.url);
|
|
3195
3379
|
}
|
|
3196
3380
|
this._navigationSessionModel.value = session;
|
|
3197
3381
|
}
|
|
@@ -3200,23 +3384,32 @@ class PlaceRouter extends GarbageCollector {
|
|
|
3200
3384
|
// @Trace()
|
|
3201
3385
|
/**
|
|
3202
3386
|
* @private
|
|
3387
|
+
* @param {?} cancelled
|
|
3203
3388
|
* @return {?}
|
|
3204
3389
|
*/
|
|
3205
|
-
onAngularRouterFinished() {
|
|
3390
|
+
onAngularRouterFinished(cancelled) {
|
|
3206
3391
|
/** @type {?} */
|
|
3207
3392
|
const session = this._navigationSessionModel.value;
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
this.placeHistory.add(v);
|
|
3218
|
-
|
|
3219
|
-
|
|
3393
|
+
if (!cancelled) {
|
|
3394
|
+
// Update visits before we end the navigation session. This allows the placeOutets to
|
|
3395
|
+
// ignore visit changes that occur while the navigation is in progress
|
|
3396
|
+
/** @type {?} */
|
|
3397
|
+
const visits = session.getVisits();
|
|
3398
|
+
visits.forEach((/**
|
|
3399
|
+
* @param {?} v
|
|
3400
|
+
* @return {?}
|
|
3401
|
+
*/
|
|
3402
|
+
v => this.placeHistory.add(v)));
|
|
3403
|
+
this._activeVisits.value = visits;
|
|
3404
|
+
}
|
|
3405
|
+
else {
|
|
3406
|
+
// Angular doesn't preserve the url when a guard cancels the back button.
|
|
3407
|
+
// See https://github.com/angular/angular/issues/13586#issuecomment-432795720
|
|
3408
|
+
if (session.isPopState) {
|
|
3409
|
+
console.log('cancelled during popstate');
|
|
3410
|
+
this.angularLocation.go(session.popStateReturnUrl);
|
|
3411
|
+
}
|
|
3412
|
+
}
|
|
3220
3413
|
this._navigationSessionModel.value = null;
|
|
3221
3414
|
}
|
|
3222
3415
|
/**
|
|
@@ -3234,8 +3427,8 @@ class PlaceRouter extends GarbageCollector {
|
|
|
3234
3427
|
* @param {?} snapshot
|
|
3235
3428
|
* @return {?}
|
|
3236
3429
|
*/
|
|
3237
|
-
|
|
3238
|
-
return new PlaceRouter.
|
|
3430
|
+
parseUrl(snapshot) {
|
|
3431
|
+
return new PlaceRouter.UrlHelper(this.urlSerializer.parse(snapshot.url));
|
|
3239
3432
|
}
|
|
3240
3433
|
}
|
|
3241
3434
|
PlaceRouter.decorators = [
|
|
@@ -3247,10 +3440,11 @@ PlaceRouter.decorators = [
|
|
|
3247
3440
|
PlaceRouter.ctorParameters = () => [
|
|
3248
3441
|
{ type: Router },
|
|
3249
3442
|
{ type: UrlSerializer },
|
|
3443
|
+
{ type: InteractionContext },
|
|
3250
3444
|
{ type: Location },
|
|
3251
3445
|
{ type: PlaceHistory }
|
|
3252
3446
|
];
|
|
3253
|
-
/** @nocollapse */ PlaceRouter.ngInjectableDef = ɵɵdefineInjectable({ factory: function PlaceRouter_Factory() { return new PlaceRouter(ɵɵinject(Router), ɵɵinject(UrlSerializer), ɵɵinject(Location), ɵɵinject(PlaceHistory)); }, token: PlaceRouter, providedIn: "root" });
|
|
3447
|
+
/** @nocollapse */ PlaceRouter.ngInjectableDef = ɵɵdefineInjectable({ factory: function PlaceRouter_Factory() { return new PlaceRouter(ɵɵinject(Router), ɵɵinject(UrlSerializer), ɵɵinject(InteractionContext), ɵɵinject(Location), ɵɵinject(PlaceHistory)); }, token: PlaceRouter, providedIn: "root" });
|
|
3254
3448
|
__decorate([
|
|
3255
3449
|
Trace(),
|
|
3256
3450
|
__metadata("design:type", Function),
|
|
@@ -3277,6 +3471,11 @@ if (false) {
|
|
|
3277
3471
|
PlaceRouter.prototype.navigationSessionActive;
|
|
3278
3472
|
/** @type {?} */
|
|
3279
3473
|
PlaceRouter.prototype.activeVisitIndex;
|
|
3474
|
+
/**
|
|
3475
|
+
* @type {?}
|
|
3476
|
+
* @private
|
|
3477
|
+
*/
|
|
3478
|
+
PlaceRouter.prototype.navigationSessionFactory;
|
|
3280
3479
|
/**
|
|
3281
3480
|
* @type {?}
|
|
3282
3481
|
* @private
|
|
@@ -3287,13 +3486,18 @@ if (false) {
|
|
|
3287
3486
|
* @private
|
|
3288
3487
|
*/
|
|
3289
3488
|
PlaceRouter.prototype.urlSerializer;
|
|
3489
|
+
/**
|
|
3490
|
+
* @type {?}
|
|
3491
|
+
* @private
|
|
3492
|
+
*/
|
|
3493
|
+
PlaceRouter.prototype.interactionContext;
|
|
3290
3494
|
/** @type {?} */
|
|
3291
3495
|
PlaceRouter.prototype.angularLocation;
|
|
3292
3496
|
/** @type {?} */
|
|
3293
3497
|
PlaceRouter.prototype.placeHistory;
|
|
3294
3498
|
}
|
|
3295
3499
|
(function (PlaceRouter) {
|
|
3296
|
-
class
|
|
3500
|
+
class UrlHelper {
|
|
3297
3501
|
/**
|
|
3298
3502
|
* @param {?} urlTree
|
|
3299
3503
|
*/
|
|
@@ -3367,20 +3571,31 @@ if (false) {
|
|
|
3367
3571
|
}));
|
|
3368
3572
|
return commands;
|
|
3369
3573
|
}
|
|
3574
|
+
/**
|
|
3575
|
+
* @param {?} placeDef
|
|
3576
|
+
* @return {?}
|
|
3577
|
+
*/
|
|
3578
|
+
includesPathOf(placeDef) {
|
|
3579
|
+
return this.cloneUrlSegmentList().find((/**
|
|
3580
|
+
* @param {?} s
|
|
3581
|
+
* @return {?}
|
|
3582
|
+
*/
|
|
3583
|
+
s => s.path === placeDef.path));
|
|
3584
|
+
}
|
|
3370
3585
|
}
|
|
3371
3586
|
__decorate([
|
|
3372
3587
|
Trace(),
|
|
3373
3588
|
__metadata("design:type", Function),
|
|
3374
3589
|
__metadata("design:paramtypes", [Visit]),
|
|
3375
3590
|
__metadata("design:returntype", Array)
|
|
3376
|
-
],
|
|
3377
|
-
PlaceRouter.
|
|
3591
|
+
], UrlHelper.prototype, "createRedirectCommandsFor", null);
|
|
3592
|
+
PlaceRouter.UrlHelper = UrlHelper;
|
|
3378
3593
|
if (false) {
|
|
3379
3594
|
/**
|
|
3380
3595
|
* @type {?}
|
|
3381
3596
|
* @private
|
|
3382
3597
|
*/
|
|
3383
|
-
|
|
3598
|
+
UrlHelper.prototype.urlTree;
|
|
3384
3599
|
}
|
|
3385
3600
|
})(PlaceRouter || (PlaceRouter = {}));
|
|
3386
3601
|
|
|
@@ -4963,7 +5178,7 @@ class EnterPlaceGuard {
|
|
|
4963
5178
|
if (initialVisit.hasRoutingChangedFrom(sanitisedVisit)) {
|
|
4964
5179
|
// Regenerate the url
|
|
4965
5180
|
/** @type {?} */
|
|
4966
|
-
const commands = this.placeRouter.
|
|
5181
|
+
const commands = this.placeRouter.parseUrl(state).createRedirectCommandsFor(sanitisedVisit);
|
|
4967
5182
|
console.log('##### Place Guard Redirect', commands);
|
|
4968
5183
|
return this.router.createUrlTree(commands, {
|
|
4969
5184
|
replaceUrl: true,
|
|
@@ -5157,86 +5372,10 @@ if (false) {
|
|
|
5157
5372
|
*/
|
|
5158
5373
|
class LeavePlaceGuard {
|
|
5159
5374
|
/**
|
|
5160
|
-
* @param {?} router
|
|
5161
|
-
* @param {?} injector
|
|
5162
5375
|
* @param {?} placeRouter
|
|
5163
|
-
* @param {?} dialogInteractionContext
|
|
5164
|
-
* @param {?} angularLocation
|
|
5165
5376
|
*/
|
|
5166
|
-
constructor(
|
|
5167
|
-
this.router = router;
|
|
5168
|
-
this.injector = injector;
|
|
5377
|
+
constructor(placeRouter) {
|
|
5169
5378
|
this.placeRouter = placeRouter;
|
|
5170
|
-
this.dialogInteractionContext = dialogInteractionContext;
|
|
5171
|
-
this.angularLocation = angularLocation;
|
|
5172
|
-
}
|
|
5173
|
-
// @Trace()
|
|
5174
|
-
/**
|
|
5175
|
-
* @private
|
|
5176
|
-
* @param {?} nextState
|
|
5177
|
-
* @param {?} placeDefinition
|
|
5178
|
-
* @return {?}
|
|
5179
|
-
*/
|
|
5180
|
-
isLeavingTheCurrentPlace(nextState, placeDefinition) {
|
|
5181
|
-
// TODO: this will break with child routes... need to examine the router states properly.
|
|
5182
|
-
// console.log('canDeactivate', {
|
|
5183
|
-
// staticPath: placeDefinitionPath,
|
|
5184
|
-
// currentStateUrl: currentState.url,
|
|
5185
|
-
// nextStateUrl: nextState.url
|
|
5186
|
-
// // alreadyDeclined: this._alreadyAccepted
|
|
5187
|
-
// });
|
|
5188
|
-
// Example of the above when navigating to a different child route.
|
|
5189
|
-
// canDeactivate {staticPath: "/hero-details",
|
|
5190
|
-
// currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-details",
|
|
5191
|
-
// nextStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats"
|
|
5192
|
-
// }
|
|
5193
|
-
// TODO: this will break with child routes... need to examine the router states properly.
|
|
5194
|
-
// console.log('canDeactivate', {
|
|
5195
|
-
// staticPath: placeDefinitionPath,
|
|
5196
|
-
// currentStateUrl: currentState.url,
|
|
5197
|
-
// nextStateUrl: nextState.url
|
|
5198
|
-
// // alreadyDeclined: this._alreadyAccepted
|
|
5199
|
-
// });
|
|
5200
|
-
// Example of the above when navigating to a different child route.
|
|
5201
|
-
// canDeactivate {staticPath: "/hero-details",
|
|
5202
|
-
// currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-details",
|
|
5203
|
-
// nextStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats"
|
|
5204
|
-
// }
|
|
5205
|
-
// Example clicking on router tab of the parent component (de-activates the parent due to route param changes)
|
|
5206
|
-
// canDeactivate {
|
|
5207
|
-
// staticPath: "/hero-stats",
|
|
5208
|
-
// currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats",
|
|
5209
|
-
// nextStateUrl: "/route-parameters/"
|
|
5210
|
-
// }
|
|
5211
|
-
// canDeactivate {
|
|
5212
|
-
// staticPath: "/route-parameters",
|
|
5213
|
-
// currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats",
|
|
5214
|
-
// nextStateUrl: "/route-parameters/"
|
|
5215
|
-
// }
|
|
5216
|
-
// logger.class.js:54 ParameterSnapshot.sanitise -> {idModel: -1, pv: undefined, pl: Array(0), dv: undefined, dl: Array(0), …}
|
|
5217
|
-
// parameter-snapshot.ts:20 {name: "idModel", mine: -1, theirs: null}
|
|
5218
|
-
// place-router.ts:28 redirect path (3) ["route-parameters", "-1", {…}]
|
|
5219
|
-
// canDeactivate {
|
|
5220
|
-
// staticPath: "/hero-stats",
|
|
5221
|
-
// currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats",
|
|
5222
|
-
// nextStateUrl: "/route-parameters/-1"
|
|
5223
|
-
// }
|
|
5224
|
-
// canDeactivate {
|
|
5225
|
-
// staticPath: "/route-parameters",
|
|
5226
|
-
// currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats",
|
|
5227
|
-
// nextStateUrl: "/route-parameters/-1"
|
|
5228
|
-
// }
|
|
5229
|
-
// logger.class.js:54 ParameterSnapshot.sanitise -> {idModel: -1, pv: undefined, pl: Array(0), dv: "A", dl: Array(3), …}
|
|
5230
|
-
// parameter-snapshot.ts:20 {name: "dv", mine: "A", theirs: undefined}
|
|
5231
|
-
// place-router.ts:28 redirect path (3) ["route-parameters", "-1", {…}]
|
|
5232
|
-
// canDeactivate {
|
|
5233
|
-
// staticPath: "/hero-stats",
|
|
5234
|
-
// currentStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c/hero-stats",
|
|
5235
|
-
// nextStateUrl: "/route-parameters/-1;dv=A;dl=a,b,c;rdv=A;rdl=a,b,c"
|
|
5236
|
-
// }
|
|
5237
|
-
/** @type {?} */
|
|
5238
|
-
const placeDefinitionPath = `/${placeDefinition.path}`;
|
|
5239
|
-
return !nextState.url.startsWith(placeDefinitionPath);
|
|
5240
5379
|
}
|
|
5241
5380
|
/**
|
|
5242
5381
|
* @param {?} component
|
|
@@ -5247,77 +5386,7 @@ class LeavePlaceGuard {
|
|
|
5247
5386
|
*/
|
|
5248
5387
|
canDeactivate(component, currentRoute, currentState, nextState) {
|
|
5249
5388
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5250
|
-
|
|
5251
|
-
// We'll get called multiple times if there's any parameter sanitisation so
|
|
5252
|
-
// we always return true if we accepted on a previous cycle of the current
|
|
5253
|
-
// navigation session.
|
|
5254
|
-
return true;
|
|
5255
|
-
}
|
|
5256
|
-
else {
|
|
5257
|
-
/** @type {?} */
|
|
5258
|
-
const self = this;
|
|
5259
|
-
/** @type {?} */
|
|
5260
|
-
let canLeave = true;
|
|
5261
|
-
if (this.isLeavingTheCurrentPlace(nextState, component.placeDefinition)) {
|
|
5262
|
-
// we check the dialog interaction first, so that components that don't need to check if they're in an
|
|
5263
|
-
// interaction during the canDeactivate cycle.
|
|
5264
|
-
// TODO: Add tests: show dialog -> hit back -> same route
|
|
5265
|
-
if (this.dialogInteractionContext.isActive()) {
|
|
5266
|
-
console.log('cancelling', { activity: this.dialogInteractionContext.currentActivity });
|
|
5267
|
-
this.dialogInteractionContext.currentActivity.cancel(null);
|
|
5268
|
-
canLeave = false;
|
|
5269
|
-
}
|
|
5270
|
-
else {
|
|
5271
|
-
canLeave = true;
|
|
5272
|
-
}
|
|
5273
|
-
if (canLeave) {
|
|
5274
|
-
// now check if the component has an active interaction. This will handle
|
|
5275
|
-
// an inplace interaction contexts
|
|
5276
|
-
if (component.interactionContext && component.interactionContext.isActive()) {
|
|
5277
|
-
canLeave = false;
|
|
5278
|
-
console.log('cancelling', { activity: component.interactionContext.currentActivity });
|
|
5279
|
-
component.interactionContext.currentActivity.cancel(null);
|
|
5280
|
-
}
|
|
5281
|
-
}
|
|
5282
|
-
// No interaction in progress, so ask the component .
|
|
5283
|
-
// This may start an interaction, hence checking the interaction context above. I.e. if the place pops up the dialog, and
|
|
5284
|
-
// the user clicks back again, we'll re-enter here and go bang when the component tries to open another
|
|
5285
|
-
// dialog.
|
|
5286
|
-
if (canLeave) {
|
|
5287
|
-
// TODO: Add tests: hit back -> confirm leave dialog -> hit back -> close dialog -> hit back -> confirm leave dialog.
|
|
5288
|
-
canLeave = yield component.canDeactivate();
|
|
5289
|
-
}
|
|
5290
|
-
// We also block back button parameter changes while the dialog is open.
|
|
5291
|
-
// NOTE: Now that I'm catching parameter changes I could possibly retry using a fragment or
|
|
5292
|
-
// query parameter to track the dialog being open. Previously I was just checking this on
|
|
5293
|
-
// path changes... if that worked it'd fix the case where the back button breaks with an activity
|
|
5294
|
-
// open on the first page: https://coolon.atlassian.net/browse/AUP-33
|
|
5295
|
-
}
|
|
5296
|
-
else {
|
|
5297
|
-
if (this.dialogInteractionContext.isActive()) {
|
|
5298
|
-
console.log('cancelling', { activity: this.dialogInteractionContext.currentActivity });
|
|
5299
|
-
this.dialogInteractionContext.currentActivity.cancel(null);
|
|
5300
|
-
canLeave = false;
|
|
5301
|
-
}
|
|
5302
|
-
else {
|
|
5303
|
-
canLeave = true;
|
|
5304
|
-
}
|
|
5305
|
-
}
|
|
5306
|
-
if (canLeave) {
|
|
5307
|
-
// We'll get called multiple times if there's any parameter sanitisation so
|
|
5308
|
-
// we remember the acceptance for the duration of the current navigation session.
|
|
5309
|
-
self.placeRouter.navigationSession.rememberAcceptanceOf(component);
|
|
5310
|
-
}
|
|
5311
|
-
else {
|
|
5312
|
-
// Angular doesn't preserve the url when a guard cancels the back button.
|
|
5313
|
-
// See https://github.com/angular/angular/issues/13586#issuecomment-432795720
|
|
5314
|
-
if (this.placeRouter.navigationSession.isPopState) {
|
|
5315
|
-
console.log('cancelled during popstate');
|
|
5316
|
-
this.angularLocation.go(this.placeRouter.navigationSession.popStateReturnUrl);
|
|
5317
|
-
}
|
|
5318
|
-
}
|
|
5319
|
-
return canLeave;
|
|
5320
|
-
}
|
|
5389
|
+
return this.placeRouter.navigationSession.canDeactivate(component, this.placeRouter.parseUrl(nextState));
|
|
5321
5390
|
});
|
|
5322
5391
|
}
|
|
5323
5392
|
}
|
|
@@ -5328,33 +5397,15 @@ LeavePlaceGuard.decorators = [
|
|
|
5328
5397
|
];
|
|
5329
5398
|
/** @nocollapse */
|
|
5330
5399
|
LeavePlaceGuard.ctorParameters = () => [
|
|
5331
|
-
{ type:
|
|
5332
|
-
{ type: Injector },
|
|
5333
|
-
{ type: PlaceRouter },
|
|
5334
|
-
{ type: InteractionContext },
|
|
5335
|
-
{ type: Location }
|
|
5400
|
+
{ type: PlaceRouter }
|
|
5336
5401
|
];
|
|
5337
|
-
/** @nocollapse */ LeavePlaceGuard.ngInjectableDef = ɵɵdefineInjectable({ factory: function LeavePlaceGuard_Factory() { return new LeavePlaceGuard(ɵɵinject(
|
|
5402
|
+
/** @nocollapse */ LeavePlaceGuard.ngInjectableDef = ɵɵdefineInjectable({ factory: function LeavePlaceGuard_Factory() { return new LeavePlaceGuard(ɵɵinject(PlaceRouter)); }, token: LeavePlaceGuard, providedIn: "root" });
|
|
5338
5403
|
if (false) {
|
|
5339
|
-
/**
|
|
5340
|
-
* @type {?}
|
|
5341
|
-
* @private
|
|
5342
|
-
*/
|
|
5343
|
-
LeavePlaceGuard.prototype.router;
|
|
5344
|
-
/**
|
|
5345
|
-
* @type {?}
|
|
5346
|
-
* @private
|
|
5347
|
-
*/
|
|
5348
|
-
LeavePlaceGuard.prototype.injector;
|
|
5349
5404
|
/**
|
|
5350
5405
|
* @type {?}
|
|
5351
5406
|
* @private
|
|
5352
5407
|
*/
|
|
5353
5408
|
LeavePlaceGuard.prototype.placeRouter;
|
|
5354
|
-
/** @type {?} */
|
|
5355
|
-
LeavePlaceGuard.prototype.dialogInteractionContext;
|
|
5356
|
-
/** @type {?} */
|
|
5357
|
-
LeavePlaceGuard.prototype.angularLocation;
|
|
5358
5409
|
}
|
|
5359
5410
|
|
|
5360
5411
|
/**
|
|
@@ -5377,5 +5428,5 @@ if (false) {
|
|
|
5377
5428
|
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
5378
5429
|
*/
|
|
5379
5430
|
|
|
5380
|
-
export { ACTIVITY_DATA, AUP_PLACE_CONFIG, AbstractActivity, AbstractInputComponent, AbstractPlaceNavigationComponent, Activity, ActivityContainerComponent, ActivityOutletComponent, AlertDialogComponent, AngularUiPowerupsModule, Bounds, BusyOverlayComponent, CommandDirective, ComponentsModule, ConfirmThenDialogComponent, ConfirmationDialogComponent, DEFINITION_META_DATA_KEY, DIALOG_INTERACTION_SERVICE_DEFAULTS, DialogInteractionService, Dimension, DirectivesModule, DisposableComponent, EmptyStateComponent, EnterPlaceGuard, FocusBindingDirective, Formatter, InplaceInteractionContextComponent, InteractionContext, InteractionGuard, InteractionModule, InteractionOutletComponent, LEFT_RIGHT_PLACE_ANIMATION, LeavePlaceGuard, ListPlaceNavComponent, NavigationSession, NoopComponent, NumberInputComponent, ParameterDefinition, PasswordInputComponent, Place, PlaceComponent, PlaceDefinition, PlaceHistory, PlaceModule, PlaceOutletComponent, PlaceRouter, Point, ROUTE_PARAMETER_LIST_KEY, ResizeAwareComponent, RouteId, SelectInputComponent, StringInputComponent, TabbedPlaceNavigationComponent, Visit, VisitParameter, VisitParameterList, VisitSanitiser, leftRightPlaceAnimation, slideDownAndUpAnimation, DirectivesModule as ɵa, CommandDirective as ɵb,
|
|
5431
|
+
export { ACTIVITY_DATA, AUP_PLACE_CONFIG, AbstractActivity, AbstractInputComponent, AbstractPlaceNavigationComponent, Activity, ActivityContainerComponent, ActivityOutletComponent, AlertDialogComponent, AngularUiPowerupsModule, Bounds, BusyOverlayComponent, CommandDirective, ComponentsModule, ConfirmThenDialogComponent, ConfirmationDialogComponent, DEFINITION_META_DATA_KEY, DIALOG_INTERACTION_SERVICE_DEFAULTS, DialogInteractionService, Dimension, DirectivesModule, DisposableComponent, EmptyStateComponent, EnterPlaceGuard, FocusBindingDirective, Formatter, InplaceInteractionContextComponent, InteractionContext, InteractionGuard, InteractionModule, InteractionOutletComponent, LEFT_RIGHT_PLACE_ANIMATION, LeavePlaceGuard, ListPlaceNavComponent, NavigationSession, NoopComponent, NumberInputComponent, ParameterDefinition, PasswordInputComponent, Place, PlaceComponent, PlaceDefinition, PlaceHistory, PlaceModule, PlaceOutletComponent, PlaceRouter, Point, ROUTE_PARAMETER_LIST_KEY, ResizeAwareComponent, RouteId, SelectInputComponent, StringInputComponent, TabbedPlaceNavigationComponent, Visit, VisitParameter, VisitParameterList, VisitSanitiser, leftRightPlaceAnimation, slideDownAndUpAnimation, DirectivesModule as ɵa, CommandDirective as ɵb, ActivityContainerComponent as ɵba, ActivityOutletComponent as ɵbb, ConfirmationDialogComponent as ɵbc, AbstractActivity as ɵbd, ACTIVITY_DATA as ɵbe, Activity as ɵbf, ConfirmThenDialogComponent as ɵbh, AlertDialogComponent as ɵbi, InteractionOutletComponent as ɵbk, InplaceInteractionContextComponent as ɵbl, DIALOG_INTERACTION_SERVICE_DEFAULTS as ɵbm, DialogInteractionService as ɵbn, FocusBindingDirective as ɵc, DisposableComponent as ɵd, ComponentsModule as ɵe, NumberInputComponent as ɵf, AbstractInputComponent as ɵg, StringInputComponent as ɵh, PasswordInputComponent as ɵi, SelectInputComponent as ɵj, NoopComponent as ɵk, PlaceModule as ɵl, EmptyStateComponent as ɵm, BusyOverlayComponent as ɵn, PlaceOutletComponent as ɵo, leftRightPlaceAnimation as ɵp, LEFT_RIGHT_PLACE_ANIMATION as ɵq, AUP_PLACE_CONFIG as ɵr, PlaceRouter as ɵt, InteractionContext as ɵu, PlaceHistory as ɵv, TabbedPlaceNavigationComponent as ɵw, AbstractPlaceNavigationComponent as ɵx, ListPlaceNavComponent as ɵy, InteractionModule as ɵz };
|
|
5381
5432
|
//# sourceMappingURL=coolon-angular-ui-powerups.js.map
|