@coolon/angular-ui-powerups 0.0.121 → 0.0.123

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 (27) hide show
  1. package/bundles/coolon-angular-ui-powerups.umd.js +117 -14
  2. package/bundles/coolon-angular-ui-powerups.umd.js.map +1 -1
  3. package/bundles/coolon-angular-ui-powerups.umd.min.js +1 -1
  4. package/bundles/coolon-angular-ui-powerups.umd.min.js.map +1 -1
  5. package/esm2015/lib/place/components/place-outlet/place-outlet.component.js +8 -3
  6. package/esm2015/lib/place/components/place-outlet/place-outlet.component.js.map +1 -1
  7. package/esm2015/lib/place/place-component.js +19 -5
  8. package/esm2015/lib/place/place-component.js.map +1 -1
  9. package/esm2015/lib/place/place-component.metadata.json +1 -1
  10. package/esm2015/lib/place/place-definition.js +7 -1
  11. package/esm2015/lib/place/place-definition.js.map +1 -1
  12. package/esm2015/lib/place/route/parameter-decorators.js +83 -7
  13. package/esm2015/lib/place/route/parameter-decorators.js.map +1 -1
  14. package/esm5/lib/place/components/place-outlet/place-outlet.component.js +8 -3
  15. package/esm5/lib/place/components/place-outlet/place-outlet.component.js.map +1 -1
  16. package/esm5/lib/place/place-component.js +19 -5
  17. package/esm5/lib/place/place-component.js.map +1 -1
  18. package/esm5/lib/place/place-definition.js +11 -2
  19. package/esm5/lib/place/place-definition.js.map +1 -1
  20. package/esm5/lib/place/route/parameter-decorators.js +83 -7
  21. package/esm5/lib/place/route/parameter-decorators.js.map +1 -1
  22. package/fesm2015/coolon-angular-ui-powerups.js +114 -14
  23. package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
  24. package/fesm5/coolon-angular-ui-powerups.js +118 -15
  25. package/fesm5/coolon-angular-ui-powerups.js.map +1 -1
  26. package/lib/place/place-component.d.ts +1 -1
  27. package/package.json +2 -2
@@ -3,12 +3,13 @@
3
3
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4
4
  */
5
5
  import * as tslib_1 from "tslib";
6
- import { assert, Binding, DebugContext, lang } from '@coolon/pectin';
6
+ import { assert, Binding, DebugContext, lang, Trace } from '@coolon/pectin';
7
7
  import { Klass } from '@coolon/typescript-utilities';
8
8
  import { Memoize } from '@typescript-plus/fast-memoize-decorator';
9
9
  import 'reflect-metadata';
10
10
  import { DisposableComponent } from '../components/disposable-component';
11
11
  import { PlaceDefinition } from './place-definition';
12
+ import { ParameterDefinition } from './route/parameter-definition.class';
12
13
  // RAKE: making this Symbol(...) broke things.
13
14
  /** @type {?} */
14
15
  export var DEFINITION_META_DATA_KEY = 'PLACE_DEFINITION_OPTIONS';
@@ -24,7 +25,7 @@ var PlaceComponent = /** @class */ (function (_super) {
24
25
  * @param {?} visit
25
26
  * @return {?}
26
27
  */
27
- PlaceComponent.prototype.initialiseBindings = /**
28
+ PlaceComponent.prototype.initialiseVisit = /**
28
29
  * @param {?} visit
29
30
  * @return {?}
30
31
  */
@@ -56,8 +57,9 @@ var PlaceComponent = /** @class */ (function (_super) {
56
57
  function (parameterDef) {
57
58
  /** @type {?} */
58
59
  var model = (/** @type {?} */ (this[parameterDef.propertyName]));
59
- // this.txo.observe(parameterDef.propertyName, model);
60
- this.registerDisposable(new Binding(this.visit, model, {
60
+ DebugContext.tag(model, this.placeDefinition.component.name + "." + parameterDef.propertyName);
61
+ /** @type {?} */
62
+ var binding = this.registerDisposable(new Binding(this.visit, model, {
61
63
  toRight: /**
62
64
  * @param {?} visit
63
65
  * @return {?}
@@ -65,7 +67,7 @@ var PlaceComponent = /** @class */ (function (_super) {
65
67
  function (visit) {
66
68
  /** @type {?} */
67
69
  var value = visit.getParameter(parameterDef.name);
68
- // console.log('push to component', {name:parameterDef.name, value, visit});
70
+ console.log('push to component', { name: parameterDef.name, value: value, visit: visit });
69
71
  return value;
70
72
  },
71
73
  toLeft: /**
@@ -78,6 +80,12 @@ var PlaceComponent = /** @class */ (function (_super) {
78
80
  return currentVisit.replace(parameterDef, value);
79
81
  }
80
82
  }));
83
+ setTimeout((/**
84
+ * @return {?}
85
+ */
86
+ function () {
87
+ binding.writeRight();
88
+ }));
81
89
  };
82
90
  Object.defineProperty(PlaceComponent.prototype, "placeDefinition", {
83
91
  get: /**
@@ -111,6 +119,12 @@ var PlaceComponent = /** @class */ (function (_super) {
111
119
  */
112
120
  function () {
113
121
  };
122
+ tslib_1.__decorate([
123
+ Trace(),
124
+ tslib_1.__metadata("design:type", Function),
125
+ tslib_1.__metadata("design:paramtypes", [ParameterDefinition]),
126
+ tslib_1.__metadata("design:returntype", void 0)
127
+ ], PlaceComponent.prototype, "installBinding", null);
114
128
  tslib_1.__decorate([
115
129
  Memoize(),
116
130
  tslib_1.__metadata("design:type", PlaceDefinition),
@@ -1 +1 @@
1
- {"version":3,"file":"place-component.js","sourceRoot":"ng://@coolon/angular-ui-powerups/","sources":["lib/place/place-component.ts"],"names":[],"mappings":";;;;;AAAA,OAAO,EACL,MAAM,EACN,OAAO,EAEP,YAAY,EAEZ,IAAI,EAGL,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;AAClE,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAEzE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;;;AAKrD,MAAM,KAAO,wBAAwB,GAAG,0BAA0B;;;AAElE,MAAM,KAAO,wBAAwB,GAAG,MAAM,CAAC,wBAAwB,CAAC;AAExE;IAAoC,0CAAmB;IASrD;eACE,iBAAO;IACT,CAAC;;;;;IAEM,2CAAkB;;;;IAAzB,UAA0B,KAAwB;QAAlD,iBAOC;QANC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,YAAY,CAAC,GAAG,CAAC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AAC,CAAC;QAC7D,CAAC;;;OAAA;;;;IAED,qCAAY;;;IAAZ;IACA,CAAC;IATD;QADC,OAAO,EAAE;0CACa,eAAe;;yDAErC;IASH,qBAAC;CAAA,AAlDD,CAAoC,mBAAmB,GAkDtD;SAlDY,cAAc;;;;;;IAEzB,+BAAiC;;IAGjC,4CAAwC;;AA+C1C,WAAiB,cAAc;;;;;IAE7B,SAAgB,2BAA2B,CAAC,MAAW;QACrD,OAAO,IAAI,CAAC,gBAAgB,CAAC,mBAAA,MAAM,EAAsB,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;IACtF,CAAC;IAFe,0CAA2B,8BAE1C,CAAA;;;;;IAED,SAAgB,kBAAkB,CAAC,KAAoC;QACrE,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,eAAe,CAAC,wBAAwB,CAAC,CAAC;IACpE,CAAC;IAFe,iCAAkB,qBAEjC,CAAA;;;;;IAED,SAAgB,aAAa,CAAC,KAAoC;QAChE,OAAO,OAAO,CAAC,WAAW,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;IAC9D,CAAC;IAFe,4BAAa,gBAE5B,CAAA;;;;;;IAED,SAAgB,gBAAgB,CAAC,KAAoC,EAAE,UAA2B;QAChG,OAAO,CAAC,cAAc,CAAC,wBAAwB,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;IACtE,CAAC;IAFe,+BAAgB,mBAE/B,CAAA;AAEH,CAAC,EAlBgB,cAAc,KAAd,cAAc,QAkB9B","sourcesContent":["import {\n assert,\n Binding,\n Constructable,\n DebugContext,\n IMutableHasValue,\n lang,\n TransactionObserver,\n ValueModel\n} from '@coolon/pectin';\nimport { Klass } from '@coolon/typescript-utilities';\nimport { Memoize } from '@typescript-plus/fast-memoize-decorator';\nimport 'reflect-metadata';\nimport { DisposableComponent } from '../components/disposable-component';\nimport { InteractionContext } from '../interaction/interaction-context';\nimport { PlaceDefinition } from './place-definition';\nimport { ParameterDefinition } from './route/parameter-definition.class';\nimport { Visit } from './visit';\n\n// RAKE: making this Symbol(...) broke things.\nexport const DEFINITION_META_DATA_KEY = 'PLACE_DEFINITION_OPTIONS';\n// this one seems ok.\nexport const ROUTE_PARAMETER_LIST_KEY = Symbol('place:route:parameters');\n\nexport class PlaceComponent extends DisposableComponent {\n\n private visit: ValueModel<Visit>;\n // private _inDeactivationGuard = new MutableValueModel<boolean>(false);\n\n interactionContext?: InteractionContext;\n\n canDeactivate?(interactionContext: InteractionContext): boolean | Promise<boolean>;\n\n constructor() {\n super();\n }\n\n public initialiseBindings(visit: ValueModel<Visit>) {\n assert.isNil(this.visit);\n this.visit = visit;\n DebugContext.get(this.visit).tag(`${this.placeDefinition.component.name}.visit`);\n this.placeDefinition.getVisitParameterDefs().forEach(parameterDef => {\n this.installBinding(parameterDef);\n });\n }\n\n private installBinding<T, S>(parameterDef: ParameterDefinition<T, S>) {\n const model = this[parameterDef.propertyName] as IMutableHasValue<S>;\n // this.txo.observe(parameterDef.propertyName, model);\n this.registerDisposable(new Binding(this.visit, model, {\n toRight(visit: Visit): S {\n const value = visit.getParameter(parameterDef.name);\n // console.log('push to component', {name:parameterDef.name, value, visit});\n return value;\n },\n toLeft(value: S, currentVisit?: Visit): Visit {\n console.log('push to route', { name: parameterDef.name, value, currentVisit });\n return currentVisit.replace(parameterDef, value);\n }\n }));\n }\n\n @Memoize()\n get placeDefinition(): PlaceDefinition {\n return PlaceComponent.getDefinition(this.constructor as any as Constructable<PlaceComponent>);\n }\n\n get childPlaces(): Constructable<PlaceComponent>[] {\n return this.placeDefinition.children.map(d => d.component);\n }\n\n onPlaceReady() {\n }\n\n}\n\nexport namespace PlaceComponent {\n\n export function isPlaceComponentConstructor(target: any): target is Constructable<PlaceComponent> {\n return lang.constructorChain(target as Constructable<any>).includes(PlaceComponent);\n }\n\n export function getRouteParameters(klass: Constructable<PlaceComponent>): ParameterDefinition<any>[] {\n return Klass.get(klass).getMetadataList(ROUTE_PARAMETER_LIST_KEY);\n }\n\n export function getDefinition(klass: Constructable<PlaceComponent>): PlaceDefinition {\n return Reflect.getMetadata(DEFINITION_META_DATA_KEY, klass);\n }\n\n export function injectDefinition(klass: Constructable<PlaceComponent>, definition: PlaceDefinition) {\n Reflect.defineMetadata(DEFINITION_META_DATA_KEY, definition, klass);\n }\n\n}\n"]}
1
+ {"version":3,"file":"place-component.js","sourceRoot":"ng://@coolon/angular-ui-powerups/","sources":["lib/place/place-component.ts"],"names":[],"mappings":";;;;;AACA,OAAO,EACL,MAAM,EACN,OAAO,EAEP,YAAY,EAEZ,IAAI,EAAE,KAAK,EAGZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;AAClE,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAEzE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;;;AAIzE,MAAM,KAAO,wBAAwB,GAAG,0BAA0B;;;AAElE,MAAM,KAAO,wBAAwB,GAAG,MAAM,CAAC,wBAAwB,CAAC;AAExE;IAAoC,0CAAmB;IASrD;eACE,iBAAO;IACT,CAAC;;;;;IAEM,wCAAe;;;;IAAtB,UAAuB,KAAwB;QAA/C,iBAOC;QANC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAI,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,WAAQ,CAAC,CAAC;QACjF,IAAI,CAAC,eAAe,CAAC,qBAAqB,EAAE,CAAC,OAAO;;;;QAAC,UAAA,YAAY;YAC/D,KAAI,CAAC,c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IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,GAAG;;;;YAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,SAAS,EAAX,CAAW,EAAC,CAAC;QAC7D,CAAC;;;OAAA;;;;IAED,qCAAY;;;IAAZ;IACA,CAAC;IA7BD;QADC,KAAK,EAAE;;iDACmC,mBAAmB;;wDAiB7D;IAGD;QADC,OAAO,EAAE;0CACa,eAAe;;yDAErC;IASH,qBAAC;CAAA,AAtDD,CAAoC,mBAAmB,GAsDtD;SAtDY,cAAc;;;;;;IAEzB,+BAAiC;;IAGjC,4CAAwC;;AAmD1C,WAAiB,cAAc;;;;;IAE7B,SAAgB,2BAA2B,CAAC,MAAW;QACrD,OAAO,IAAI,CAAC,gBAAgB,CAAC,mBAAA,MAAM,EAAsB,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;IACtF,CAAC;IAFe,0CAA2B,8BAE1C,CAAA;;;;;IAED,SAAgB,kBAAkB,CAAC,KAAoC;QACrE,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,eAAe,CAAC,wBAAwB,CAAC,CAAC;IACpE,CAAC;IAFe,iCAAkB,qBAEjC,CAAA;;;;;IAED,SAAgB,aAAa,CAAC,KAAoC;QAChE,OAAO,OAAO,CAAC,WAAW,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;IAC9D,CAAC;IAFe,4BAAa,gBAE5B,CAAA;;;;;;IAED,SAAgB,gBAAgB,CAAC,KAAoC,EAAE,UAA2B;QAChG,OAAO,CAAC,cAAc,CAAC,wBAAwB,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;IACtE,CAAC;IAFe,+BAAgB,mBAE/B,CAAA;AAEH,CAAC,EAlBgB,cAAc,KAAd,cAAc,QAkB9B","sourcesContent":["import { AfterViewInit } from '@angular/core';\nimport {\n assert,\n Binding,\n Constructable,\n DebugContext,\n IMutableHasValue,\n lang, Trace,\n TransactionObserver,\n ValueModel\n} from '@coolon/pectin';\nimport { Klass } from '@coolon/typescript-utilities';\nimport { Memoize } from '@typescript-plus/fast-memoize-decorator';\nimport 'reflect-metadata';\nimport { DisposableComponent } from '../components/disposable-component';\nimport { InteractionContext } from '../interaction/interaction-context';\nimport { PlaceDefinition } from './place-definition';\nimport { ParameterDefinition } from './route/parameter-definition.class';\nimport { Visit } from './visit';\n\n// RAKE: making this Symbol(...) broke things.\nexport const DEFINITION_META_DATA_KEY = 'PLACE_DEFINITION_OPTIONS';\n// this one seems ok.\nexport const ROUTE_PARAMETER_LIST_KEY = Symbol('place:route:parameters');\n\nexport class PlaceComponent extends DisposableComponent {\n\n private visit: ValueModel<Visit>;\n // private _inDeactivationGuard = new MutableValueModel<boolean>(false);\n\n interactionContext?: InteractionContext;\n\n canDeactivate?(interactionContext: InteractionContext): boolean | Promise<boolean>;\n\n constructor() {\n super();\n }\n\n public initialiseVisit(visit: ValueModel<Visit>) {\n assert.isNil(this.visit);\n this.visit = visit;\n DebugContext.get(this.visit).tag(`${this.placeDefinition.component.name}.visit`);\n this.placeDefinition.getVisitParameterDefs().forEach(parameterDef => {\n this.installBinding(parameterDef);\n });\n }\n\n @Trace()\n private installBinding<T, S>(parameterDef: ParameterDefinition<T, S>) {\n const model = this[parameterDef.propertyName] as IMutableHasValue<S>;\n DebugContext.tag(model, `${this.placeDefinition.component.name}.${parameterDef.propertyName}`);\n const binding = this.registerDisposable(new Binding(this.visit, model, {\n toRight(visit: Visit): S {\n const value = visit.getParameter(parameterDef.name);\n console.log('push to component', {name:parameterDef.name, value, visit});\n return value;\n },\n toLeft(value: S, currentVisit?: Visit): Visit {\n console.log('push to route', { name: parameterDef.name, value, currentVisit });\n return currentVisit.replace(parameterDef, value);\n }\n }));\n setTimeout(() => {\n binding.writeRight();\n })\n }\n\n @Memoize()\n get placeDefinition(): PlaceDefinition {\n return PlaceComponent.getDefinition(this.constructor as any as Constructable<PlaceComponent>);\n }\n\n get childPlaces(): Constructable<PlaceComponent>[] {\n return this.placeDefinition.children.map(d => d.component);\n }\n\n onPlaceReady() {\n }\n\n}\n\nexport namespace PlaceComponent {\n\n export function isPlaceComponentConstructor(target: any): target is Constructable<PlaceComponent> {\n return lang.constructorChain(target as Constructable<any>).includes(PlaceComponent);\n }\n\n export function getRouteParameters(klass: Constructable<PlaceComponent>): ParameterDefinition<any>[] {\n return Klass.get(klass).getMetadataList(ROUTE_PARAMETER_LIST_KEY);\n }\n\n export function getDefinition(klass: Constructable<PlaceComponent>): PlaceDefinition {\n return Reflect.getMetadata(DEFINITION_META_DATA_KEY, klass);\n }\n\n export function injectDefinition(klass: Constructable<PlaceComponent>, definition: PlaceDefinition) {\n Reflect.defineMetadata(DEFINITION_META_DATA_KEY, definition, klass);\n }\n\n}\n"]}
@@ -150,12 +150,16 @@ var PlaceDefinition = /** @class */ (function () {
150
150
  // an empty string.
151
151
  return visit.hasRouteId() ? this.getRouteIdParameterDef().urlFormat.format(visit.getRouteId()) : "";
152
152
  };
153
+ // @Trace()
154
+ // @Trace()
153
155
  /**
154
156
  * @param {?} visit
155
157
  * @param {?=} includeRouteId
156
158
  * @return {?}
157
159
  */
158
- PlaceDefinition.prototype.getFormattedRouteParameters = /**
160
+ PlaceDefinition.prototype.getFormattedRouteParameters =
161
+ // @Trace()
162
+ /**
159
163
  * @param {?} visit
160
164
  * @param {?=} includeRouteId
161
165
  * @return {?}
@@ -241,8 +245,13 @@ var PlaceDefinition = /** @class */ (function () {
241
245
  // params will return null for non existent names
242
246
  if (params.has(def.name)) {
243
247
  if (def.isArray) {
248
+ // const values = params.getAll(def.name); // TODO: EEEK getAll is returning ["1,2,3,4"] when we gave it ["1","2","3","4"].
244
249
  /** @type {?} */
245
- var values = params.getAll(def.name);
250
+ var values = params.get(def.name).split(',').map((/**
251
+ * @param {?} s
252
+ * @return {?}
253
+ */
254
+ function (s) { return s.trim(); }));
246
255
  result[def.name] = values.map((/**
247
256
  * @param {?} v
248
257
  * @return {?}
@@ -1 +1 @@
1
- {"version":3,"file":"place-definition.js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M,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC;oBAClC,IAAI,GAAG,CAAC,SAAS,EAAE,EAAE,8DAA8D;wBACjF,6EAA6E;wBAC7E,wFAAwF;wBACxF,0EAA0E;wBAC1E,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;4BACrB,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;yBAC/C;qBACF;yBAAM;wBACL,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;qBAC/C;iBACF;aACF;QACH,CAAC,EAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;IA7GD;QADC,OAAO,EAAE;;;gDACgB,mBAAmB;iEAE5C;IAGD;QADC,OAAO,EAAE;;;;gEAGT;IAGD;QADC,OAAO,EAAE;;;;gEAYT;IA0FH,sBAAC;CAAA,AA9HD,IA8HC;SA9HY,eAAe;;;IAEd,oCAAiD;;IACjD,+BAAqB;;IACrB,uCAA8B;;IAC9B,+BAAqC;;IACrC,0CAAoD;;IACpD,mCAAoC;;AAyHlD,WAAiB,eAAe;;;;IAC9B,+BAIC;;;;QAHC,0CAAyB;;QACzB,kDAAiC;;QACjC,qDAAoC;;AAExC,CAAC,EANgB,eAAe,KAAf,eAAe,QAM/B","sourcesContent":["import { ParamMap } from '@angular/router';\nimport { assert, Constructable, Trace } from '@coolon/pectin';\nimport { Opts } from '@coolon/typescript-utilities';\nimport { Memoize } from '@typescript-plus/fast-memoize-decorator/dist/src';\nimport _ from 'lodash';\nimport { PlaceComponent } from './place-component';\nimport { ParameterDefinition } from './route/parameter-definition.class';\nimport { Visit } from './visit';\n\nexport class PlaceDefinition {\n\n constructor(readonly component: Constructable<PlaceComponent>,\n readonly path: string,\n readonly authenticate: boolean,\n readonly data: { [key: string]: any },\n readonly routeParameters: ParameterDefinition<any>[],\n readonly children: PlaceDefinition[]) {\n }\n\n hasRouteId() {\n return !!this.getRouteIdParameterDef();\n }\n\n @Memoize()\n getRouteIdParameterDef(): ParameterDefinition<any> {\n return this.routeParameters.find(p => p.isRouteId);\n }\n\n @Memoize()\n getRouteParameterDefs(includeRouteId = false): ParameterDefinition<any>[] {\n return this.getVisitParameterDefs({ includeRouteId, includeRouteParameters: true });\n }\n\n @Memoize()\n getVisitParameterDefs(include?: PlaceDefinition.ParameterOptions): ParameterDefinition<any>[] {\n const opts = Opts.get(include);\n // includes\n const includeRouteId = !include || opts.getOptional('includeRouteId', false);\n const includeRouteParameters = !include || opts.getOptional('includeRouteParameters', false);\n const includeNonRouteParameters = !include || opts.getOptional('includeNonRouteParameters', false);\n return this.routeParameters.filter(p => {\n return (includeRouteId && p.isRouteId)\n || (includeRouteParameters && p.isRouteParameter && !p.isRouteId) // route id is included in the line above\n || (includeNonRouteParameters && !p.isRouteParameter);\n });\n }\n\n getPlaceData<T>(key: string, defaultValue?: T): T {\n return this.data ?\n _.isNil(this.data[key]) ? defaultValue : this.data[key] :\n defaultValue;\n }\n\n searchPlaceData<T>(keys: string[], defaultValue?: T): T {\n if (this.data) {\n const found = keys.find(key => !_.isNil(this.data[key]));\n return found ? this.data[found] : defaultValue;\n } else {\n return defaultValue;\n }\n }\n\n getRouteIdFrom(visit: Visit) {\n const routeIdParameterDef = this.getRouteIdParameterDef();\n return routeIdParameterDef ? visit.getParameter(routeIdParameterDef.name) : null;\n }\n\n getFormattedRouteId(visit: Visit): any {\n // Note: RouteIds are always present in the url and are just empty strings when not defined. This is\n // mandated by the fact that redirects from <path> to <path>/:id always include the id parameter as\n // an empty string.\n return visit.hasRouteId() ? this.getRouteIdParameterDef().urlFormat.format(visit.getRouteId()) : \"\";\n }\n\n getFormattedRouteParameters(visit: Visit, includeRouteId = false): { [p: string]: string } {\n const result: { [p: string]: string } = {};\n this.getVisitParameterDefs({\n includeRouteId, includeRouteParameters: true\n }).forEach(def => {\n const value = visit.getParameter(def.name);\n if (!def.isEmptyValue(value)) {\n if (def.isArray) {\n assert.isArray(value);\n result[def.name] = value.map(v => def.urlFormat.format(v));\n } else {\n assert.isFalsey(Array.isArray(value));\n result[def.name] = def.urlFormat.format(value);\n }\n }\n });\n return result;\n }\n\n getNonRouteParameters(visit: Visit): { [p: string]: string } {\n const result: { [p: string]: string } = {};\n this.getVisitParameterDefs({ includeNonRouteParameters: true }).forEach(def => {\n const value = visit.getParameter(def.name);\n if (!def.isEmptyValue(value)) {\n result[def.name] = value;\n }\n });\n return result;\n }\n\n // @Trace()\n parseRouteParams(params: ParamMap): { [p: string]: any } {\n const result: { [p: string]: any } = {};\n this.getVisitParameterDefs({\n includeRouteId: true,\n includeRouteParameters: true,\n includeNonRouteParameters: false\n }).forEach(def => {\n // params will return null for non existent names\n if (params.has(def.name)) {\n if (def.isArray) {\n const values = params.getAll(def.name);\n result[def.name] = values.map(v => def.urlFormat.parse(v));\n } else {\n const value = params.get(def.name);\n if (def.isRouteId) { // TODO: Move this to parameter def so it's a strategy pattern\n // because our id routes redirect if the id isn't present we always have a id\n // parameter in our params. This will bugger our remember and defaultvalue sanitisation\n // as it'll see that the id is present (event thought its a blank string).\n if (!_.isEmpty(value)) {\n result[def.name] = def.urlFormat.parse(value);\n }\n } else {\n result[def.name] = def.urlFormat.parse(value);\n }\n }\n }\n });\n return result;\n }\n\n}\n\nexport namespace PlaceDefinition {\n export interface ParameterOptions {\n includeRouteId?: boolean;\n includeRouteParameters?: boolean;\n includeNonRouteParameters?: boolean;\n }\n}\n"]}
1
+ {"version":3,"file":"place-definition.js","sourceRoot":"ng://@coolon/angular-ui-powerups/","sources":["lib/place/place-definition.ts"],"names":[],"mappings":";;;;;AACA,OAAO,EAAE,MAAM,EAAwB,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,kDAAk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EAAE,8DAA8D;wBACjF,6EAA6E;wBAC7E,wFAAwF;wBACxF,0EAA0E;wBAC1E,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;4BACrB,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;yBAC/C;qBACF;yBAAM;wBACL,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;qBAC/C;iBACF;aACF;QACH,CAAC,EAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;IA/GD;QADC,OAAO,EAAE;;;gDACgB,mBAAmB;iEAE5C;IAGD;QADC,OAAO,EAAE;;;;gEAGT;IAGD;QADC,OAAO,EAAE;;;;gEAYT;IA4FH,sBAAC;CAAA,AAhID,IAgIC;SAhIY,eAAe;;;IAEd,oCAAiD;;IACjD,+BAAqB;;IACrB,uCAA8B;;IAC9B,+BAAqC;;IACrC,0CAAoD;;IACpD,mCAAoC;;AA2HlD,WAAiB,eAAe;;;;IAC9B,+BAIC;;;;QAHC,0CAAyB;;QACzB,kDAAiC;;QACjC,qDAAoC;;AAExC,CAAC,EANgB,eAAe,KAAf,eAAe,QAM/B","sourcesContent":["import { ParamMap } from '@angular/router';\nimport { assert, Constructable, Trace } from '@coolon/pectin';\nimport { Opts } from '@coolon/typescript-utilities';\nimport { Memoize } from '@typescript-plus/fast-memoize-decorator/dist/src';\nimport _ from 'lodash';\nimport { PlaceComponent } from './place-component';\nimport { ParameterDefinition } from './route/parameter-definition.class';\nimport { Visit } from './visit';\n\nexport class PlaceDefinition {\n\n constructor(readonly component: Constructable<PlaceComponent>,\n readonly path: string,\n readonly authenticate: boolean,\n readonly data: { [key: string]: any },\n readonly routeParameters: ParameterDefinition<any>[],\n readonly children: PlaceDefinition[]) {\n }\n\n hasRouteId() {\n return !!this.getRouteIdParameterDef();\n }\n\n @Memoize()\n getRouteIdParameterDef(): ParameterDefinition<any> {\n return this.routeParameters.find(p => p.isRouteId);\n }\n\n @Memoize()\n getRouteParameterDefs(includeRouteId = false): ParameterDefinition<any>[] {\n return this.getVisitParameterDefs({ includeRouteId, includeRouteParameters: true });\n }\n\n @Memoize()\n getVisitParameterDefs(include?: PlaceDefinition.ParameterOptions): ParameterDefinition<any>[] {\n const opts = Opts.get(include);\n // includes\n const includeRouteId = !include || opts.getOptional('includeRouteId', false);\n const includeRouteParameters = !include || opts.getOptional('includeRouteParameters', false);\n const includeNonRouteParameters = !include || opts.getOptional('includeNonRouteParameters', false);\n return this.routeParameters.filter(p => {\n return (includeRouteId && p.isRouteId)\n || (includeRouteParameters && p.isRouteParameter && !p.isRouteId) // route id is included in the line above\n || (includeNonRouteParameters && !p.isRouteParameter);\n });\n }\n\n getPlaceData<T>(key: string, defaultValue?: T): T {\n return this.data ?\n _.isNil(this.data[key]) ? defaultValue : this.data[key] :\n defaultValue;\n }\n\n searchPlaceData<T>(keys: string[], defaultValue?: T): T {\n if (this.data) {\n const found = keys.find(key => !_.isNil(this.data[key]));\n return found ? this.data[found] : defaultValue;\n } else {\n return defaultValue;\n }\n }\n\n getRouteIdFrom(visit: Visit) {\n const routeIdParameterDef = this.getRouteIdParameterDef();\n return routeIdParameterDef ? visit.getParameter(routeIdParameterDef.name) : null;\n }\n\n getFormattedRouteId(visit: Visit): any {\n // Note: RouteIds are always present in the url and are just empty strings when not defined. This is\n // mandated by the fact that redirects from <path> to <path>/:id always include the id parameter as\n // an empty string.\n return visit.hasRouteId() ? this.getRouteIdParameterDef().urlFormat.format(visit.getRouteId()) : \"\";\n }\n\n // @Trace()\n getFormattedRouteParameters(visit: Visit, includeRouteId = false): { [p: string]: string } {\n const result: { [p: string]: string } = {};\n this.getVisitParameterDefs({\n includeRouteId, includeRouteParameters: true\n }).forEach(def => {\n const value = visit.getParameter(def.name);\n if (!def.isEmptyValue(value)) {\n if (def.isArray) {\n assert.isArray(value);\n result[def.name] = value.map(v => def.urlFormat.format(v));\n } else {\n assert.isFalsey(Array.isArray(value));\n result[def.name] = def.urlFormat.format(value);\n }\n }\n });\n return result;\n }\n\n getNonRouteParameters(visit: Visit): { [p: string]: string } {\n const result: { [p: string]: string } = {};\n this.getVisitParameterDefs({ includeNonRouteParameters: true }).forEach(def => {\n const value = visit.getParameter(def.name);\n if (!def.isEmptyValue(value)) {\n result[def.name] = value;\n }\n });\n return result;\n }\n\n // @Trace()\n parseRouteParams(params: ParamMap): { [p: string]: any } {\n const result: { [p: string]: any } = {};\n this.getVisitParameterDefs({\n includeRouteId: true,\n includeRouteParameters: true,\n includeNonRouteParameters: false\n }).forEach(def => {\n // params will return null for non existent names\n if (params.has(def.name)) {\n if (def.isArray) {\n // const values = params.getAll(def.name); // TODO: EEEK getAll is returning [\"1,2,3,4\"] when we gave it [\"1\",\"2\",\"3\",\"4\"].\n const values = params.get(def.name).split(',').map(s => s.trim());\n result[def.name] = values.map(v => def.urlFormat.parse(v));\n } else {\n const value = params.get(def.name);\n if (def.isRouteId) { // TODO: Move this to parameter def so it's a strategy pattern\n // because our id routes redirect if the id isn't present we always have a id\n // parameter in our params. This will bugger our remember and defaultvalue sanitisation\n // as it'll see that the id is present (event thought its a blank string).\n if (!_.isEmpty(value)) {\n result[def.name] = def.urlFormat.parse(value);\n }\n } else {\n result[def.name] = def.urlFormat.parse(value);\n }\n }\n }\n });\n return result;\n }\n\n}\n\nexport namespace PlaceDefinition {\n export interface ParameterOptions {\n includeRouteId?: boolean;\n includeRouteParameters?: boolean;\n includeNonRouteParameters?: boolean;\n }\n}\n"]}
@@ -2,7 +2,7 @@
2
2
  * @fileoverview added by tsickle
3
3
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4
4
  */
5
- import { UseDelegate } from '@coolon/pectin';
5
+ import { Binding, DebugContext, Logger, MutableListModel, MutableValueModel, UseDelegate } from '@coolon/pectin';
6
6
  import { Klass, Opts } from '@coolon/typescript-utilities';
7
7
  import { ROUTE_PARAMETER_LIST_KEY } from '../place-component';
8
8
  import { ParameterDefinition } from './parameter-definition.class';
@@ -90,10 +90,48 @@ export function VisitParameter(options) {
90
90
  */
91
91
  function (prototype, propertyKey) {
92
92
  /** @type {?} */
93
- var param = new ParameterDefinition.ValueParameter(propertyKey.toString(), options, opts.getOptional("storeInUrl", null));
93
+ var param = new ParameterDefinition.ValueParameter(propertyKey.toString(), options, opts.getOptional('storeInUrl', null));
94
94
  Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
95
- UseDelegate({ tag: "@VisitParameter(" + prototype.constructor.name + "." + propertyKey.toString() + ")" })(prototype, propertyKey);
96
- // UseDelegate()(prototype, propertyKey);
95
+ /** @type {?} */
96
+ var mechanics = {
97
+ backingModel: new MutableValueModel(),
98
+ binding: (/** @type {?} */ (null))
99
+ };
100
+ /** @type {?} */
101
+ var tag = "@VisitParameter(" + prototype.constructor.name + "." + propertyKey.toString() + ")";
102
+ DebugContext.get(mechanics.backingModel).tag(tag);
103
+ Logger.get(mechanics.backingModel).tag(tag);
104
+ Object.defineProperty(prototype, propertyKey, {
105
+ get: (/**
106
+ * @return {?}
107
+ */
108
+ function () {
109
+ return mechanics.backingModel;
110
+ }),
111
+ set: (/**
112
+ * @param {?} userModel
113
+ * @return {?}
114
+ */
115
+ function (userModel) {
116
+ // This handles the scenario where we want to push an existing value model (such as a form model)
117
+ // to and from the route.
118
+ if (mechanics.binding) {
119
+ mechanics.binding.dispose();
120
+ }
121
+ if (userModel) {
122
+ mechanics.binding = new Binding(mechanics.backingModel, userModel);
123
+ if (userModel.query().isNil()) {
124
+ mechanics.binding.writeRight(); // push the visit into the user model;
125
+ }
126
+ else {
127
+ if (!mechanics.backingModel.query().isNil()) {
128
+ console.warn('Assigning a visit model with an existing value to a visit parameter with an existing value. Visit parameter will be overridden');
129
+ }
130
+ mechanics.binding.writeLeft(); // push the user model into the visit
131
+ }
132
+ }
133
+ })
134
+ });
97
135
  });
98
136
  }
99
137
  /**
@@ -111,10 +149,48 @@ export function VisitParameterList(options) {
111
149
  */
112
150
  function (prototype, propertyKey) {
113
151
  /** @type {?} */
114
- var param = new ParameterDefinition.ArrayParameter(propertyKey.toString(), options, opts.getOptional("storeInUrl", null));
115
- UseDelegate({ tag: "@VisitParameterList(" + prototype.constructor.name + "." + propertyKey.toString() + ")" })(prototype, propertyKey);
116
- // UseDelegate()(prototype, propertyKey);
152
+ var param = new ParameterDefinition.ArrayParameter(propertyKey.toString(), options, opts.getOptional('storeInUrl', null));
117
153
  Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
154
+ /** @type {?} */
155
+ var mechanics = {
156
+ backingModel: new MutableListModel(),
157
+ binding: (/** @type {?} */ (null))
158
+ };
159
+ /** @type {?} */
160
+ var tag = "@VisitParameterList(" + prototype.constructor.name + "." + propertyKey.toString() + ")";
161
+ DebugContext.get(mechanics.backingModel).tag(tag);
162
+ Logger.get(mechanics.backingModel).tag(tag);
163
+ Object.defineProperty(prototype, propertyKey, {
164
+ get: (/**
165
+ * @return {?}
166
+ */
167
+ function () {
168
+ return mechanics.backingModel;
169
+ }),
170
+ set: (/**
171
+ * @param {?} userModel
172
+ * @return {?}
173
+ */
174
+ function (userModel) {
175
+ // This handles the scenario where we want to push an existing value model (such as a form model)
176
+ // to and from the route.
177
+ if (mechanics.binding) {
178
+ mechanics.binding.dispose();
179
+ }
180
+ if (userModel) {
181
+ mechanics.binding = new Binding(mechanics.backingModel, userModel);
182
+ if (userModel.query().isEmpty()) {
183
+ mechanics.binding.writeRight(); // push the visit into the user model;
184
+ }
185
+ else {
186
+ if (!mechanics.backingModel.query().isEmpty()) {
187
+ console.warn('Assigning a visit model with an existing value to a visit parameter with an existing value. Visit parameter will be overridden');
188
+ }
189
+ mechanics.binding.writeLeft(); // push the user model into the visit
190
+ }
191
+ }
192
+ })
193
+ });
118
194
  });
119
195
  }
120
196
  //# sourceMappingURL=parameter-decorators.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"parameter-decorators.js","sourceRoot":"ng://@coolon/angular-ui-powerups/","sources":["lib/place/route/parameter-decorators.ts"],"names":[],"mappings":";;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;;;;;AAInE,oCAMC;;;IALC,4BAAY;;IACZ,kCAAmB;;IACnB,kCAAmB;;IACnB,sCAAiB;;;;;;AAInB,2CAOC;;;IANC,mCAAY;;IACZ,yCAAmB;;IACnB,yCAAmB;;IACnB,6CAAiB;;IACjB,2CAAyB;;;;;;AAI3B,+CAOC;;;IANC,uCAAY;;IACZ,6CAAmB;;IACnB,6CAAmB;;IACnB,iDAAmB;;IACnB,+CAAyB;;;;;;;;AAI3B,MAAM,UAAU,OAAO,CAA4B,IAAkB,EAAE,OAA2B;IAChG;;;;;IAAO,UAAC,SAAiB,EAAE,WAA4B;;YAC/C,KAAK,GAAG,IAAI,mBAAmB,CAAC,OAAO,CAAC,WAAW,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC;QACpF,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,oBAAoB,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;QAC3E,WAAW,CAAC,EAAC,GAAG,EAAE,cAAY,SAAS,CAAC,WAAW,CAAC,IAAI,SAAI,WAAW,CAAC,QAAQ,EAAE,MAAG,EAAC,CAAC,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;QAChH,yCAAyC;IAC3C,CAAC,EAAC;AACJ,CAAC;;;;;;AAED,MAAM,UAAU,cAAc,CAAI,OAAkC;;QAC5D,IAAI,GAAG,IAAI,CA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nimport { ParameterDefinition } from './parameter-definition.class';\nimport { Formatter } from './formatter';\n\n\nexport interface RouteIdOptions<T> {\n as?: string;\n optional?: boolean;\n remember?: boolean;\n defaultValue?: T;\n // sanitiser?: Constructable<ParameterSanitiser<T>> | ParameterSanitiser<T>;\n}\n\nexport interface RouteParameterOptions<T> {\n as?: string;\n optional?: boolean;\n remember?: boolean;\n defaultValue?: T;\n storeInUrl?: Formatter<T>\n // sanitiser?: Constructable<ParameterSanitiser<T>> | ParameterSanitiser<T>;\n}\n\nexport interface RouteListParameterOptions<T> {\n as?: string;\n optional?: boolean;\n remember?: boolean;\n defaultValue?: T[];\n storeInUrl?: Formatter<T>\n // sanitiser?: Constructable<ParameterSanitiser<T[]>> | ParameterSanitiser<T[]>;\n}\n\nexport function RouteId<T extends string | number>(type: Formatter<T>, options?: RouteIdOptions<T>): PropertyDecorator {\n return (prototype: Object, propertyKey: string | symbol) => {\n const param = new ParameterDefinition.RouteId(propertyKey.toString(), options, type);\n Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);\n UseDelegate({tag: `@RouteId(${prototype.constructor.name}.${propertyKey.toString()})`})(prototype, propertyKey);\n // UseDelegate()(prototype, propertyKey);\n };\n}\n\nexport function VisitParameter<T>(options?: RouteParameterOptions<T>): PropertyDecorator {\n const opts = Opts.get(options);\n return (prototype: Object, propertyKey: string | symbol) => {\n const param = new ParameterDefinition.ValueParameter(propertyKey.toString(), options, opts.getOptional(\"storeInUrl\", null));\n Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);\n UseDelegate({tag: `@VisitParameter(${prototype.constructor.name}.${propertyKey.toString()})`})(prototype, propertyKey);\n // UseDelegate()(prototype, propertyKey);\n };\n}\n\nexport function VisitParameterList<E>(options?: RouteListParameterOptions<E>): PropertyDecorator {\n const opts = Opts.get(options);\n return (prototype: Object, propertyKey: string | symbol) => {\n const param = new ParameterDefinition.ArrayParameter(propertyKey.toString(), options, opts.getOptional(\"storeInUrl\", null));\n UseDelegate({tag: `@VisitParameterList(${prototype.constructor.name}.${propertyKey.toString()})`})(prototype, propertyKey);\n // UseDelegate()(prototype, propertyKey);\n Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);\n };\n}\n\n// export function RouteParameter<T>(type: ParameterType<T>, options?: RouteParameterOptions<T>): PropertyDecorator {\n// return (prototype: Object, propertyKey: string | symbol) => {\n// const param = new ParameterDefinition.ValueParameter(propertyKey.toString(), options, type);\n// Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);\n// UseDelegate()(prototype, propertyKey);\n// };\n// }\n//\n// export function RouteParameterList<E>(elementType: ParameterType<E>, options?: RouteListParameterOptions<E>): PropertyDecorator {\n// return (prototype: Object, propertyKey: string | symbol) => {\n// const param = new ParameterDefinition.ArrayParameter(propertyKey.toString(), options, elementType);\n// Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);\n// UseDelegate()(prototype, propertyKey);\n// };\n// }\n"]}
1
+ {"version":3,"file":"parameter-decorators.js","sourceRoot":"ng://@coolon/angular-ui-powerups/","sources":["lib/place/route/parameter-decorators.ts"],"names":[],"mappings":";;;;AAAA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACjH,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;;;;;AAGnE,oCAMC;;;IALC,4BAAY;;IACZ,kCAAmB;;IACnB,kCAAmB;;IACnB,sCAAiB;;;;;;AAInB,2CAOC;;;IANC,mCAAY;;IACZ,yCAAmB;;IACnB,yCAAmB;;IACnB,6CAAiB;;IACjB,2CAAyB;;;;;;AAI3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CAAC,qCAAqC;qBACrE;iBACF;YACH,CAAC,CAAA;SACF,CAAC,CAAC;IAEL,CAAC,EAAC;AACJ,CAAC","sourcesContent":["import { Binding, DebugContext, Logger, MutableListModel, MutableValueModel, UseDelegate } from '@coolon/pectin';\nimport { Klass, Opts } from '@coolon/typescript-utilities';\nimport { ROUTE_PARAMETER_LIST_KEY } from '../place-component';\nimport { Formatter } from './formatter';\nimport { ParameterDefinition } from './parameter-definition.class';\n\n\nexport interface RouteIdOptions<T> {\n as?: string;\n optional?: boolean;\n remember?: boolean;\n defaultValue?: T;\n // sanitiser?: Constructable<ParameterSanitiser<T>> | ParameterSanitiser<T>;\n}\n\nexport interface RouteParameterOptions<T> {\n as?: string;\n optional?: boolean;\n remember?: boolean;\n defaultValue?: T;\n storeInUrl?: Formatter<T>\n // sanitiser?: Constructable<ParameterSanitiser<T>> | ParameterSanitiser<T>;\n}\n\nexport interface RouteListParameterOptions<T> {\n as?: string;\n optional?: boolean;\n remember?: boolean;\n defaultValue?: T[];\n storeInUrl?: Formatter<T>\n // sanitiser?: Constructable<ParameterSanitiser<T[]>> | ParameterSanitiser<T[]>;\n}\n\nexport function RouteId<T extends string | number>(type: Formatter<T>, options?: RouteIdOptions<T>): PropertyDecorator {\n return (prototype: Object, propertyKey: string | symbol) => {\n const param = new ParameterDefinition.RouteId(propertyKey.toString(), options, type);\n Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);\n UseDelegate({ tag: `@RouteId(${prototype.constructor.name}.${propertyKey.toString()})` })(prototype, propertyKey);\n // UseDelegate()(prototype, propertyKey);\n };\n}\n\nexport function VisitParameter<T>(options?: RouteParameterOptions<T>): PropertyDecorator {\n const opts = Opts.get(options);\n return (prototype: Object, propertyKey: string | symbol) => {\n const param = new ParameterDefinition.ValueParameter(propertyKey.toString(), options, opts.getOptional('storeInUrl', null));\n Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);\n const mechanics = {\n backingModel: new MutableValueModel<T>(),\n binding: null as Binding<T, T>\n };\n const tag = `@VisitParameter(${prototype.constructor.name}.${propertyKey.toString()})`;\n DebugContext.get(mechanics.backingModel).tag(tag);\n Logger.get(mechanics.backingModel).tag(tag);\n Object.defineProperty(prototype, propertyKey, {\n get: function() {\n return mechanics.backingModel;\n },\n set: function(userModel: MutableValueModel<T>) {\n // This handles the scenario where we want to push an existing value model (such as a form model)\n // to and from the route.\n if (mechanics.binding) {\n mechanics.binding.dispose();\n }\n if (userModel) {\n mechanics.binding = new Binding(mechanics.backingModel, userModel);\n if (userModel.query().isNil()) {\n mechanics.binding.writeRight(); // push the visit into the user model;\n } else {\n if (!mechanics.backingModel.query().isNil()) {\n console.warn('Assigning a visit model with an existing value to a visit parameter with an existing value. Visit parameter will be overridden');\n }\n mechanics.binding.writeLeft(); // push the user model into the visit\n }\n }\n }\n });\n };\n}\n\nexport function VisitParameterList<E>(options?: RouteListParameterOptions<E>): PropertyDecorator {\n const opts = Opts.get(options);\n return (prototype: Object, propertyKey: string | symbol) => {\n const param = new ParameterDefinition.ArrayParameter(propertyKey.toString(), options, opts.getOptional('storeInUrl', null));\n Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);\n const mechanics = {\n backingModel: new MutableListModel<E>(),\n binding: null as Binding<E[], E[]>\n };\n const tag = `@VisitParameterList(${prototype.constructor.name}.${propertyKey.toString()})`;\n DebugContext.get(mechanics.backingModel).tag(tag);\n Logger.get(mechanics.backingModel).tag(tag);\n Object.defineProperty(prototype, propertyKey, {\n get: function() {\n return mechanics.backingModel;\n },\n set: function(userModel: MutableListModel<E>) {\n // This handles the scenario where we want to push an existing value model (such as a form model)\n // to and from the route.\n if (mechanics.binding) {\n mechanics.binding.dispose();\n }\n if (userModel) {\n mechanics.binding = new Binding(mechanics.backingModel, userModel);\n if (userModel.query().isEmpty()) {\n mechanics.binding.writeRight(); // push the visit into the user model;\n } else {\n if (!mechanics.backingModel.query().isEmpty()) {\n console.warn('Assigning a visit model with an existing value to a visit parameter with an existing value. Visit parameter will be overridden');\n }\n mechanics.binding.writeLeft(); // push the user model into the visit\n }\n }\n }\n });\n\n };\n}\n\n// export function RouteParameter<T>(type: ParameterType<T>, options?: RouteParameterOptions<T>): PropertyDecorator {\n// return (prototype: Object, propertyKey: string | symbol) => {\n// const param = new ParameterDefinition.ValueParameter(propertyKey.toString(), options, type);\n// Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);\n// UseDelegate()(prototype, propertyKey);\n// };\n// }\n//\n// export function RouteParameterList<E>(elementType: ParameterType<E>, options?: RouteListParameterOptions<E>): PropertyDecorator {\n// return (prototype: Object, propertyKey: string | symbol) => {\n// const param = new ParameterDefinition.ArrayParameter(propertyKey.toString(), options, elementType);\n// Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);\n// UseDelegate()(prototype, propertyKey);\n// };\n// }\n"]}
@@ -4,7 +4,7 @@ import { FormsModule } from '@angular/forms';
4
4
  import { MatInputModule, MatFormFieldModule, MatSelectModule, MatButtonModule, MatDialogModule, MatTabsModule as MatTabsModule$1, MatProgressSpinnerModule, MatDialog } from '@angular/material';
5
5
  import { MatTabsModule } from '@angular/material/tabs';
6
6
  import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
7
- import { GarbageCollector, DelegatingValueModel, assert, UnaryCommand, lang, Dsl, Logger, DelegatingFormValueModel, UseDelegate, ValueModel, ListModel, StoreInListModel, DelegatingListModel, Deferred, MutableStream, MutableValueModel, MutableListModel, DebugContext, Binding, Guard, StoreInValueModel, Command, ValueHolder } from '@coolon/pectin';
7
+ import { GarbageCollector, DelegatingValueModel, assert, UnaryCommand, lang, Dsl, Logger, DelegatingFormValueModel, UseDelegate, ValueModel, ListModel, StoreInListModel, DelegatingListModel, Deferred, MutableStream, MutableValueModel, MutableListModel, DebugContext, Binding, Trace, Guard, StoreInValueModel, Command, ValueHolder } from '@coolon/pectin';
8
8
  import { __decorate, __metadata, __awaiter } from 'tslib';
9
9
  import { PortalModule } from '@angular/cdk/portal';
10
10
  import { RouterModule, UrlSegment, NavigationStart, NavigationEnd, NavigationError, NavigationCancel, Router, UrlSerializer } from '@angular/router';
@@ -2505,6 +2505,7 @@ class PlaceDefinition {
2505
2505
  // an empty string.
2506
2506
  return visit.hasRouteId() ? this.getRouteIdParameterDef().urlFormat.format(visit.getRouteId()) : "";
2507
2507
  }
2508
+ // @Trace()
2508
2509
  /**
2509
2510
  * @param {?} visit
2510
2511
  * @param {?=} includeRouteId
@@ -2579,8 +2580,13 @@ class PlaceDefinition {
2579
2580
  // params will return null for non existent names
2580
2581
  if (params.has(def.name)) {
2581
2582
  if (def.isArray) {
2583
+ // const values = params.getAll(def.name); // TODO: EEEK getAll is returning ["1,2,3,4"] when we gave it ["1","2","3","4"].
2582
2584
  /** @type {?} */
2583
- const values = params.getAll(def.name);
2585
+ const values = params.get(def.name).split(',').map((/**
2586
+ * @param {?} s
2587
+ * @return {?}
2588
+ */
2589
+ s => s.trim()));
2584
2590
  result[def.name] = values.map((/**
2585
2591
  * @param {?} v
2586
2592
  * @return {?}
@@ -2673,7 +2679,7 @@ class PlaceComponent extends DisposableComponent {
2673
2679
  * @param {?} visit
2674
2680
  * @return {?}
2675
2681
  */
2676
- initialiseBindings(visit) {
2682
+ initialiseVisit(visit) {
2677
2683
  assert.isNil(this.visit);
2678
2684
  this.visit = visit;
2679
2685
  DebugContext.get(this.visit).tag(`${this.placeDefinition.component.name}.visit`);
@@ -2694,8 +2700,9 @@ class PlaceComponent extends DisposableComponent {
2694
2700
  installBinding(parameterDef) {
2695
2701
  /** @type {?} */
2696
2702
  const model = (/** @type {?} */ (this[parameterDef.propertyName]));
2697
- // this.txo.observe(parameterDef.propertyName, model);
2698
- this.registerDisposable(new Binding(this.visit, model, {
2703
+ DebugContext.tag(model, `${this.placeDefinition.component.name}.${parameterDef.propertyName}`);
2704
+ /** @type {?} */
2705
+ const binding = this.registerDisposable(new Binding(this.visit, model, {
2699
2706
  /**
2700
2707
  * @param {?} visit
2701
2708
  * @return {?}
@@ -2703,7 +2710,7 @@ class PlaceComponent extends DisposableComponent {
2703
2710
  toRight(visit) {
2704
2711
  /** @type {?} */
2705
2712
  const value = visit.getParameter(parameterDef.name);
2706
- // console.log('push to component', {name:parameterDef.name, value, visit});
2713
+ console.log('push to component', { name: parameterDef.name, value, visit });
2707
2714
  return value;
2708
2715
  },
2709
2716
  /**
@@ -2716,6 +2723,12 @@ class PlaceComponent extends DisposableComponent {
2716
2723
  return currentVisit.replace(parameterDef, value);
2717
2724
  }
2718
2725
  }));
2726
+ setTimeout((/**
2727
+ * @return {?}
2728
+ */
2729
+ () => {
2730
+ binding.writeRight();
2731
+ }));
2719
2732
  }
2720
2733
  /**
2721
2734
  * @return {?}
@@ -2739,6 +2752,12 @@ class PlaceComponent extends DisposableComponent {
2739
2752
  onPlaceReady() {
2740
2753
  }
2741
2754
  }
2755
+ __decorate([
2756
+ Trace(),
2757
+ __metadata("design:type", Function),
2758
+ __metadata("design:paramtypes", [ParameterDefinition]),
2759
+ __metadata("design:returntype", void 0)
2760
+ ], PlaceComponent.prototype, "installBinding", null);
2742
2761
  __decorate([
2743
2762
  Memoize$1(),
2744
2763
  __metadata("design:type", PlaceDefinition),
@@ -4971,7 +4990,11 @@ class PlaceOutletComponent extends DisposableComponent {
4971
4990
  this.initialPlaceIndex = null;
4972
4991
  const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);
4973
4992
  this.parentOutletModel = new MutableValueModel(parentOutlet);
4974
- this._activePlaceVisitModel.setDelegate(new MutableValueModel());
4993
+ /** @type {?} */
4994
+ const mutableValueModel = new MutableValueModel();
4995
+ DebugContext.tag(mutableValueModel, "PlaceOutletComponent -> mutableValueModel");
4996
+ this._activePlaceVisitModel.setDelegate(mutableValueModel);
4997
+ DebugContext.tag(this._activePlaceVisitModel, "PlaceOutletComponent._activePlaceVisitModel");
4975
4998
  this._inOutletUpdate = valueOf.any(this._inOutletDeactivation, this._inOutletActivation).areTruthy();
4976
4999
  /** @type {?} */
4977
5000
  const defaultPlaceAnimationOrder = chain(this.parentOutletModel)
@@ -5131,8 +5154,9 @@ class PlaceOutletComponent extends DisposableComponent {
5131
5154
  this._placeDefinition.value = place.placeDefinition;
5132
5155
  /** @type {?} */
5133
5156
  const visitModel = new MutableValueModel();
5157
+ DebugContext.tag(visitModel, "PlaceOutletCompeont.visitModel");
5134
5158
  this._activePlaceVisitModel.setDelegate(visitModel);
5135
- place.initialiseBindings(visitModel);
5159
+ place.initialiseVisit(visitModel);
5136
5160
  }
5137
5161
  catch (error) {
5138
5162
  console.error(error);
@@ -6834,10 +6858,48 @@ function VisitParameter(options) {
6834
6858
  */
6835
6859
  (prototype, propertyKey) => {
6836
6860
  /** @type {?} */
6837
- const param = new ParameterDefinition.ValueParameter(propertyKey.toString(), options, opts.getOptional("storeInUrl", null));
6861
+ const param = new ParameterDefinition.ValueParameter(propertyKey.toString(), options, opts.getOptional('storeInUrl', null));
6838
6862
  Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
6839
- UseDelegate({ tag: `@VisitParameter(${prototype.constructor.name}.${propertyKey.toString()})` })(prototype, propertyKey);
6840
- // UseDelegate()(prototype, propertyKey);
6863
+ /** @type {?} */
6864
+ const mechanics = {
6865
+ backingModel: new MutableValueModel(),
6866
+ binding: (/** @type {?} */ (null))
6867
+ };
6868
+ /** @type {?} */
6869
+ const tag = `@VisitParameter(${prototype.constructor.name}.${propertyKey.toString()})`;
6870
+ DebugContext.get(mechanics.backingModel).tag(tag);
6871
+ Logger.get(mechanics.backingModel).tag(tag);
6872
+ Object.defineProperty(prototype, propertyKey, {
6873
+ get: (/**
6874
+ * @return {?}
6875
+ */
6876
+ function () {
6877
+ return mechanics.backingModel;
6878
+ }),
6879
+ set: (/**
6880
+ * @param {?} userModel
6881
+ * @return {?}
6882
+ */
6883
+ function (userModel) {
6884
+ // This handles the scenario where we want to push an existing value model (such as a form model)
6885
+ // to and from the route.
6886
+ if (mechanics.binding) {
6887
+ mechanics.binding.dispose();
6888
+ }
6889
+ if (userModel) {
6890
+ mechanics.binding = new Binding(mechanics.backingModel, userModel);
6891
+ if (userModel.query().isNil()) {
6892
+ mechanics.binding.writeRight(); // push the visit into the user model;
6893
+ }
6894
+ else {
6895
+ if (!mechanics.backingModel.query().isNil()) {
6896
+ console.warn('Assigning a visit model with an existing value to a visit parameter with an existing value. Visit parameter will be overridden');
6897
+ }
6898
+ mechanics.binding.writeLeft(); // push the user model into the visit
6899
+ }
6900
+ }
6901
+ })
6902
+ });
6841
6903
  });
6842
6904
  }
6843
6905
  /**
@@ -6855,10 +6917,48 @@ function VisitParameterList(options) {
6855
6917
  */
6856
6918
  (prototype, propertyKey) => {
6857
6919
  /** @type {?} */
6858
- const param = new ParameterDefinition.ArrayParameter(propertyKey.toString(), options, opts.getOptional("storeInUrl", null));
6859
- UseDelegate({ tag: `@VisitParameterList(${prototype.constructor.name}.${propertyKey.toString()})` })(prototype, propertyKey);
6860
- // UseDelegate()(prototype, propertyKey);
6920
+ const param = new ParameterDefinition.ArrayParameter(propertyKey.toString(), options, opts.getOptional('storeInUrl', null));
6861
6921
  Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
6922
+ /** @type {?} */
6923
+ const mechanics = {
6924
+ backingModel: new MutableListModel(),
6925
+ binding: (/** @type {?} */ (null))
6926
+ };
6927
+ /** @type {?} */
6928
+ const tag = `@VisitParameterList(${prototype.constructor.name}.${propertyKey.toString()})`;
6929
+ DebugContext.get(mechanics.backingModel).tag(tag);
6930
+ Logger.get(mechanics.backingModel).tag(tag);
6931
+ Object.defineProperty(prototype, propertyKey, {
6932
+ get: (/**
6933
+ * @return {?}
6934
+ */
6935
+ function () {
6936
+ return mechanics.backingModel;
6937
+ }),
6938
+ set: (/**
6939
+ * @param {?} userModel
6940
+ * @return {?}
6941
+ */
6942
+ function (userModel) {
6943
+ // This handles the scenario where we want to push an existing value model (such as a form model)
6944
+ // to and from the route.
6945
+ if (mechanics.binding) {
6946
+ mechanics.binding.dispose();
6947
+ }
6948
+ if (userModel) {
6949
+ mechanics.binding = new Binding(mechanics.backingModel, userModel);
6950
+ if (userModel.query().isEmpty()) {
6951
+ mechanics.binding.writeRight(); // push the visit into the user model;
6952
+ }
6953
+ else {
6954
+ if (!mechanics.backingModel.query().isEmpty()) {
6955
+ console.warn('Assigning a visit model with an existing value to a visit parameter with an existing value. Visit parameter will be overridden');
6956
+ }
6957
+ mechanics.binding.writeLeft(); // push the user model into the visit
6958
+ }
6959
+ }
6960
+ })
6961
+ });
6862
6962
  });
6863
6963
  }
6864
6964