@coolon/angular-ui-powerups 0.0.122 → 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.
- package/bundles/coolon-angular-ui-powerups.umd.js +83 -18
- package/bundles/coolon-angular-ui-powerups.umd.js.map +1 -1
- package/bundles/coolon-angular-ui-powerups.umd.min.js +1 -1
- package/bundles/coolon-angular-ui-powerups.umd.min.js.map +1 -1
- package/esm2015/lib/place/place-component.js +0 -8
- package/esm2015/lib/place/place-component.js.map +1 -1
- package/esm2015/lib/place/place-component.metadata.json +1 -1
- package/esm2015/lib/place/route/parameter-decorators.js +83 -7
- package/esm2015/lib/place/route/parameter-decorators.js.map +1 -1
- package/esm5/lib/place/place-component.js +1 -12
- package/esm5/lib/place/place-component.js.map +1 -1
- package/esm5/lib/place/route/parameter-decorators.js +83 -7
- package/esm5/lib/place/route/parameter-decorators.js.map +1 -1
- package/fesm2015/coolon-angular-ui-powerups.js +82 -14
- package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
- package/fesm5/coolon-angular-ui-powerups.js +83 -18
- package/fesm5/coolon-angular-ui-powerups.js.map +1 -1
- package/lib/place/place-component.d.ts +1 -3
- package/package.json +1 -1
|
@@ -28,14 +28,6 @@ export class PlaceComponent extends DisposableComponent {
|
|
|
28
28
|
assert.isNil(this.visit);
|
|
29
29
|
this.visit = visit;
|
|
30
30
|
DebugContext.get(this.visit).tag(`${this.placeDefinition.component.name}.visit`);
|
|
31
|
-
// this.placeDefinition.getVisitParameterDefs().forEach(parameterDef => {
|
|
32
|
-
// this.installBinding(parameterDef);
|
|
33
|
-
// });
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* @return {?}
|
|
37
|
-
*/
|
|
38
|
-
ngAfterViewInit() {
|
|
39
31
|
this.placeDefinition.getVisitParameterDefs().forEach((/**
|
|
40
32
|
* @param {?} parameterDef
|
|
41
33
|
* @return {?}
|
|
@@ -1 +1 @@
|
|
|
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,OAAO,wBAAwB,GAAG,0BAA0B;;;AAElE,MAAM,OAAO,wBAAwB,GAAG,MAAM,CAAC,wBAAwB,CAAC;AAExE,MAAM,OAAO,cAAe,SAAQ,mBAAmB;IASrD;QACE,KAAK,EAAE,CAAC;IACV,CAAC;;;;;IAEM,eAAe,CAAC,KAAwB;QAC7C,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,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,QAAQ,CAAC,CAAC;QACjF,
|
|
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,yCAA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oC;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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"DEFINITION_META_DATA_KEY":"PLACE_DEFINITION_OPTIONS","ROUTE_PARAMETER_LIST_KEY":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Symbol"},"arguments":["place:route:parameters"]},"PlaceComponent":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"../components/disposable-component","name":"DisposableComponent","line":25,"character":36},"members":{"canDeactivate":[{"__symbolic":"method"}],"__ctor__":[{"__symbolic":"constructor"}],"initialiseVisit":[{"__symbolic":"method"}],"
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"DEFINITION_META_DATA_KEY":"PLACE_DEFINITION_OPTIONS","ROUTE_PARAMETER_LIST_KEY":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Symbol"},"arguments":["place:route:parameters"]},"PlaceComponent":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"../components/disposable-component","name":"DisposableComponent","line":25,"character":36},"members":{"canDeactivate":[{"__symbolic":"method"}],"__ctor__":[{"__symbolic":"constructor"}],"initialiseVisit":[{"__symbolic":"method"}],"installBinding":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@coolon/pectin","name":"Trace","line":47,"character":3}}]}],"placeDefinition":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@typescript-plus/fast-memoize-decorator","name":"Memoize","line":67,"character":3}}]}],"onPlaceReady":[{"__symbolic":"method"}]}}}}]
|
|
@@ -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
|
(prototype, propertyKey) => {
|
|
92
92
|
/** @type {?} */
|
|
93
|
-
const param = new ParameterDefinition.ValueParameter(propertyKey.toString(), options, opts.getOptional(
|
|
93
|
+
const param = new ParameterDefinition.ValueParameter(propertyKey.toString(), options, opts.getOptional('storeInUrl', null));
|
|
94
94
|
Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
/** @type {?} */
|
|
96
|
+
const mechanics = {
|
|
97
|
+
backingModel: new MutableValueModel(),
|
|
98
|
+
binding: (/** @type {?} */ (null))
|
|
99
|
+
};
|
|
100
|
+
/** @type {?} */
|
|
101
|
+
const 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
|
(prototype, propertyKey) => {
|
|
113
151
|
/** @type {?} */
|
|
114
|
-
const param = new ParameterDefinition.ArrayParameter(propertyKey.toString(), options, opts.getOptional(
|
|
115
|
-
UseDelegate({ tag: `@VisitParameterList(${prototype.constructor.name}.${propertyKey.toString()})` })(prototype, propertyKey);
|
|
116
|
-
// UseDelegate()(prototype, propertyKey);
|
|
152
|
+
const 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
|
+
const mechanics = {
|
|
156
|
+
backingModel: new MutableListModel(),
|
|
157
|
+
binding: (/** @type {?} */ (null))
|
|
158
|
+
};
|
|
159
|
+
/** @type {?} */
|
|
160
|
+
const 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;
|
|
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,6CAA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CAAC;yBACjJ;wBACD,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,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"]}
|
|
@@ -30,21 +30,10 @@ var PlaceComponent = /** @class */ (function (_super) {
|
|
|
30
30
|
* @return {?}
|
|
31
31
|
*/
|
|
32
32
|
function (visit) {
|
|
33
|
+
var _this = this;
|
|
33
34
|
assert.isNil(this.visit);
|
|
34
35
|
this.visit = visit;
|
|
35
36
|
DebugContext.get(this.visit).tag(this.placeDefinition.component.name + ".visit");
|
|
36
|
-
// this.placeDefinition.getVisitParameterDefs().forEach(parameterDef => {
|
|
37
|
-
// this.installBinding(parameterDef);
|
|
38
|
-
// });
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* @return {?}
|
|
42
|
-
*/
|
|
43
|
-
PlaceComponent.prototype.ngAfterViewInit = /**
|
|
44
|
-
* @return {?}
|
|
45
|
-
*/
|
|
46
|
-
function () {
|
|
47
|
-
var _this = this;
|
|
48
37
|
this.placeDefinition.getVisitParameterDefs().forEach((/**
|
|
49
38
|
* @param {?} parameterDef
|
|
50
39
|
* @return {?}
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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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AAC;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"]}
|
|
@@ -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(
|
|
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
|
-
|
|
96
|
-
|
|
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(
|
|
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;
|
|
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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O,CAAC,UAAU,EAAE,CAAC,CAAC,sCAAsC;qBACvE;yBAAM;wBACL,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC,OAAO,EAAE,EAAE;4BAC7C,OAAO,CAAC,IAAI,CAAC,iIAAiI,CAAC,CAAC;yBACjJ;wBACD,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,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"]}
|
|
@@ -2683,14 +2683,6 @@ class PlaceComponent extends DisposableComponent {
|
|
|
2683
2683
|
assert.isNil(this.visit);
|
|
2684
2684
|
this.visit = visit;
|
|
2685
2685
|
DebugContext.get(this.visit).tag(`${this.placeDefinition.component.name}.visit`);
|
|
2686
|
-
// this.placeDefinition.getVisitParameterDefs().forEach(parameterDef => {
|
|
2687
|
-
// this.installBinding(parameterDef);
|
|
2688
|
-
// });
|
|
2689
|
-
}
|
|
2690
|
-
/**
|
|
2691
|
-
* @return {?}
|
|
2692
|
-
*/
|
|
2693
|
-
ngAfterViewInit() {
|
|
2694
2686
|
this.placeDefinition.getVisitParameterDefs().forEach((/**
|
|
2695
2687
|
* @param {?} parameterDef
|
|
2696
2688
|
* @return {?}
|
|
@@ -6866,10 +6858,48 @@ function VisitParameter(options) {
|
|
|
6866
6858
|
*/
|
|
6867
6859
|
(prototype, propertyKey) => {
|
|
6868
6860
|
/** @type {?} */
|
|
6869
|
-
const param = new ParameterDefinition.ValueParameter(propertyKey.toString(), options, opts.getOptional(
|
|
6861
|
+
const param = new ParameterDefinition.ValueParameter(propertyKey.toString(), options, opts.getOptional('storeInUrl', null));
|
|
6870
6862
|
Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
|
|
6871
|
-
|
|
6872
|
-
|
|
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
|
+
});
|
|
6873
6903
|
});
|
|
6874
6904
|
}
|
|
6875
6905
|
/**
|
|
@@ -6887,10 +6917,48 @@ function VisitParameterList(options) {
|
|
|
6887
6917
|
*/
|
|
6888
6918
|
(prototype, propertyKey) => {
|
|
6889
6919
|
/** @type {?} */
|
|
6890
|
-
const param = new ParameterDefinition.ArrayParameter(propertyKey.toString(), options, opts.getOptional(
|
|
6891
|
-
UseDelegate({ tag: `@VisitParameterList(${prototype.constructor.name}.${propertyKey.toString()})` })(prototype, propertyKey);
|
|
6892
|
-
// UseDelegate()(prototype, propertyKey);
|
|
6920
|
+
const param = new ParameterDefinition.ArrayParameter(propertyKey.toString(), options, opts.getOptional('storeInUrl', null));
|
|
6893
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
|
+
});
|
|
6894
6962
|
});
|
|
6895
6963
|
}
|
|
6896
6964
|
|