@coolon/angular-ui-powerups 3.6.0 → 3.7.0-alpha.0

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.
Files changed (112) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/bundles/coolon-angular-ui-powerups-cypress.umd.js +41 -1
  3. package/bundles/coolon-angular-ui-powerups-cypress.umd.js.map +1 -1
  4. package/bundles/coolon-angular-ui-powerups-cypress.umd.min.js +1 -1
  5. package/bundles/coolon-angular-ui-powerups-cypress.umd.min.js.map +1 -1
  6. package/bundles/coolon-angular-ui-powerups.umd.js +228 -184
  7. package/bundles/coolon-angular-ui-powerups.umd.js.map +1 -1
  8. package/bundles/coolon-angular-ui-powerups.umd.min.js +1 -1
  9. package/bundles/coolon-angular-ui-powerups.umd.min.js.map +1 -1
  10. package/coolon-angular-ui-powerups.metadata.json +1 -1
  11. package/cypress/components/aup-navigation.d.ts +9 -0
  12. package/cypress/coolon-angular-ui-powerups-cypress.metadata.json +1 -1
  13. package/cypress/exports.d.ts +1 -0
  14. package/cypress/package.json +2 -1
  15. package/cypress/page.d.ts +3 -0
  16. package/cypress/section.d.ts +5 -0
  17. package/esm2015/cypress/components/aup-navigation.js +21 -0
  18. package/esm2015/cypress/components/aup-navigation.js.map +1 -0
  19. package/esm2015/cypress/components/aup-navigation.metadata.json +1 -0
  20. package/esm2015/cypress/exports.js +1 -0
  21. package/esm2015/cypress/exports.js.map +1 -1
  22. package/esm2015/cypress/exports.metadata.json +1 -1
  23. package/esm2015/cypress/page.js +10 -1
  24. package/esm2015/cypress/page.js.map +1 -1
  25. package/esm2015/cypress/page.metadata.json +1 -1
  26. package/esm2015/cypress/section.js +7 -0
  27. package/esm2015/cypress/section.js.map +1 -1
  28. package/esm2015/lib/place/components/abstract-place-navigation.component.js +7 -5
  29. package/esm2015/lib/place/components/abstract-place-navigation.component.js.map +1 -1
  30. package/esm2015/lib/place/components/abstract-place-navigation.component.metadata.json +1 -1
  31. package/esm2015/lib/place/components/list-place-nav/list-place-nav.component.js +6 -6
  32. package/esm2015/lib/place/components/list-place-nav/list-place-nav.component.js.map +1 -1
  33. package/esm2015/lib/place/components/list-place-nav/list-place-nav.component.metadata.json +1 -1
  34. package/esm2015/lib/place/components/side-place-navigation/side-place-navigation.component.js +5 -5
  35. package/esm2015/lib/place/components/side-place-navigation/side-place-navigation.component.js.map +1 -1
  36. package/esm2015/lib/place/components/side-place-navigation/side-place-navigation.component.metadata.json +1 -1
  37. package/esm2015/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.js +5 -5
  38. package/esm2015/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.js.map +1 -1
  39. package/esm2015/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.metadata.json +1 -1
  40. package/esm2015/lib/place/exports.js +1 -0
  41. package/esm2015/lib/place/exports.js.map +1 -1
  42. package/esm2015/lib/place/exports.metadata.json +1 -1
  43. package/esm2015/lib/place/guards/place.guard.js +94 -43
  44. package/esm2015/lib/place/guards/place.guard.js.map +1 -1
  45. package/esm2015/lib/place/guards/place.guard.metadata.json +1 -1
  46. package/esm2015/lib/place/guards/place.guard.ngfactory.js.map +1 -0
  47. package/esm2015/lib/place/place-auth-service.js +3 -0
  48. package/esm2015/lib/place/place-auth-service.js.map +1 -0
  49. package/esm2015/lib/place/place-auth-service.metadata.json +1 -0
  50. package/esm2015/lib/place/place-component.js +12 -2
  51. package/esm2015/lib/place/place-component.js.map +1 -1
  52. package/esm2015/lib/place/place-component.metadata.json +1 -1
  53. package/esm2015/lib/place/place-definition.js +2 -1
  54. package/esm2015/lib/place/place-definition.js.map +1 -1
  55. package/esm2015/lib/place/place-definition.metadata.json +1 -1
  56. package/esm2015/lib/place/place-router.js +6 -0
  57. package/esm2015/lib/place/place-router.js.map +1 -1
  58. package/esm2015/lib/place/place-router.metadata.json +1 -1
  59. package/esm2015/lib/place/place.decorator.js +1 -1
  60. package/esm2015/lib/place/place.decorator.js.map +1 -1
  61. package/fesm2015/coolon-angular-ui-powerups-cypress.js +36 -2
  62. package/fesm2015/coolon-angular-ui-powerups-cypress.js.map +1 -1
  63. package/fesm2015/coolon-angular-ui-powerups.js +185 -128
  64. package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
  65. package/lib/place/components/abstract-place-navigation.component.d.ts +2 -2
  66. package/lib/place/components/list-place-nav/list-place-nav.component.d.ts +2 -2
  67. package/lib/place/components/side-place-navigation/side-place-navigation.component.d.ts +2 -2
  68. package/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.d.ts +2 -2
  69. package/lib/place/exports.d.ts +1 -0
  70. package/lib/place/guards/place.guard.d.ts +5 -7
  71. package/lib/place/place-auth-service.d.ts +36 -0
  72. package/lib/place/place-component.d.ts +2 -1
  73. package/lib/place/place-definition.d.ts +2 -1
  74. package/lib/place/place-router.d.ts +1 -0
  75. package/lib/place/place.decorator.d.ts +1 -0
  76. package/package.json +1 -1
  77. package/schematics/bootstrap-app/index.js +4 -0
  78. package/schematics/bootstrap-app/index.js.map +1 -1
  79. package/schematics/bootstrap-app/templates/app/app.module.ts.template +4 -2
  80. package/schematics/bootstrap-app/templates/app/auth/place-auth.service.ts.template +41 -0
  81. package/schematics/collection.json +5 -0
  82. package/schematics/ng-add/index.js +1 -1
  83. package/schematics/ng-add/index.js.map +1 -1
  84. package/schematics/place-add/index.js +2 -1
  85. package/schematics/place-add/index.js.map +1 -1
  86. package/schematics/place-add/templates/component/__name@dasherize__.component.scss.template +1 -0
  87. package/schematics/place-bootstrap/index.d.ts +3 -0
  88. package/schematics/place-bootstrap/index.js +21 -0
  89. package/schematics/place-bootstrap/index.js.map +1 -0
  90. package/schematics/place-bootstrap/schema.d.ts +4 -0
  91. package/schematics/place-bootstrap/schema.js +3 -0
  92. package/schematics/place-bootstrap/schema.js.map +1 -0
  93. package/schematics/place-bootstrap/schema.json +28 -0
  94. package/schematics/place-routes/place-builder.d.ts +0 -1
  95. package/schematics/place-routes/place-builder.js +34 -24
  96. package/schematics/place-routes/place-builder.js.map +1 -1
  97. package/schematics/place-routes/place-class-scanner.js +2 -1
  98. package/schematics/place-routes/place-class-scanner.js.map +1 -1
  99. package/schematics/place-routes/place-def.d.ts +1 -0
  100. package/schematics/place-routes/place-def.js +2 -2
  101. package/schematics/place-routes/place-def.js.map +1 -1
  102. package/schematics/place-routes/schema.d.ts +1 -4
  103. package/schematics/place-routes/schema.json +9 -1
  104. package/schematics/place-routes/templates/place-destinations.ts.template +1 -9
  105. package/schematics/place-routes/templates/place-routes.ts.template +3 -39
  106. package/schematics/place-routes/templates/place-visits.ts.template +1 -10
  107. package/schematics/bootstrap-app/templates/app/auth/auth.guard.ts.template +0 -23
  108. package/schematics/bootstrap-app/templates/app/auth/auth.module.ts.template +0 -13
  109. package/schematics/bootstrap-app/templates/app/auth/auth.service.ts.template +0 -13
  110. package/schematics/bootstrap-app/templates/app/places/places.json5.template +0 -3
  111. /package/schematics/{bootstrap-app/templates/app/places → place-bootstrap/templates/__name@dasherize__}/place-routes.ts.template +0 -0
  112. /package/schematics/{bootstrap-app/templates/app/places → place-bootstrap/templates/__name@dasherize__}/places.module.ts.template +0 -0
@@ -1,5 +1,5 @@
1
1
  import { DOCUMENT, CommonModule, Location } from '@angular/common';
2
- import { Directive, ElementRef, Inject, Host, Optional, Input, HostListener, NgZone, ɵɵdefineInjectable, ɵɵinject, Injectable, NgModule, Component, ContentChild, EventEmitter, SkipSelf, ViewChild, Output, ViewChildren, HostBinding, ViewEncapsulation, Self, TemplateRef, ChangeDetectorRef, ContentChildren, ViewContainerRef, InjectionToken, Injector, ComponentFactoryResolver } from '@angular/core';
2
+ import { Directive, ElementRef, Inject, Host, Optional, Input, HostListener, NgZone, ɵɵdefineInjectable, ɵɵinject, Injectable, NgModule, Component, ContentChild, EventEmitter, SkipSelf, ViewChild, Output, ViewChildren, HostBinding, ViewEncapsulation, Self, TemplateRef, ChangeDetectorRef, ContentChildren, ViewContainerRef, InjectionToken, Injector, ComponentFactoryResolver, INJECTOR } from '@angular/core';
3
3
  import { FormsModule } from '@angular/forms';
4
4
  import { MatFormFieldModule } from '@angular/material/form-field';
5
5
  import { MatInputModule } from '@angular/material/input';
@@ -21,13 +21,13 @@ import { fas } from '@fortawesome/free-solid-svg-icons';
21
21
  import { GarbageCollector, DelegatingValueModel, assert, UnaryCommand, lang, Dsl, Logger, TrackExternal, Command, MutableValueModel, StoreInValueModel, ValueModel, MutableListModel, ListModel, StoreInListModel, FocusManager, EventListenerList, Form, Guard, Binding, DebugContext, MultipleSelectionModel, DirtyTrackingForm, DelegatingCommand, Deferred, Trace, Functions } from '@coolon/pectin';
22
22
  import { __decorate, __metadata, __awaiter } from 'tslib';
23
23
  import { Memoize } from '@typescript-plus/fast-memoize-decorator/dist/src';
24
- import _, { isEqual, isNil } from 'lodash';
24
+ import _, { isNil, isEqual } from 'lodash';
25
25
  import { Enum } from 'typescript-string-enums';
26
26
  import { assert as assert$1, Opts, lang as lang$1, Klass } from '@coolon/typescript-utilities';
27
27
  import produce from 'immer';
28
28
  import { FlexModule, GridModule } from '@angular/flex-layout';
29
29
  import { MatDialogModule, MatDialog, MAT_DIALOG_DEFAULT_OPTIONS, MatDialogConfig } from '@angular/material/dialog';
30
- import { RouterModule, NavigationStart, NavigationCancel, UrlSegment, Router, UrlSerializer, NavigationEnd, NavigationError, RouterOutlet } from '@angular/router';
30
+ import { RouterModule, ActivatedRouteSnapshot, NavigationStart, NavigationCancel, UrlSegment, Router, UrlSerializer, NavigationEnd, NavigationError, RouterOutlet, RouterStateSnapshot } from '@angular/router';
31
31
  import { Overlay, CdkScrollable } from '@angular/cdk/overlay';
32
32
  import ResizeObserver from 'resize-observer-polyfill';
33
33
  import { MatListModule } from '@angular/material/list';
@@ -35,7 +35,6 @@ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
35
35
  import { Memoize as Memoize$1 } from '@typescript-plus/fast-memoize-decorator';
36
36
  import 'reflect-metadata';
37
37
  import { style, query, group, animate, trigger, transition } from '@angular/animations';
38
- import { Observable } from 'rxjs';
39
38
 
40
39
  class CommandDirective extends GarbageCollector {
41
40
  constructor(elementRef, matButton, matMenuItem) {
@@ -4389,6 +4388,8 @@ InteractionModule.decorators = [
4389
4388
  },] }
4390
4389
  ];
4391
4390
 
4391
+ const PLACE_AUTH_SERVICE = new InjectionToken("PlaceAuthService");
4392
+
4392
4393
  class ParameterDefinition {
4393
4394
  constructor(propertyName, options, urlFormat) {
4394
4395
  this.propertyName = propertyName;
@@ -4474,10 +4475,11 @@ class ParameterDefinition {
4474
4475
  })(ParameterDefinition || (ParameterDefinition = {}));
4475
4476
 
4476
4477
  class PlaceDefinition {
4477
- constructor(component, path, authenticate, data, routeParameters, children) {
4478
+ constructor(component, path, authenticate, roles, data, routeParameters, children) {
4478
4479
  this.component = component;
4479
4480
  this.path = path;
4480
4481
  this.authenticate = authenticate;
4482
+ this.roles = roles;
4481
4483
  this.data = data;
4482
4484
  this.routeParameters = routeParameters;
4483
4485
  this.children = children;
@@ -4697,8 +4699,17 @@ __decorate([
4697
4699
  return Klass.get(klass).getMetadataList(ROUTE_PARAMETER_LIST_KEY);
4698
4700
  }
4699
4701
  PlaceComponent.getRouteParameters = getRouteParameters;
4700
- function getDefinition(klass) {
4701
- return Reflect.getMetadata(DEFINITION_META_DATA_KEY, klass);
4702
+ function getDefinition(snapshotOrConstructor) {
4703
+ if (snapshotOrConstructor instanceof ActivatedRouteSnapshot) {
4704
+ const component = snapshotOrConstructor.component;
4705
+ if (!isPlaceComponentConstructor(component)) {
4706
+ throw new Error(`ActivatedRouteSnapshot component is not a PlaceComponent, got ${component}`);
4707
+ }
4708
+ return Reflect.getMetadata(DEFINITION_META_DATA_KEY, component);
4709
+ }
4710
+ else {
4711
+ return Reflect.getMetadata(DEFINITION_META_DATA_KEY, snapshotOrConstructor);
4712
+ }
4702
4713
  }
4703
4714
  PlaceComponent.getDefinition = getDefinition;
4704
4715
  function injectDefinition(klass, definition) {
@@ -4707,6 +4718,72 @@ __decorate([
4707
4718
  PlaceComponent.injectDefinition = injectDefinition;
4708
4719
  })(PlaceComponent || (PlaceComponent = {}));
4709
4720
 
4721
+ class Visit {
4722
+ constructor(placeDefinition, visitParameters = {}) {
4723
+ this.placeDefinition = placeDefinition;
4724
+ this.visitParameters = visitParameters;
4725
+ }
4726
+ // @Trace()
4727
+ getRouteId() {
4728
+ return this.placeDefinition.getRouteIdFrom(this);
4729
+ }
4730
+ // @Trace()
4731
+ hasRouteId() {
4732
+ return !isNil(this.getRouteId());
4733
+ }
4734
+ /**
4735
+ * Returns the value of the place parameter with the specified name. The parameter
4736
+ * name is taken from the `as` option, e.g. {as: 'aCustomName'} otherwise it is the
4737
+ * same as the the ValueModel property name.
4738
+ * @param parameterName the field name of the property model or the `as` option if specified.
4739
+ */
4740
+ getParameter(parameterName) {
4741
+ return this.visitParameters[parameterName];
4742
+ }
4743
+ // @Trace()
4744
+ hasParameter(parameterName) {
4745
+ return Object.keys(this.visitParameters).includes(parameterName);
4746
+ }
4747
+ replace(parameter, value) {
4748
+ return new Visit(this.placeDefinition, Object.assign(Object.assign({}, this.visitParameters), { [parameter.name]: value }));
4749
+ }
4750
+ mergeRouteParameters(routeParams) {
4751
+ // todo: whitelist parameters.
4752
+ const routeParameterKeys = Object.keys(routeParams);
4753
+ const params = {};
4754
+ this.placeDefinition.getVisitParameterDefs().forEach(def => {
4755
+ if (def.isRouteId || def.isRouteParameter) {
4756
+ if (routeParameterKeys.includes(def.name)) {
4757
+ params[def.name] = routeParams[def.name];
4758
+ }
4759
+ }
4760
+ else {
4761
+ // copy non route params as is, but only if they already exist otherwise we'll inject nil values and break the
4762
+ // defaults and remember sanitisation process.
4763
+ const value = this.getParameter(def.name);
4764
+ if (this.hasParameter(def.name)) {
4765
+ params[def.name] = value;
4766
+ }
4767
+ }
4768
+ });
4769
+ return new Visit(this.placeDefinition, params);
4770
+ }
4771
+ hasRoutingChangedFrom(other) {
4772
+ const samePlace = other.placeDefinition === this.placeDefinition;
4773
+ const sameRouteParameters = isEqual(this.placeDefinition.getFormattedRouteParameters(this, true), this.placeDefinition.getFormattedRouteParameters(other, true));
4774
+ return !samePlace || !sameRouteParameters;
4775
+ }
4776
+ hasChangedFrom(other) {
4777
+ const sameNonRouteParameters = isEqual(this.placeDefinition.getNonRouteParameters(this), this.placeDefinition.getNonRouteParameters(other));
4778
+ return !sameNonRouteParameters || this.hasRoutingChangedFrom(other);
4779
+ }
4780
+ toDebugString() {
4781
+ return Object.keys(this.visitParameters).map(k => `${k}=${this.visitParameters[k]}`).join(",");
4782
+ }
4783
+ }
4784
+
4785
+ const AUP_PLACE_CONFIG = new InjectionToken('AUP_PLACE_CONFIG');
4786
+
4710
4787
  /**
4711
4788
  * This class handles the logic around canDeactivate for a given router state transition. It's core responsibilities are:
4712
4789
  * 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.)
@@ -5775,6 +5852,9 @@ class PlaceRouter extends GarbageCollector {
5775
5852
  this.navigationSessionModel = new MutableValueModel();
5776
5853
  this._activeVisits = new MutableListModel();
5777
5854
  this.sessionFinishedJobs = [];
5855
+ if (window['Cypress']) {
5856
+ window['aup.PlaceRouter'] = this;
5857
+ }
5778
5858
  this.routerInteractionAdapter = interactionService.registerPlaceRouter(this);
5779
5859
  // TODO: Make this an interface and use 'this' instead.
5780
5860
  this.navigationContext = new NavigationContext.Impl(this.urlService, this.routerInteractionAdapter, (urlSnapshot, options) => {
@@ -5836,6 +5916,9 @@ class PlaceRouter extends GarbageCollector {
5836
5916
  get currentSession() {
5837
5917
  return this.navigationSessionModel.value;
5838
5918
  }
5919
+ isNavigating() {
5920
+ return this.navigationInProgress.value;
5921
+ }
5839
5922
  // @Trace()
5840
5923
  onPopState(event) {
5841
5924
  assert.isTruthy(event.navigationTrigger === 'popstate');
@@ -6028,72 +6111,6 @@ PlaceRouter.ctorParameters = () => [
6028
6111
  { type: PlaceHistory }
6029
6112
  ];
6030
6113
 
6031
- class Visit {
6032
- constructor(placeDefinition, visitParameters = {}) {
6033
- this.placeDefinition = placeDefinition;
6034
- this.visitParameters = visitParameters;
6035
- }
6036
- // @Trace()
6037
- getRouteId() {
6038
- return this.placeDefinition.getRouteIdFrom(this);
6039
- }
6040
- // @Trace()
6041
- hasRouteId() {
6042
- return !isNil(this.getRouteId());
6043
- }
6044
- /**
6045
- * Returns the value of the place parameter with the specified name. The parameter
6046
- * name is taken from the `as` option, e.g. {as: 'aCustomName'} otherwise it is the
6047
- * same as the the ValueModel property name.
6048
- * @param parameterName the field name of the property model or the `as` option if specified.
6049
- */
6050
- getParameter(parameterName) {
6051
- return this.visitParameters[parameterName];
6052
- }
6053
- // @Trace()
6054
- hasParameter(parameterName) {
6055
- return Object.keys(this.visitParameters).includes(parameterName);
6056
- }
6057
- replace(parameter, value) {
6058
- return new Visit(this.placeDefinition, Object.assign(Object.assign({}, this.visitParameters), { [parameter.name]: value }));
6059
- }
6060
- mergeRouteParameters(routeParams) {
6061
- // todo: whitelist parameters.
6062
- const routeParameterKeys = Object.keys(routeParams);
6063
- const params = {};
6064
- this.placeDefinition.getVisitParameterDefs().forEach(def => {
6065
- if (def.isRouteId || def.isRouteParameter) {
6066
- if (routeParameterKeys.includes(def.name)) {
6067
- params[def.name] = routeParams[def.name];
6068
- }
6069
- }
6070
- else {
6071
- // copy non route params as is, but only if they already exist otherwise we'll inject nil values and break the
6072
- // defaults and remember sanitisation process.
6073
- const value = this.getParameter(def.name);
6074
- if (this.hasParameter(def.name)) {
6075
- params[def.name] = value;
6076
- }
6077
- }
6078
- });
6079
- return new Visit(this.placeDefinition, params);
6080
- }
6081
- hasRoutingChangedFrom(other) {
6082
- const samePlace = other.placeDefinition === this.placeDefinition;
6083
- const sameRouteParameters = isEqual(this.placeDefinition.getFormattedRouteParameters(this, true), this.placeDefinition.getFormattedRouteParameters(other, true));
6084
- return !samePlace || !sameRouteParameters;
6085
- }
6086
- hasChangedFrom(other) {
6087
- const sameNonRouteParameters = isEqual(this.placeDefinition.getNonRouteParameters(this), this.placeDefinition.getNonRouteParameters(other));
6088
- return !sameNonRouteParameters || this.hasRoutingChangedFrom(other);
6089
- }
6090
- toDebugString() {
6091
- return Object.keys(this.visitParameters).map(k => `${k}=${this.visitParameters[k]}`).join(",");
6092
- }
6093
- }
6094
-
6095
- const AUP_PLACE_CONFIG = new InjectionToken('AUP_PLACE_CONFIG');
6096
-
6097
6114
  // Freezes the state of the components at the start of the animation.
6098
6115
  const animationStartStyle = style({ position: 'absolute', top: '0', left: '0', bottom: '0', right: '0' });
6099
6116
  const left = [
@@ -6349,11 +6366,13 @@ __decorate([
6349
6366
  ], PlaceOutletComponent.prototype, "onOutletDeactivated", null);
6350
6367
 
6351
6368
  class AbstractPlaceNavigationComponent extends DisposableComponent {
6352
- constructor(placeRouter) {
6369
+ constructor(authService) {
6353
6370
  super();
6354
6371
  this._activePlaceComponent = new DelegatingValueModel();
6355
6372
  const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);
6356
- this.placeDefinitions = chain(this.placesModel).map(c => PlaceComponent.getDefinition(c));
6373
+ this.placeDefinitions = chain(this.placesModel)
6374
+ .map(c => PlaceComponent.getDefinition(c))
6375
+ .select(d => authService.authoriserModel.value(d), { dependsOn: authService.authoriserModel });
6357
6376
  this.commandFactory = Command.createFactory((placeDefinition) => {
6358
6377
  this.placeOutlet.navigate(new Visit(placeDefinition));
6359
6378
  });
@@ -6385,7 +6404,7 @@ AbstractPlaceNavigationComponent.decorators = [
6385
6404
  },] }
6386
6405
  ];
6387
6406
  AbstractPlaceNavigationComponent.ctorParameters = () => [
6388
- { type: PlaceRouter }
6407
+ { type: undefined, decorators: [{ type: Inject, args: [PLACE_AUTH_SERVICE,] }] }
6389
6408
  ];
6390
6409
  AbstractPlaceNavigationComponent.propDecorators = {
6391
6410
  places: [{ type: Input }],
@@ -6463,19 +6482,19 @@ EmptyStateComponent.decorators = [
6463
6482
  EmptyStateComponent.ctorParameters = () => [];
6464
6483
 
6465
6484
  class ListPlaceNavComponent extends AbstractPlaceNavigationComponent {
6466
- constructor(placeRouter) {
6467
- super(placeRouter);
6485
+ constructor(authService) {
6486
+ super(authService);
6468
6487
  }
6469
6488
  }
6470
6489
  ListPlaceNavComponent.decorators = [
6471
6490
  { type: Component, args: [{
6472
6491
  selector: 'aup-list-place-nav',
6473
6492
  template: "<mat-nav-list fxFlex>\n <a mat-list-item *ngFor=\"let placeDefinition of placeDefinitions.value\"\n [pectinCommand]=\"commandFactory.create(placeDefinition)\"\n [class.active]=\"isActive(placeDefinition)\"\n [matTooltip]=\"getNavigationFace(placeDefinition).tooltip()\">\n <aup-command-face [faces]=\"[getNavigationFace(placeDefinition)]\"></aup-command-face>\n </a>\n</mat-nav-list>\n",
6474
- styles: [":host{--selected-background:#f1f1f1;--selected-border-color:#838383;--selected-color:inherit;display:flex;flex-direction:column}mat-nav-list{padding-top:0}a.active{background:var(--selected-background);border-right:2px solid var(--selected-border-color);color:var(--selected-color)}"]
6493
+ styles: [":host{--selected-background:#f1f1f1;--selected-border-color:#838383;--selected-color:inherit;display:flex;flex-direction:column}mat-nav-list{padding-top:0}a{border-right:2px solid transparent}a.active{background:var(--selected-background);border-right:2px solid var(--selected-border-color);color:var(--selected-color)}"]
6475
6494
  },] }
6476
6495
  ];
6477
6496
  ListPlaceNavComponent.ctorParameters = () => [
6478
- { type: PlaceRouter }
6497
+ { type: undefined, decorators: [{ type: Inject, args: [PLACE_AUTH_SERVICE,] }] }
6479
6498
  ];
6480
6499
 
6481
6500
  /**
@@ -6521,8 +6540,8 @@ ListPlaceNavComponent.ctorParameters = () => [
6521
6540
  * })
6522
6541
  */
6523
6542
  class SidePlaceNavigationComponent extends AbstractPlaceNavigationComponent {
6524
- constructor(router, placeRouter) {
6525
- super(placeRouter);
6543
+ constructor(router, authService) {
6544
+ super(authService);
6526
6545
  this.router = router;
6527
6546
  this.expanded = false;
6528
6547
  }
@@ -6545,7 +6564,7 @@ SidePlaceNavigationComponent.decorators = [
6545
6564
  ];
6546
6565
  SidePlaceNavigationComponent.ctorParameters = () => [
6547
6566
  { type: Router },
6548
- { type: PlaceRouter }
6567
+ { type: undefined, decorators: [{ type: Inject, args: [PLACE_AUTH_SERVICE,] }] }
6549
6568
  ];
6550
6569
  SidePlaceNavigationComponent.propDecorators = {
6551
6570
  expanded: [{ type: HostBinding, args: ['class.expanded',] }],
@@ -6553,8 +6572,8 @@ SidePlaceNavigationComponent.propDecorators = {
6553
6572
  };
6554
6573
 
6555
6574
  class TabbedPlaceNavigationComponent extends AbstractPlaceNavigationComponent {
6556
- constructor(placeRouter) {
6557
- super(placeRouter);
6575
+ constructor(authService) {
6576
+ super(authService);
6558
6577
  }
6559
6578
  }
6560
6579
  TabbedPlaceNavigationComponent.decorators = [
@@ -6565,7 +6584,7 @@ TabbedPlaceNavigationComponent.decorators = [
6565
6584
  },] }
6566
6585
  ];
6567
6586
  TabbedPlaceNavigationComponent.ctorParameters = () => [
6568
- { type: PlaceRouter }
6587
+ { type: undefined, decorators: [{ type: Inject, args: [PLACE_AUTH_SERVICE,] }] }
6569
6588
  ];
6570
6589
 
6571
6590
  class PlaceModule {
@@ -6758,7 +6777,7 @@ DialogInteractionContextFactory.ctorParameters = () => [
6758
6777
  function Place(options) {
6759
6778
  return (target) => {
6760
6779
  if (PlaceComponent.isPlaceComponentConstructor(target)) {
6761
- PlaceComponent.injectDefinition(target, new PlaceDefinition(target, options.path, isNil(options.authenticate) ? true : options.authenticate, options.data, PlaceComponent.getRouteParameters(target), (options.children || []).map(c => PlaceComponent.getDefinition(c))));
6780
+ PlaceComponent.injectDefinition(target, new PlaceDefinition(target, options.path, isNil(options.authenticate) ? true : options.authenticate, isNil(options.roles) ? [] : options.roles, options.data, PlaceComponent.getRouteParameters(target), (options.children || []).map(c => PlaceComponent.getDefinition(c))));
6762
6781
  }
6763
6782
  else {
6764
6783
  lang.illegalState(`${target} must extend PlaceComponent to use the @Place decorator`);
@@ -6875,20 +6894,27 @@ class VisitSanitiser {
6875
6894
  }
6876
6895
 
6877
6896
  class PlaceGuard {
6878
- constructor(router, urlService, placeRouter, placeHistory, interactionService, injector) {
6897
+ constructor(router, urlService, placeRouter, placeHistory, placeAuthService, interactionService, injector) {
6879
6898
  this.router = router;
6880
6899
  this.urlService = urlService;
6881
6900
  this.placeRouter = placeRouter;
6882
6901
  this.placeHistory = placeHistory;
6902
+ this.placeAuthService = placeAuthService;
6883
6903
  this.interactionService = interactionService;
6884
6904
  this.injector = injector;
6885
6905
  }
6886
- // @Trace()
6887
6906
  canActivate(activatedRoute, state) {
6888
6907
  return __awaiter(this, void 0, void 0, function* () {
6889
- // TODO: this is ugly now that I'm return UrlSnapshots and not UrlTrees. It'd be better if the functions
6890
- // weren't nested or if I implemented a handler chain.
6891
- return this.authorisePlaceThen(activatedRoute, state, (placeDefinition) => __awaiter(this, void 0, void 0, function* () {
6908
+ if (PlaceComponent.isPlaceComponentConstructor(activatedRoute.component)) {
6909
+ const placeDefinition = PlaceComponent.getDefinition(activatedRoute.component);
6910
+ const needsAuth = placeDefinition.authenticate;
6911
+ const proceed = !needsAuth || (yield this.placeAuthService.isAuthenticated());
6912
+ if (!proceed) {
6913
+ return this.handleGuardResult(this.placeAuthService.handleNotAuthenticated(activatedRoute, state));
6914
+ }
6915
+ if (!this.placeAuthService.isAuthorised(placeDefinition)) {
6916
+ return this.handleGuardResult(this.placeAuthService.handleNotAuthorisation(activatedRoute, state));
6917
+ }
6892
6918
  const result = yield this.cleanInteractionState(activatedRoute, state, () => __awaiter(this, void 0, void 0, function* () {
6893
6919
  // Parse our route params.
6894
6920
  const params = new ConsolidatedParameterMap(activatedRoute.paramMap, activatedRoute.url);
@@ -6909,57 +6935,51 @@ class PlaceGuard {
6909
6935
  return true;
6910
6936
  }
6911
6937
  }));
6912
- return this.handleGuardResult(result);
6913
- }));
6938
+ return result instanceof UrlSnapshot ? result.urlTree : result;
6939
+ }
6940
+ else {
6941
+ return lang.illegalState(`expected component to be an instance of PlaceComponent, got ${activatedRoute.component}`);
6942
+ }
6914
6943
  });
6915
6944
  }
6916
- // @Trace()
6917
6945
  canDeactivate(component, currentRoute, currentState, nextState) {
6918
6946
  return __awaiter(this, void 0, void 0, function* () {
6919
6947
  const currentUrl = this.urlService.parseUrl(currentState.url);
6920
6948
  const nextUrl = this.urlService.parseUrl(nextState.url);
6921
6949
  const result = yield this.placeRouter.navigationSession.canDeactivatePlace(component, currentUrl, nextUrl);
6922
- return this.handleGuardResult(result);
6950
+ return result instanceof UrlSnapshot ? result.urlTree : result;
6923
6951
  });
6924
6952
  }
6925
- // @Trace()
6926
6953
  handleGuardResult(result) {
6927
6954
  if (result instanceof UrlSnapshot) {
6928
6955
  return result.urlTree;
6929
6956
  }
6930
6957
  else {
6931
- return result;
6958
+ return this.urlService.createUrlSnapshot(result).urlTree;
6932
6959
  }
6933
6960
  }
6961
+ // protected async ensureAuthenticatedThen(activatedRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot, next: (placeDefinition: PlaceDefinition) => Promise<boolean | UrlTree>): Promise<boolean | UrlTree> {
6962
+ // const authoriseResult = placeDefinition.authenticate ? await this.isAuthorised(activatedRoute, state) : true;
6963
+ // if (authoriseResult === true) {
6964
+ // // we're authorised, now run the place guards.
6965
+ // return next(placeDefinition);
6966
+ // } else {
6967
+ // console.log('not authorised result', authoriseResult);
6968
+ // return authoriseResult;
6969
+ // }
6970
+ // }
6971
+ //
6972
+ // // @Trace()
6973
+ // protected async ensureAuthorisedThen(activatedRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot, next: (placeDefinition: PlaceDefinition) => Promise<boolean | UrlTree>): Promise<boolean | UrlTree> {
6974
+ //
6975
+ // }
6934
6976
  // @Trace()
6935
- authorisePlaceThen(activatedRoute, state, runPlaceGuards) {
6936
- return __awaiter(this, void 0, void 0, function* () {
6937
- if (PlaceComponent.isPlaceComponentConstructor(activatedRoute.component)) {
6938
- const placeDefinition = PlaceComponent.getDefinition(activatedRoute.component);
6939
- const authoriseResult = placeDefinition.authenticate ? yield this.isAuthorised(activatedRoute, state) : true;
6940
- if (authoriseResult === true) {
6941
- // we're authorised, now run the place guards.
6942
- return runPlaceGuards(placeDefinition);
6943
- }
6944
- else {
6945
- console.log('not authorised result', authoriseResult);
6946
- return authoriseResult;
6947
- }
6948
- }
6949
- else {
6950
- return lang.illegalState(`expected component to be an instance of PlaceComponent, got ${activatedRoute.component}`);
6951
- }
6952
- });
6953
- }
6954
- // @Trace()
6955
- isAuthorised(activatedRoute, state) {
6956
- return __awaiter(this, void 0, void 0, function* () {
6957
- const authorised = this.getAuthGuard(this.injector).canActivate(activatedRoute, state);
6958
- return (authorised instanceof Observable) ? authorised.toPromise() : authorised;
6959
- });
6960
- }
6961
- // @Trace()
6962
- cleanInteractionState(route, state, then) {
6977
+ // async isAuthorised(activatedRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean | UrlTree> {
6978
+ // const authorised = this.getAuthGuard(this.injector).canActivate(activatedRoute, state);
6979
+ // return (authorised instanceof Observable) ? authorised.toPromise() : authorised;
6980
+ // }
6981
+ // abstract getAuthGuard(injector: Injector): CanActivate;
6982
+ cleanInteractionState(route, state, next) {
6963
6983
  return __awaiter(this, void 0, void 0, function* () {
6964
6984
  const url = this.urlService.parseUrl(state.url);
6965
6985
  if (!this.interactionService.isActive() && url.hasInteractions()) {
@@ -6968,11 +6988,48 @@ class PlaceGuard {
6968
6988
  return url.removeInteractionIds();
6969
6989
  }
6970
6990
  else {
6971
- return then();
6991
+ return next();
6972
6992
  }
6973
6993
  });
6974
6994
  }
6975
6995
  }
6996
+ PlaceGuard.ɵprov = ɵɵdefineInjectable({ factory: function PlaceGuard_Factory() { return new PlaceGuard(ɵɵinject(Router), ɵɵinject(UrlService), ɵɵinject(PlaceRouter), ɵɵinject(PlaceHistory), ɵɵinject(PLACE_AUTH_SERVICE), ɵɵinject(InteractionService), ɵɵinject(INJECTOR)); }, token: PlaceGuard, providedIn: "root" });
6997
+ PlaceGuard.decorators = [
6998
+ { type: Injectable, args: [{ providedIn: 'root' },] }
6999
+ ];
7000
+ PlaceGuard.ctorParameters = () => [
7001
+ { type: Router },
7002
+ { type: UrlService },
7003
+ { type: PlaceRouter },
7004
+ { type: PlaceHistory },
7005
+ { type: undefined, decorators: [{ type: Inject, args: [PLACE_AUTH_SERVICE,] }] },
7006
+ { type: InteractionService },
7007
+ { type: Injector }
7008
+ ];
7009
+ __decorate([
7010
+ Trace(),
7011
+ __metadata("design:type", Function),
7012
+ __metadata("design:paramtypes", [ActivatedRouteSnapshot, RouterStateSnapshot]),
7013
+ __metadata("design:returntype", Promise)
7014
+ ], PlaceGuard.prototype, "canActivate", null);
7015
+ __decorate([
7016
+ Trace(),
7017
+ __metadata("design:type", Function),
7018
+ __metadata("design:paramtypes", [PlaceComponent, ActivatedRouteSnapshot, RouterStateSnapshot, RouterStateSnapshot]),
7019
+ __metadata("design:returntype", Promise)
7020
+ ], PlaceGuard.prototype, "canDeactivate", null);
7021
+ __decorate([
7022
+ Trace(),
7023
+ __metadata("design:type", Function),
7024
+ __metadata("design:paramtypes", [Object]),
7025
+ __metadata("design:returntype", void 0)
7026
+ ], PlaceGuard.prototype, "handleGuardResult", null);
7027
+ __decorate([
7028
+ Trace(),
7029
+ __metadata("design:type", Function),
7030
+ __metadata("design:paramtypes", [ActivatedRouteSnapshot, RouterStateSnapshot, Function]),
7031
+ __metadata("design:returntype", Promise)
7032
+ ], PlaceGuard.prototype, "cleanInteractionState", null);
6976
7033
 
6977
7034
  var Formatter;
6978
7035
  (function (Formatter) {
@@ -7074,5 +7131,5 @@ function VisitParameterList(options) {
7074
7131
  * Generated bundle index. Do not edit.
7075
7132
  */
7076
7133
 
7077
- export { ACTIVITY_DATA, AUP_PLACE_CONFIG, AbstractInputActivity, AbstractInputComponent, AbstractInteractionContext, AbstractListInputComponent, AbstractPlaceNavigationComponent, AbstractPopStateNavigation, AbstractValueInputComponent, Activity, ActivityActionsComponent, ActivityContainerComponent, ActivityOutletComponent, ActivityRef, AddItemInteractionContextComponent, AlertDialogComponent, AngularUiPowerupsModule, AutocompleteInputComponent, Bounds, BusyOverlayComponent, CELL_EDITOR_PORTAL, CELL_RENDERER_PORTAL, CardContainerComponent, CellEditorPortalRef, CellHeaderPortalRef, CellPortalRef, CellRendererPortalRef, CheckboxInputComponent, ColumnModel, ColumnTemplateDirective, CommandComponent, CommandDirective, CommandFace, CommandFaceComponent, CommandGroup, CommandGroupComponent, CommandGroupMenuRendererComponent, CommandGroupRendererComponent, ComponentCellRendererPortalRef, ComponentsModule, ConfirmThenDialogComponent, ConfirmationDialogComponent, ConsolidatedParameterMap, CustomTemplateColumnModel, CustomValueColumnModel, DEFINITION_META_DATA_KEY, DIALOG_INTERACTION_SERVICE_DEFAULTS, DefaultCellRendererComponent, DefaultHeaderCellRendererComponent, DialogInteractionContext, DialogInteractionContextFactory, Dimension, DirectivesModule, DisposableComponent, EditRowControls, EditSession, EditorControlColumnModel, EmptyStateComponent, EventCleanUpSession, FlexComponent, FocusBinding, FocusBindingDirective, FocusBindingFactory, FocusContainerComponent, FocusableComponent, Formatter, HEADER_CELL_RENDERER_PORTAL, IconComponent, InPlaceInteractionContextComponent, InteractionContextTriggerFor, InteractionModule, InteractionService, InteractionServiceRoutingAdapter, LEFT_RIGHT_PLACE_ANIMATION, ListPlaceNavComponent, ListPropertyColumnModel, ModalInteractionContextFactory, MoreMenuComponent, MultipleSelectInputComponent, Navigating, NavigatingDuringInteraction, NavigationContext, NavigationSession, NoopAuthGuard, NoopComponent, NumberInputComponent, PORTAL_EDITOR_COMPONENT, PORTAL_RENDERER_COMPONENT, ParameterDefinition, PasswordInputComponent, Place, PlaceComponent, PlaceComponentDeactivationHandler, PlaceDefinition, PlaceGuard, PlaceHistory, PlaceModule, PlaceOutletComponent, PlaceRouter, Point, PopStateDuringInteractionNavigation, PopStateNavigation, PopupInteractionContextComponent, PopupMenuComponent, PropertyColumnModel, ROUTE_PARAMETER_LIST_KEY, Registration, RemoveLastInteractionFromUrlNavigationSession, ResizeAwareComponent, RouteId, ScrollContainerComponent, SectionHeaderComponent, SelectCellRendererComponent, SelectHeaderCellRendererComponent, SelectInputActivity, SelectInputComponent, SelectionColumnModel, SeparatorComponent, SidePlaceNavigationComponent, StringInputActivity, StringInputComponent, SwitchCaseComponent, SwitchCaseDefaultDirective, SwitchCaseOption, SwitchCaseWhenDirective, SynchroniseInteractionContextIdsWithRoute, TabbedPlaceNavigationComponent, TableCellRendererComponent, TableComponent, TableHeaderCellRendererComponent, TableModel, TableRowMenuComponent, TemplateCellRendererPortalRef, TextInputComponent, ToolBarComponent, TrackBy, UrlService, UrlSnapshot, VerticalFocusContainerComponent, ViewData, Visit, VisitParameter, VisitParameterList, VisitSanitiser, WaitUntilLeavingInteractionTransitionCancelled, WaitUntilLinkTriggeredNavigationInteractionCancellationTypeDetermined, WaitUntilPopStateDuringCanDeactivateInteractionFinishes, leftRightPlaceAnimation, slideDownOnEnterAnimation, slideRightOnEnterAnimation, ɵ0 };
7134
+ export { ACTIVITY_DATA, AUP_PLACE_CONFIG, AbstractInputActivity, AbstractInputComponent, AbstractInteractionContext, AbstractListInputComponent, AbstractPlaceNavigationComponent, AbstractPopStateNavigation, AbstractValueInputComponent, Activity, ActivityActionsComponent, ActivityContainerComponent, ActivityOutletComponent, ActivityRef, AddItemInteractionContextComponent, AlertDialogComponent, AngularUiPowerupsModule, AutocompleteInputComponent, Bounds, BusyOverlayComponent, CELL_EDITOR_PORTAL, CELL_RENDERER_PORTAL, CardContainerComponent, CellEditorPortalRef, CellHeaderPortalRef, CellPortalRef, CellRendererPortalRef, CheckboxInputComponent, ColumnModel, ColumnTemplateDirective, CommandComponent, CommandDirective, CommandFace, CommandFaceComponent, CommandGroup, CommandGroupComponent, CommandGroupMenuRendererComponent, CommandGroupRendererComponent, ComponentCellRendererPortalRef, ComponentsModule, ConfirmThenDialogComponent, ConfirmationDialogComponent, ConsolidatedParameterMap, CustomTemplateColumnModel, CustomValueColumnModel, DEFINITION_META_DATA_KEY, DIALOG_INTERACTION_SERVICE_DEFAULTS, DefaultCellRendererComponent, DefaultHeaderCellRendererComponent, DialogInteractionContext, DialogInteractionContextFactory, Dimension, DirectivesModule, DisposableComponent, EditRowControls, EditSession, EditorControlColumnModel, EmptyStateComponent, EventCleanUpSession, FlexComponent, FocusBinding, FocusBindingDirective, FocusBindingFactory, FocusContainerComponent, FocusableComponent, Formatter, HEADER_CELL_RENDERER_PORTAL, IconComponent, InPlaceInteractionContextComponent, InteractionContextTriggerFor, InteractionModule, InteractionService, InteractionServiceRoutingAdapter, LEFT_RIGHT_PLACE_ANIMATION, ListPlaceNavComponent, ListPropertyColumnModel, ModalInteractionContextFactory, MoreMenuComponent, MultipleSelectInputComponent, Navigating, NavigatingDuringInteraction, NavigationContext, NavigationSession, NoopAuthGuard, NoopComponent, NumberInputComponent, PLACE_AUTH_SERVICE, PORTAL_EDITOR_COMPONENT, PORTAL_RENDERER_COMPONENT, ParameterDefinition, PasswordInputComponent, Place, PlaceComponent, PlaceComponentDeactivationHandler, PlaceDefinition, PlaceGuard, PlaceHistory, PlaceModule, PlaceOutletComponent, PlaceRouter, Point, PopStateDuringInteractionNavigation, PopStateNavigation, PopupInteractionContextComponent, PopupMenuComponent, PropertyColumnModel, ROUTE_PARAMETER_LIST_KEY, Registration, RemoveLastInteractionFromUrlNavigationSession, ResizeAwareComponent, RouteId, ScrollContainerComponent, SectionHeaderComponent, SelectCellRendererComponent, SelectHeaderCellRendererComponent, SelectInputActivity, SelectInputComponent, SelectionColumnModel, SeparatorComponent, SidePlaceNavigationComponent, StringInputActivity, StringInputComponent, SwitchCaseComponent, SwitchCaseDefaultDirective, SwitchCaseOption, SwitchCaseWhenDirective, SynchroniseInteractionContextIdsWithRoute, TabbedPlaceNavigationComponent, TableCellRendererComponent, TableComponent, TableHeaderCellRendererComponent, TableModel, TableRowMenuComponent, TemplateCellRendererPortalRef, TextInputComponent, ToolBarComponent, TrackBy, UrlService, UrlSnapshot, VerticalFocusContainerComponent, ViewData, Visit, VisitParameter, VisitParameterList, VisitSanitiser, WaitUntilLeavingInteractionTransitionCancelled, WaitUntilLinkTriggeredNavigationInteractionCancellationTypeDetermined, WaitUntilPopStateDuringCanDeactivateInteractionFinishes, leftRightPlaceAnimation, slideDownOnEnterAnimation, slideRightOnEnterAnimation, ɵ0 };
7078
7135
  //# sourceMappingURL=coolon-angular-ui-powerups.js.map