@coolon/angular-ui-powerups 12.3.1 → 12.4.0-alpha.1

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 (113) hide show
  1. package/bundles/coolon-angular-ui-powerups-cypress.umd.js +299 -93
  2. package/bundles/coolon-angular-ui-powerups-cypress.umd.js.map +1 -1
  3. package/bundles/coolon-angular-ui-powerups.umd.js +315 -200
  4. package/bundles/coolon-angular-ui-powerups.umd.js.map +1 -1
  5. package/coolon-angular-ui-powerups.metadata.json +1 -1
  6. package/cypress/components/aup-command-face.d.ts +2 -5
  7. package/cypress/components/aup-command.d.ts +18 -4
  8. package/cypress/components/aup-navigation.d.ts +0 -1
  9. package/cypress/components/aup-popup-menu.d.ts +2 -0
  10. package/cypress/components/aup-table.d.ts +19 -0
  11. package/cypress/components/button-mixin.d.ts +17 -0
  12. package/cypress/components/button.d.ts +17 -3
  13. package/cypress/coolon-angular-ui-powerups-cypress.d.ts +1 -0
  14. package/cypress/coolon-angular-ui-powerups-cypress.metadata.json +1 -1
  15. package/cypress/exports.d.ts +3 -0
  16. package/cypress/page-element.d.ts +11 -2
  17. package/cypress/page.d.ts +20 -13
  18. package/cypress/path.d.ts +26 -0
  19. package/cypress/section.d.ts +8 -1
  20. package/esm2015/cypress/components/aup-command-face.js +20 -11
  21. package/esm2015/cypress/components/aup-command-face.js.map +1 -1
  22. package/esm2015/cypress/components/aup-command-face.metadata.json +1 -1
  23. package/esm2015/cypress/components/aup-command.js +10 -7
  24. package/esm2015/cypress/components/aup-command.js.map +1 -1
  25. package/esm2015/cypress/components/aup-command.metadata.json +1 -1
  26. package/esm2015/cypress/components/aup-more-menu.js +1 -2
  27. package/esm2015/cypress/components/aup-more-menu.js.map +1 -1
  28. package/esm2015/cypress/components/aup-more-menu.metadata.json +1 -1
  29. package/esm2015/cypress/components/aup-navigation.js +1 -5
  30. package/esm2015/cypress/components/aup-navigation.js.map +1 -1
  31. package/esm2015/cypress/components/aup-popup-menu.js +12 -3
  32. package/esm2015/cypress/components/aup-popup-menu.js.map +1 -1
  33. package/esm2015/cypress/components/aup-popup-menu.metadata.json +1 -1
  34. package/esm2015/cypress/components/aup-table.js +36 -0
  35. package/esm2015/cypress/components/aup-table.js.map +1 -0
  36. package/esm2015/cypress/components/aup-table.metadata.json +1 -0
  37. package/esm2015/cypress/components/button-mixin.js +15 -0
  38. package/esm2015/cypress/components/button-mixin.js.map +1 -0
  39. package/esm2015/cypress/components/button-mixin.metadata.json +1 -0
  40. package/esm2015/cypress/components/button.js +11 -7
  41. package/esm2015/cypress/components/button.js.map +1 -1
  42. package/esm2015/cypress/components/button.metadata.json +1 -1
  43. package/esm2015/cypress/coolon-angular-ui-powerups-cypress.js.map +1 -1
  44. package/esm2015/cypress/coolon-angular-ui-powerups-cypress.metadata.json +1 -1
  45. package/esm2015/cypress/exports.js +3 -0
  46. package/esm2015/cypress/exports.js.map +1 -1
  47. package/esm2015/cypress/exports.metadata.json +1 -1
  48. package/esm2015/cypress/page-element.js +21 -5
  49. package/esm2015/cypress/page-element.js.map +1 -1
  50. package/esm2015/cypress/page-element.metadata.json +1 -1
  51. package/esm2015/cypress/page.js +34 -22
  52. package/esm2015/cypress/page.js.map +1 -1
  53. package/esm2015/cypress/page.metadata.json +1 -1
  54. package/esm2015/cypress/path.js +61 -0
  55. package/esm2015/cypress/path.js.map +1 -0
  56. package/esm2015/cypress/path.metadata.json +1 -0
  57. package/esm2015/cypress/section.js +20 -10
  58. package/esm2015/cypress/section.js.map +1 -1
  59. package/esm2015/lib/components/switch-case/switch-case.component.js +7 -0
  60. package/esm2015/lib/components/switch-case/switch-case.component.js.map +1 -1
  61. package/esm2015/lib/components/switch-case/switch-case.component.metadata.json +1 -1
  62. package/esm2015/lib/components/tables/table/table.component.js +1 -1
  63. package/esm2015/lib/components/tables/table/table.component.js.map +1 -1
  64. package/esm2015/lib/components/tables/table/table.component.metadata.json +1 -1
  65. package/esm2015/lib/components/tables/tree-table/tree-table-component.js +1 -1
  66. package/esm2015/lib/components/tables/tree-table/tree-table-component.js.map +1 -1
  67. package/esm2015/lib/components/tables/tree-table/tree-table-component.metadata.json +1 -1
  68. package/esm2015/lib/place/components/place-outlet/place-outlet.component.js.map +1 -1
  69. package/esm2015/lib/place/components/place-outlet/place-outlet.component.metadata.json +1 -1
  70. package/esm2015/lib/place/guards/consolidated-param-map.js +7 -2
  71. package/esm2015/lib/place/guards/consolidated-param-map.js.map +1 -1
  72. package/esm2015/lib/place/guards/consolidated-param-map.metadata.json +1 -1
  73. package/esm2015/lib/place/guards/place.guard.js +1 -22
  74. package/esm2015/lib/place/guards/place.guard.js.map +1 -1
  75. package/esm2015/lib/place/navigation/place-component-deactivation-handler.js +15 -11
  76. package/esm2015/lib/place/navigation/place-component-deactivation-handler.js.map +1 -1
  77. package/esm2015/lib/place/navigation/place-component-deactivation-handler.metadata.json +1 -1
  78. package/esm2015/lib/place/navigation/session/interactions/synchronise-interaction-context-ids-with-route.js.map +1 -1
  79. package/esm2015/lib/place/navigation/session/interactions/synchronise-interaction-context-ids-with-route.metadata.json +1 -1
  80. package/esm2015/lib/place/place-component.js +67 -5
  81. package/esm2015/lib/place/place-component.js.map +1 -1
  82. package/esm2015/lib/place/place-component.metadata.json +1 -1
  83. package/esm2015/lib/place/place-definition.js +3 -3
  84. package/esm2015/lib/place/place-definition.js.map +1 -1
  85. package/esm2015/lib/place/place-router.js +9 -4
  86. package/esm2015/lib/place/place-router.js.map +1 -1
  87. package/esm2015/lib/place/place-router.metadata.json +1 -1
  88. package/esm2015/lib/place/route/parameter-decorators.js +13 -14
  89. package/esm2015/lib/place/route/parameter-decorators.js.map +1 -1
  90. package/esm2015/lib/place/route/parameter-decorators.metadata.json +1 -1
  91. package/esm2015/lib/place/route/parameter-definition.js +21 -3
  92. package/esm2015/lib/place/route/parameter-definition.js.map +1 -1
  93. package/esm2015/lib/place/route/parameter-definition.metadata.json +1 -1
  94. package/esm2015/lib/place/route/visit-sanitiser.js +1 -1
  95. package/esm2015/lib/place/route/visit-sanitiser.js.map +1 -1
  96. package/esm2015/lib/place/url-snapshot.js +30 -7
  97. package/esm2015/lib/place/url-snapshot.js.map +1 -1
  98. package/esm2015/lib/place/url-snapshot.metadata.json +1 -1
  99. package/esm2015/lib/place/visit.js +7 -7
  100. package/esm2015/lib/place/visit.js.map +1 -1
  101. package/esm2015/lib/place/visit.metadata.json +1 -1
  102. package/fesm2015/coolon-angular-ui-powerups-cypress.js +237 -74
  103. package/fesm2015/coolon-angular-ui-powerups-cypress.js.map +1 -1
  104. package/fesm2015/coolon-angular-ui-powerups.js +275 -180
  105. package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
  106. package/lib/components/switch-case/switch-case.component.d.ts +7 -0
  107. package/lib/place/guards/consolidated-param-map.d.ts +2 -2
  108. package/lib/place/navigation/place-component-deactivation-handler.d.ts +3 -1
  109. package/lib/place/place-component.d.ts +26 -3
  110. package/lib/place/route/parameter-definition.d.ts +8 -0
  111. package/lib/place/url-snapshot.d.ts +1 -0
  112. package/lib/place/visit.d.ts +4 -4
  113. package/package.json +1 -1
@@ -2394,6 +2394,13 @@
2394
2394
  SwitchCaseDefaultDirective.ctorParameters = function () { return [
2395
2395
  { type: i0.TemplateRef }
2396
2396
  ]; };
2397
+ /**
2398
+ * @example
2399
+ * <aup-switch-case [switchModel]="booleanModel">
2400
+ * <div *aupSwitchCaseWhen="true"></div>
2401
+ * <div *aupSwitchCaseDefault>The default content</div>
2402
+ * </aup-switch-case>
2403
+ */
2397
2404
  var SwitchCaseComponent = /** @class */ (function (_super) {
2398
2405
  __extends(SwitchCaseComponent, _super);
2399
2406
  function SwitchCaseComponent(cdr) {
@@ -3886,7 +3893,7 @@
3886
3893
  TableComponent.decorators = [
3887
3894
  { type: i0.Component, args: [{
3888
3895
  selector: 'aup-table',
3889
- template: "<div class=\"scroll-container\">\n <table mat-table [dataSource]=\"getModel().dataSource.value\" [trackBy]=\"getModel().trackBy\">\n\n <ng-container *ngFor=\"let column of columns.value; index as index; first as first; last as last\"\n matColumnDef=\"{{column.columnId}}\">\n <th mat-header-cell *matHeaderCellDef [class.flex]=\"column.isFlex()\" [class.hide]=\"!column.isVisible()\">\n <aup-table-header-cell-renderer [column]=\"column\"\n [attr.column-index]=\"index\"\n [attr.column-id]=\"column.columnId\"\n [class]=\"getColumnClasses(column.columnId)\"\n ></aup-table-header-cell-renderer>\n </th>\n <td mat-cell *matCellDef=\"let row\" (click)=\"notifyCellClicked(column, row)\"\n [class.enable-cursor]=\"getModel().isCursorEnabled(column)\"\n [class.flex]=\"column.isFlex()\"\n [class.hide]=\"!column.isVisible()\"\n >\n <aup-table-cell-renderer [column]=\"column\"\n [row]=\"row\"\n [tableModel]=\"getModel()\"\n [editSession]=\"getModel().getEditSessionFor(row)\"\n [attr.column-index]=\"index\"\n [attr.column-id]=\"column.columnId\"\n [class]=\"getColumnClasses(column.columnId)\"\n ></aup-table-cell-renderer>\n </td>\n </ng-container>\n\n <tr mat-header-row *matHeaderRowDef=\"columnIds.value\"></tr>\n <tr mat-row *matRowDef=\"let row; columns: columnIds.value; let i = index\"\n [ngClass]=\"getModel().getRowClasses(row)\" [class.enable-hover]=\"getModel().isHoverEnabled()\"\n [attr.trackBy]=\"getModel().trackBy(i, row)\"\n ></tr>\n\n </table>\n</div>\n",
3896
+ template: "<div class=\"scroll-container\">\n <table mat-table [dataSource]=\"getModel().dataSource.value\" [trackBy]=\"getModel().trackBy\">\n\n <ng-container *ngFor=\"let column of columns.value; index as index; first as first; last as last\"\n matColumnDef=\"{{column.columnId}}\">\n <th mat-header-cell *matHeaderCellDef [class.flex]=\"column.isFlex()\" [class.hide]=\"!column.isVisible()\">\n <aup-table-header-cell-renderer [column]=\"column\"\n [attr.column-index]=\"index\"\n [attr.column-id]=\"column.columnId\"\n [class]=\"getColumnClasses(column.columnId)\"\n ></aup-table-header-cell-renderer>\n </th>\n <td mat-cell *matCellDef=\"let row\" (click)=\"notifyCellClicked(column, row)\"\n [class.enable-cursor]=\"getModel().isCursorEnabled(column)\"\n [class.flex]=\"column.isFlex()\"\n [class.hide]=\"!column.isVisible()\"\n >\n <aup-table-cell-renderer [column]=\"column\"\n [row]=\"row\"\n [tableModel]=\"getModel()\"\n [editSession]=\"getModel().getEditSessionFor(row)\"\n [attr.column-index]=\"index\"\n [attr.column-id]=\"column.columnId\"\n [class]=\"getColumnClasses(column.columnId)\"\n ></aup-table-cell-renderer>\n </td>\n </ng-container>\n\n <tr mat-header-row *matHeaderRowDef=\"columnIds.value\"></tr>\n <tr mat-row *matRowDef=\"let row; columns: columnIds.value; let i = index\"\n [ngClass]=\"getModel().getRowClasses(row)\" [class.enable-hover]=\"getModel().isHoverEnabled()\"\n [attr.aup-row-id]=\"getModel().trackBy(i, row)\"\n ></tr>\n\n </table>\n</div>\n",
3890
3897
  providers: [
3891
3898
  { provide: AbstractTableComponent, useExisting: TableComponent }
3892
3899
  ],
@@ -4538,7 +4545,7 @@
4538
4545
  TreeTableComponent.decorators = [
4539
4546
  { type: i0.Component, args: [{
4540
4547
  selector: 'aup-tree-table',
4541
- template: "<div class=\"scroll-container\">\n <table mat-table [dataSource]=\"getModel().dataSource.value\" [trackBy]=\"getModel().trackBy\">\n\n <ng-container *ngFor=\"let column of columns.value; index as index; first as first; last as last\"\n matColumnDef=\"{{column.columnId}}\">\n <th mat-header-cell *matHeaderCellDef [class.flex]=\"column.isFlex()\" [class.hide]=\"!column.isVisible()\">\n <aup-table-header-cell-renderer [column]=\"column\"\n [attr.column-index]=\"index\"\n [attr.column-id]=\"column.columnId\"\n [class]=\"getColumnClasses(column.columnId)\"\n ></aup-table-header-cell-renderer>\n </th>\n <td mat-cell *matCellDef=\"let row\" (click)=\"notifyCellClicked(column, row)\"\n [class.enable-cursor]=\"getModel().isCursorEnabled(column)\"\n [class.flex]=\"column.isFlex()\"\n [class.hide]=\"!column.isVisible()\"\n >\n <aup-table-cell-renderer [column]=\"column\"\n [row]=\"row\"\n [tableModel]=\"getModel()\"\n [editSession]=\"getModel().getEditSessionFor(row)\"\n [attr.column-index]=\"index\"\n [attr.column-id]=\"column.columnId\"\n [class]=\"getColumnClasses(column.columnId)\"\n ></aup-table-cell-renderer>\n </td>\n </ng-container>\n\n <tr mat-header-row *matHeaderRowDef=\"columnIds.value\"></tr>\n <tr mat-row *matRowDef=\"let row; columns: columnIds.value; let i = index\"\n [ngClass]=\"getModel().getRowClasses(row)\" [class.enable-hover]=\"getModel().isHoverEnabled()\"\n [attr.trackBy]=\"getModel().trackBy(i, row)\"\n ></tr>\n\n </table>\n</div>\n",
4548
+ template: "<div class=\"scroll-container\">\n <table mat-table [dataSource]=\"getModel().dataSource.value\" [trackBy]=\"getModel().trackBy\">\n\n <ng-container *ngFor=\"let column of columns.value; index as index; first as first; last as last\"\n matColumnDef=\"{{column.columnId}}\">\n <th mat-header-cell *matHeaderCellDef [class.flex]=\"column.isFlex()\" [class.hide]=\"!column.isVisible()\">\n <aup-table-header-cell-renderer [column]=\"column\"\n [attr.column-index]=\"index\"\n [attr.column-id]=\"column.columnId\"\n [class]=\"getColumnClasses(column.columnId)\"\n ></aup-table-header-cell-renderer>\n </th>\n <td mat-cell *matCellDef=\"let row\" (click)=\"notifyCellClicked(column, row)\"\n [class.enable-cursor]=\"getModel().isCursorEnabled(column)\"\n [class.flex]=\"column.isFlex()\"\n [class.hide]=\"!column.isVisible()\"\n >\n <aup-table-cell-renderer [column]=\"column\"\n [row]=\"row\"\n [tableModel]=\"getModel()\"\n [editSession]=\"getModel().getEditSessionFor(row)\"\n [attr.column-index]=\"index\"\n [attr.column-id]=\"column.columnId\"\n [class]=\"getColumnClasses(column.columnId)\"\n ></aup-table-cell-renderer>\n </td>\n </ng-container>\n\n <tr mat-header-row *matHeaderRowDef=\"columnIds.value\"></tr>\n <tr mat-row *matRowDef=\"let row; columns: columnIds.value; let i = index\"\n [ngClass]=\"getModel().getRowClasses(row)\" [class.enable-hover]=\"getModel().isHoverEnabled()\"\n [attr.aup-row-id]=\"getModel().trackBy(i, row)\"\n ></tr>\n\n </table>\n</div>\n",
4542
4549
  providers: [
4543
4550
  { provide: AbstractTableComponent, useExisting: TreeTableComponent }
4544
4551
  ],
@@ -6525,6 +6532,7 @@
6525
6532
  },] }
6526
6533
  ];
6527
6534
 
6535
+ var PARAMETER_DEFINITION_KEY = Symbol("parameterDefinition");
6528
6536
  exports.ParameterDefinition = /** @class */ (function () {
6529
6537
  function ParameterDefinition(propertyName, options, urlFormat) {
6530
6538
  this.propertyName = propertyName;
@@ -6548,6 +6556,11 @@
6548
6556
  enumerable: false,
6549
6557
  configurable: true
6550
6558
  });
6559
+ ParameterDefinition.prototype.createBackingModel = function () {
6560
+ var model = this.backingModelFactory();
6561
+ model[PARAMETER_DEFINITION_KEY] = this;
6562
+ return model;
6563
+ };
6551
6564
  ParameterDefinition.prototype.getOptionValue = function (key) {
6552
6565
  return this.options.getOptional(key, null);
6553
6566
  };
@@ -6561,7 +6574,7 @@
6561
6574
  if (returningFromSomewhereElse) {
6562
6575
  lastKnownVisit = placeHistory.getMostRecentVisitFor(visit.placeDefinition);
6563
6576
  if (this.remember && lastKnownVisit) {
6564
- value = lastKnownVisit.getParameter(this.name);
6577
+ value = lastKnownVisit.getParameterValue(this);
6565
6578
  }
6566
6579
  return [2 /*return*/, this.isEmptyValue(value) ? this.defaultValue : value];
6567
6580
  }
@@ -6572,7 +6585,7 @@
6572
6585
  });
6573
6586
  };
6574
6587
  ParameterDefinition.prototype.isMissingFrom = function (visit) {
6575
- return !visit.hasParameter(this.name);
6588
+ return !visit.hasParameter(this);
6576
6589
  };
6577
6590
  return ParameterDefinition;
6578
6591
  }());
@@ -6583,6 +6596,7 @@
6583
6596
  var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
6584
6597
  _this.isRouteId = true;
6585
6598
  _this.isArray = false;
6599
+ _this.backingModelFactory = function () { return new pectin.MutableValueModel(); };
6586
6600
  return _this;
6587
6601
  }
6588
6602
  RouteId.prototype.isEmptyValue = function (value) {
@@ -6600,6 +6614,7 @@
6600
6614
  var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
6601
6615
  _this.isRouteId = false;
6602
6616
  _this.isArray = false;
6617
+ _this.backingModelFactory = function () { return new pectin.MutableValueModel(); };
6603
6618
  return _this;
6604
6619
  }
6605
6620
  ValueParameter.prototype.isEmptyValue = function (value) {
@@ -6617,6 +6632,7 @@
6617
6632
  var _this = _super.call(this, parameterName, options, urlFormat) || this;
6618
6633
  _this.isRouteId = false;
6619
6634
  _this.isArray = true;
6635
+ _this.backingModelFactory = function () { return new pectin.MutableListModel(); };
6620
6636
  return _this;
6621
6637
  }
6622
6638
  ArrayParameter.prototype.isEmptyValue = function (value) {
@@ -6628,6 +6644,14 @@
6628
6644
  return ArrayParameter;
6629
6645
  }(ParameterDefinition));
6630
6646
  ParameterDefinition.ArrayParameter = ArrayParameter;
6647
+ function get(model) {
6648
+ var parameterDefinition = model[PARAMETER_DEFINITION_KEY];
6649
+ if (!parameterDefinition) {
6650
+ typescriptUtilities.lang.illegalArgument("model hasn't been annotated with @VisitParameter, @VisitParameterList or @RouteId");
6651
+ }
6652
+ return parameterDefinition;
6653
+ }
6654
+ ParameterDefinition.get = get;
6631
6655
  })(exports.ParameterDefinition || (exports.ParameterDefinition = {}));
6632
6656
 
6633
6657
  var PlaceDefinition = /** @class */ (function () {
@@ -6679,7 +6703,7 @@
6679
6703
  };
6680
6704
  PlaceDefinition.prototype.getRouteIdFrom = function (visit) {
6681
6705
  var routeIdParameterDef = this.getRouteIdParameterDef();
6682
- return routeIdParameterDef ? visit.getParameter(routeIdParameterDef.name) : null;
6706
+ return routeIdParameterDef ? visit.getParameterValue(routeIdParameterDef) : null;
6683
6707
  };
6684
6708
  PlaceDefinition.prototype.getFormattedRouteId = function (visit) {
6685
6709
  // Note: RouteIds are always present in the url and are just empty strings when not defined. This is
@@ -6695,7 +6719,7 @@
6695
6719
  includeRouteId: includeRouteId,
6696
6720
  includeRouteParameters: true
6697
6721
  }).forEach(function (def) {
6698
- var value = visit.getParameter(def.name);
6722
+ var value = visit.getParameterValue(def);
6699
6723
  if (!def.isEmptyValue(value)) {
6700
6724
  if (def.isArray) {
6701
6725
  pectin.assert.isArray(value);
@@ -6712,7 +6736,7 @@
6712
6736
  PlaceDefinition.prototype.getNonRouteParameters = function (visit) {
6713
6737
  var result = {};
6714
6738
  this.getVisitParameterDefs({ includeNonRouteParameters: true }).forEach(function (def) {
6715
- var value = visit.getParameter(def.name);
6739
+ var value = visit.getParameterValue(def);
6716
6740
  if (!def.isEmptyValue(value)) {
6717
6741
  result[def.name] = value;
6718
6742
  }
@@ -6777,15 +6801,29 @@
6777
6801
  var DEFINITION_META_DATA_KEY = 'PLACE_DEFINITION_OPTIONS';
6778
6802
  // this one seems ok.
6779
6803
  var ROUTE_PARAMETER_LIST_KEY = Symbol('place:route:parameters');
6804
+ var ParameterChangeInterceptor = /** @class */ (function () {
6805
+ function ParameterChangeInterceptor(parameterDef, model, callback, options) {
6806
+ }
6807
+ ParameterChangeInterceptor.prototype.canProceed = function (nextState, interactionContext) {
6808
+ return __awaiter(this, void 0, void 0, function () {
6809
+ return __generator(this, function (_a) {
6810
+ return [2 /*return*/, true];
6811
+ });
6812
+ });
6813
+ };
6814
+ return ParameterChangeInterceptor;
6815
+ }());
6780
6816
  exports.PlaceComponent = /** @class */ (function (_super) {
6781
6817
  __extends(PlaceComponent, _super);
6782
6818
  function PlaceComponent() {
6783
6819
  var _this = _super.call(this) || this;
6820
+ _this._placeReadyCallbacks = [];
6784
6821
  _this.visitModel = new pectin.MutableValueModel();
6785
6822
  _this._inVisitUpdate = new pectin.Guard();
6786
6823
  _this._active = new pectin.MutableValueModel(false);
6824
+ _this._parameterChangeInterceptors = [];
6787
6825
  var _a = pectin.Dsl.disposeWith(_this), chain = _a.chain, valueOf = _a.valueOf, before = _a.before, when = _a.when, after = _a.after, observe = _a.observe, switchOn = _a.switchOn;
6788
- when(_this._active).becomesTruthy(function () { return _this.onPlaceReady(); });
6826
+ when(_this._active).becomesTruthy(function () { return _this._notifyPlaceReady(); });
6789
6827
  _this.childPlaces = _this.placeDefinition.children.map(function (d) { return d.component; });
6790
6828
  return _this;
6791
6829
  }
@@ -6818,7 +6856,7 @@
6818
6856
  pectin.DebugContext.tag(model, this.placeDefinition.component.name + "." + parameterDef.propertyName);
6819
6857
  var binding = this.registerDisposable(new pectin.Binding(this.visitModel, model, {
6820
6858
  toRight: function (visit) {
6821
- var value = visit.getParameter(parameterDef.name);
6859
+ var value = visit.getParameterValue(parameterDef);
6822
6860
  // console.log('push to component', { name: parameterDef.name, value, visit });
6823
6861
  return value;
6824
6862
  },
@@ -6831,7 +6869,11 @@
6831
6869
  };
6832
6870
  Object.defineProperty(PlaceComponent.prototype, "placeDefinition", {
6833
6871
  get: function () {
6834
- return PlaceComponent.getDefinition(this.constructor);
6872
+ var definition = PlaceComponent.getDefinition(this.constructor);
6873
+ if (!definition) {
6874
+ pectin.lang.illegalState(this.constructor.name + " extends PlaceComponent but doesn't have @Place({..}) decorator.");
6875
+ }
6876
+ return definition;
6835
6877
  },
6836
6878
  enumerable: false,
6837
6879
  configurable: true
@@ -6843,13 +6885,74 @@
6843
6885
  enumerable: false,
6844
6886
  configurable: true
6845
6887
  });
6888
+ /**
6889
+ * Called by the router to see if this component can deactivate. This isn't called for route parameter changes.
6890
+ * @param interactionContext
6891
+ */
6892
+ PlaceComponent.prototype._canLeavePlace = function (interactionContext) {
6893
+ return __awaiter(this, void 0, void 0, function () {
6894
+ return __generator(this, function (_a) {
6895
+ return [2 /*return*/, this.canDeactivate ? this.canDeactivate(interactionContext) : true];
6896
+ });
6897
+ });
6898
+ };
6899
+ /**
6900
+ * Called by the router to see if this component can deactivate. This isn't called for route parameter changes.
6901
+ * @param interactionContext
6902
+ * @param nextState
6903
+ */
6904
+ PlaceComponent.prototype._canChangeRouteParameters = function (interactionContext, nextState) {
6905
+ return __awaiter(this, void 0, void 0, function () {
6906
+ var visit, i, interceptor, keepGoing;
6907
+ return __generator(this, function (_a) {
6908
+ switch (_a.label) {
6909
+ case 0:
6910
+ if (!(this._parameterChangeInterceptors.length > 0)) return [3 /*break*/, 4];
6911
+ visit = nextState.createVisitFor(this.placeDefinition);
6912
+ i = 0;
6913
+ _a.label = 1;
6914
+ case 1:
6915
+ if (!(i < this._parameterChangeInterceptors.length)) return [3 /*break*/, 4];
6916
+ interceptor = this._parameterChangeInterceptors[i];
6917
+ return [4 /*yield*/, interceptor.canProceed(visit, interactionContext)];
6918
+ case 2:
6919
+ keepGoing = _a.sent();
6920
+ if (!keepGoing) {
6921
+ return [2 /*return*/, false];
6922
+ }
6923
+ _a.label = 3;
6924
+ case 3:
6925
+ i++;
6926
+ return [3 /*break*/, 1];
6927
+ case 4: return [2 /*return*/, true];
6928
+ }
6929
+ });
6930
+ });
6931
+ };
6846
6932
  /**
6847
6933
  * Called by the router when the place is ready to interact after any animations have run.
6848
6934
  */
6849
6935
  PlaceComponent.prototype._notifyActive = function (active) {
6850
6936
  this._active.value = active;
6851
6937
  };
6852
- PlaceComponent.prototype.onPlaceReady = function () {
6938
+ /**
6939
+ * Called by the router when the place is ready to interact after any animations have run.
6940
+ */
6941
+ PlaceComponent.prototype._notifyPlaceReady = function () {
6942
+ if (this.onPlaceReady.length === 1) {
6943
+ this._placeReadyCallbacks.forEach(function (callback) { return callback(); });
6944
+ }
6945
+ else {
6946
+ console.warn('Overriding PlaceComponent.onPlaceReady has been deprecated. Use PlaceComponent.onPlaceReady(() => {... do stuff...}) instead.');
6947
+ this.onPlaceReady(undefined);
6948
+ }
6949
+ };
6950
+ PlaceComponent.prototype.onPlaceReady = function (callback) {
6951
+ this._placeReadyCallbacks.push(callback);
6952
+ };
6953
+ PlaceComponent.prototype.interceptVisitParameterChange = function (model, callback, options) {
6954
+ var parameterDef = exports.ParameterDefinition.get(model);
6955
+ this._parameterChangeInterceptors.push(new ParameterChangeInterceptor(parameterDef, model, callback, options));
6853
6956
  };
6854
6957
  return PlaceComponent;
6855
6958
  }(DisposableComponent));
@@ -6918,6 +7021,13 @@
6918
7021
  enumerable: false,
6919
7022
  configurable: true
6920
7023
  });
7024
+ Object.defineProperty(PlaceComponentDeactivationHandler.prototype, "placeDefinition", {
7025
+ get: function () {
7026
+ return this.component.placeDefinition;
7027
+ },
7028
+ enumerable: false,
7029
+ configurable: true
7030
+ });
6921
7031
  // @Trace()
6922
7032
  PlaceComponentDeactivationHandler.prototype.canDeactivate = function (currentUrl, nextState) {
6923
7033
  return __awaiter(this, void 0, void 0, function () {
@@ -6936,7 +7046,7 @@
6936
7046
  // @Trace()
6937
7047
  PlaceComponentDeactivationHandler.prototype.canDeactivateComponent = function (currentUrl, nextState) {
6938
7048
  return __awaiter(this, void 0, void 0, function () {
6939
- var routeIds, currentIds;
7049
+ var routeIds, currentIds, canLeave;
6940
7050
  return __generator(this, function (_a) {
6941
7051
  switch (_a.label) {
6942
7052
  case 0:
@@ -6957,27 +7067,26 @@
6957
7067
  _a.sent();
6958
7068
  return [2 /*return*/, false];
6959
7069
  case 5:
6960
- // Ok, so now we're really leaving, so we ask the component if we should.;
6961
- if (this.isNotJustAChangeInRouteId(nextState)) {
6962
- if (this.component.canDeactivate) {
6963
- // No interaction in progress, so ask the component .
6964
- // This may start an interaction, hence checking the interaction context before now. I.e. if the place pops up the dialog, and
6965
- // the user clicks back again, we'll re-enter here and go bang when the component tries to open another dialog.
6966
- return [2 /*return*/, this.component.canDeactivate(this.navigationSession.canDeactivateInteractionContext)];
6967
- }
6968
- // The component has an active interaction but no deactivation hook. Rather than guessing what to do
6969
- // we'll just cancel the navigation and print a warning.
6970
- if (this.routerInteractionAdapter.isComponentInteracting(this.component)) {
6971
- console.warn('Route changed while component has active interaction, cancelling navigation');
6972
- return [2 /*return*/, false];
6973
- }
7070
+ if (!this.isGoingToADifferentPlace(nextState)) return [3 /*break*/, 7];
7071
+ return [4 /*yield*/, this.component._canLeavePlace(this.navigationSession.canDeactivateInteractionContext)];
7072
+ case 6:
7073
+ canLeave = _a.sent();
7074
+ // The component has an active interaction but no deactivation hook. Rather than guessing what to do
7075
+ // we'll just cancel the navigation and print a warning.
7076
+ if (canLeave && this.routerInteractionAdapter.isComponentInteracting(this.component)) {
7077
+ console.warn('Route changed while component has active interaction, cancelling navigation');
7078
+ return [2 /*return*/, false];
6974
7079
  }
6975
- return [2 /*return*/, true];
7080
+ return [2 /*return*/, canLeave];
7081
+ case 7: return [4 /*yield*/, this.component._canChangeRouteParameters(this.navigationSession.canDeactivateInteractionContext, nextState)];
7082
+ case 8:
7083
+ // either an interaction or visit parameter change.
7084
+ return [2 /*return*/, _a.sent()];
6976
7085
  }
6977
7086
  });
6978
7087
  });
6979
7088
  };
6980
- PlaceComponentDeactivationHandler.prototype.isNotJustAChangeInRouteId = function (nextState) {
7089
+ PlaceComponentDeactivationHandler.prototype.isGoingToADifferentPlace = function (nextState) {
6981
7090
  // Because places with a route-id cover two route segments we get asked to deactivate
6982
7091
  // if the route id is added or removed. So if our path is still present the url
6983
7092
  // then we shouldn't deactivate the place.
@@ -7901,6 +8010,141 @@
7901
8010
  // }
7902
8011
  })(exports.PlaceHistory || (exports.PlaceHistory = {}));
7903
8012
 
8013
+ /**
8014
+ * This a work around for the fact that an activated route with multiple segments doesn't
8015
+ * include the segment params in the paramMap as well as each segment returns an empty
8016
+ * param map even when `parameter`s has content.
8017
+ */
8018
+ var ConsolidatedParameterMap = /** @class */ (function () {
8019
+ function ConsolidatedParameterMap(urlSegments, paramMap) {
8020
+ this.paramMaps = [];
8021
+ // TODO: can we get all our params from teh url segments? If so we can drop the paramMap altogether.
8022
+ var segmentParams = (urlSegments || []).map(function (s) { return new ParamMapAdapter(s.parameters); });
8023
+ this.paramMaps = segmentParams
8024
+ .concat(paramMap)
8025
+ .filter(function (m) { return !!m; }); // the activated route param map can be null
8026
+ }
8027
+ ConsolidatedParameterMap.prototype.get = function (name) {
8028
+ var paramMap = this.paramMaps.find(function (m) { return m.has(name); });
8029
+ return paramMap.get(name);
8030
+ };
8031
+ ConsolidatedParameterMap.prototype.getAll = function (name) {
8032
+ var paramMap = this.paramMaps.find(function (m) { return m.has(name); });
8033
+ return paramMap.getAll(name);
8034
+ };
8035
+ ConsolidatedParameterMap.prototype.has = function (name) {
8036
+ return !!this.paramMaps.find(function (m) { return m.has(name); });
8037
+ };
8038
+ Object.defineProperty(ConsolidatedParameterMap.prototype, "keys", {
8039
+ get: function () {
8040
+ return this.paramMaps.reduce(function (result, params) { return result.concat(params.keys); }, []);
8041
+ },
8042
+ enumerable: false,
8043
+ configurable: true
8044
+ });
8045
+ return ConsolidatedParameterMap;
8046
+ }());
8047
+ __decorate([
8048
+ src.Memoize(),
8049
+ __metadata("design:type", Array),
8050
+ __metadata("design:paramtypes", [])
8051
+ ], ConsolidatedParameterMap.prototype, "keys", null);
8052
+ var ParamMapAdapter = /** @class */ (function () {
8053
+ function ParamMapAdapter(params) {
8054
+ this.params = params;
8055
+ }
8056
+ ParamMapAdapter.prototype.get = function (name) {
8057
+ return this.params[name];
8058
+ };
8059
+ ParamMapAdapter.prototype.getAll = function (name) {
8060
+ var value = this.get(name);
8061
+ return Array.isArray(value) ? value : [value];
8062
+ };
8063
+ ParamMapAdapter.prototype.has = function (name) {
8064
+ return this.keys.includes(name);
8065
+ };
8066
+ Object.defineProperty(ParamMapAdapter.prototype, "keys", {
8067
+ get: function () {
8068
+ return Object.keys(this.params);
8069
+ },
8070
+ enumerable: false,
8071
+ configurable: true
8072
+ });
8073
+ return ParamMapAdapter;
8074
+ }());
8075
+
8076
+ var Visit = /** @class */ (function () {
8077
+ function Visit(placeDefinition, visitParameters) {
8078
+ if (visitParameters === void 0) { visitParameters = {}; }
8079
+ this.placeDefinition = placeDefinition;
8080
+ this.visitParameters = visitParameters;
8081
+ }
8082
+ // @Trace()
8083
+ Visit.prototype.getRouteId = function () {
8084
+ return this.placeDefinition.getRouteIdFrom(this);
8085
+ };
8086
+ // @Trace()
8087
+ Visit.prototype.hasRouteId = function () {
8088
+ return !___namespace.isNil(this.getRouteId());
8089
+ };
8090
+ /**
8091
+ * Returns the value of the place parameter with the specified name. The parameter
8092
+ * name is taken from the `as` option, e.g. {as: 'aCustomName'} otherwise it is the
8093
+ * same as the the ValueModel property name.
8094
+ * @param parameterDef the visit parameter definition
8095
+ */
8096
+ Visit.prototype.getParameterValue = function (parameterDef) {
8097
+ return this.visitParameters[parameterDef.name];
8098
+ };
8099
+ // @Trace()
8100
+ Visit.prototype.hasParameter = function (parameterDef) {
8101
+ return Object.keys(this.visitParameters).includes(parameterDef.name);
8102
+ };
8103
+ Visit.prototype.replace = function (parameter, value) {
8104
+ var _a;
8105
+ return new Visit(this.placeDefinition, Object.assign(Object.assign({}, this.visitParameters), (_a = {}, _a[parameter.name] = value, _a)));
8106
+ };
8107
+ Visit.prototype.mergeRouteParameters = function (routeParams) {
8108
+ var _this = this;
8109
+ // todo: whitelist parameters.
8110
+ var routeParameterKeys = Object.keys(routeParams);
8111
+ var params = {};
8112
+ this.placeDefinition.getVisitParameterDefs().forEach(function (def) {
8113
+ if (def.isRouteId || def.isRouteParameter) {
8114
+ if (routeParameterKeys.includes(def.name)) {
8115
+ params[def.name] = routeParams[def.name];
8116
+ }
8117
+ }
8118
+ else {
8119
+ // copy non route params as is, but only if they already exist otherwise we'll inject nil values and break the
8120
+ // defaults and remember sanitisation process.
8121
+ var value = _this.getParameterValue(def);
8122
+ if (_this.hasParameter(def)) {
8123
+ params[def.name] = value;
8124
+ }
8125
+ }
8126
+ });
8127
+ return new Visit(this.placeDefinition, params);
8128
+ };
8129
+ Visit.prototype.hasRoutingChangedFrom = function (other) {
8130
+ var samePlace = other.placeDefinition === this.placeDefinition;
8131
+ var sameRouteParameters = ___namespace.isEqual(this.placeDefinition.getFormattedRouteParameters(this, true), this.placeDefinition.getFormattedRouteParameters(other, true));
8132
+ return !samePlace || !sameRouteParameters;
8133
+ };
8134
+ Visit.prototype.hasChangedFrom = function (other) {
8135
+ var sameNonRouteParameters = ___namespace.isEqual(this.placeDefinition.getNonRouteParameters(this), this.placeDefinition.getNonRouteParameters(other));
8136
+ return !sameNonRouteParameters || this.hasRoutingChangedFrom(other);
8137
+ };
8138
+ Visit.prototype.toDebugString = function () {
8139
+ var _this = this;
8140
+ return Object.keys(this.visitParameters).map(function (k) { return k + "=" + _this.visitParameters[k]; }).join(',');
8141
+ };
8142
+ return Visit;
8143
+ }());
8144
+
8145
+ function extractPrimarySegments(urlTree) {
8146
+ return urlTree.root.children.primary.segments;
8147
+ }
7904
8148
  exports.UrlSnapshot = /** @class */ (function () {
7905
8149
  // TODO: Update this accept a url Parser so it can be immutable and generate new trees on mutation using toString() are parseUrl.
7906
8150
  function UrlSnapshot(urlSerializer, url) {
@@ -7909,18 +8153,18 @@
7909
8153
  this.urlTree = urlSerializer.parse(url);
7910
8154
  }
7911
8155
  UrlSnapshot.prototype.updateVisitSegments = function (visit) {
7912
- var urlTree = this.urlSerializer.parse(this.url);
8156
+ var newUrlTree = this.urlSerializer.parse(this.url);
7913
8157
  // Ugly, but it works for now.
7914
- var segments = __spreadArray([], __read(this.getPrimarySegments(urlTree)));
8158
+ var segments = __spreadArray([], __read(extractPrimarySegments(newUrlTree)));
7915
8159
  var visitSegments = this.getSegmentsFor(visit);
7916
8160
  var replaceAt = segments.findIndex(function (segment) { return segment.path === visitSegments[0].path; });
7917
8161
  // do not use the return value, it's the items that were removed!
7918
8162
  segments.splice.apply(segments, __spreadArray([replaceAt, visitSegments.length], __read(visitSegments)));
7919
- urlTree.root.children.primary.segments = segments;
7920
- return new UrlSnapshot(this.urlSerializer, urlTree.toString());
8163
+ newUrlTree.root.children.primary.segments = segments;
8164
+ return new UrlSnapshot(this.urlSerializer, newUrlTree.toString());
7921
8165
  };
7922
- UrlSnapshot.prototype.getPrimarySegments = function (urlTree) {
7923
- return this.urlTree.root.children.primary.segments;
8166
+ UrlSnapshot.prototype.getPrimarySegments = function () {
8167
+ return extractPrimarySegments(this.urlTree);
7924
8168
  };
7925
8169
  /**
7926
8170
  * Converts the visit into segments. Please not that these segments are not e
@@ -7941,7 +8185,10 @@
7941
8185
  ];
7942
8186
  };
7943
8187
  UrlSnapshot.prototype.includesPathOf = function (placeDef) {
7944
- return this.getPrimarySegments(this.urlTree).find(function (s) { return s.path === placeDef.path; });
8188
+ return this.getPrimarySegments().find(function (s) { return s.path === placeDef.path; });
8189
+ };
8190
+ UrlSnapshot.prototype.createVisitFor = function (placeDef) {
8191
+ return new Visit(placeDef, new ConsolidatedParameterMap(this.getPrimarySegments()));
7945
8192
  };
7946
8193
  UrlSnapshot.prototype.getInteractionIds = function () {
7947
8194
  var queryParam = this.urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM];
@@ -7982,6 +8229,18 @@
7982
8229
  };
7983
8230
  return UrlSnapshot;
7984
8231
  }());
8232
+ __decorate([
8233
+ pectin.Trace(),
8234
+ __metadata("design:type", Function),
8235
+ __metadata("design:paramtypes", [Visit]),
8236
+ __metadata("design:returntype", exports.UrlSnapshot)
8237
+ ], exports.UrlSnapshot.prototype, "updateVisitSegments", null);
8238
+ __decorate([
8239
+ src.Memoize(),
8240
+ __metadata("design:type", Function),
8241
+ __metadata("design:paramtypes", []),
8242
+ __metadata("design:returntype", Array)
8243
+ ], exports.UrlSnapshot.prototype, "getPrimarySegments", null);
7985
8244
  (function (UrlSnapshot) {
7986
8245
  UrlSnapshot.INTERACTION_QUERY_PARAM = 'aup-interactions';
7987
8246
  UrlSnapshot.INTERACTION_ID_SEPARATOR = '--';
@@ -8292,7 +8551,7 @@
8292
8551
  });
8293
8552
  };
8294
8553
  PlaceRouter.prototype.navigateByUrl = function (urlSnapshot, navigationExtras) {
8295
- // console.log(`### navigationByUrl -> ${urlSnapshot.urlTree.toString()}`);
8554
+ console.log("### navigationByUrl -> " + urlSnapshot.urlTree.toString());
8296
8555
  return this.angularRouter.navigateByUrl(urlSnapshot.urlTree, navigationExtras);
8297
8556
  };
8298
8557
  Object.defineProperty(PlaceRouter.prototype, "activeVisits", {
@@ -8366,7 +8625,6 @@
8366
8625
  * to be able to capture the back button on the first page. If we don't then the back click will exit
8367
8626
  * the app directly and we don't get to ask.
8368
8627
  */
8369
- // @Trace()
8370
8628
  PlaceRouter.prototype.syncInteractionContextIdsWithRouter = function () {
8371
8629
  var _this = this;
8372
8630
  if (this.navigationSession) {
@@ -8410,6 +8668,12 @@
8410
8668
  { type: UrlService },
8411
8669
  { type: exports.PlaceHistory }
8412
8670
  ]; };
8671
+ __decorate([
8672
+ pectin.Trace(),
8673
+ __metadata("design:type", Function),
8674
+ __metadata("design:paramtypes", []),
8675
+ __metadata("design:returntype", Promise)
8676
+ ], exports.PlaceRouter.prototype, "syncInteractionContextIdsWithRouter", null);
8413
8677
  (function (PlaceRouter) {
8414
8678
  var State = /** @class */ (function () {
8415
8679
  function State(activeVisits) {
@@ -8426,75 +8690,6 @@
8426
8690
  PlaceRouter.State = State;
8427
8691
  })(exports.PlaceRouter || (exports.PlaceRouter = {}));
8428
8692
 
8429
- var Visit = /** @class */ (function () {
8430
- function Visit(placeDefinition, visitParameters) {
8431
- if (visitParameters === void 0) { visitParameters = {}; }
8432
- this.placeDefinition = placeDefinition;
8433
- this.visitParameters = visitParameters;
8434
- }
8435
- // @Trace()
8436
- Visit.prototype.getRouteId = function () {
8437
- return this.placeDefinition.getRouteIdFrom(this);
8438
- };
8439
- // @Trace()
8440
- Visit.prototype.hasRouteId = function () {
8441
- return !___namespace.isNil(this.getRouteId());
8442
- };
8443
- /**
8444
- * Returns the value of the place parameter with the specified name. The parameter
8445
- * name is taken from the `as` option, e.g. {as: 'aCustomName'} otherwise it is the
8446
- * same as the the ValueModel property name.
8447
- * @param parameterName the field name of the property model or the `as` option if specified.
8448
- */
8449
- Visit.prototype.getParameter = function (parameterName) {
8450
- return this.visitParameters[parameterName];
8451
- };
8452
- // @Trace()
8453
- Visit.prototype.hasParameter = function (parameterName) {
8454
- return Object.keys(this.visitParameters).includes(parameterName);
8455
- };
8456
- Visit.prototype.replace = function (parameter, value) {
8457
- var _a;
8458
- return new Visit(this.placeDefinition, Object.assign(Object.assign({}, this.visitParameters), (_a = {}, _a[parameter.name] = value, _a)));
8459
- };
8460
- Visit.prototype.mergeRouteParameters = function (routeParams) {
8461
- var _this = this;
8462
- // todo: whitelist parameters.
8463
- var routeParameterKeys = Object.keys(routeParams);
8464
- var params = {};
8465
- this.placeDefinition.getVisitParameterDefs().forEach(function (def) {
8466
- if (def.isRouteId || def.isRouteParameter) {
8467
- if (routeParameterKeys.includes(def.name)) {
8468
- params[def.name] = routeParams[def.name];
8469
- }
8470
- }
8471
- else {
8472
- // copy non route params as is, but only if they already exist otherwise we'll inject nil values and break the
8473
- // defaults and remember sanitisation process.
8474
- var value = _this.getParameter(def.name);
8475
- if (_this.hasParameter(def.name)) {
8476
- params[def.name] = value;
8477
- }
8478
- }
8479
- });
8480
- return new Visit(this.placeDefinition, params);
8481
- };
8482
- Visit.prototype.hasRoutingChangedFrom = function (other) {
8483
- var samePlace = other.placeDefinition === this.placeDefinition;
8484
- var sameRouteParameters = ___namespace.isEqual(this.placeDefinition.getFormattedRouteParameters(this, true), this.placeDefinition.getFormattedRouteParameters(other, true));
8485
- return !samePlace || !sameRouteParameters;
8486
- };
8487
- Visit.prototype.hasChangedFrom = function (other) {
8488
- var sameNonRouteParameters = ___namespace.isEqual(this.placeDefinition.getNonRouteParameters(this), this.placeDefinition.getNonRouteParameters(other));
8489
- return !sameNonRouteParameters || this.hasRoutingChangedFrom(other);
8490
- };
8491
- Visit.prototype.toDebugString = function () {
8492
- var _this = this;
8493
- return Object.keys(this.visitParameters).map(function (k) { return k + "=" + _this.visitParameters[k]; }).join(',');
8494
- };
8495
- return Visit;
8496
- }());
8497
-
8498
8693
  var AUP_PLACE_CONFIG = new i0.InjectionToken('AUP_PLACE_CONFIG');
8499
8694
 
8500
8695
  var NotAuthorisedNoticeComponent = /** @class */ (function () {
@@ -9205,64 +9400,6 @@
9205
9400
  };
9206
9401
  }
9207
9402
 
9208
- /**
9209
- * This a work around for the fact that an activated route with multiple segments doesn't
9210
- * include the segment params in the paramMap as well as each segment returns an empty
9211
- * param map even when `parameter`s has content.
9212
- */
9213
- var ConsolidatedParameterMap = /** @class */ (function () {
9214
- function ConsolidatedParameterMap(paramMap, urlSegments) {
9215
- this.paramMaps = [paramMap].concat((urlSegments || []).map(function (s) { return new ParamMapAdapter(s.parameters); })).filter(function (m) { return !!m; }); // the activated route param map can be null
9216
- }
9217
- ConsolidatedParameterMap.prototype.get = function (name) {
9218
- var paramMap = this.paramMaps.find(function (m) { return m.has(name); });
9219
- return paramMap.get(name);
9220
- };
9221
- ConsolidatedParameterMap.prototype.getAll = function (name) {
9222
- var paramMap = this.paramMaps.find(function (m) { return m.has(name); });
9223
- return paramMap.getAll(name);
9224
- };
9225
- ConsolidatedParameterMap.prototype.has = function (name) {
9226
- return !!this.paramMaps.find(function (m) { return m.has(name); });
9227
- };
9228
- Object.defineProperty(ConsolidatedParameterMap.prototype, "keys", {
9229
- get: function () {
9230
- return this.paramMaps.reduce(function (result, params) { return result.concat(params.keys); }, []);
9231
- },
9232
- enumerable: false,
9233
- configurable: true
9234
- });
9235
- return ConsolidatedParameterMap;
9236
- }());
9237
- __decorate([
9238
- src.Memoize(),
9239
- __metadata("design:type", Array),
9240
- __metadata("design:paramtypes", [])
9241
- ], ConsolidatedParameterMap.prototype, "keys", null);
9242
- var ParamMapAdapter = /** @class */ (function () {
9243
- function ParamMapAdapter(params) {
9244
- this.params = params;
9245
- }
9246
- ParamMapAdapter.prototype.get = function (name) {
9247
- return this.params[name];
9248
- };
9249
- ParamMapAdapter.prototype.getAll = function (name) {
9250
- var value = this.get(name);
9251
- return Array.isArray(value) ? value : [value];
9252
- };
9253
- ParamMapAdapter.prototype.has = function (name) {
9254
- return this.keys.includes(name);
9255
- };
9256
- Object.defineProperty(ParamMapAdapter.prototype, "keys", {
9257
- get: function () {
9258
- return Object.keys(this.params);
9259
- },
9260
- enumerable: false,
9261
- configurable: true
9262
- });
9263
- return ParamMapAdapter;
9264
- }());
9265
-
9266
9403
  var NoopAuthGuard = /** @class */ (function () {
9267
9404
  function NoopAuthGuard() {
9268
9405
  }
@@ -9324,7 +9461,7 @@
9324
9461
  case 3:
9325
9462
  if (!(i < parameterDefs.length)) return [3 /*break*/, 6];
9326
9463
  def = parameterDefs[i];
9327
- value = visit.getParameter(def.name);
9464
+ value = visit.getParameterValue(def);
9328
9465
  return [4 /*yield*/, def.sanitise(value, sanitisedVisit, this.placeHistory, this.injector, this.navigationSession.isPopState)];
9329
9466
  case 4:
9330
9467
  sanitisedValue = _a.sent();
@@ -9379,7 +9516,7 @@
9379
9516
  return __generator(this, function (_a) {
9380
9517
  switch (_a.label) {
9381
9518
  case 0:
9382
- params = new ConsolidatedParameterMap(activatedRoute.paramMap, activatedRoute.url);
9519
+ params = new ConsolidatedParameterMap(activatedRoute.url, activatedRoute.paramMap);
9383
9520
  parsedParams = placeDefinition_1.parseRouteParams(params);
9384
9521
  navigationSession = this.placeRouter.navigationSession;
9385
9522
  initialVisit = navigationSession.getVisitFor(placeDefinition_1) || new Visit(placeDefinition_1, parsedParams);
@@ -9440,27 +9577,6 @@
9440
9577
  var visit = result instanceof Visit ? result : new Visit(exports.PlaceComponent.getDefinition(result), {});
9441
9578
  return this.urlService.createUrlSnapshot(visit).urlTree;
9442
9579
  };
9443
- // protected async ensureAuthenticatedThen(activatedRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot, next: (placeDefinition: PlaceDefinition) => Promise<boolean | UrlTree>): Promise<boolean | UrlTree> {
9444
- // const authoriseResult = placeDefinition.authenticate ? await this.isAuthorised(activatedRoute, state) : true;
9445
- // if (authoriseResult === true) {
9446
- // // we're authorised, now run the place guards.
9447
- // return next(placeDefinition);
9448
- // } else {
9449
- // console.log('not authorised result', authoriseResult);
9450
- // return authoriseResult;
9451
- // }
9452
- // }
9453
- //
9454
- // // @Trace()
9455
- // protected async ensureAuthorisedThen(activatedRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot, next: (placeDefinition: PlaceDefinition) => Promise<boolean | UrlTree>): Promise<boolean | UrlTree> {
9456
- //
9457
- // }
9458
- // @Trace()
9459
- // async isAuthorised(activatedRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean | UrlTree> {
9460
- // const authorised = this.getAuthGuard(this.injector).canActivate(activatedRoute, state);
9461
- // return (authorised instanceof Observable) ? authorised.toPromise() : authorised;
9462
- // }
9463
- // abstract getAuthGuard(injector: Injector): CanActivate;
9464
9580
  // @Trace()
9465
9581
  PlaceGuard.prototype.cleanInteractionState = function (route, state, next) {
9466
9582
  return __awaiter(this, void 0, void 0, function () {
@@ -9535,12 +9651,14 @@
9535
9651
  Formatter.BOOLEAN = new BooleanType();
9536
9652
  })(exports.Formatter || (exports.Formatter = {}));
9537
9653
 
9538
- function installMechanics(prototype, propertyKey, backingModelFactory, tagPrefix, isEmpty) {
9654
+ function installMechanics(parameterDef, prototype, propertyKey, tagPrefix) {
9655
+ typescriptUtilities.Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, parameterDef);
9539
9656
  function getMechanics(instance, propertyName) {
9540
9657
  var key = "__mechanics_" + propertyName.toString();
9541
9658
  if (!instance[key]) {
9659
+ var backingModel = parameterDef.createBackingModel();
9542
9660
  instance[key] = {
9543
- backingModel: backingModelFactory(),
9661
+ backingModel: backingModel,
9544
9662
  binding: null
9545
9663
  };
9546
9664
  var tag = tagPrefix + "(" + prototype.constructor.name + "." + propertyKey.toString() + ")";
@@ -9564,12 +9682,12 @@
9564
9682
  toLeft: pectin.Functions.identity,
9565
9683
  toRight: pectin.Functions.identity
9566
9684
  });
9567
- if (isEmpty(userModel)) {
9685
+ if (parameterDef.isEmptyValue(userModel.value)) {
9568
9686
  // console.log(`Push visit to model for ${tag}`, {value: mechanics.backingModel.value});
9569
9687
  mechanics.binding.writeRight(); // push the visit into the user model;
9570
9688
  }
9571
9689
  else {
9572
- if (!isEmpty(mechanics.backingModel)) {
9690
+ if (!parameterDef.isEmptyValue(mechanics.backingModel.value)) {
9573
9691
  console.warn('Assigning a visit model with an existing value to a visit parameter with an existing value. Visit parameter will be overridden');
9574
9692
  }
9575
9693
  mechanics.binding.writeLeft(); // push the user model into the visit
@@ -9580,25 +9698,22 @@
9580
9698
  }
9581
9699
  function RouteId(type, options) {
9582
9700
  return function (prototype, propertyKey) {
9583
- var param = new exports.ParameterDefinition.RouteId(propertyKey.toString(), options, type);
9584
- typescriptUtilities.Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
9585
- installMechanics(prototype, propertyKey, function () { return new pectin.MutableValueModel(); }, '@RouteId', function (m) { return m.query().isNil(); });
9701
+ var parameterDef = new exports.ParameterDefinition.RouteId(propertyKey.toString(), options, type);
9702
+ installMechanics(parameterDef, prototype, propertyKey, '@RouteId');
9586
9703
  };
9587
9704
  }
9588
9705
  function VisitParameter(options) {
9589
9706
  var opts = typescriptUtilities.Opts.get(options);
9590
9707
  return function (prototype, propertyKey) {
9591
- var param = new exports.ParameterDefinition.ValueParameter(propertyKey.toString(), options, opts.getOptional('storeInUrl', null));
9592
- typescriptUtilities.Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
9593
- installMechanics(prototype, propertyKey, function () { return new pectin.MutableValueModel(); }, '@VisitParameter', function (m) { return m.query().isNil(); });
9708
+ var parameterDef = new exports.ParameterDefinition.ValueParameter(propertyKey.toString(), options, opts.getOptional('storeInUrl', null));
9709
+ installMechanics(parameterDef, prototype, propertyKey, '@VisitParameter');
9594
9710
  };
9595
9711
  }
9596
9712
  function VisitParameterList(options) {
9597
9713
  var opts = typescriptUtilities.Opts.get(options);
9598
9714
  return function (prototype, propertyKey) {
9599
- var param = new exports.ParameterDefinition.ArrayParameter(propertyKey.toString(), options, opts.getOptional('storeInUrl', null));
9600
- typescriptUtilities.Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
9601
- installMechanics(prototype, propertyKey, function () { return new pectin.MutableListModel(); }, '@VisitParameterList', function (m) { return m.query().isEmpty(); });
9715
+ var parameterDef = new exports.ParameterDefinition.ArrayParameter(propertyKey.toString(), options, opts.getOptional('storeInUrl', null));
9716
+ installMechanics(parameterDef, prototype, propertyKey, '@VisitParameterList');
9602
9717
  };
9603
9718
  }
9604
9719