@coolon/angular-ui-powerups 0.0.66 → 0.0.67
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 +51 -8
- 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/lib/place/guards/leave-place.guard.js +57 -22
- package/esm2015/lib/place/place-router.js +4 -1
- package/esm5/lib/place/guards/leave-place.guard.js +52 -10
- package/esm5/lib/place/place-router.js +4 -1
- package/fesm2015/coolon-angular-ui-powerups.js +58 -22
- package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
- package/fesm5/coolon-angular-ui-powerups.js +53 -10
- package/fesm5/coolon-angular-ui-powerups.js.map +1 -1
- package/lib/place/guards/leave-place.guard.d.ts +1 -0
- package/lib/place/place-router.d.ts +1 -0
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ import { MatDialog, MatButtonModule, MatDialogModule, MatTabsModule, MatProgress
|
|
|
5
5
|
import { MatTabsModule as MatTabsModule$1 } from '@angular/material/tabs';
|
|
6
6
|
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
|
7
7
|
import { __extends, __decorate, __metadata, __assign, __awaiter, __generator } from 'tslib';
|
|
8
|
-
import { GarbageCollector, DelegatingFormValueModel, UseDelegate, ValueModel, ListModel, StoreInListModel, assert, UnaryCommand, lang, Dsl, Logger, DelegatingValueModel, MutableStream, MutableListModel, DelegatingListModel, StoreInValueModel, Binding, MutableValueModel, Guard as Guard$1, OptionsHelper, ValueHolder } from '@coolon/pectin';
|
|
8
|
+
import { GarbageCollector, DelegatingFormValueModel, UseDelegate, ValueModel, ListModel, StoreInListModel, assert, UnaryCommand, lang, Dsl, Logger, DelegatingValueModel, MutableStream, MutableListModel, DelegatingListModel, StoreInValueModel, Binding, MutableValueModel, Guard as Guard$1, OptionsHelper, ValueHolder, Trace } from '@coolon/pectin';
|
|
9
9
|
import { PortalModule } from '@angular/cdk/portal';
|
|
10
10
|
import ___default, { last, isNil } from 'lodash';
|
|
11
11
|
import { assert as assert$1, Klass, Opts } from '@coolon/typescript-utilities';
|
|
@@ -14,7 +14,7 @@ import { v1 } from 'uuid';
|
|
|
14
14
|
import { MatIconModule } from '@angular/material/icon';
|
|
15
15
|
import { MatListModule } from '@angular/material/list';
|
|
16
16
|
import { MatTooltipModule } from '@angular/material/tooltip';
|
|
17
|
-
import { Router, NavigationStart, NavigationEnd, NavigationError, RouterModule } from '@angular/router';
|
|
17
|
+
import { Router, NavigationStart, NavigationEnd, NavigationError, RouterModule, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
|
|
18
18
|
import { Memoize as Memoize$1 } from '@typescript-plus/fast-memoize-decorator/dist/src';
|
|
19
19
|
import { Memoize } from '@typescript-plus/fast-memoize-decorator';
|
|
20
20
|
import 'reflect-metadata';
|
|
@@ -2739,6 +2739,7 @@ var PlaceRouter = /** @class */ (function () {
|
|
|
2739
2739
|
function PlaceRouter(router, angularLocation) {
|
|
2740
2740
|
var _this = this;
|
|
2741
2741
|
this.router = router;
|
|
2742
|
+
this.angularLocation = angularLocation;
|
|
2742
2743
|
this._navigationSession = new MutableValueModel();
|
|
2743
2744
|
angularLocation.onUrlChange((/**
|
|
2744
2745
|
* @param {?} url
|
|
@@ -2881,6 +2882,8 @@ if (false) {
|
|
|
2881
2882
|
* @private
|
|
2882
2883
|
*/
|
|
2883
2884
|
PlaceRouter.prototype.router;
|
|
2885
|
+
/** @type {?} */
|
|
2886
|
+
PlaceRouter.prototype.angularLocation;
|
|
2884
2887
|
}
|
|
2885
2888
|
|
|
2886
2889
|
/**
|
|
@@ -4837,6 +4840,22 @@ var LeavePlaceGuard = /** @class */ (function () {
|
|
|
4837
4840
|
this.interactionContext = interactionContext;
|
|
4838
4841
|
this.angularLocation = angularLocation;
|
|
4839
4842
|
}
|
|
4843
|
+
/**
|
|
4844
|
+
* @private
|
|
4845
|
+
* @param {?} nextState
|
|
4846
|
+
* @param {?} placeDefinitionPath
|
|
4847
|
+
* @return {?}
|
|
4848
|
+
*/
|
|
4849
|
+
LeavePlaceGuard.prototype.isLeavingTheCurrentPlace = /**
|
|
4850
|
+
* @private
|
|
4851
|
+
* @param {?} nextState
|
|
4852
|
+
* @param {?} placeDefinitionPath
|
|
4853
|
+
* @return {?}
|
|
4854
|
+
*/
|
|
4855
|
+
function (nextState, placeDefinitionPath) {
|
|
4856
|
+
// TODO: this will break with child routes... need to examine the router states properly.
|
|
4857
|
+
return !nextState.url.startsWith(placeDefinitionPath);
|
|
4858
|
+
};
|
|
4840
4859
|
/**
|
|
4841
4860
|
* @param {?} component
|
|
4842
4861
|
* @param {?} currentRoute
|
|
@@ -4859,23 +4878,42 @@ var LeavePlaceGuard = /** @class */ (function () {
|
|
|
4859
4878
|
case 0:
|
|
4860
4879
|
placeDefinitionPath = "/" + component.placeDefinition.path;
|
|
4861
4880
|
if (!this.placeRouter.navigationSession.alreadyAccepted(component)) return [3 /*break*/, 1];
|
|
4881
|
+
// We'll get called multiple times if there's any parameter sanitisation so
|
|
4882
|
+
// we always return true if we accepted on a previous cycle of the current
|
|
4883
|
+
// navigation session.
|
|
4862
4884
|
return [2 /*return*/, true];
|
|
4863
4885
|
case 1:
|
|
4864
|
-
if (!!nextState.url.startsWith(placeDefinitionPath)) return [3 /*break*/, 3];
|
|
4865
4886
|
self_1 = this;
|
|
4887
|
+
canLeave = true;
|
|
4888
|
+
if (!this.isLeavingTheCurrentPlace(nextState, placeDefinitionPath)) return [3 /*break*/, 4];
|
|
4889
|
+
// we check the interaction first, so that components that don't need to check if they're in an
|
|
4890
|
+
// interaction during the canDeactivate cycle.
|
|
4891
|
+
if (this.interactionContext.isActive()) {
|
|
4892
|
+
canLeave = false;
|
|
4893
|
+
console.log("cancelling", { activity: this.interactionContext.currentActivity });
|
|
4894
|
+
this.interactionContext.currentActivity.cancel(null);
|
|
4895
|
+
}
|
|
4896
|
+
if (!canLeave) return [3 /*break*/, 3];
|
|
4866
4897
|
return [4 /*yield*/, component.canDeactivate()];
|
|
4867
4898
|
case 2:
|
|
4868
4899
|
canLeave = _a.sent();
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4900
|
+
_a.label = 3;
|
|
4901
|
+
case 3: return [3 /*break*/, 5];
|
|
4902
|
+
case 4:
|
|
4903
|
+
// this is a parameter change.
|
|
4904
|
+
if (this.interactionContext.isActive()) {
|
|
4873
4905
|
console.log("cancelling", { activity: this.interactionContext.currentActivity });
|
|
4874
4906
|
this.interactionContext.currentActivity.cancel(null);
|
|
4907
|
+
canLeave = false;
|
|
4875
4908
|
}
|
|
4876
|
-
|
|
4877
|
-
|
|
4909
|
+
else {
|
|
4910
|
+
canLeave = true;
|
|
4911
|
+
}
|
|
4912
|
+
_a.label = 5;
|
|
4913
|
+
case 5:
|
|
4878
4914
|
if (canLeave) {
|
|
4915
|
+
// We'll get called multiple times if there's any parameter sanitisation so
|
|
4916
|
+
// we remember the acceptance for the duration of the current routing session.
|
|
4879
4917
|
self_1.placeRouter.navigationSession.rememberAcceptanceOf(component);
|
|
4880
4918
|
}
|
|
4881
4919
|
else {
|
|
@@ -4887,7 +4925,6 @@ var LeavePlaceGuard = /** @class */ (function () {
|
|
|
4887
4925
|
}
|
|
4888
4926
|
}
|
|
4889
4927
|
return [2 /*return*/, canLeave];
|
|
4890
|
-
case 3: return [2 /*return*/, true];
|
|
4891
4928
|
}
|
|
4892
4929
|
});
|
|
4893
4930
|
});
|
|
@@ -4906,6 +4943,12 @@ var LeavePlaceGuard = /** @class */ (function () {
|
|
|
4906
4943
|
{ type: Location }
|
|
4907
4944
|
]; };
|
|
4908
4945
|
/** @nocollapse */ LeavePlaceGuard.ngInjectableDef = ɵɵdefineInjectable({ factory: function LeavePlaceGuard_Factory() { return new LeavePlaceGuard(ɵɵinject(Router), ɵɵinject(INJECTOR), ɵɵinject(PlaceRouter), ɵɵinject(InteractionContext), ɵɵinject(Location)); }, token: LeavePlaceGuard, providedIn: "root" });
|
|
4946
|
+
__decorate([
|
|
4947
|
+
Trace(),
|
|
4948
|
+
__metadata("design:type", Function),
|
|
4949
|
+
__metadata("design:paramtypes", [PlaceComponent, ActivatedRouteSnapshot, RouterStateSnapshot, RouterStateSnapshot]),
|
|
4950
|
+
__metadata("design:returntype", Promise)
|
|
4951
|
+
], LeavePlaceGuard.prototype, "canDeactivate", null);
|
|
4909
4952
|
return LeavePlaceGuard;
|
|
4910
4953
|
}());
|
|
4911
4954
|
if (false) {
|