@coolon/angular-ui-powerups 12.0.0-alpha.1 → 12.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/coolon-angular-ui-powerups.umd.js +244 -222
- package/bundles/coolon-angular-ui-powerups.umd.js.map +1 -1
- package/coolon-angular-ui-powerups.metadata.json +1 -1
- package/esm2015/lib/place/exports.js +1 -1
- package/esm2015/lib/place/exports.js.map +1 -1
- package/esm2015/lib/place/exports.metadata.json +1 -1
- package/esm2015/lib/place/place-component.js +17 -5
- package/esm2015/lib/place/place-component.js.map +1 -1
- package/esm2015/lib/place/place-component.metadata.json +1 -1
- package/esm2015/lib/place/place-definition.js +1 -1
- package/esm2015/lib/place/place-definition.js.map +1 -1
- package/esm2015/lib/place/place-definition.metadata.json +1 -1
- package/esm2015/lib/place/route/parameter-decorators.js +19 -12
- package/esm2015/lib/place/route/parameter-decorators.js.map +1 -1
- package/esm2015/lib/place/route/parameter-decorators.metadata.json +1 -1
- package/esm2015/lib/place/route/{parameter-definition.class.js → parameter-definition.js} +12 -3
- package/esm2015/lib/place/route/parameter-definition.js.map +1 -0
- package/esm2015/lib/place/route/{parameter-definition.class.metadata.json → parameter-definition.metadata.json} +1 -1
- package/esm2015/lib/place/route/parameter-snapshot.js.map +1 -1
- package/esm2015/lib/place/visit.js.map +1 -1
- package/fesm2015/coolon-angular-ui-powerups.js +236 -214
- package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
- package/lib/place/exports.d.ts +1 -1
- package/lib/place/place-component.d.ts +1 -1
- package/lib/place/place-definition.d.ts +1 -1
- package/lib/place/route/parameter-snapshot.d.ts +1 -1
- package/lib/place/visit.d.ts +1 -1
- package/package.json +2 -2
- package/schematics/activity/templates/component/__name@dasherize__.component.html.template +5 -1
- package/schematics/activity/templates/component/__name@dasherize__.component.scss.template +0 -1
- package/schematics/activity/templates/component/__name@dasherize__.component.ts.template +7 -0
- package/esm2015/lib/place/route/parameter-definition.class.js.map +0 -1
- /package/lib/place/route/{parameter-definition.class.d.ts → parameter-definition.d.ts} +0 -0
|
@@ -6248,6 +6248,212 @@
|
|
|
6248
6248
|
},] }
|
|
6249
6249
|
];
|
|
6250
6250
|
|
|
6251
|
+
exports.PlaceHistory = /** @class */ (function () {
|
|
6252
|
+
function PlaceHistory() {
|
|
6253
|
+
this._archive = new Map();
|
|
6254
|
+
this.placeHistoryDepth = 4;
|
|
6255
|
+
}
|
|
6256
|
+
PlaceHistory.prototype.notifyNavigationStarted = function () {
|
|
6257
|
+
if (this._activeVisits) {
|
|
6258
|
+
this.archive(this._activeVisits.visits);
|
|
6259
|
+
this._previousVisits = this._activeVisits;
|
|
6260
|
+
}
|
|
6261
|
+
};
|
|
6262
|
+
PlaceHistory.prototype.notifyNavigationFinished = function (visits) {
|
|
6263
|
+
this._activeVisits = new PlaceHistory.VisitRecord(visits);
|
|
6264
|
+
};
|
|
6265
|
+
PlaceHistory.prototype.updateVisit = function (visit) {
|
|
6266
|
+
pectin.assert.isTruthy(this._activeVisits);
|
|
6267
|
+
this._activeVisits.update(visit);
|
|
6268
|
+
};
|
|
6269
|
+
PlaceHistory.prototype.lastVisitIncluded = function (placeDef) {
|
|
6270
|
+
var _a;
|
|
6271
|
+
return !!((_a = this._previousVisits) === null || _a === void 0 ? void 0 : _a.getVisitFor(placeDef));
|
|
6272
|
+
};
|
|
6273
|
+
PlaceHistory.prototype.getMostRecentVisitFor = function (placeDef) {
|
|
6274
|
+
return ___default['default'].first(this.getHistory(placeDef));
|
|
6275
|
+
};
|
|
6276
|
+
PlaceHistory.prototype.getHistory = function (placeDef) {
|
|
6277
|
+
var history = this._archive.get(placeDef);
|
|
6278
|
+
if (!history) {
|
|
6279
|
+
history = [];
|
|
6280
|
+
this.setHistory(placeDef, history);
|
|
6281
|
+
}
|
|
6282
|
+
return history;
|
|
6283
|
+
};
|
|
6284
|
+
PlaceHistory.prototype.setHistory = function (placeDef, history) {
|
|
6285
|
+
this._archive.set(placeDef, history);
|
|
6286
|
+
};
|
|
6287
|
+
PlaceHistory.prototype.archive = function (visits) {
|
|
6288
|
+
var _this = this;
|
|
6289
|
+
visits.forEach(function (state) {
|
|
6290
|
+
var history = _this.getHistory(state.placeDefinition);
|
|
6291
|
+
var previousState = ___default['default'].first(history);
|
|
6292
|
+
if (!previousState || state.hasChangedFrom(previousState)) {
|
|
6293
|
+
history.unshift(state); // LIFO
|
|
6294
|
+
_this.setHistory(state.placeDefinition, history.slice(0, _this.placeHistoryDepth));
|
|
6295
|
+
}
|
|
6296
|
+
});
|
|
6297
|
+
};
|
|
6298
|
+
return PlaceHistory;
|
|
6299
|
+
}());
|
|
6300
|
+
exports.PlaceHistory.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function PlaceHistory_Factory() { return new exports.PlaceHistory(); }, token: exports.PlaceHistory, providedIn: "root" });
|
|
6301
|
+
exports.PlaceHistory.decorators = [
|
|
6302
|
+
{ type: i0.Injectable, args: [{
|
|
6303
|
+
providedIn: 'root'
|
|
6304
|
+
},] }
|
|
6305
|
+
];
|
|
6306
|
+
exports.PlaceHistory.ctorParameters = function () { return []; };
|
|
6307
|
+
(function (PlaceHistory) {
|
|
6308
|
+
var VisitRecord = /** @class */ (function () {
|
|
6309
|
+
function VisitRecord(visits) {
|
|
6310
|
+
this.visits = visits;
|
|
6311
|
+
}
|
|
6312
|
+
VisitRecord.prototype.update = function (visit) {
|
|
6313
|
+
this.visits = this.visits.filter(function (v) { return v.placeDefinition !== visit.placeDefinition; }).concat(visit);
|
|
6314
|
+
};
|
|
6315
|
+
VisitRecord.prototype.getVisitFor = function (placeDef) {
|
|
6316
|
+
return this.visits.find(function (v) { return v.placeDefinition === placeDef; });
|
|
6317
|
+
};
|
|
6318
|
+
return VisitRecord;
|
|
6319
|
+
}());
|
|
6320
|
+
PlaceHistory.VisitRecord = VisitRecord;
|
|
6321
|
+
// export class Query {
|
|
6322
|
+
// private _history: Visit.State[];
|
|
6323
|
+
// private _places: Place[];
|
|
6324
|
+
// private _predicate: (visit: any) => boolean;
|
|
6325
|
+
// private _limit: number;
|
|
6326
|
+
//
|
|
6327
|
+
// constructor(history, limit = history.length) {
|
|
6328
|
+
// this._history = history;
|
|
6329
|
+
// this._places = [];
|
|
6330
|
+
// this._predicate = (visit => true);
|
|
6331
|
+
// this._limit = limit;
|
|
6332
|
+
// }
|
|
6333
|
+
//
|
|
6334
|
+
// to(...places:Place[]):this {
|
|
6335
|
+
// this._places = places;
|
|
6336
|
+
// return this;
|
|
6337
|
+
// }
|
|
6338
|
+
//
|
|
6339
|
+
// with(parameters: { [parameter: string]: any }): this {
|
|
6340
|
+
// this.matching(state => {
|
|
6341
|
+
// return Object.keys(parameters).reduce((acc, key) => {
|
|
6342
|
+
// const matchValue = parameters[key];
|
|
6343
|
+
// const visitValue = state.get(key);
|
|
6344
|
+
// const matched = matchValue === '*' ? !_.isNil(visitValue) : visitValue == matchValue;
|
|
6345
|
+
// // Logger.get(this).info(`matched=${matched}`, parameters, visitValue);
|
|
6346
|
+
// return acc && matched;
|
|
6347
|
+
// }, true);
|
|
6348
|
+
// });
|
|
6349
|
+
// return this;
|
|
6350
|
+
// }
|
|
6351
|
+
//
|
|
6352
|
+
// last(): Visit.State {
|
|
6353
|
+
// return _.findLast(this._history, visit => this._matches(visit))
|
|
6354
|
+
// }
|
|
6355
|
+
//
|
|
6356
|
+
// // @trace
|
|
6357
|
+
// allThatMatch(): Visit.State[] {
|
|
6358
|
+
// return _.filter(this._history, visit => this._matches(visit)).slice(-this._limit);
|
|
6359
|
+
// }
|
|
6360
|
+
//
|
|
6361
|
+
// // @trace
|
|
6362
|
+
// mostRecentValueOf<T=any>(param: string, defaultValue: T = null): T {
|
|
6363
|
+
// const lastStateWithParam = _.findLast(this.allThatMatch(), state => !_.isNil(state.get(param)));
|
|
6364
|
+
// return _.isNil(lastStateWithParam) ? defaultValue : lastStateWithParam.get(param);
|
|
6365
|
+
// }
|
|
6366
|
+
//
|
|
6367
|
+
// limit(limit: number): this {
|
|
6368
|
+
// this._limit = limit;
|
|
6369
|
+
// return this;
|
|
6370
|
+
// }
|
|
6371
|
+
//
|
|
6372
|
+
// matching(predicate: (visit: Visit.State) => boolean): this {
|
|
6373
|
+
// this._predicate = predicate;
|
|
6374
|
+
// return this;
|
|
6375
|
+
// }
|
|
6376
|
+
//
|
|
6377
|
+
// _matches(visit: Visit.State) {
|
|
6378
|
+
// return this._isPlaceMatch(visit) && this._predicate(visit);
|
|
6379
|
+
// }
|
|
6380
|
+
//
|
|
6381
|
+
// _isPlaceMatch(visit: Visit.State) {
|
|
6382
|
+
// return this._places.length < 1 || this._places.includes(visit.place)
|
|
6383
|
+
// }
|
|
6384
|
+
//
|
|
6385
|
+
// }
|
|
6386
|
+
})(exports.PlaceHistory || (exports.PlaceHistory = {}));
|
|
6387
|
+
|
|
6388
|
+
var Visit = /** @class */ (function () {
|
|
6389
|
+
function Visit(placeDefinition, visitParameters) {
|
|
6390
|
+
if (visitParameters === void 0) { visitParameters = {}; }
|
|
6391
|
+
this.placeDefinition = placeDefinition;
|
|
6392
|
+
this.visitParameters = visitParameters;
|
|
6393
|
+
}
|
|
6394
|
+
// @Trace()
|
|
6395
|
+
Visit.prototype.getRouteId = function () {
|
|
6396
|
+
return this.placeDefinition.getRouteIdFrom(this);
|
|
6397
|
+
};
|
|
6398
|
+
// @Trace()
|
|
6399
|
+
Visit.prototype.hasRouteId = function () {
|
|
6400
|
+
return !___namespace.isNil(this.getRouteId());
|
|
6401
|
+
};
|
|
6402
|
+
/**
|
|
6403
|
+
* Returns the value of the place parameter with the specified name. The parameter
|
|
6404
|
+
* name is taken from the `as` option, e.g. {as: 'aCustomName'} otherwise it is the
|
|
6405
|
+
* same as the the ValueModel property name.
|
|
6406
|
+
* @param parameterName the field name of the property model or the `as` option if specified.
|
|
6407
|
+
*/
|
|
6408
|
+
Visit.prototype.getParameter = function (parameterName) {
|
|
6409
|
+
return this.visitParameters[parameterName];
|
|
6410
|
+
};
|
|
6411
|
+
// @Trace()
|
|
6412
|
+
Visit.prototype.hasParameter = function (parameterName) {
|
|
6413
|
+
return Object.keys(this.visitParameters).includes(parameterName);
|
|
6414
|
+
};
|
|
6415
|
+
Visit.prototype.replace = function (parameter, value) {
|
|
6416
|
+
var _a;
|
|
6417
|
+
return new Visit(this.placeDefinition, Object.assign(Object.assign({}, this.visitParameters), (_a = {}, _a[parameter.name] = value, _a)));
|
|
6418
|
+
};
|
|
6419
|
+
Visit.prototype.mergeRouteParameters = function (routeParams) {
|
|
6420
|
+
var _this = this;
|
|
6421
|
+
// todo: whitelist parameters.
|
|
6422
|
+
var routeParameterKeys = Object.keys(routeParams);
|
|
6423
|
+
var params = {};
|
|
6424
|
+
this.placeDefinition.getVisitParameterDefs().forEach(function (def) {
|
|
6425
|
+
if (def.isRouteId || def.isRouteParameter) {
|
|
6426
|
+
if (routeParameterKeys.includes(def.name)) {
|
|
6427
|
+
params[def.name] = routeParams[def.name];
|
|
6428
|
+
}
|
|
6429
|
+
}
|
|
6430
|
+
else {
|
|
6431
|
+
// copy non route params as is, but only if they already exist otherwise we'll inject nil values and break the
|
|
6432
|
+
// defaults and remember sanitisation process.
|
|
6433
|
+
var value = _this.getParameter(def.name);
|
|
6434
|
+
if (_this.hasParameter(def.name)) {
|
|
6435
|
+
params[def.name] = value;
|
|
6436
|
+
}
|
|
6437
|
+
}
|
|
6438
|
+
});
|
|
6439
|
+
return new Visit(this.placeDefinition, params);
|
|
6440
|
+
};
|
|
6441
|
+
Visit.prototype.hasRoutingChangedFrom = function (other) {
|
|
6442
|
+
var samePlace = other.placeDefinition === this.placeDefinition;
|
|
6443
|
+
var sameRouteParameters = ___namespace.isEqual(this.placeDefinition.getFormattedRouteParameters(this, true), this.placeDefinition.getFormattedRouteParameters(other, true));
|
|
6444
|
+
return !samePlace || !sameRouteParameters;
|
|
6445
|
+
};
|
|
6446
|
+
Visit.prototype.hasChangedFrom = function (other) {
|
|
6447
|
+
var sameNonRouteParameters = ___namespace.isEqual(this.placeDefinition.getNonRouteParameters(this), this.placeDefinition.getNonRouteParameters(other));
|
|
6448
|
+
return !sameNonRouteParameters || this.hasRoutingChangedFrom(other);
|
|
6449
|
+
};
|
|
6450
|
+
Visit.prototype.toDebugString = function () {
|
|
6451
|
+
var _this = this;
|
|
6452
|
+
return Object.keys(this.visitParameters).map(function (k) { return k + "=" + _this.visitParameters[k]; }).join(',');
|
|
6453
|
+
};
|
|
6454
|
+
return Visit;
|
|
6455
|
+
}());
|
|
6456
|
+
|
|
6251
6457
|
exports.ParameterDefinition = /** @class */ (function () {
|
|
6252
6458
|
function ParameterDefinition(propertyName, options, urlFormat) {
|
|
6253
6459
|
this.propertyName = propertyName;
|
|
@@ -6274,7 +6480,6 @@
|
|
|
6274
6480
|
ParameterDefinition.prototype.getOptionValue = function (key) {
|
|
6275
6481
|
return this.options.getOptional(key, null);
|
|
6276
6482
|
};
|
|
6277
|
-
// @Trace()
|
|
6278
6483
|
ParameterDefinition.prototype.sanitise = function (value, visit, placeHistory, injector, isPopState) {
|
|
6279
6484
|
return __awaiter(this, void 0, void 0, function () {
|
|
6280
6485
|
var returningFromSomewhereElse, lastKnownVisit;
|
|
@@ -6299,6 +6504,12 @@
|
|
|
6299
6504
|
};
|
|
6300
6505
|
return ParameterDefinition;
|
|
6301
6506
|
}());
|
|
6507
|
+
__decorate([
|
|
6508
|
+
pectin.Trace(),
|
|
6509
|
+
__metadata("design:type", Function),
|
|
6510
|
+
__metadata("design:paramtypes", [Object, Visit, exports.PlaceHistory, i0.Injector, Boolean]),
|
|
6511
|
+
__metadata("design:returntype", Promise)
|
|
6512
|
+
], exports.ParameterDefinition.prototype, "sanitise", null);
|
|
6302
6513
|
(function (ParameterDefinition) {
|
|
6303
6514
|
var RouteId = /** @class */ (function (_super) {
|
|
6304
6515
|
__extends(RouteId, _super);
|
|
@@ -6512,7 +6723,6 @@
|
|
|
6512
6723
|
_this.childPlaces = _this.placeDefinition.children.map(function (d) { return d.component; });
|
|
6513
6724
|
return _this;
|
|
6514
6725
|
}
|
|
6515
|
-
// @Trace()
|
|
6516
6726
|
PlaceComponent.prototype.initialiseVisit = function (visit, notifyVisitChanged) {
|
|
6517
6727
|
var _this = this;
|
|
6518
6728
|
pectin.assert.isNil(this.visitModel.value);
|
|
@@ -6535,18 +6745,17 @@
|
|
|
6535
6745
|
PlaceComponent.prototype.isInitialised = function () {
|
|
6536
6746
|
return !!this.visitModel.value;
|
|
6537
6747
|
};
|
|
6538
|
-
// @Trace()
|
|
6539
6748
|
PlaceComponent.prototype.installBinding = function (parameterDef) {
|
|
6540
6749
|
var model = this[parameterDef.propertyName];
|
|
6541
6750
|
pectin.DebugContext.tag(model, this.placeDefinition.component.name + "." + parameterDef.propertyName);
|
|
6542
6751
|
var binding = this.registerDisposable(new pectin.Binding(this.visitModel, model, {
|
|
6543
6752
|
toRight: function (visit) {
|
|
6544
6753
|
var value = visit.getParameter(parameterDef.name);
|
|
6545
|
-
|
|
6754
|
+
console.log('push to component', { name: parameterDef.name, value: value, visit: visit });
|
|
6546
6755
|
return value;
|
|
6547
6756
|
},
|
|
6548
6757
|
toLeft: function (value, currentVisit) {
|
|
6549
|
-
|
|
6758
|
+
console.log('push to route', { name: parameterDef.name, value: value, currentVisit: currentVisit });
|
|
6550
6759
|
return currentVisit.replace(parameterDef, value);
|
|
6551
6760
|
}
|
|
6552
6761
|
}));
|
|
@@ -6580,6 +6789,18 @@
|
|
|
6580
6789
|
{ type: i0.Directive }
|
|
6581
6790
|
];
|
|
6582
6791
|
exports.PlaceComponent.ctorParameters = function () { return []; };
|
|
6792
|
+
__decorate([
|
|
6793
|
+
pectin.Trace(),
|
|
6794
|
+
__metadata("design:type", Function),
|
|
6795
|
+
__metadata("design:paramtypes", [Visit, Function]),
|
|
6796
|
+
__metadata("design:returntype", void 0)
|
|
6797
|
+
], exports.PlaceComponent.prototype, "initialiseVisit", null);
|
|
6798
|
+
__decorate([
|
|
6799
|
+
pectin.Trace(),
|
|
6800
|
+
__metadata("design:type", Function),
|
|
6801
|
+
__metadata("design:paramtypes", [exports.ParameterDefinition]),
|
|
6802
|
+
__metadata("design:returntype", void 0)
|
|
6803
|
+
], exports.PlaceComponent.prototype, "installBinding", null);
|
|
6583
6804
|
__decorate([
|
|
6584
6805
|
fastMemoizeDecorator.Memoize(),
|
|
6585
6806
|
__metadata("design:type", PlaceDefinition),
|
|
@@ -7497,143 +7718,6 @@
|
|
|
7497
7718
|
PlaceAccessGuard.NoAuth = NoAuth;
|
|
7498
7719
|
})(exports.PlaceAccessGuard || (exports.PlaceAccessGuard = {}));
|
|
7499
7720
|
|
|
7500
|
-
exports.PlaceHistory = /** @class */ (function () {
|
|
7501
|
-
function PlaceHistory() {
|
|
7502
|
-
this._archive = new Map();
|
|
7503
|
-
this.placeHistoryDepth = 4;
|
|
7504
|
-
}
|
|
7505
|
-
PlaceHistory.prototype.notifyNavigationStarted = function () {
|
|
7506
|
-
if (this._activeVisits) {
|
|
7507
|
-
this.archive(this._activeVisits.visits);
|
|
7508
|
-
this._previousVisits = this._activeVisits;
|
|
7509
|
-
}
|
|
7510
|
-
};
|
|
7511
|
-
PlaceHistory.prototype.notifyNavigationFinished = function (visits) {
|
|
7512
|
-
this._activeVisits = new PlaceHistory.VisitRecord(visits);
|
|
7513
|
-
};
|
|
7514
|
-
PlaceHistory.prototype.updateVisit = function (visit) {
|
|
7515
|
-
pectin.assert.isTruthy(this._activeVisits);
|
|
7516
|
-
this._activeVisits.update(visit);
|
|
7517
|
-
};
|
|
7518
|
-
PlaceHistory.prototype.lastVisitIncluded = function (placeDef) {
|
|
7519
|
-
var _a;
|
|
7520
|
-
return !!((_a = this._previousVisits) === null || _a === void 0 ? void 0 : _a.getVisitFor(placeDef));
|
|
7521
|
-
};
|
|
7522
|
-
PlaceHistory.prototype.getMostRecentVisitFor = function (placeDef) {
|
|
7523
|
-
return ___default['default'].first(this.getHistory(placeDef));
|
|
7524
|
-
};
|
|
7525
|
-
PlaceHistory.prototype.getHistory = function (placeDef) {
|
|
7526
|
-
var history = this._archive.get(placeDef);
|
|
7527
|
-
if (!history) {
|
|
7528
|
-
history = [];
|
|
7529
|
-
this.setHistory(placeDef, history);
|
|
7530
|
-
}
|
|
7531
|
-
return history;
|
|
7532
|
-
};
|
|
7533
|
-
PlaceHistory.prototype.setHistory = function (placeDef, history) {
|
|
7534
|
-
this._archive.set(placeDef, history);
|
|
7535
|
-
};
|
|
7536
|
-
PlaceHistory.prototype.archive = function (visits) {
|
|
7537
|
-
var _this = this;
|
|
7538
|
-
visits.forEach(function (state) {
|
|
7539
|
-
var history = _this.getHistory(state.placeDefinition);
|
|
7540
|
-
var previousState = ___default['default'].first(history);
|
|
7541
|
-
if (!previousState || state.hasChangedFrom(previousState)) {
|
|
7542
|
-
history.unshift(state); // LIFO
|
|
7543
|
-
_this.setHistory(state.placeDefinition, history.slice(0, _this.placeHistoryDepth));
|
|
7544
|
-
}
|
|
7545
|
-
});
|
|
7546
|
-
};
|
|
7547
|
-
return PlaceHistory;
|
|
7548
|
-
}());
|
|
7549
|
-
exports.PlaceHistory.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function PlaceHistory_Factory() { return new exports.PlaceHistory(); }, token: exports.PlaceHistory, providedIn: "root" });
|
|
7550
|
-
exports.PlaceHistory.decorators = [
|
|
7551
|
-
{ type: i0.Injectable, args: [{
|
|
7552
|
-
providedIn: 'root'
|
|
7553
|
-
},] }
|
|
7554
|
-
];
|
|
7555
|
-
exports.PlaceHistory.ctorParameters = function () { return []; };
|
|
7556
|
-
(function (PlaceHistory) {
|
|
7557
|
-
var VisitRecord = /** @class */ (function () {
|
|
7558
|
-
function VisitRecord(visits) {
|
|
7559
|
-
this.visits = visits;
|
|
7560
|
-
}
|
|
7561
|
-
VisitRecord.prototype.update = function (visit) {
|
|
7562
|
-
this.visits = this.visits.filter(function (v) { return v.placeDefinition !== visit.placeDefinition; }).concat(visit);
|
|
7563
|
-
};
|
|
7564
|
-
VisitRecord.prototype.getVisitFor = function (placeDef) {
|
|
7565
|
-
return this.visits.find(function (v) { return v.placeDefinition === placeDef; });
|
|
7566
|
-
};
|
|
7567
|
-
return VisitRecord;
|
|
7568
|
-
}());
|
|
7569
|
-
PlaceHistory.VisitRecord = VisitRecord;
|
|
7570
|
-
// export class Query {
|
|
7571
|
-
// private _history: Visit.State[];
|
|
7572
|
-
// private _places: Place[];
|
|
7573
|
-
// private _predicate: (visit: any) => boolean;
|
|
7574
|
-
// private _limit: number;
|
|
7575
|
-
//
|
|
7576
|
-
// constructor(history, limit = history.length) {
|
|
7577
|
-
// this._history = history;
|
|
7578
|
-
// this._places = [];
|
|
7579
|
-
// this._predicate = (visit => true);
|
|
7580
|
-
// this._limit = limit;
|
|
7581
|
-
// }
|
|
7582
|
-
//
|
|
7583
|
-
// to(...places:Place[]):this {
|
|
7584
|
-
// this._places = places;
|
|
7585
|
-
// return this;
|
|
7586
|
-
// }
|
|
7587
|
-
//
|
|
7588
|
-
// with(parameters: { [parameter: string]: any }): this {
|
|
7589
|
-
// this.matching(state => {
|
|
7590
|
-
// return Object.keys(parameters).reduce((acc, key) => {
|
|
7591
|
-
// const matchValue = parameters[key];
|
|
7592
|
-
// const visitValue = state.get(key);
|
|
7593
|
-
// const matched = matchValue === '*' ? !_.isNil(visitValue) : visitValue == matchValue;
|
|
7594
|
-
// // Logger.get(this).info(`matched=${matched}`, parameters, visitValue);
|
|
7595
|
-
// return acc && matched;
|
|
7596
|
-
// }, true);
|
|
7597
|
-
// });
|
|
7598
|
-
// return this;
|
|
7599
|
-
// }
|
|
7600
|
-
//
|
|
7601
|
-
// last(): Visit.State {
|
|
7602
|
-
// return _.findLast(this._history, visit => this._matches(visit))
|
|
7603
|
-
// }
|
|
7604
|
-
//
|
|
7605
|
-
// // @trace
|
|
7606
|
-
// allThatMatch(): Visit.State[] {
|
|
7607
|
-
// return _.filter(this._history, visit => this._matches(visit)).slice(-this._limit);
|
|
7608
|
-
// }
|
|
7609
|
-
//
|
|
7610
|
-
// // @trace
|
|
7611
|
-
// mostRecentValueOf<T=any>(param: string, defaultValue: T = null): T {
|
|
7612
|
-
// const lastStateWithParam = _.findLast(this.allThatMatch(), state => !_.isNil(state.get(param)));
|
|
7613
|
-
// return _.isNil(lastStateWithParam) ? defaultValue : lastStateWithParam.get(param);
|
|
7614
|
-
// }
|
|
7615
|
-
//
|
|
7616
|
-
// limit(limit: number): this {
|
|
7617
|
-
// this._limit = limit;
|
|
7618
|
-
// return this;
|
|
7619
|
-
// }
|
|
7620
|
-
//
|
|
7621
|
-
// matching(predicate: (visit: Visit.State) => boolean): this {
|
|
7622
|
-
// this._predicate = predicate;
|
|
7623
|
-
// return this;
|
|
7624
|
-
// }
|
|
7625
|
-
//
|
|
7626
|
-
// _matches(visit: Visit.State) {
|
|
7627
|
-
// return this._isPlaceMatch(visit) && this._predicate(visit);
|
|
7628
|
-
// }
|
|
7629
|
-
//
|
|
7630
|
-
// _isPlaceMatch(visit: Visit.State) {
|
|
7631
|
-
// return this._places.length < 1 || this._places.includes(visit.place)
|
|
7632
|
-
// }
|
|
7633
|
-
//
|
|
7634
|
-
// }
|
|
7635
|
-
})(exports.PlaceHistory || (exports.PlaceHistory = {}));
|
|
7636
|
-
|
|
7637
7721
|
exports.UrlSnapshot = /** @class */ (function () {
|
|
7638
7722
|
// TODO: Update this accept a url Parser so it can be immutable and generate new trees on mutation using toString() are parseUrl.
|
|
7639
7723
|
function UrlSnapshot(urlSerializer, url) {
|
|
@@ -8159,75 +8243,6 @@
|
|
|
8159
8243
|
PlaceRouter.State = State;
|
|
8160
8244
|
})(exports.PlaceRouter || (exports.PlaceRouter = {}));
|
|
8161
8245
|
|
|
8162
|
-
var Visit = /** @class */ (function () {
|
|
8163
|
-
function Visit(placeDefinition, visitParameters) {
|
|
8164
|
-
if (visitParameters === void 0) { visitParameters = {}; }
|
|
8165
|
-
this.placeDefinition = placeDefinition;
|
|
8166
|
-
this.visitParameters = visitParameters;
|
|
8167
|
-
}
|
|
8168
|
-
// @Trace()
|
|
8169
|
-
Visit.prototype.getRouteId = function () {
|
|
8170
|
-
return this.placeDefinition.getRouteIdFrom(this);
|
|
8171
|
-
};
|
|
8172
|
-
// @Trace()
|
|
8173
|
-
Visit.prototype.hasRouteId = function () {
|
|
8174
|
-
return !___namespace.isNil(this.getRouteId());
|
|
8175
|
-
};
|
|
8176
|
-
/**
|
|
8177
|
-
* Returns the value of the place parameter with the specified name. The parameter
|
|
8178
|
-
* name is taken from the `as` option, e.g. {as: 'aCustomName'} otherwise it is the
|
|
8179
|
-
* same as the the ValueModel property name.
|
|
8180
|
-
* @param parameterName the field name of the property model or the `as` option if specified.
|
|
8181
|
-
*/
|
|
8182
|
-
Visit.prototype.getParameter = function (parameterName) {
|
|
8183
|
-
return this.visitParameters[parameterName];
|
|
8184
|
-
};
|
|
8185
|
-
// @Trace()
|
|
8186
|
-
Visit.prototype.hasParameter = function (parameterName) {
|
|
8187
|
-
return Object.keys(this.visitParameters).includes(parameterName);
|
|
8188
|
-
};
|
|
8189
|
-
Visit.prototype.replace = function (parameter, value) {
|
|
8190
|
-
var _a;
|
|
8191
|
-
return new Visit(this.placeDefinition, Object.assign(Object.assign({}, this.visitParameters), (_a = {}, _a[parameter.name] = value, _a)));
|
|
8192
|
-
};
|
|
8193
|
-
Visit.prototype.mergeRouteParameters = function (routeParams) {
|
|
8194
|
-
var _this = this;
|
|
8195
|
-
// todo: whitelist parameters.
|
|
8196
|
-
var routeParameterKeys = Object.keys(routeParams);
|
|
8197
|
-
var params = {};
|
|
8198
|
-
this.placeDefinition.getVisitParameterDefs().forEach(function (def) {
|
|
8199
|
-
if (def.isRouteId || def.isRouteParameter) {
|
|
8200
|
-
if (routeParameterKeys.includes(def.name)) {
|
|
8201
|
-
params[def.name] = routeParams[def.name];
|
|
8202
|
-
}
|
|
8203
|
-
}
|
|
8204
|
-
else {
|
|
8205
|
-
// copy non route params as is, but only if they already exist otherwise we'll inject nil values and break the
|
|
8206
|
-
// defaults and remember sanitisation process.
|
|
8207
|
-
var value = _this.getParameter(def.name);
|
|
8208
|
-
if (_this.hasParameter(def.name)) {
|
|
8209
|
-
params[def.name] = value;
|
|
8210
|
-
}
|
|
8211
|
-
}
|
|
8212
|
-
});
|
|
8213
|
-
return new Visit(this.placeDefinition, params);
|
|
8214
|
-
};
|
|
8215
|
-
Visit.prototype.hasRoutingChangedFrom = function (other) {
|
|
8216
|
-
var samePlace = other.placeDefinition === this.placeDefinition;
|
|
8217
|
-
var sameRouteParameters = ___namespace.isEqual(this.placeDefinition.getFormattedRouteParameters(this, true), this.placeDefinition.getFormattedRouteParameters(other, true));
|
|
8218
|
-
return !samePlace || !sameRouteParameters;
|
|
8219
|
-
};
|
|
8220
|
-
Visit.prototype.hasChangedFrom = function (other) {
|
|
8221
|
-
var sameNonRouteParameters = ___namespace.isEqual(this.placeDefinition.getNonRouteParameters(this), this.placeDefinition.getNonRouteParameters(other));
|
|
8222
|
-
return !sameNonRouteParameters || this.hasRoutingChangedFrom(other);
|
|
8223
|
-
};
|
|
8224
|
-
Visit.prototype.toDebugString = function () {
|
|
8225
|
-
var _this = this;
|
|
8226
|
-
return Object.keys(this.visitParameters).map(function (k) { return k + "=" + _this.visitParameters[k]; }).join(',');
|
|
8227
|
-
};
|
|
8228
|
-
return Visit;
|
|
8229
|
-
}());
|
|
8230
|
-
|
|
8231
8246
|
var AUP_PLACE_CONFIG = new i0.InjectionToken('AUP_PLACE_CONFIG');
|
|
8232
8247
|
|
|
8233
8248
|
var NotAuthorisedNoticeComponent = /** @class */ (function () {
|
|
@@ -9268,18 +9283,25 @@
|
|
|
9268
9283
|
Formatter.BOOLEAN = new BooleanType();
|
|
9269
9284
|
})(exports.Formatter || (exports.Formatter = {}));
|
|
9270
9285
|
|
|
9271
|
-
function installMechanics(prototype, propertyKey,
|
|
9272
|
-
|
|
9273
|
-
|
|
9274
|
-
|
|
9275
|
-
|
|
9276
|
-
|
|
9277
|
-
|
|
9286
|
+
function installMechanics(prototype, propertyKey, backingModelFactory, tagPrefix, isEmpty) {
|
|
9287
|
+
function getMechanics(instance, propertyName) {
|
|
9288
|
+
var key = "__mechanics_" + propertyName.toString();
|
|
9289
|
+
if (!instance[key]) {
|
|
9290
|
+
instance[key] = {
|
|
9291
|
+
backingModel: backingModelFactory(),
|
|
9292
|
+
binding: null
|
|
9293
|
+
};
|
|
9294
|
+
var tag = tagPrefix + "(" + prototype.constructor.name + "." + propertyKey.toString() + ")";
|
|
9295
|
+
pectin.DebugContext.getOrCreate(instance[key].backingModel).tag(tag);
|
|
9296
|
+
}
|
|
9297
|
+
return instance[key];
|
|
9298
|
+
}
|
|
9278
9299
|
Object.defineProperty(prototype, propertyKey, {
|
|
9279
9300
|
get: function () {
|
|
9280
|
-
return
|
|
9301
|
+
return getMechanics(this, propertyKey).backingModel;
|
|
9281
9302
|
},
|
|
9282
9303
|
set: function (userModel) {
|
|
9304
|
+
var mechanics = getMechanics(this, propertyKey);
|
|
9283
9305
|
// This handles the scenario where we want to push an existing value model (such as a form model)
|
|
9284
9306
|
// to and from the route.
|
|
9285
9307
|
if (mechanics.binding) {
|
|
@@ -9308,7 +9330,7 @@
|
|
|
9308
9330
|
return function (prototype, propertyKey) {
|
|
9309
9331
|
var param = new exports.ParameterDefinition.RouteId(propertyKey.toString(), options, type);
|
|
9310
9332
|
typescriptUtilities.Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
|
|
9311
|
-
installMechanics(prototype, propertyKey, new pectin.MutableValueModel(), '@RouteId', function (m) { return m.query().isNil(); });
|
|
9333
|
+
installMechanics(prototype, propertyKey, function () { return new pectin.MutableValueModel(); }, '@RouteId', function (m) { return m.query().isNil(); });
|
|
9312
9334
|
};
|
|
9313
9335
|
}
|
|
9314
9336
|
function VisitParameter(options) {
|
|
@@ -9316,7 +9338,7 @@
|
|
|
9316
9338
|
return function (prototype, propertyKey) {
|
|
9317
9339
|
var param = new exports.ParameterDefinition.ValueParameter(propertyKey.toString(), options, opts.getOptional('storeInUrl', null));
|
|
9318
9340
|
typescriptUtilities.Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
|
|
9319
|
-
installMechanics(prototype, propertyKey, new pectin.MutableValueModel(), '@VisitParameter', function (m) { return m.query().isNil(); });
|
|
9341
|
+
installMechanics(prototype, propertyKey, function () { return new pectin.MutableValueModel(); }, '@VisitParameter', function (m) { return m.query().isNil(); });
|
|
9320
9342
|
};
|
|
9321
9343
|
}
|
|
9322
9344
|
function VisitParameterList(options) {
|
|
@@ -9324,7 +9346,7 @@
|
|
|
9324
9346
|
return function (prototype, propertyKey) {
|
|
9325
9347
|
var param = new exports.ParameterDefinition.ArrayParameter(propertyKey.toString(), options, opts.getOptional('storeInUrl', null));
|
|
9326
9348
|
typescriptUtilities.Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
|
|
9327
|
-
installMechanics(prototype, propertyKey, new pectin.MutableListModel(), '@VisitParameterList', function (m) { return m.query().isEmpty(); });
|
|
9349
|
+
installMechanics(prototype, propertyKey, function () { return new pectin.MutableListModel(); }, '@VisitParameterList', function (m) { return m.query().isEmpty(); });
|
|
9328
9350
|
};
|
|
9329
9351
|
}
|
|
9330
9352
|
|