@coolon/angular-ui-powerups 11.0.0-alpha.2 → 11.0.0-alpha.3
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 +81 -42
- 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/components/abstract-place-navigation.component.js +3 -2
- package/esm2015/lib/place/components/abstract-place-navigation.component.js.map +1 -1
- package/esm2015/lib/place/components/abstract-place-navigation.component.metadata.json +1 -1
- package/esm2015/lib/place/components/not-authorised-notice/not-authorised-notice.component.js +14 -0
- package/esm2015/lib/place/components/not-authorised-notice/not-authorised-notice.component.js.map +1 -0
- package/esm2015/lib/place/components/not-authorised-notice/not-authorised-notice.component.metadata.json +1 -0
- package/esm2015/lib/place/components/not-authorised-notice/not-authorised-notice.component.ngfactory.js.map +1 -0
- package/esm2015/lib/place/components/not-authorised-notice/not-authorised-notice.component.scss.shim.ngstyle.js.map +1 -0
- package/esm2015/lib/place/components/place-outlet/place-outlet.component.js +23 -14
- package/esm2015/lib/place/components/place-outlet/place-outlet.component.js.map +1 -1
- package/esm2015/lib/place/components/place-outlet/place-outlet.component.metadata.json +1 -1
- package/esm2015/lib/place/exports.js +1 -0
- package/esm2015/lib/place/exports.js.map +1 -1
- package/esm2015/lib/place/exports.metadata.json +1 -1
- package/esm2015/lib/place/guards/place.guard.js +5 -8
- package/esm2015/lib/place/guards/place.guard.js.map +1 -1
- package/esm2015/lib/place/navigation/place-component-deactivation-handler.js +2 -0
- package/esm2015/lib/place/navigation/place-component-deactivation-handler.js.map +1 -1
- package/esm2015/lib/place/place-router.js +15 -4
- package/esm2015/lib/place/place-router.js.map +1 -1
- package/esm2015/lib/place/place-router.metadata.json +1 -1
- package/esm2015/lib/place/place.module.js +6 -2
- package/esm2015/lib/place/place.module.js.map +1 -1
- package/esm2015/lib/place/place.module.metadata.json +1 -1
- package/esm2015/lib/place/place.module.ngfactory.js.map +1 -1
- package/fesm2015/coolon-angular-ui-powerups.js +62 -30
- package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
- package/lib/place/components/not-authorised-notice/not-authorised-notice.component.d.ts +3 -0
- package/lib/place/components/place-outlet/place-outlet.component.d.ts +10 -3
- package/lib/place/exports.d.ts +1 -0
- package/lib/place/place-router.d.ts +10 -6
- package/package.json +1 -1
- package/schematics/utils/build-context.d.ts +4 -5
- package/schematics/utils/workspace.d.ts +3 -4
- package/schematics/utils/workspace.js.map +1 -1
|
@@ -19,8 +19,9 @@ export class AbstractPlaceNavigationComponent extends DisposableComponent {
|
|
|
19
19
|
.map(c => PlaceComponent.getDefinition(c))
|
|
20
20
|
.select(d => {
|
|
21
21
|
const guard = placeRouter.accessGuard.value;
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
const state = placeRouter.state.value;
|
|
23
|
+
return guard.isAuthorised(d) || state.isPlaceActive(d);
|
|
24
|
+
}, { dependsOn: [placeRouter.accessGuard, placeRouter.state] });
|
|
24
25
|
this.commandFactory = Command.createFactory((placeDefinition) => {
|
|
25
26
|
this.placeOutlet.navigate(new Visit(placeDefinition));
|
|
26
27
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstract-place-navigation.component.js","sourceRoot":"","sources":["../../../../../../../libs/angular-ui-powerups/src/lib/place/components/abstract-place-navigation.component.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAU,MAAM,eAAe,CAAC;AACzD,OAAO,EACL,OAAO,EAEP,oBAAoB,EACpB,GAAG,EACH,SAAS,EAET,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,UAAU,EAEX,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,kDAAkD,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAE5E,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAK7E,MAAM,OAAO,gCAAiC,SAAQ,mBAAmB;IAqBvE,YAAqB,WAAwB;QAC3C,KAAK,EAAE,CAAC;QADW,gBAAW,GAAX,WAAW,CAAa;QAHpC,0BAAqB,GAAG,IAAI,oBAAoB,EAAkB,CAAC;QAK1E,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACzF,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC;aAC5C,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;aACzC,MAAM,CAAC,CAAC,CAAC,EAAE;YACV,MAAM,KAAK,GAAG,WAAW,CAAC,WAAW,CAAC,KAAK,CAAC;YAC5C,OAAO,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"abstract-place-navigation.component.js","sourceRoot":"","sources":["../../../../../../../libs/angular-ui-powerups/src/lib/place/components/abstract-place-navigation.component.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAU,MAAM,eAAe,CAAC;AACzD,OAAO,EACL,OAAO,EAEP,oBAAoB,EACpB,GAAG,EACH,SAAS,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CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC,SAAS,EAAE,IAAI,CAAC;SAC9F,CAAC;IACJ,CAAC;IAED,QAAQ,CAAC,KAAsB;QAC7B,OAAO,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1D,CAAC;IAED,QAAQ;IACR,CAAC;;;YAhEF,SAAS,SAAC;gBACT,QAAQ,EAAE,EAAE;aACb;;;YANQ,WAAW;;;qBASjB,KAAK;0BAGL,KAAK;0BAIL,KAAK;+BAGL,KAAK;;AATN;IADU,gBAAgB,CAAC,aAAa,CAAC;;gEACD;AAGxC;IADU,aAAa,EAAE;8BACZ,SAAS;qEAAgC;AAItD;IADU,iBAAiB,CAAC,kBAAkB,CAAC;8BAClC,oBAAoB;qEAAC;AAGlC;IADU,aAAa,EAAE;8BACP,UAAU;0EAAuB;AAkCnD;IADC,OAAO,EAAE;;qCACkB,eAAe;;yEAO1C","sourcesContent":["import { Component, Input, OnInit } from '@angular/core';\nimport {\n Command,\n Constructable,\n DelegatingValueModel,\n Dsl,\n ListModel,\n ListModelChain,\n StoreInListModel,\n StoreInValueModel,\n TrackExternal,\n ValueModel,\n ValueModelChain\n} from '@coolon/pectin';\nimport { Memoize } from '@typescript-plus/fast-memoize-decorator/dist/src';\nimport { CommandFace } from '../../components/commands/command-face';\nimport { DisposableComponent } from '../../components/disposable-component';\nimport { NavItem } from '../nav-item';\nimport { PlaceComponent } from '../place-component';\nimport { PlaceDefinition } from '../place-definition';\nimport { PlaceRouter } from '../place-router';\nimport { Visit } from '../visit';\nimport { PlaceOutletComponent } from './place-outlet/place-outlet.component';\n\n@Component({\n template: ''\n})\nexport class AbstractPlaceNavigationComponent extends DisposableComponent implements OnInit {\n\n @Input() @StoreInListModel('placesModel')\n places: Constructable<PlaceComponent>[];\n\n @Input() @TrackExternal()\n placesModel: ListModel<Constructable<PlaceComponent>>;\n\n\n @Input() @StoreInValueModel('placeOutletModel')\n placeOutlet: PlaceOutletComponent;\n\n @Input() @TrackExternal()\n placeOutletModel: ValueModel<PlaceOutletComponent>;\n\n readonly placeDefinitions: ListModelChain<PlaceDefinition>;\n\n readonly commandFactory: Command.Factory<PlaceDefinition, void>;\n readonly _activePlaceComponent = new DelegatingValueModel<PlaceComponent>();\n private activePlaceDefinition: ValueModelChain<PlaceDefinition>;\n\n constructor(readonly placeRouter: PlaceRouter) {\n super();\n const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);\n this.placeDefinitions = chain(this.placesModel)\n .map(c => PlaceComponent.getDefinition(c))\n .select(d => {\n const guard = placeRouter.accessGuard.value;\n const state = placeRouter.state.value;\n return guard.isAuthorised(d) || state.isPlaceActive(d);\n }, { dependsOn: [placeRouter.accessGuard, placeRouter.state] });\n\n this.commandFactory = Command.createFactory((placeDefinition: PlaceDefinition) => {\n this.placeOutlet.navigate(new Visit(placeDefinition));\n });\n\n when(this.placeOutletModel).changes(outlet => {\n // NOTE: this updates during a change cycle and causes our isActiveMethod to return 2 different\n // values in the one change detection cycle. So instead we delay the update to a different\n // tick.\n setTimeout(() => this._activePlaceComponent.setDelegate(outlet ? outlet.activePlaceModel : null));\n });\n this.activePlaceDefinition = chain(this._activePlaceComponent).pluck('placeDefinition');\n }\n\n\n @Memoize()\n getNavigationFace(placeDef: PlaceDefinition): CommandFace {\n const navItem = placeDef.getPlaceData('nav') as NavItem;\n return {\n text: () => navItem ? navItem.title() : placeDef.searchPlaceData(['navTitle', 'title']),\n tooltip: () => navItem && navItem.tooltip ? navItem.tooltip() : placeDef.getPlaceData('navTooltip', null),\n icon: () => navItem && navItem.icon ? navItem.icon() : placeDef.getPlaceData('navIcon', null)\n };\n }\n\n isActive(place: PlaceDefinition): boolean {\n return this.activePlaceDefinition.query().equals(place);\n }\n\n ngOnInit() {\n }\n\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"AbstractPlaceNavigationComponent":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"../../components/disposable-component","name":"DisposableComponent","line":27,"character":54},"decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component","line":24,"character":1},"arguments":[{"template":""}]}],"members":{"places":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":29,"character":3}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@coolon/pectin","name":"StoreInListModel","line":29,"character":12},"arguments":["placesModel"]}]}],"placesModel":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":32,"character":3}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@coolon/pectin","name":"TrackExternal","line":32,"character":12}}]}],"placeOutlet":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":36,"character":3}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@coolon/pectin","name":"StoreInValueModel","line":36,"character":12},"arguments":["placeOutletModel"]}]}],"placeOutletModel":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":39,"character":3}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@coolon/pectin","name":"TrackExternal","line":39,"character":12}}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"../place-router","name":"PlaceRouter","line":48,"character":36}]}],"getNavigationFace":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@typescript-plus/fast-memoize-decorator/dist/src","name":"Memoize","line":
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"AbstractPlaceNavigationComponent":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"../../components/disposable-component","name":"DisposableComponent","line":27,"character":54},"decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component","line":24,"character":1},"arguments":[{"template":""}]}],"members":{"places":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":29,"character":3}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@coolon/pectin","name":"StoreInListModel","line":29,"character":12},"arguments":["placesModel"]}]}],"placesModel":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":32,"character":3}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@coolon/pectin","name":"TrackExternal","line":32,"character":12}}]}],"placeOutlet":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":36,"character":3}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@coolon/pectin","name":"StoreInValueModel","line":36,"character":12},"arguments":["placeOutletModel"]}]}],"placeOutletModel":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":39,"character":3}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@coolon/pectin","name":"TrackExternal","line":39,"character":12}}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"../place-router","name":"PlaceRouter","line":48,"character":36}]}],"getNavigationFace":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@typescript-plus/fast-memoize-decorator/dist/src","name":"Memoize","line":73,"character":3}}]}],"isActive":[{"__symbolic":"method"}],"ngOnInit":[{"__symbolic":"method"}]}}}}]
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Component } from '@angular/core';
|
|
2
|
+
export class NotAuthorisedNoticeComponent {
|
|
3
|
+
constructor() {
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
NotAuthorisedNoticeComponent.decorators = [
|
|
7
|
+
{ type: Component, args: [{
|
|
8
|
+
selector: 'aup-not-authorised-notice',
|
|
9
|
+
template: "<p>You are not authorised to access this page</p>\n",
|
|
10
|
+
styles: [":host{display:flex;flex-direction:column;align-items:center;justify-content:center}"]
|
|
11
|
+
},] }
|
|
12
|
+
];
|
|
13
|
+
NotAuthorisedNoticeComponent.ctorParameters = () => [];
|
|
14
|
+
//# sourceMappingURL=not-authorised-notice.component.js.map
|
package/esm2015/lib/place/components/not-authorised-notice/not-authorised-notice.component.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"not-authorised-notice.component.js","sourceRoot":"","sources":["../../../../../../../../libs/angular-ui-powerups/src/lib/place/components/not-authorised-notice/not-authorised-notice.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAO1C,MAAM,OAAO,4BAA4B;IAEvC;IACA,CAAC;;;YARF,SAAS,SAAC;gBACT,QAAQ,EAAE,2BAA2B;gBACrC,+DAAqD;;aAEtD","sourcesContent":["import { Component } from '@angular/core';\n\n@Component({\n selector: 'aup-not-authorised-notice',\n templateUrl: './not-authorised-notice.component.html',\n styleUrls: ['./not-authorised-notice.component.scss']\n})\nexport class NotAuthorisedNoticeComponent {\n\n constructor() {\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"NotAuthorisedNoticeComponent":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component","line":2,"character":1},"arguments":[{"selector":"aup-not-authorised-notice","template":"<p>You are not authorised to access this page</p>\n","styles":[":host{display:flex;flex-direction:column;align-items:center;justify-content:center}"]}]}],"members":{"__ctor__":[{"__symbolic":"constructor"}]}}}}]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"not-authorised-notice.component.ngfactory.js","sourceRoot":"","sources":["../../../../../../../../libs/angular-ui-powerups/src/lib/place/components/not-authorised-notice/not-authorised-notice.component.ngfactory.ts"],"names":[],"mappings":"","sourcesContent":["import * as i0 from '@angular/core';\ni0.ComponentFactory;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"not-authorised-notice.component.scss.shim.ngstyle.js","sourceRoot":"","sources":["../../../../../../../../libs/angular-ui-powerups/src/lib/place/components/not-authorised-notice/not-authorised-notice.component.scss.shim.ngstyle.ts"],"names":[],"mappings":"","sourcesContent":["import * as i0 from '@angular/core';\ni0.ComponentFactory;\n"]}
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import {
|
|
2
|
+
import { ComponentPortal } from '@angular/cdk/portal';
|
|
3
|
+
import { ChangeDetectorRef, Component, EventEmitter, HostBinding, Inject, InjectionToken, Input, Optional, Output, SkipSelf, ViewChild } from '@angular/core';
|
|
3
4
|
import { Router, RouterOutlet } from '@angular/router';
|
|
4
5
|
import { DebugContext, Dsl, lang, ListModel, MutableValueModel, StoreInListModel, StoreInValueModel, TrackExternal, ValueModel } from '@coolon/pectin';
|
|
5
6
|
import * as _ from 'lodash';
|
|
6
7
|
import { DisposableComponent } from '../../../components/disposable-component';
|
|
7
8
|
import { AUP_PLACE_CONFIG } from '../../place-config';
|
|
8
9
|
import { PlaceRouter } from '../../place-router';
|
|
10
|
+
import { NotAuthorisedNoticeComponent } from '../not-authorised-notice/not-authorised-notice.component';
|
|
9
11
|
import { LEFT_RIGHT_PLACE_ANIMATION } from './route-animations';
|
|
12
|
+
export const AUP_UNAUTHORISED_PLACE_NOTICE_COMPONENT = new InjectionToken('AUP_UNAUTHORISED_PLACE_COMPONENT');
|
|
10
13
|
export class PlaceOutletComponent extends DisposableComponent {
|
|
11
|
-
constructor(router, placeRouter, placeConfig, parentOutlet) {
|
|
14
|
+
constructor(router, placeRouter, placeConfig, unauthorisedPlaceNotice, parentOutlet, cdr) {
|
|
12
15
|
super();
|
|
13
16
|
this.router = router;
|
|
14
17
|
this.placeRouter = placeRouter;
|
|
15
18
|
this.placeConfig = placeConfig;
|
|
19
|
+
this.cdr = cdr;
|
|
16
20
|
this.placeChanged = new EventEmitter();
|
|
17
21
|
this.outletActivated = new MutableValueModel(false);
|
|
18
22
|
this._activatedRouteModel = new MutableValueModel();
|
|
@@ -45,7 +49,7 @@ export class PlaceOutletComponent extends DisposableComponent {
|
|
|
45
49
|
this.animationEnabled = valueOf.all(this.animateModel, this.animationSupported).areTruthy();
|
|
46
50
|
// Extract our visit model from the place router.
|
|
47
51
|
this._activePlaceDefinition = chain(this._activePlaceModel).pluck('placeDefinition');
|
|
48
|
-
this.routerVisitModel =
|
|
52
|
+
this.routerVisitModel = chain(placeRouter.state).map(state => state.getVisitFor(this._activePlaceDefinition.value), { dependsOn: this._activePlaceDefinition });
|
|
49
53
|
this.navigationInProgress = chain(this.placeRouter.navigationInProgress);
|
|
50
54
|
when(this.navigationInProgress).becomesFalsey(() => {
|
|
51
55
|
this.checkStateAndInitialise();
|
|
@@ -56,13 +60,11 @@ export class PlaceOutletComponent extends DisposableComponent {
|
|
|
56
60
|
chain(this._activePlaceModel)
|
|
57
61
|
.postponeWhile(this.navigationInProgress)
|
|
58
62
|
.subscribe(place => this.placeChanged.emit(place));
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
});
|
|
63
|
+
this.authorised = chain(placeRouter.accessGuard).map(guard => guard.isAuthorised(this._activePlaceDefinition.value), {
|
|
64
|
+
dependsOn: this._activePlaceDefinition,
|
|
65
|
+
postponeWhile: chain(this._activePlaceDefinition).isNil()
|
|
66
|
+
}).otherwise(true); // if we don't have a place def yet we need to show the outlet so we get one injected.
|
|
67
|
+
this.notAuthorisedNoticePortal = new ComponentPortal(unauthorisedPlaceNotice !== null && unauthorisedPlaceNotice !== void 0 ? unauthorisedPlaceNotice : NotAuthorisedNoticeComponent);
|
|
66
68
|
}
|
|
67
69
|
// @Trace()
|
|
68
70
|
ngOnInit() {
|
|
@@ -74,6 +76,9 @@ export class PlaceOutletComponent extends DisposableComponent {
|
|
|
74
76
|
get animationDuration() {
|
|
75
77
|
return this.placeConfig && this.placeConfig.animationDuration ? this.placeConfig.animationDuration : '500ms';
|
|
76
78
|
}
|
|
79
|
+
get isAuthorised() {
|
|
80
|
+
return this.authorised.value;
|
|
81
|
+
}
|
|
77
82
|
// @Trace()
|
|
78
83
|
navigate(visit) {
|
|
79
84
|
// const place = this.placesInAnimationOrder.query().findMatching(p => visit.placeDefinition.component === p);
|
|
@@ -128,6 +133,7 @@ export class PlaceOutletComponent extends DisposableComponent {
|
|
|
128
133
|
lang.illegalState('wrong visit!!!');
|
|
129
134
|
}
|
|
130
135
|
this.initialisePlace(routerVisit, activePlace);
|
|
136
|
+
this.cdr.detectChanges();
|
|
131
137
|
}
|
|
132
138
|
}
|
|
133
139
|
initialisePlace(routerVisit, activePlace) {
|
|
@@ -178,16 +184,18 @@ export class PlaceOutletComponent extends DisposableComponent {
|
|
|
178
184
|
PlaceOutletComponent.decorators = [
|
|
179
185
|
{ type: Component, args: [{
|
|
180
186
|
selector: 'aup-place-outlet',
|
|
181
|
-
template: "<ng-container *ngIf=\"animationEnabled.value\">\n <div class=\"router-outlet-container\"
|
|
187
|
+
template: "<ng-container *ngIf=\"animationEnabled.value\">\n <div class=\"router-outlet-container\"\n cdkScrollable\n [@routeAnimations]=\"{value: getAnimationOrder(), params:{duration: animationDuration}}\"\n (@routeAnimations.start)=\"animationStarted()\"\n (@routeAnimations.done)=\"animationDone()\"\n >\n <router-outlet #routerOutlet=\"outlet\"\n (activate)=\"onOutletActivated(routerOutlet, $event)\"\n (deactivate)=\"onOutletDeactivated()\">\n </router-outlet>\n </div>\n</ng-container>\n\n<ng-container *ngIf=\"!animationEnabled.value\">\n <div class=\"router-outlet-container\"\n cdkScrollable>\n <router-outlet #routerOutlet=\"outlet\"\n (activate)=\"onOutletActivated(routerOutlet, $event)\"\n (deactivate)=\"onOutletDeactivated()\">\n </router-outlet>\n </div>\n</ng-container>\n\n<div class=\"not-authorised-component-container\" *ngIf=\"!authorised.value\">\n <ng-template [cdkPortalOutlet]=\"notAuthorisedNoticePortal\"></ng-template>\n</div>\n",
|
|
182
188
|
animations: [LEFT_RIGHT_PLACE_ANIMATION],
|
|
183
|
-
styles: [":host{display:flex;flex-direction:column;min-height:0}.router-outlet-container{flex:1;display:block;position:relative;min-height:0;overflow-x:hidden;overflow-y:scroll}router-outlet{display:none}"]
|
|
189
|
+
styles: [":host{display:flex;flex-direction:column;min-height:0}:host:not(.authorised) .router-outlet-container{display:none}.router-outlet-container{flex:1;display:block;position:relative;min-height:0;overflow-x:hidden;overflow-y:scroll}router-outlet{display:none}.not-authorised-component-container{flex:1;display:grid;grid-template-columns:1fr;grid-template-rows:1fr}"]
|
|
184
190
|
},] }
|
|
185
191
|
];
|
|
186
192
|
PlaceOutletComponent.ctorParameters = () => [
|
|
187
193
|
{ type: Router },
|
|
188
194
|
{ type: PlaceRouter },
|
|
189
195
|
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [AUP_PLACE_CONFIG,] }] },
|
|
190
|
-
{ type:
|
|
196
|
+
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [AUP_UNAUTHORISED_PLACE_NOTICE_COMPONENT,] }] },
|
|
197
|
+
{ type: PlaceOutletComponent, decorators: [{ type: SkipSelf }, { type: Optional }] },
|
|
198
|
+
{ type: ChangeDetectorRef }
|
|
191
199
|
];
|
|
192
200
|
PlaceOutletComponent.propDecorators = {
|
|
193
201
|
animate: [{ type: Input }],
|
|
@@ -195,7 +203,8 @@ PlaceOutletComponent.propDecorators = {
|
|
|
195
203
|
customPlaceAnimationOrderModel: [{ type: Input, args: ['placeAnimationOrderModel',] }],
|
|
196
204
|
customPlaceAnimationOrder: [{ type: Input, args: ['placeAnimationOrder',] }],
|
|
197
205
|
placeChanged: [{ type: Output }],
|
|
198
|
-
routerOut: [{ type: ViewChild, args: ['routeOutlet', { static: true },] }]
|
|
206
|
+
routerOut: [{ type: ViewChild, args: ['routeOutlet', { static: true },] }],
|
|
207
|
+
isAuthorised: [{ type: HostBinding, args: ["class.authorised",] }]
|
|
199
208
|
};
|
|
200
209
|
__decorate([
|
|
201
210
|
StoreInValueModel('animateModel'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"place-outlet.component.js","sourceRoot":"","sources":["../../../../../../../../libs/angular-ui-powerups/src/lib/place/components/place-outlet/place-outlet.component.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAU,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACtH,OAAO,EAAkB,MAAM,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAGL,YAAY,EACZ,GAAG,EACH,IAAI,EACJ,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,UAAU,EAEX,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAE/E,OAAO,EAAE,gBAAgB,EAAe,MAAM,oBAAoB,CAAC;AAEnE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGjD,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAiBhE,MAAM,OAAO,oBAAqB,SAAQ,mBAAmB;IA2C3D,YAA6B,MAAc,EACd,WAAwB,EACM,WAAwB,EAC/C,YAAkC;QACpE,KAAK,EAAE,CAAC;QAJmB,WAAM,GAAN,MAAM,CAAQ;QACd,gBAAW,GAAX,WAAW,CAAa;QACM,gBAAW,GAAX,WAAW,CAAa;QA5B1E,iBAAY,GAAG,IAAI,YAAY,EAAkB,CAAC;QAQnD,oBAAe,GAAG,IAAI,iBAAiB,CAAC,KAAK,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CAAC,cAAc,CAAC;;qDAC1B;AAGjB;IADU,aAAa,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;8BACjC,UAAU;0DAAU;AAIlC;IADoC,aAAa,EAAE;8BACnB,SAAS;4EAAgC;AAIzE;IAD+B,gBAAgB,CAAC,gCAAgC,CAAC;;uEACtB","sourcesContent":["import { Component, EventEmitter, Inject, Input, OnInit, Optional, Output, SkipSelf, ViewChild } from '@angular/core';\nimport { ActivatedRoute, Router, RouterOutlet } from '@angular/router';\nimport {\n BooleanValueModelChain,\n Constructable,\n DebugContext,\n Dsl,\n lang,\n ListModel, ListModelChain,\n MutableValueModel,\n StoreInListModel,\n StoreInValueModel, Trace,\n TrackExternal,\n ValueModel,\n ValueModelChain\n} from '@coolon/pectin';\nimport * as _ from 'lodash';\nimport { DisposableComponent } from '../../../components/disposable-component';\nimport { PlaceComponent } from '../../place-component';\nimport { AUP_PLACE_CONFIG, PlaceConfig } from '../../place-config';\nimport { PlaceDefinition } from '../../place-definition';\nimport { PlaceRouter } from '../../place-router';\n\nimport { Visit } from '../../visit';\nimport { LEFT_RIGHT_PLACE_ANIMATION } from './route-animations';\n\n// Quick hack to avoid circular references between this and PlaceComponents.\ninterface PlaceRef {\n readonly placeDefinition: PlaceDefinition\n\n initialiseBindings(param: ValueModel<Visit>): void;\n\n onPlaceReady(): void;\n}\n\n@Component({\n selector: 'aup-place-outlet',\n templateUrl: './place-outlet.component.html',\n styleUrls: ['./place-outlet.component.scss'],\n animations: [LEFT_RIGHT_PLACE_ANIMATION]\n})\nexport class PlaceOutletComponent extends DisposableComponent implements OnInit {\n\n @Input() @StoreInValueModel('animateModel')\n animate: boolean;\n\n @Input() @TrackExternal({ defaultValue: true })\n animateModel: ValueModel<boolean>;\n\n // tslint:disable-next-line:no-input-rename\n @Input('placeAnimationOrderModel') @TrackExternal()\n customPlaceAnimationOrderModel: ListModel<Constructable<PlaceComponent>>;\n\n // tslint:disable-next-line:no-input-rename\n @Input('placeAnimationOrder') @StoreInListModel('customPlaceAnimationOrderModel')\n customPlaceAnimationOrder: Constructable<PlaceComponent>[];\n\n @Output()\n readonly placeChanged = new EventEmitter<PlaceComponent>();\n\n @ViewChild('routeOutlet', { static: true })\n routerOut: RouterOutlet;\n\n private onAnimationFinishedJob: () => void;\n\n\n private outletActivated = new MutableValueModel(false);\n private readonly _activatedRouteModel = new MutableValueModel<ActivatedRoute>();\n private readonly _activePlaceModel = new MutableValueModel<PlaceComponent>();\n private readonly _activePlaceDefinition: ValueModelChain<PlaceDefinition>;\n\n private parentOutletModel: MutableValueModel<PlaceOutletComponent>;\n public readonly activePlaceAnimationPosition: ValueModelChain<number>;\n\n private initialPlaceIndex: number = null;\n private routerVisitModel: ValueModelChain<Visit>;\n private _isPushingVisitToRoute = new MutableValueModel<boolean>(false);\n private navigationInProgress: ValueModelChain<boolean>;\n\n private isVeryFirstLoad = true;\n private placesInAnimationOrder: ListModelChain<Constructable<PlaceComponent>>;\n private animationSupported: BooleanValueModelChain;\n readonly animationEnabled: BooleanValueModelChain;\n\n constructor(private readonly router: Router,\n private readonly placeRouter: PlaceRouter,\n @Optional() @Inject(AUP_PLACE_CONFIG) readonly placeConfig: PlaceConfig,\n @SkipSelf() @Optional() parentOutlet: PlaceOutletComponent) {\n super();\n const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);\n\n this.parentOutletModel = new MutableValueModel(parentOutlet);\n\n const defaultPlaceAnimationOrder = chain(this.parentOutletModel)\n .pullValueModel(o => o.activePlaceModel)\n .pluck('placeDefinition')\n .pluckList('children')\n .pluck('component');\n\n const activatePlaceType = chain(this.activePlaceModel).map(p => p.constructor as Constructable<PlaceComponent>);\n\n this.placesInAnimationOrder = chain(this.customPlaceAnimationOrderModel)\n .otherwise(defaultPlaceAnimationOrder);\n\n this.activePlaceAnimationPosition = this.placesInAnimationOrder\n .reduce((placesInOrder) => {\n let placeIndex = 0;\n if (activatePlaceType.value) {\n placeIndex = placesInOrder.indexOf(activatePlaceType.value);\n if (_.isNil(this.initialPlaceIndex)) {\n this.initialPlaceIndex = placeIndex;\n }\n }\n return _.isNil(this.initialPlaceIndex) ? 0 : placeIndex - this.initialPlaceIndex;\n }, { dependsOn: activatePlaceType });\n\n this.animationSupported = this.placesInAnimationOrder.count().isGreaterThan(0);\n this.animationEnabled = valueOf.all(\n this.animateModel,\n this.animationSupported\n ).areTruthy();\n\n // Extract our visit model from the place router.\n this._activePlaceDefinition = chain(this._activePlaceModel).pluck('placeDefinition');\n this.routerVisitModel = this._activePlaceDefinition.findIn(chain(placeRouter.activeVisitsByPlaceDefinition));\n\n this.navigationInProgress = chain(this.placeRouter.navigationInProgress);\n\n when(this.navigationInProgress).becomesFalsey(() => {\n this.checkStateAndInitialise();\n });\n when(this.outletActivated).becomesTruthy(() => {\n this.checkStateAndInitialise();\n });\n\n chain(this._activePlaceModel)\n .postponeWhile(this.navigationInProgress)\n .subscribe(place => this.placeChanged.emit(place));\n\n when(placeRouter.accessGuard).changes(guard => {\n const activePlace = this._activePlaceModel.value;\n if (activePlace && !guard.isAuthorised(activePlace.placeDefinition)) {\n const visit = placeRouter.getAuthorisationFailureRedirect(this._activatedRouteModel.value.snapshot, this.router.routerState.snapshot);\n this.placeRouter.navigate(visit)\n }\n });\n\n }\n\n // @Trace()\n ngOnInit() {\n }\n\n // @Trace()\n getAnimationOrder() {\n return this.activePlaceAnimationPosition.value;\n }\n\n get animationDuration() {\n return this.placeConfig && this.placeConfig.animationDuration ? this.placeConfig.animationDuration : '500ms';\n }\n\n // @Trace()\n navigate(visit: Visit) {\n // const place = this.placesInAnimationOrder.query().findMatching(p => visit.placeDefinition.component === p);\n // if (!place) {\n // lang.illegalState()\n // }\n this.placeRouter.navigate(visit, {\n relativeTo: this.parentOutlet ? this.parentOutlet.activatedRouteModel.value : null\n });\n }\n\n get parentOutlet(): PlaceOutletComponent {\n return this.parentOutletModel.value;\n }\n\n\n get activePlaceModel(): ValueModel<PlaceComponent> {\n return this._activePlaceModel.readonly;\n }\n\n get activatedRouteModel(): ValueModel<ActivatedRoute> {\n return this._activatedRouteModel.readonly;\n }\n\n // @Trace()\n onOutletActivated(routerOutlet: RouterOutlet, place: PlaceComponent) {\n this._activatedRouteModel.value = routerOutlet.activatedRoute;\n this._activePlaceModel.value = place;\n this.validateAnimationState(place);\n this.outletActivated.value = true;\n this.checkStateAndInitialise();\n }\n\n private validateAnimationState(place: PlaceComponent) {\n if (this.animateModel.value) {\n if (this.placesInAnimationOrder.length < 1) {\n console.error('PlaceOutlet.animate === true but placeAnimationOrder has not been set. Animation is disabled.');\n } else {\n if (!this.placesInAnimationOrder.query().includes(place.placeDefinition.component)) {\n console.error(`PlaceOutlet.animate === true but placeAnimationOrder doesn't contain ${place.placeDefinition.component.name}.`);\n }\n }\n }\n }\n\n // @Trace()\n onOutletDeactivated() {\n this.outletActivated.value = false;\n this._activePlaceModel.value = null;\n this._activatedRouteModel.value = null;\n }\n\n // @Trace()\n private checkStateAndInitialise() {\n const routerVisit = this.routerVisitModel.value;\n const activePlace = this.activePlaceModel.value;\n if (routerVisit && activePlace && !activePlace.isInitialised()) {\n if (routerVisit.placeDefinition !== activePlace.placeDefinition) {\n lang.illegalState('wrong visit!!!');\n }\n this.initialisePlace(routerVisit, activePlace);\n }\n }\n\n private initialisePlace(routerVisit: Visit, activePlace: PlaceComponent) {\n const visitModel = new MutableValueModel<Visit>(routerVisit);\n DebugContext.tag(visitModel, `PlaceOutletComponent[${activePlace.constructor.name})].visitModel`);\n activePlace.initialiseVisit(routerVisit, (current, previous) => {\n this.pushVisitChangeToRoute(previous, current);\n });\n const finishPlaceLoad = () => {\n this._activePlaceModel.value._notifyActive(true);\n }\n if (!this.animationEnabled.value || this.isVeryFirstLoad) {\n // if animation is disabled or this is the very first load then\n // we won't get our animation done callback so we finish the\n // process here and now.\n this.isVeryFirstLoad = false;\n finishPlaceLoad()\n } else {\n this.onAnimationFinishedJob = finishPlaceLoad;\n }\n const { when, chain, valueOf } = Dsl.disposeWith(activePlace);\n when(this.routerVisitModel)\n .changes(visit => {\n activePlace.updateVisit(visit);\n }, {\n unless: valueOf.any(\n this._isPushingVisitToRoute,\n this.routerVisitModel.isNil()\n ).areTruthy()\n });\n }\n\n private pushVisitChangeToRoute(previous: Visit, current: Visit) {\n this._isPushingVisitToRoute.value = true;\n this.placeRouter.pushVisitChangesToRoute(previous, current).finally(() => {\n this._isPushingVisitToRoute.value = false;\n });\n }\n\n// @Trace()\n animationStarted() {\n // console.log({ activePlace: this._activePlaceModel.value });\n }\n\n // @Trace()\n animationDone() {\n if (this.onAnimationFinishedJob) {\n this.onAnimationFinishedJob();\n this.onAnimationFinishedJob = undefined;\n }\n }\n\n}\n"]}
|
|
1
|
+
{"version":3,"file":"place-outlet.component.js","sourceRoot":"","sources":["../../../../../../../../libs/angular-ui-powerups/src/lib/place/components/place-outlet/place-outlet.component.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EACL,iBAAiB,EACjB,SAAS,EACT,YAAY,EAAE,WAAW,EACzB,MAAM,EACN,cAAc,EACd,KAAK,EAEL,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,SAAS,EACV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAkB,MAAM,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAGL,YAAY,EACZ,GAAG,EACH,IAAI,EACJ,SAAS,EAET,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,UAAU,EAEX,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAG/E,OAAO,EAAE,gBAAgB,EAAe,MAAM,oBAAoB,CAAC;AAEnE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGjD,OAAO,EAAE,4BAA4B,EAAE,MAAM,0DAA0D,C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AO,CAAC,GAAG,EAAE;YACvE,IAAI,CAAC,sBAAsB,CAAC,KAAK,GAAG,KAAK,CAAC;QAC5C,CAAC,CAAC,CAAC;IACL,CAAC;IAEH,WAAW;IACT,gBAAgB;QACd,8DAA8D;IAChE,CAAC;IAED,WAAW;IACX,aAAa;QACX,IAAI,IAAI,CAAC,sBAAsB,EAAE;YAC/B,IAAI,CAAC,sBAAsB,EAAE,CAAC;YAC9B,IAAI,CAAC,sBAAsB,GAAG,SAAS,CAAC;SACzC;IACH,CAAC;;;YAxPF,SAAS,SAAC;gBACT,QAAQ,EAAE,kBAAkB;gBAC5B,yjCAA4C;gBAE5C,UAAU,EAAE,CAAC,0BAA0B,CAAC;;aACzC;;;YA9CwB,MAAM;YAsBtB,WAAW;4CAyEL,QAAQ,YAAI,MAAM,SAAC,gBAAgB;4CACnC,QAAQ,YAAI,MAAM,SAAC,uCAAuC;YACrB,oBAAoB,uBAAzD,QAAQ,YAAI,QAAQ;YA7GjC,iBAAiB;;;sBA6DhB,KAAK;2BAGL,KAAK;6CAIL,KAAK,SAAC,0BAA0B;wCAIhC,KAAK,SAAC,qBAAqB;2BAG3B,MAAM;wBAGN,SAAS,SAAC,aAAa,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;2BAyGzC,WAAW,SAAC,kBAAkB;;AAzH/B;IADU,iBAAiB,CAAC,cAAc,CAAC;;qDAC1B;AAGjB;IADU,aAAa,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;8BACjC,UAAU;0DAAU;AAIlC;IADoC,aAAa,EAAE;8BACnB,SAAS;4EAAgC;AAIzE;IAD+B,gBAAgB,CAAC,gCAAgC,CAAC;;uEACtB","sourcesContent":["import { ComponentPortal } from '@angular/cdk/portal';\nimport {\n ChangeDetectorRef,\n Component,\n EventEmitter, HostBinding,\n Inject,\n InjectionToken,\n Input,\n OnInit,\n Optional,\n Output,\n SkipSelf,\n ViewChild\n} from '@angular/core';\nimport { ActivatedRoute, Router, RouterOutlet } from '@angular/router';\nimport {\n BooleanValueModelChain,\n Constructable,\n DebugContext,\n Dsl,\n lang,\n ListModel,\n ListModelChain,\n MutableValueModel,\n StoreInListModel,\n StoreInValueModel,\n TrackExternal,\n ValueModel,\n ValueModelChain\n} from '@coolon/pectin';\nimport * as _ from 'lodash';\nimport { DisposableComponent } from '../../../components/disposable-component';\nimport { PlaceComponent } from '../../place-component';\n\nimport { AUP_PLACE_CONFIG, PlaceConfig } from '../../place-config';\nimport { PlaceDefinition } from '../../place-definition';\nimport { PlaceRouter } from '../../place-router';\nimport { Visit } from '../../visit';\n\nimport { NotAuthorisedNoticeComponent } from '../not-authorised-notice/not-authorised-notice.component';\nimport { LEFT_RIGHT_PLACE_ANIMATION } from './route-animations';\n\n\nexport const AUP_UNAUTHORISED_PLACE_NOTICE_COMPONENT = new InjectionToken<Constructable<any>>('AUP_UNAUTHORISED_PLACE_COMPONENT');\n\n\n// Quick hack to avoid circular references between this and PlaceComponents.\ninterface PlaceRef {\n readonly placeDefinition: PlaceDefinition\n\n initialiseBindings(param: ValueModel<Visit>): void;\n\n onPlaceReady(): void;\n}\n\n@Component({\n selector: 'aup-place-outlet',\n templateUrl: './place-outlet.component.html',\n styleUrls: ['./place-outlet.component.scss'],\n animations: [LEFT_RIGHT_PLACE_ANIMATION]\n})\nexport class PlaceOutletComponent extends DisposableComponent implements OnInit {\n\n @Input() @StoreInValueModel('animateModel')\n animate: boolean;\n\n @Input() @TrackExternal({ defaultValue: true })\n animateModel: ValueModel<boolean>;\n\n // tslint:disable-next-line:no-input-rename\n @Input('placeAnimationOrderModel') @TrackExternal()\n customPlaceAnimationOrderModel: ListModel<Constructable<PlaceComponent>>;\n\n // tslint:disable-next-line:no-input-rename\n @Input('placeAnimationOrder') @StoreInListModel('customPlaceAnimationOrderModel')\n customPlaceAnimationOrder: Constructable<PlaceComponent>[];\n\n @Output()\n readonly placeChanged = new EventEmitter<PlaceComponent>();\n\n @ViewChild('routeOutlet', { static: true })\n routerOut: RouterOutlet;\n\n private onAnimationFinishedJob: () => void;\n\n\n private outletActivated = new MutableValueModel(false);\n private readonly _activatedRouteModel = new MutableValueModel<ActivatedRoute>();\n private readonly _activePlaceModel = new MutableValueModel<PlaceComponent>();\n\n readonly _activePlaceDefinition: ValueModelChain<PlaceDefinition>;\n\n private parentOutletModel: MutableValueModel<PlaceOutletComponent>;\n public readonly activePlaceAnimationPosition: ValueModelChain<number>;\n\n private initialPlaceIndex: number = null;\n private routerVisitModel: ValueModelChain<Visit>;\n private _isPushingVisitToRoute = new MutableValueModel<boolean>(false);\n private navigationInProgress: ValueModelChain<boolean>;\n\n private isVeryFirstLoad = true;\n private placesInAnimationOrder: ListModelChain<Constructable<PlaceComponent>>;\n private animationSupported: BooleanValueModelChain;\n readonly animationEnabled: BooleanValueModelChain;\n readonly authorised: ValueModelChain<boolean>;\n readonly notAuthorisedNoticePortal: ComponentPortal<any>;\n\n constructor(private readonly router: Router,\n private readonly placeRouter: PlaceRouter,\n @Optional() @Inject(AUP_PLACE_CONFIG) readonly placeConfig: PlaceConfig,\n @Optional() @Inject(AUP_UNAUTHORISED_PLACE_NOTICE_COMPONENT) unauthorisedPlaceNotice: Constructable<any>,\n @SkipSelf() @Optional() parentOutlet: PlaceOutletComponent,\n private readonly cdr: ChangeDetectorRef) {\n super();\n const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);\n\n this.parentOutletModel = new MutableValueModel(parentOutlet);\n\n const defaultPlaceAnimationOrder = chain(this.parentOutletModel)\n .pullValueModel(o => o.activePlaceModel)\n .pluck('placeDefinition')\n .pluckList('children')\n .pluck('component');\n\n const activatePlaceType = chain(this.activePlaceModel).map(p => p.constructor as Constructable<PlaceComponent>);\n\n this.placesInAnimationOrder = chain(this.customPlaceAnimationOrderModel)\n .otherwise(defaultPlaceAnimationOrder);\n\n this.activePlaceAnimationPosition = this.placesInAnimationOrder\n .reduce((placesInOrder) => {\n let placeIndex = 0;\n if (activatePlaceType.value) {\n placeIndex = placesInOrder.indexOf(activatePlaceType.value);\n if (_.isNil(this.initialPlaceIndex)) {\n this.initialPlaceIndex = placeIndex;\n }\n }\n return _.isNil(this.initialPlaceIndex) ? 0 : placeIndex - this.initialPlaceIndex;\n }, { dependsOn: activatePlaceType });\n\n this.animationSupported = this.placesInAnimationOrder.count().isGreaterThan(0);\n this.animationEnabled = valueOf.all(\n this.animateModel,\n this.animationSupported\n ).areTruthy();\n\n // Extract our visit model from the place router.\n this._activePlaceDefinition = chain(this._activePlaceModel).pluck('placeDefinition');\n this.routerVisitModel = chain(placeRouter.state).map(state => state.getVisitFor(this._activePlaceDefinition.value), { dependsOn: this._activePlaceDefinition });\n\n this.navigationInProgress = chain(this.placeRouter.navigationInProgress);\n\n when(this.navigationInProgress).becomesFalsey(() => {\n this.checkStateAndInitialise();\n });\n when(this.outletActivated).becomesTruthy(() => {\n this.checkStateAndInitialise();\n });\n\n chain(this._activePlaceModel)\n .postponeWhile(this.navigationInProgress)\n .subscribe(place => this.placeChanged.emit(place));\n\n this.authorised = chain(placeRouter.accessGuard).map(guard => guard.isAuthorised(this._activePlaceDefinition.value), {\n dependsOn: this._activePlaceDefinition,\n postponeWhile: chain(this._activePlaceDefinition).isNil()\n }).otherwise(true); // if we don't have a place def yet we need to show the outlet so we get one injected.\n\n this.notAuthorisedNoticePortal = new ComponentPortal(unauthorisedPlaceNotice ?? NotAuthorisedNoticeComponent);\n }\n\n // @Trace()\n ngOnInit() {\n }\n\n // @Trace()\n getAnimationOrder() {\n return this.activePlaceAnimationPosition.value;\n }\n\n get animationDuration() {\n return this.placeConfig && this.placeConfig.animationDuration ? this.placeConfig.animationDuration : '500ms';\n }\n\n @HostBinding(\"class.authorised\")\n get isAuthorised() {\n return this.authorised.value;\n }\n\n // @Trace()\n navigate(visit: Visit) {\n // const place = this.placesInAnimationOrder.query().findMatching(p => visit.placeDefinition.component === p);\n // if (!place) {\n // lang.illegalState()\n // }\n this.placeRouter.navigate(visit, {\n relativeTo: this.parentOutlet ? this.parentOutlet.activatedRouteModel.value : null\n });\n }\n\n get parentOutlet(): PlaceOutletComponent {\n return this.parentOutletModel.value;\n }\n\n\n get activePlaceModel(): ValueModel<PlaceComponent> {\n return this._activePlaceModel.readonly;\n }\n\n get activatedRouteModel(): ValueModel<ActivatedRoute> {\n return this._activatedRouteModel.readonly;\n }\n\n // @Trace()\n onOutletActivated(routerOutlet: RouterOutlet, place: PlaceComponent) {\n this._activatedRouteModel.value = routerOutlet.activatedRoute;\n this._activePlaceModel.value = place;\n this.validateAnimationState(place);\n this.outletActivated.value = true;\n this.checkStateAndInitialise();\n }\n\n private validateAnimationState(place: PlaceComponent) {\n if (this.animateModel.value) {\n if (this.placesInAnimationOrder.length < 1) {\n console.error('PlaceOutlet.animate === true but placeAnimationOrder has not been set. Animation is disabled.');\n } else {\n if (!this.placesInAnimationOrder.query().includes(place.placeDefinition.component)) {\n console.error(`PlaceOutlet.animate === true but placeAnimationOrder doesn't contain ${place.placeDefinition.component.name}.`);\n }\n }\n }\n }\n\n // @Trace()\n onOutletDeactivated() {\n this.outletActivated.value = false;\n this._activePlaceModel.value = null;\n this._activatedRouteModel.value = null;\n }\n\n // @Trace()\n private checkStateAndInitialise() {\n const routerVisit = this.routerVisitModel.value;\n const activePlace = this.activePlaceModel.value;\n if (routerVisit && activePlace && !activePlace.isInitialised()) {\n if (routerVisit.placeDefinition !== activePlace.placeDefinition) {\n lang.illegalState('wrong visit!!!');\n }\n this.initialisePlace(routerVisit, activePlace);\n this.cdr.detectChanges()\n }\n }\n\n private initialisePlace(routerVisit: Visit, activePlace: PlaceComponent) {\n const visitModel = new MutableValueModel<Visit>(routerVisit);\n DebugContext.tag(visitModel, `PlaceOutletComponent[${activePlace.constructor.name})].visitModel`);\n activePlace.initialiseVisit(routerVisit, (current, previous) => {\n this.pushVisitChangeToRoute(previous, current);\n });\n const finishPlaceLoad = () => {\n this._activePlaceModel.value._notifyActive(true);\n };\n if (!this.animationEnabled.value || this.isVeryFirstLoad) {\n // if animation is disabled or this is the very first load then\n // we won't get our animation done callback so we finish the\n // process here and now.\n this.isVeryFirstLoad = false;\n finishPlaceLoad();\n } else {\n this.onAnimationFinishedJob = finishPlaceLoad;\n }\n const { when, chain, valueOf } = Dsl.disposeWith(activePlace);\n when(this.routerVisitModel)\n .changes(visit => {\n activePlace.updateVisit(visit);\n }, {\n unless: valueOf.any(\n this._isPushingVisitToRoute,\n this.routerVisitModel.isNil()\n ).areTruthy()\n });\n }\n\n private pushVisitChangeToRoute(previous: Visit, current: Visit) {\n this._isPushingVisitToRoute.value = true;\n this.placeRouter.pushVisitChangesToRoute(previous, current).finally(() => {\n this._isPushingVisitToRoute.value = false;\n });\n }\n\n// @Trace()\n animationStarted() {\n // console.log({ activePlace: this._activePlaceModel.value });\n }\n\n // @Trace()\n animationDone() {\n if (this.onAnimationFinishedJob) {\n this.onAnimationFinishedJob();\n this.onAnimationFinishedJob = undefined;\n }\n }\n\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"PlaceOutletComponent":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"../../../components/disposable-component","name":"DisposableComponent","line":
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"AUP_UNAUTHORISED_PLACE_NOTICE_COMPONENT":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":43,"character":59},"arguments":["AUP_UNAUTHORISED_PLACE_COMPONENT"]},"PlaceOutletComponent":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"../../../components/disposable-component","name":"DisposableComponent","line":61,"character":42},"decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component","line":55,"character":1},"arguments":[{"selector":"aup-place-outlet","animations":[{"__symbolic":"reference","module":"./route-animations","name":"LEFT_RIGHT_PLACE_ANIMATION","line":59,"character":15}],"template":"<ng-container *ngIf=\"animationEnabled.value\">\n <div class=\"router-outlet-container\"\n cdkScrollable\n [@routeAnimations]=\"{value: getAnimationOrder(), params:{duration: animationDuration}}\"\n (@routeAnimations.start)=\"animationStarted()\"\n (@routeAnimations.done)=\"animationDone()\"\n >\n <router-outlet #routerOutlet=\"outlet\"\n (activate)=\"onOutletActivated(routerOutlet, $event)\"\n (deactivate)=\"onOutletDeactivated()\">\n </router-outlet>\n </div>\n</ng-container>\n\n<ng-container *ngIf=\"!animationEnabled.value\">\n <div class=\"router-outlet-container\"\n cdkScrollable>\n <router-outlet #routerOutlet=\"outlet\"\n (activate)=\"onOutletActivated(routerOutlet, $event)\"\n (deactivate)=\"onOutletDeactivated()\">\n </router-outlet>\n </div>\n</ng-container>\n\n<div class=\"not-authorised-component-container\" *ngIf=\"!authorised.value\">\n <ng-template [cdkPortalOutlet]=\"notAuthorisedNoticePortal\"></ng-template>\n</div>\n","styles":[":host{display:flex;flex-direction:column;min-height:0}:host:not(.authorised) .router-outlet-container{display:none}.router-outlet-container{flex:1;display:block;position:relative;min-height:0;overflow-x:hidden;overflow-y:scroll}router-outlet{display:none}.not-authorised-component-container{flex:1;display:grid;grid-template-columns:1fr;grid-template-rows:1fr}"]}]}],"members":{"animate":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":63,"character":3}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@coolon/pectin","name":"StoreInValueModel","line":63,"character":12},"arguments":["animateModel"]}]}],"animateModel":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":66,"character":3}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@coolon/pectin","name":"TrackExternal","line":66,"character":12},"arguments":[{"defaultValue":true}]}]}],"customPlaceAnimationOrderModel":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":70,"character":3},"arguments":["placeAnimationOrderModel"]},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@coolon/pectin","name":"TrackExternal","line":70,"character":38}}]}],"customPlaceAnimationOrder":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":74,"character":3},"arguments":["placeAnimationOrder"]},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@coolon/pectin","name":"StoreInListModel","line":74,"character":33},"arguments":["customPlaceAnimationOrderModel"]}]}],"placeChanged":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output","line":77,"character":3}}]}],"routerOut":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"ViewChild","line":80,"character":3},"arguments":["routeOutlet",{"static":true}]}]}],"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[null,null,[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional","line":109,"character":15}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":109,"character":27},"arguments":[{"__symbolic":"reference","module":"../../place-config","name":"AUP_PLACE_CONFIG","line":109,"character":34}]}],[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional","line":110,"character":15}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":110,"character":27},"arguments":[{"__symbolic":"reference","name":"AUP_UNAUTHORISED_PLACE_NOTICE_COMPONENT"}]}],[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"SkipSelf","line":111,"character":15}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional","line":111,"character":27}}],null],"parameters":[{"__symbolic":"reference","module":"@angular/router","name":"Router","line":107,"character":39},{"__symbolic":"reference","module":"../../place-router","name":"PlaceRouter","line":108,"character":44},{"__symbolic":"reference","module":"../../place-config","name":"PlaceConfig","line":109,"character":74},{"__symbolic":"reference","module":"@coolon/pectin","name":"Constructable","line":110,"character":100,"arguments":[{"__symbolic":"reference","name":"any"}]},{"__symbolic":"reference","name":"PlaceOutletComponent"},{"__symbolic":"reference","module":"@angular/core","name":"ChangeDetectorRef","line":112,"character":36}]}],"ngOnInit":[{"__symbolic":"method"}],"getAnimationOrder":[{"__symbolic":"method"}],"isAuthorised":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"HostBinding","line":185,"character":3},"arguments":["class.authorised"]}]}],"navigate":[{"__symbolic":"method"}],"onOutletActivated":[{"__symbolic":"method"}],"validateAnimationState":[{"__symbolic":"method"}],"onOutletDeactivated":[{"__symbolic":"method"}],"checkStateAndInitialise":[{"__symbolic":"method"}],"initialisePlace":[{"__symbolic":"method"}],"pushVisitChangeToRoute":[{"__symbolic":"method"}],"animationStarted":[{"__symbolic":"method"}],"animationDone":[{"__symbolic":"method"}]}}}}]
|
|
@@ -15,6 +15,7 @@ export * from "./url-snapshot";
|
|
|
15
15
|
export * from "./visit";
|
|
16
16
|
export * from "./components/abstract-place-navigation.component";
|
|
17
17
|
export * from "./components/list-place-nav/list-place-nav.component";
|
|
18
|
+
export * from "./components/not-authorised-notice/not-authorised-notice.component";
|
|
18
19
|
export * from "./components/place-outlet/place-outlet.component";
|
|
19
20
|
export * from "./components/place-outlet/route-animations";
|
|
20
21
|
export * from "./components/side-place-navigation/side-place-navigation.component";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.js","sourceRoot":"","sources":["../../../../../../libs/angular-ui-powerups/src/lib/place/exports.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,kDAAkD,CAAC;AACjE,cAAc,sDAAsD,CAAC;AACrE,cAAc,kDAAkD,CAAC;AACjE,cAAc,4CAA4C,CAAC;AAC3D,cAAc,oEAAoE,CAAC;AACnF,cAAc,wEAAwE,CAAC;AACvF,cAAc,iCAAiC,CAAC;AAChD,cAAc,kCAAkC,CAAC;AACjD,cAAc,sBAAsB,CAAC;AACrC,cAAc,mDAAmD,CAAC;AAClE,cAAc,oDAAoD,CAAC;AACnE,cAAc,iCAAiC,CAAC;AAChD,cAAc,yCAAyC,CAAC;AACxD,cAAc,yCAAyC,CAAC;AACxD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,2DAA2D,CAAC;AAC1E,cAAc,wFAAwF,CAAC;AACvG,cAAc,iHAAiH,CAAC;AAChI,cAAc,kGAAkG,CAAC;AACjH,cAAc,iEAAiE,CAAC;AAChF,cAAc,2EAA2E,CAAC;AAC1F,cAAc,uFAAuF,CAAC;AACtG,cAAc,kFAAkF,CAAC;AACjG,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oCAAoC,CAAC;AACnD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./nav-item\";\nexport * from \"./place-access-guard\";\nexport * from \"./place-component\";\nexport * from \"./place-config\";\nexport * from \"./place-definition\";\nexport * from \"./place-history\";\nexport * from \"./place-router\";\nexport * from \"./place.decorator\";\nexport * from \"./place.module\";\nexport * from \"./url-service\";\nexport * from \"./url-snapshot\";\nexport * from \"./visit\";\nexport * from \"./components/abstract-place-navigation.component\";\nexport * from \"./components/list-place-nav/list-place-nav.component\";\nexport * from \"./components/place-outlet/place-outlet.component\";\nexport * from \"./components/place-outlet/route-animations\";\nexport * from \"./components/side-place-navigation/side-place-navigation.component\";\nexport * from \"./components/tabbed-place-navigation/tabbed-place-navigation.component\";\nexport * from \"./guards/consolidated-param-map\";\nexport * from \"./guards/noop-auth-guard.service\";\nexport * from \"./guards/place.guard\";\nexport * from \"./navigation/place-component-deactivation-handler\";\nexport * from \"./navigation/session/abstract-pop-state-navigation\";\nexport * from \"./navigation/session/navigating\";\nexport * from \"./navigation/session/navigation-context\";\nexport * from \"./navigation/session/navigation-session\";\nexport * from \"./navigation/session/pop-state-navigation\";\nexport * from \"./navigation/session/event-cleanup/event-clean-up-session\";\nexport * from \"./navigation/session/event-cleanup/wait-until-leaving-interaction-transition-cancelled\";\nexport * from \"./navigation/session/event-cleanup/wait-until-link-triggered-navigation-interaction-cancelation-type-determined\";\nexport * from \"./navigation/session/event-cleanup/wait-until-popstate-during-can-deactivate-transition-finishes\";\nexport * from \"./navigation/session/interactions/navigating-during-interaction\";\nexport * from \"./navigation/session/interactions/pop-state-during-interaction-navigation\";\nexport * from \"./navigation/session/interactions/remove-last-interaction-from-url-navigation-session\";\nexport * from \"./navigation/session/interactions/synchronise-interaction-context-ids-with-route\";\nexport * from \"./route/formatter\";\nexport * from \"./route/json-types\";\nexport * from \"./route/parameter-decorators\";\nexport * from \"./route/parameter-definition.class\";\nexport * from \"./route/parameter-sanitiser\";\nexport * from \"./route/parameter-snapshot\";\nexport * from \"./route/visit-sanitiser\";\n"]}
|
|
1
|
+
{"version":3,"file":"exports.js","sourceRoot":"","sources":["../../../../../../libs/angular-ui-powerups/src/lib/place/exports.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,kDAAkD,CAAC;AACjE,cAAc,sDAAsD,CAAC;AACrE,cAAc,oEAAoE,CAAC;AACnF,cAAc,kDAAkD,CAAC;AACjE,cAAc,4CAA4C,CAAC;AAC3D,cAAc,oEAAoE,CAAC;AACnF,cAAc,wEAAwE,CAAC;AACvF,cAAc,iCAAiC,CAAC;AAChD,cAAc,kCAAkC,CAAC;AACjD,cAAc,sBAAsB,CAAC;AACrC,cAAc,mDAAmD,CAAC;AAClE,cAAc,oDAAoD,CAAC;AACnE,cAAc,iCAAiC,CAAC;AAChD,cAAc,yCAAyC,CAAC;AACxD,cAAc,yCAAyC,CAAC;AACxD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,2DAA2D,CAAC;AAC1E,cAAc,wFAAwF,CAAC;AACvG,cAAc,iHAAiH,CAAC;AAChI,cAAc,kGAAkG,CAAC;AACjH,cAAc,iEAAiE,CAAC;AAChF,cAAc,2EAA2E,CAAC;AAC1F,cAAc,uFAAuF,CAAC;AACtG,cAAc,kFAAkF,CAAC;AACjG,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oCAAoC,CAAC;AACnD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./nav-item\";\nexport * from \"./place-access-guard\";\nexport * from \"./place-component\";\nexport * from \"./place-config\";\nexport * from \"./place-definition\";\nexport * from \"./place-history\";\nexport * from \"./place-router\";\nexport * from \"./place.decorator\";\nexport * from \"./place.module\";\nexport * from \"./url-service\";\nexport * from \"./url-snapshot\";\nexport * from \"./visit\";\nexport * from \"./components/abstract-place-navigation.component\";\nexport * from \"./components/list-place-nav/list-place-nav.component\";\nexport * from \"./components/not-authorised-notice/not-authorised-notice.component\";\nexport * from \"./components/place-outlet/place-outlet.component\";\nexport * from \"./components/place-outlet/route-animations\";\nexport * from \"./components/side-place-navigation/side-place-navigation.component\";\nexport * from \"./components/tabbed-place-navigation/tabbed-place-navigation.component\";\nexport * from \"./guards/consolidated-param-map\";\nexport * from \"./guards/noop-auth-guard.service\";\nexport * from \"./guards/place.guard\";\nexport * from \"./navigation/place-component-deactivation-handler\";\nexport * from \"./navigation/session/abstract-pop-state-navigation\";\nexport * from \"./navigation/session/navigating\";\nexport * from \"./navigation/session/navigation-context\";\nexport * from \"./navigation/session/navigation-session\";\nexport * from \"./navigation/session/pop-state-navigation\";\nexport * from \"./navigation/session/event-cleanup/event-clean-up-session\";\nexport * from \"./navigation/session/event-cleanup/wait-until-leaving-interaction-transition-cancelled\";\nexport * from \"./navigation/session/event-cleanup/wait-until-link-triggered-navigation-interaction-cancelation-type-determined\";\nexport * from \"./navigation/session/event-cleanup/wait-until-popstate-during-can-deactivate-transition-finishes\";\nexport * from \"./navigation/session/interactions/navigating-during-interaction\";\nexport * from \"./navigation/session/interactions/pop-state-during-interaction-navigation\";\nexport * from \"./navigation/session/interactions/remove-last-interaction-from-url-navigation-session\";\nexport * from \"./navigation/session/interactions/synchronise-interaction-context-ids-with-route\";\nexport * from \"./route/formatter\";\nexport * from \"./route/json-types\";\nexport * from \"./route/parameter-decorators\";\nexport * from \"./route/parameter-definition.class\";\nexport * from \"./route/parameter-sanitiser\";\nexport * from \"./route/parameter-snapshot\";\nexport * from \"./route/visit-sanitiser\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{},"exports":[{"from":"./nav-item"},{"from":"./place-access-guard"},{"from":"./place-component"},{"from":"./place-config"},{"from":"./place-definition"},{"from":"./place-history"},{"from":"./place-router"},{"from":"./place.decorator"},{"from":"./place.module"},{"from":"./url-service"},{"from":"./url-snapshot"},{"from":"./visit"},{"from":"./components/abstract-place-navigation.component"},{"from":"./components/list-place-nav/list-place-nav.component"},{"from":"./components/place-outlet/place-outlet.component"},{"from":"./components/place-outlet/route-animations"},{"from":"./components/side-place-navigation/side-place-navigation.component"},{"from":"./components/tabbed-place-navigation/tabbed-place-navigation.component"},{"from":"./guards/consolidated-param-map"},{"from":"./guards/noop-auth-guard.service"},{"from":"./guards/place.guard"},{"from":"./navigation/place-component-deactivation-handler"},{"from":"./navigation/session/abstract-pop-state-navigation"},{"from":"./navigation/session/navigating"},{"from":"./navigation/session/navigation-context"},{"from":"./navigation/session/navigation-session"},{"from":"./navigation/session/pop-state-navigation"},{"from":"./navigation/session/event-cleanup/event-clean-up-session"},{"from":"./navigation/session/event-cleanup/wait-until-leaving-interaction-transition-cancelled"},{"from":"./navigation/session/event-cleanup/wait-until-link-triggered-navigation-interaction-cancelation-type-determined"},{"from":"./navigation/session/event-cleanup/wait-until-popstate-during-can-deactivate-transition-finishes"},{"from":"./navigation/session/interactions/navigating-during-interaction"},{"from":"./navigation/session/interactions/pop-state-during-interaction-navigation"},{"from":"./navigation/session/interactions/remove-last-interaction-from-url-navigation-session"},{"from":"./navigation/session/interactions/synchronise-interaction-context-ids-with-route"},{"from":"./route/formatter"},{"from":"./route/json-types"},{"from":"./route/parameter-decorators"},{"from":"./route/parameter-definition.class"},{"from":"./route/parameter-sanitiser"},{"from":"./route/parameter-snapshot"},{"from":"./route/visit-sanitiser"}]}]
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{},"exports":[{"from":"./nav-item"},{"from":"./place-access-guard"},{"from":"./place-component"},{"from":"./place-config"},{"from":"./place-definition"},{"from":"./place-history"},{"from":"./place-router"},{"from":"./place.decorator"},{"from":"./place.module"},{"from":"./url-service"},{"from":"./url-snapshot"},{"from":"./visit"},{"from":"./components/abstract-place-navigation.component"},{"from":"./components/list-place-nav/list-place-nav.component"},{"from":"./components/not-authorised-notice/not-authorised-notice.component"},{"from":"./components/place-outlet/place-outlet.component"},{"from":"./components/place-outlet/route-animations"},{"from":"./components/side-place-navigation/side-place-navigation.component"},{"from":"./components/tabbed-place-navigation/tabbed-place-navigation.component"},{"from":"./guards/consolidated-param-map"},{"from":"./guards/noop-auth-guard.service"},{"from":"./guards/place.guard"},{"from":"./navigation/place-component-deactivation-handler"},{"from":"./navigation/session/abstract-pop-state-navigation"},{"from":"./navigation/session/navigating"},{"from":"./navigation/session/navigation-context"},{"from":"./navigation/session/navigation-session"},{"from":"./navigation/session/pop-state-navigation"},{"from":"./navigation/session/event-cleanup/event-clean-up-session"},{"from":"./navigation/session/event-cleanup/wait-until-leaving-interaction-transition-cancelled"},{"from":"./navigation/session/event-cleanup/wait-until-link-triggered-navigation-interaction-cancelation-type-determined"},{"from":"./navigation/session/event-cleanup/wait-until-popstate-during-can-deactivate-transition-finishes"},{"from":"./navigation/session/interactions/navigating-during-interaction"},{"from":"./navigation/session/interactions/pop-state-during-interaction-navigation"},{"from":"./navigation/session/interactions/remove-last-interaction-from-url-navigation-session"},{"from":"./navigation/session/interactions/synchronise-interaction-context-ids-with-route"},{"from":"./route/formatter"},{"from":"./route/json-types"},{"from":"./route/parameter-decorators"},{"from":"./route/parameter-definition.class"},{"from":"./route/parameter-sanitiser"},{"from":"./route/parameter-snapshot"},{"from":"./route/visit-sanitiser"}]}]
|
|
@@ -40,14 +40,6 @@ export class PlaceGuard {
|
|
|
40
40
|
}
|
|
41
41
|
return this.createUrlTree(redirectLocation);
|
|
42
42
|
}
|
|
43
|
-
if (!(this.placeRouter.accessGuard.value ? this.placeRouter.accessGuard.value.isAuthorised(placeDefinition) : true)) {
|
|
44
|
-
const redirectLocation = this.placeRouter.getAuthorisationFailureRedirect(activatedRoute, state);
|
|
45
|
-
const nextPlaceDef = this.getPlaceDefinition(redirectLocation);
|
|
46
|
-
if (!(this.placeRouter.accessGuard.value ? this.placeRouter.accessGuard.value.isAuthorised(nextPlaceDef) : true)) {
|
|
47
|
-
lang.illegalState(`handleNotAuthorised hook returned place ${nextPlaceDef.component.name} that is not authorised for the current user.`);
|
|
48
|
-
}
|
|
49
|
-
return this.createUrlTree(redirectLocation);
|
|
50
|
-
}
|
|
51
43
|
}
|
|
52
44
|
const result = yield this.cleanInteractionState(activatedRoute, state, () => __awaiter(this, void 0, void 0, function* () {
|
|
53
45
|
// Parse our route params.
|
|
@@ -79,6 +71,11 @@ export class PlaceGuard {
|
|
|
79
71
|
// @Trace()
|
|
80
72
|
canDeactivate(component, currentRoute, currentState, nextState) {
|
|
81
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
if (!component) {
|
|
75
|
+
// this happens when the place wasn't authorised and the associated
|
|
76
|
+
// router outlet was removed from the dom.
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
82
79
|
const currentUrl = this.urlService.parseUrl(currentState.url);
|
|
83
80
|
const nextUrl = this.urlService.parseUrl(nextState.url);
|
|
84
81
|
const result = yield this.placeRouter.navigationSession.canDeactivatePlace(component, currentUrl, nextUrl);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"place.guard.js","sourceRoot":"","sources":["../../../../../../../libs/angular-ui-powerups/src/lib/place/guards/place.guard.ts"],"names":[],"mappings":";AAAA,OAAO,EAAU,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAIL,MAAM,EAGP,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAiB,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;AACpF,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,iBA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,YAAY;YAHZ,kBAAkB;YAVE,QAAQ","sourcesContent":["import { Inject, Injectable, Injector } from '@angular/core';\nimport {\n ActivatedRouteSnapshot,\n CanActivate,\n CanDeactivate,\n Router,\n RouterStateSnapshot,\n UrlTree\n} from '@angular/router';\nimport { Constructable, lang } from '@coolon/pectin';\nimport { InteractionService } from '../../interaction/services/interaction.service';\nimport { PlaceComponent } from '../place-component';\nimport { PlaceDefinition } from '../place-definition';\nimport { PlaceHistory } from '../place-history';\nimport { PlaceRouter } from '../place-router';\nimport { VisitSanitiser } from '../route/visit-sanitiser';\nimport { UrlService } from '../url-service';\nimport { UrlSnapshot } from '../url-snapshot';\nimport { Visit } from '../visit';\nimport { ConsolidatedParameterMap } from './consolidated-param-map';\n\n@Injectable({ providedIn: 'root' })\nexport class PlaceGuard implements CanActivate, CanDeactivate<PlaceComponent> {\n\n\n constructor(private readonly router: Router,\n private urlService: UrlService,\n private readonly placeRouter: PlaceRouter,\n private readonly placeHistory: PlaceHistory,\n private readonly interactionService: InteractionService,\n private readonly injector: Injector) {\n }\n\n // @Trace()\n async canActivate(activatedRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean | UrlTree> {\n\n if (PlaceComponent.isPlaceComponentConstructor(activatedRoute.component)) {\n const placeDefinition = PlaceComponent.getDefinition(activatedRoute.component);\n\n if (placeDefinition.authenticate) {\n\n if (!await this.placeRouter.accessGuard.value.isAuthenticated()) {\n const redirectLocation = this.placeRouter.getAuthenticationFailureRedirect(activatedRoute, state);\n const nextPlaceDef = this.getPlaceDefinition(redirectLocation);\n if (nextPlaceDef.authenticate) {\n lang.illegalState(`handleNotAuthenticated hook returned place ${nextPlaceDef.component.name} that requires authentication.`);\n }\n return this.createUrlTree(redirectLocation);\n }\n\n if (!(this.placeRouter.accessGuard.value ? this.placeRouter.accessGuard.value.isAuthorised(placeDefinition) : true)) {\n const redirectLocation = this.placeRouter.getAuthorisationFailureRedirect(activatedRoute, state);\n const nextPlaceDef = this.getPlaceDefinition(redirectLocation);\n if (!(this.placeRouter.accessGuard.value ? this.placeRouter.accessGuard.value.isAuthorised(nextPlaceDef) : true)) {\n lang.illegalState(`handleNotAuthorised hook returned place ${nextPlaceDef.component.name} that is not authorised for the current user.`);\n }\n return this.createUrlTree(redirectLocation);\n }\n }\n\n const result = await this.cleanInteractionState(activatedRoute, state, async () => {\n // Parse our route params.\n const params = new ConsolidatedParameterMap(activatedRoute.paramMap, activatedRoute.url);\n const parsedParams = placeDefinition.parseRouteParams(params);\n\n const navigationSession = this.placeRouter.navigationSession;\n const initialVisit = navigationSession.getVisitFor(placeDefinition) || new Visit(placeDefinition, parsedParams);\n const sanitiser = new VisitSanitiser(navigationSession, activatedRoute, this.router, this.placeHistory, this.injector);\n const sanitisedVisit = await sanitiser.sanitise(initialVisit.mergeRouteParameters(parsedParams));\n\n // Save the visit with any updated parameters. We need to save it so we remember any non route parameters\n navigationSession.storeVisit(sanitisedVisit);\n if (initialVisit.hasRoutingChangedFrom(sanitisedVisit)) {\n // Regenerate the url\n const urlSnapshot = this.urlService.parseUrl(state.url).updateVisitSegments(sanitisedVisit);\n // console.log('##### Place Guard Redirect', urlSnapshot);\n return urlSnapshot;\n } else {\n return true;\n }\n });\n return result instanceof UrlSnapshot ? result.urlTree : result;\n\n } else {\n return lang.illegalState(`expected component to be an instance of PlaceComponent, got ${activatedRoute.component}`);\n }\n }\n\n // @Trace()\n async canDeactivate(component: PlaceComponent, currentRoute: ActivatedRouteSnapshot, currentState: RouterStateSnapshot, nextState?: RouterStateSnapshot): Promise<boolean | UrlTree> {\n const currentUrl = this.urlService.parseUrl(currentState.url);\n const nextUrl = this.urlService.parseUrl(nextState.url);\n const result = await this.placeRouter.navigationSession.canDeactivatePlace(component, currentUrl, nextUrl);\n return result instanceof UrlSnapshot ? result.urlTree : result;\n }\n\n private getPlaceDefinition(result: Constructable<PlaceComponent> | Visit): PlaceDefinition {\n return result instanceof Visit ?\n result.placeDefinition :\n PlaceComponent.getDefinition(result);\n }\n\n private createUrlTree(result: Constructable<PlaceComponent> | Visit) {\n const visit = result instanceof Visit ? result : new Visit(PlaceComponent.getDefinition(result), {});\n return this.urlService.createUrlSnapshot(visit).urlTree;\n }\n\n // protected async ensureAuthenticatedThen(activatedRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot, next: (placeDefinition: PlaceDefinition) => Promise<boolean | UrlTree>): Promise<boolean | UrlTree> {\n // const authoriseResult = placeDefinition.authenticate ? await this.isAuthorised(activatedRoute, state) : true;\n // if (authoriseResult === true) {\n // // we're authorised, now run the place guards.\n // return next(placeDefinition);\n // } else {\n // console.log('not authorised result', authoriseResult);\n // return authoriseResult;\n // }\n // }\n //\n // // @Trace()\n // protected async ensureAuthorisedThen(activatedRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot, next: (placeDefinition: PlaceDefinition) => Promise<boolean | UrlTree>): Promise<boolean | UrlTree> {\n //\n // }\n\n // @Trace()\n // async isAuthorised(activatedRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean | UrlTree> {\n // const authorised = this.getAuthGuard(this.injector).canActivate(activatedRoute, state);\n // return (authorised instanceof Observable) ? authorised.toPromise() : authorised;\n // }\n\n // abstract getAuthGuard(injector: Injector): CanActivate;\n\n // @Trace()\n async cleanInteractionState(route: ActivatedRouteSnapshot, state: RouterStateSnapshot, next: () => Promise<boolean | UrlSnapshot>): Promise<boolean | UrlSnapshot> {\n const url = this.urlService.parseUrl(state.url);\n if (!this.interactionService.isActive() && url.hasInteractions()) {\n // This happens if we reload the page or the url was pasted as the route should only be activated\n // after the interaction context has become active.\n return url.removeInteractionIds();\n } else {\n return next();\n }\n }\n\n}\n"]}
|
|
1
|
+
{"version":3,"file":"place.guard.js","sourceRoot":"","sources":["../../../../../../../libs/angular-ui-powerups/src/lib/place/guards/place.guard.ts"],"names":[],"mappings":";AAAA,OAAO,EAAU,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAIL,MAAM,EAG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ACjE,MAAM,KAAK,GAAG,MAAM,YAAY,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,cAAc,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC;QACrG,OAAO,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;IAC1D,CAAC;IAED,oNAAoN;IACpN,kHAAkH;IAClH,oCAAoC;IACpC,qDAAqD;IACrD,oCAAoC;IACpC,aAAa;IACb,6DAA6D;IAC7D,8BAA8B;IAC9B,MAAM;IACN,IAAI;IACJ,EAAE;IACF,cAAc;IACd,iNAAiN;IACjN,EAAE;IACF,IAAI;IAEJ,WAAW;IACX,uHAAuH;IACvH,4FAA4F;IAC5F,qFAAqF;IACrF,IAAI;IAEJ,0DAA0D;IAE1D,WAAW;IACL,qBAAqB,CAAC,KAA6B,EAAE,KAA0B,EAAE,IAA0C;;YAC/H,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAChD,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,QAAQ,EAAE,IAAI,GAAG,CAAC,eAAe,EAAE,EAAE;gBAChE,iGAAiG;gBACjG,mDAAmD;gBACnD,OAAO,GAAG,CAAC,oBAAoB,EAAE,CAAC;aACnC;iBAAM;gBACL,OAAO,IAAI,EAAE,CAAC;aACf;QACH,CAAC;KAAA;;;;YApHF,UAAU,SAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;YAhBhC,MAAM;YAWC,UAAU;YAFV,WAAW;YADX,YAAY;YAHZ,kBAAkB;YAVE,QAAQ","sourcesContent":["import { Inject, Injectable, Injector } from '@angular/core';\nimport {\n ActivatedRouteSnapshot,\n CanActivate,\n CanDeactivate,\n Router,\n RouterStateSnapshot,\n UrlTree\n} from '@angular/router';\nimport { Constructable, lang } from '@coolon/pectin';\nimport { InteractionService } from '../../interaction/services/interaction.service';\nimport { PlaceComponent } from '../place-component';\nimport { PlaceDefinition } from '../place-definition';\nimport { PlaceHistory } from '../place-history';\nimport { PlaceRouter } from '../place-router';\nimport { VisitSanitiser } from '../route/visit-sanitiser';\nimport { UrlService } from '../url-service';\nimport { UrlSnapshot } from '../url-snapshot';\nimport { Visit } from '../visit';\nimport { ConsolidatedParameterMap } from './consolidated-param-map';\n\n@Injectable({ providedIn: 'root' })\nexport class PlaceGuard implements CanActivate, CanDeactivate<PlaceComponent> {\n\n\n constructor(private readonly router: Router,\n private urlService: UrlService,\n private readonly placeRouter: PlaceRouter,\n private readonly placeHistory: PlaceHistory,\n private readonly interactionService: InteractionService,\n private readonly injector: Injector) {\n }\n\n // @Trace()\n async canActivate(activatedRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean | UrlTree> {\n\n if (PlaceComponent.isPlaceComponentConstructor(activatedRoute.component)) {\n const placeDefinition = PlaceComponent.getDefinition(activatedRoute.component);\n\n if (placeDefinition.authenticate) {\n\n if (!await this.placeRouter.accessGuard.value.isAuthenticated()) {\n const redirectLocation = this.placeRouter.getAuthenticationFailureRedirect(activatedRoute, state);\n const nextPlaceDef = this.getPlaceDefinition(redirectLocation);\n if (nextPlaceDef.authenticate) {\n lang.illegalState(`handleNotAuthenticated hook returned place ${nextPlaceDef.component.name} that requires authentication.`);\n }\n return this.createUrlTree(redirectLocation);\n }\n }\n\n const result = await this.cleanInteractionState(activatedRoute, state, async () => {\n // Parse our route params.\n const params = new ConsolidatedParameterMap(activatedRoute.paramMap, activatedRoute.url);\n const parsedParams = placeDefinition.parseRouteParams(params);\n\n const navigationSession = this.placeRouter.navigationSession;\n const initialVisit = navigationSession.getVisitFor(placeDefinition) || new Visit(placeDefinition, parsedParams);\n const sanitiser = new VisitSanitiser(navigationSession, activatedRoute, this.router, this.placeHistory, this.injector);\n const sanitisedVisit = await sanitiser.sanitise(initialVisit.mergeRouteParameters(parsedParams));\n\n // Save the visit with any updated parameters. We need to save it so we remember any non route parameters\n navigationSession.storeVisit(sanitisedVisit);\n if (initialVisit.hasRoutingChangedFrom(sanitisedVisit)) {\n // Regenerate the url\n const urlSnapshot = this.urlService.parseUrl(state.url).updateVisitSegments(sanitisedVisit);\n // console.log('##### Place Guard Redirect', urlSnapshot);\n return urlSnapshot;\n } else {\n return true;\n }\n });\n return result instanceof UrlSnapshot ? result.urlTree : result;\n\n } else {\n return lang.illegalState(`expected component to be an instance of PlaceComponent, got ${activatedRoute.component}`);\n }\n }\n\n // @Trace()\n async canDeactivate(component: PlaceComponent, currentRoute: ActivatedRouteSnapshot, currentState: RouterStateSnapshot, nextState?: RouterStateSnapshot): Promise<boolean | UrlTree> {\n if (!component) {\n // this happens when the place wasn't authorised and the associated\n // router outlet was removed from the dom.\n return true;\n }\n const currentUrl = this.urlService.parseUrl(currentState.url);\n const nextUrl = this.urlService.parseUrl(nextState.url);\n const result = await this.placeRouter.navigationSession.canDeactivatePlace(component, currentUrl, nextUrl);\n return result instanceof UrlSnapshot ? result.urlTree : result;\n }\n\n private getPlaceDefinition(result: Constructable<PlaceComponent> | Visit): PlaceDefinition {\n return result instanceof Visit ?\n result.placeDefinition :\n PlaceComponent.getDefinition(result);\n }\n\n private createUrlTree(result: Constructable<PlaceComponent> | Visit) {\n const visit = result instanceof Visit ? result : new Visit(PlaceComponent.getDefinition(result), {});\n return this.urlService.createUrlSnapshot(visit).urlTree;\n }\n\n // protected async ensureAuthenticatedThen(activatedRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot, next: (placeDefinition: PlaceDefinition) => Promise<boolean | UrlTree>): Promise<boolean | UrlTree> {\n // const authoriseResult = placeDefinition.authenticate ? await this.isAuthorised(activatedRoute, state) : true;\n // if (authoriseResult === true) {\n // // we're authorised, now run the place guards.\n // return next(placeDefinition);\n // } else {\n // console.log('not authorised result', authoriseResult);\n // return authoriseResult;\n // }\n // }\n //\n // // @Trace()\n // protected async ensureAuthorisedThen(activatedRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot, next: (placeDefinition: PlaceDefinition) => Promise<boolean | UrlTree>): Promise<boolean | UrlTree> {\n //\n // }\n\n // @Trace()\n // async isAuthorised(activatedRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean | UrlTree> {\n // const authorised = this.getAuthGuard(this.injector).canActivate(activatedRoute, state);\n // return (authorised instanceof Observable) ? authorised.toPromise() : authorised;\n // }\n\n // abstract getAuthGuard(injector: Injector): CanActivate;\n\n // @Trace()\n async cleanInteractionState(route: ActivatedRouteSnapshot, state: RouterStateSnapshot, next: () => Promise<boolean | UrlSnapshot>): Promise<boolean | UrlSnapshot> {\n const url = this.urlService.parseUrl(state.url);\n if (!this.interactionService.isActive() && url.hasInteractions()) {\n // This happens if we reload the page or the url was pasted as the route should only be activated\n // after the interaction context has become active.\n return url.removeInteractionIds();\n } else {\n return next();\n }\n }\n\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
+
import { assert } from '@coolon/pectin';
|
|
2
3
|
import * as _ from 'lodash';
|
|
3
4
|
/**
|
|
4
5
|
* This class handles the logic around canDeactivate for a given router state transition. It's core responsibilities are:
|
|
@@ -12,6 +13,7 @@ export class PlaceComponentDeactivationHandler {
|
|
|
12
13
|
this.component = component;
|
|
13
14
|
this.navigationSession = navigationSession;
|
|
14
15
|
this.isPrimaryComponent = isPrimaryComponent;
|
|
16
|
+
assert.notNil(component);
|
|
15
17
|
}
|
|
16
18
|
get routerInteractionAdapter() {
|
|
17
19
|
return this.navigationSession.interactionServiceAdapter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"place-component-deactivation-handler.js","sourceRoot":"","sources":["../../../../../../../libs/angular-ui-powerups/src/lib/place/navigation/place-component-deactivation-handler.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"place-component-deactivation-handler.js","sourceRoot":"","sources":["../../../../../../../libs/angular-ui-powerups/src/lib/place/nav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C,8BAA8B,EAAE,CAAC;oBAClF,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,QAAQ,CAAC,EAAE,EAAE,6BAA6B;wBACnE,MAAM,IAAI,CAAC,wBAAwB,CAAC,6BAA6B,EAAE,CAAC;wBACpE,OAAO,KAAK,CAAC;qBACd;iBACF;qBAAM;oBACL,qDAAqD;oBACrD,IAAI,IAAI,CAAC,wBAAwB,CAAC,sBAAsB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;wBACxE,MAAM,IAAI,CAAC,wBAAwB,CAAC,0BAA0B,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;wBAC/E,OAAO,KAAK,CAAC;qBACd;iBACF;aACF;YAGD,0EAA0E;YAC1E,IAAI,IAAI,CAAC,yBAAyB,CAAC,SAAS,CAAC,EAAE;gBAE7C,IAAI,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE;oBAChC,qDAAqD;oBACrD,8HAA8H;oBAC9H,+GAA+G;oBAC/G,OAAO,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,iBAAiB,CAAC,+BAA+B,CAAC,CAAC;iBAC7F;gBAED,qGAAqG;gBACrG,wDAAwD;gBACxD,IAAI,IAAI,CAAC,wBAAwB,CAAC,sBAAsB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;oBACxE,OAAO,CAAC,IAAI,CAAC,6EAA6E,CAAC,CAAC;oBAC5F,OAAO,KAAK,CAAC;iBACd;aAEF;YACD,OAAO,IAAI,CAAC;QACd,CAAC;KAAA;IAES,yBAAyB,CAAC,SAAsB;QACxD,qFAAqF;QACrF,gFAAgF;QAChF,0CAA0C;QAC1C,OAAO,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;IACnE,CAAC;CACF","sourcesContent":["import { Trace, assert } from '@coolon/pectin';\nimport * as _ from 'lodash';\nimport { PlaceComponent } from '../place-component';\nimport { UrlSnapshot } from '../url-snapshot';\nimport { NavigationSession } from './session/navigation-session';\n\n/**\n * This class handles the logic around canDeactivate for a given router state transition. It's core responsibilities are:\n * 1. Ensure we only ask the component to deactivate once on a given navigation cycle (since visit sanitisation can result in multiple round trips to through the router.)\n * 2. Ensure only the primary place component is asked when there are nested places. The primary component is the one at the top\n * of the routing change tree.\n * 3. Automatically handle standard interaction scenarios on the components behalf.\n */\nexport class PlaceComponentDeactivationHandler {\n\n private canDeactivatePromise: Promise<boolean | UrlSnapshot>;\n\n constructor(readonly component: PlaceComponent, readonly navigationSession: NavigationSession, readonly isPrimaryComponent: boolean) {\n assert.notNil(component);\n }\n\n get routerInteractionAdapter() {\n return this.navigationSession.interactionServiceAdapter;\n }\n\n get urlService() {\n return this.navigationSession.urlService;\n }\n\n // @Trace()\n async canDeactivate(currentUrl: UrlSnapshot, nextState: UrlSnapshot): Promise<boolean | UrlSnapshot> {\n // We'll get called multiple times if there's any parameter sanitisation so\n // we always return true if we accepted promise from a previous cycle of the current\n // navigation session.\n if (!this.canDeactivatePromise) {\n // console.log(`creating deactivate promise for -> ${this.component.constructor.name}`);\n this.canDeactivatePromise = this.canDeactivateComponent(currentUrl, nextState);\n }\n return this.canDeactivatePromise;\n }\n\n\n // @Trace()\n protected async canDeactivateComponent(currentUrl: UrlSnapshot, nextState: UrlSnapshot): Promise<UrlSnapshot | boolean> {\n // Automatically cancel any active activities if the navigation session was triggered by the back button.\n // If we handled more than just the pop state then it leads to the UI ignoring clicks and just cancelling things which is deeply disconcerting.\n if (this.navigationSession.isPopState) {\n\n if (this.isPrimaryComponent && this.routerInteractionAdapter.isModalActive()) {\n const routeIds = this.urlService.getActiveInteractionIdsFromUrl(nextState.url);\n const currentIds = this.routerInteractionAdapter.getActiveInteractionContextIds();\n if (!_.isEqual(currentIds, routeIds)) { // why am I checking this????\n await this.routerInteractionAdapter.cancelCurrentModalInteraction();\n return false;\n }\n } else {\n // check if the component has an in place interaction\n if (this.routerInteractionAdapter.isComponentInteracting(this.component)) {\n await this.routerInteractionAdapter.cancelComponentInteraction(this.component);\n return false;\n }\n }\n }\n\n\n // Ok, so now we're really leaving, so we ask the component if we should.;\n if (this.isNotJustAChangeInRouteId(nextState)) {\n\n if (this.component.canDeactivate) {\n // No interaction in progress, so ask the component .\n // This may start an interaction, hence checking the interaction context before now. I.e. if the place pops up the dialog, and\n // the user clicks back again, we'll re-enter here and go bang when the component tries to open another dialog.\n return this.component.canDeactivate(this.navigationSession.canDeactivateInteractionContext);\n }\n\n // The component has an active interaction but no deactivation hook. Rather than guessing what to do\n // we'll just cancel the navigation and print a warning.\n if (this.routerInteractionAdapter.isComponentInteracting(this.component)) {\n console.warn('Route changed while component has active interaction, cancelling navigation');\n return false;\n }\n\n }\n return true;\n }\n\n protected isNotJustAChangeInRouteId(nextState: UrlSnapshot) {\n // Because places with a route-id cover two route segments we get asked to deactivate\n // if the route id is added or removed. So if our path is still present the url\n // then we shouldn't deactivate the place.\n return !nextState.includesPathOf(this.component.placeDefinition);\n }\n}\n"]}
|
|
@@ -54,7 +54,7 @@ export class PlaceRouter extends GarbageCollector {
|
|
|
54
54
|
.pluck('name')
|
|
55
55
|
.otherwise(idleStateName);
|
|
56
56
|
DebugContext.tag(this._activeVisits, 'PlaceRouter.activeVisits');
|
|
57
|
-
this.
|
|
57
|
+
this.state = chain(this._activeVisits).reduce(visits => new PlaceRouter.State(visits));
|
|
58
58
|
// TODO: make setup the callbacks in during module initiation to make this testable.
|
|
59
59
|
angularRouter.events.subscribe(event => {
|
|
60
60
|
// Routing event sequence
|
|
@@ -113,9 +113,6 @@ export class PlaceRouter extends GarbageCollector {
|
|
|
113
113
|
getAuthenticationFailureRedirect(activatedRoute, state) {
|
|
114
114
|
return this.redirections.onAuthenticationFailure(activatedRoute, state);
|
|
115
115
|
}
|
|
116
|
-
getAuthorisationFailureRedirect(activatedRoute, state) {
|
|
117
|
-
return this.redirections.onAuthorisationFailure(activatedRoute, state);
|
|
118
|
-
}
|
|
119
116
|
get navigationSession() {
|
|
120
117
|
return this.navigationSessionModel.value;
|
|
121
118
|
}
|
|
@@ -325,4 +322,18 @@ PlaceRouter.ctorParameters = () => [
|
|
|
325
322
|
{ type: UrlService },
|
|
326
323
|
{ type: PlaceHistory }
|
|
327
324
|
];
|
|
325
|
+
(function (PlaceRouter) {
|
|
326
|
+
class State {
|
|
327
|
+
constructor(activeVisits) {
|
|
328
|
+
this.activeVisits = activeVisits;
|
|
329
|
+
}
|
|
330
|
+
isPlaceActive(placeDefinition) {
|
|
331
|
+
return !!this.getVisitFor(placeDefinition);
|
|
332
|
+
}
|
|
333
|
+
getVisitFor(placeDefinition) {
|
|
334
|
+
return this.activeVisits.find(v => v.placeDefinition === placeDefinition);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
PlaceRouter.State = State;
|
|
338
|
+
})(PlaceRouter || (PlaceRouter = {}));
|
|
328
339
|
//# sourceMappingURL=place-router.js.map
|