@coolon/angular-ui-powerups 0.0.65 → 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 +57 -11
- 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/interaction/activity.js +4 -3
- package/esm2015/lib/place/guards/leave-place.guard.js +57 -22
- package/esm2015/lib/place/place-router.js +4 -1
- package/esm5/lib/interaction/activity.js +9 -5
- 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 +60 -23
- package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
- package/fesm5/coolon-angular-ui-powerups.js +59 -13
- package/fesm5/coolon-angular-ui-powerups.js.map +1 -1
- package/lib/interaction/activity.d.ts +2 -2
- 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';
|
|
@@ -885,9 +885,12 @@ var /**
|
|
|
885
885
|
* @abstract
|
|
886
886
|
* @template D, R, E
|
|
887
887
|
*/
|
|
888
|
-
Activity = /** @class */ (function () {
|
|
888
|
+
Activity = /** @class */ (function (_super) {
|
|
889
|
+
__extends(Activity, _super);
|
|
889
890
|
function Activity() {
|
|
890
|
-
|
|
891
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
892
|
+
_this._busyModel = new DelegatingValueModel().withDefault(false);
|
|
893
|
+
return _this;
|
|
891
894
|
}
|
|
892
895
|
/**
|
|
893
896
|
* @param {?} activityContext
|
|
@@ -966,7 +969,7 @@ Activity = /** @class */ (function () {
|
|
|
966
969
|
return this._busyModel.value;
|
|
967
970
|
};
|
|
968
971
|
return Activity;
|
|
969
|
-
}());
|
|
972
|
+
}(GarbageCollector));
|
|
970
973
|
if (false) {
|
|
971
974
|
/**
|
|
972
975
|
* @type {?}
|
|
@@ -2736,6 +2739,7 @@ var PlaceRouter = /** @class */ (function () {
|
|
|
2736
2739
|
function PlaceRouter(router, angularLocation) {
|
|
2737
2740
|
var _this = this;
|
|
2738
2741
|
this.router = router;
|
|
2742
|
+
this.angularLocation = angularLocation;
|
|
2739
2743
|
this._navigationSession = new MutableValueModel();
|
|
2740
2744
|
angularLocation.onUrlChange((/**
|
|
2741
2745
|
* @param {?} url
|
|
@@ -2878,6 +2882,8 @@ if (false) {
|
|
|
2878
2882
|
* @private
|
|
2879
2883
|
*/
|
|
2880
2884
|
PlaceRouter.prototype.router;
|
|
2885
|
+
/** @type {?} */
|
|
2886
|
+
PlaceRouter.prototype.angularLocation;
|
|
2881
2887
|
}
|
|
2882
2888
|
|
|
2883
2889
|
/**
|
|
@@ -4834,6 +4840,22 @@ var LeavePlaceGuard = /** @class */ (function () {
|
|
|
4834
4840
|
this.interactionContext = interactionContext;
|
|
4835
4841
|
this.angularLocation = angularLocation;
|
|
4836
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
|
+
};
|
|
4837
4859
|
/**
|
|
4838
4860
|
* @param {?} component
|
|
4839
4861
|
* @param {?} currentRoute
|
|
@@ -4856,23 +4878,42 @@ var LeavePlaceGuard = /** @class */ (function () {
|
|
|
4856
4878
|
case 0:
|
|
4857
4879
|
placeDefinitionPath = "/" + component.placeDefinition.path;
|
|
4858
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.
|
|
4859
4884
|
return [2 /*return*/, true];
|
|
4860
4885
|
case 1:
|
|
4861
|
-
if (!!nextState.url.startsWith(placeDefinitionPath)) return [3 /*break*/, 3];
|
|
4862
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];
|
|
4863
4897
|
return [4 /*yield*/, component.canDeactivate()];
|
|
4864
4898
|
case 2:
|
|
4865
4899
|
canLeave = _a.sent();
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
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()) {
|
|
4870
4905
|
console.log("cancelling", { activity: this.interactionContext.currentActivity });
|
|
4871
4906
|
this.interactionContext.currentActivity.cancel(null);
|
|
4907
|
+
canLeave = false;
|
|
4872
4908
|
}
|
|
4873
|
-
|
|
4874
|
-
|
|
4909
|
+
else {
|
|
4910
|
+
canLeave = true;
|
|
4911
|
+
}
|
|
4912
|
+
_a.label = 5;
|
|
4913
|
+
case 5:
|
|
4875
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.
|
|
4876
4917
|
self_1.placeRouter.navigationSession.rememberAcceptanceOf(component);
|
|
4877
4918
|
}
|
|
4878
4919
|
else {
|
|
@@ -4884,7 +4925,6 @@ var LeavePlaceGuard = /** @class */ (function () {
|
|
|
4884
4925
|
}
|
|
4885
4926
|
}
|
|
4886
4927
|
return [2 /*return*/, canLeave];
|
|
4887
|
-
case 3: return [2 /*return*/, true];
|
|
4888
4928
|
}
|
|
4889
4929
|
});
|
|
4890
4930
|
});
|
|
@@ -4903,6 +4943,12 @@ var LeavePlaceGuard = /** @class */ (function () {
|
|
|
4903
4943
|
{ type: Location }
|
|
4904
4944
|
]; };
|
|
4905
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);
|
|
4906
4952
|
return LeavePlaceGuard;
|
|
4907
4953
|
}());
|
|
4908
4954
|
if (false) {
|