@coolon/angular-ui-powerups 0.0.123 → 0.0.125
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 +66 -82
- 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/route/parameter-decorators.js +67 -83
- package/esm2015/lib/place/route/parameter-decorators.js.map +1 -1
- package/esm2015/lib/place/route/parameter-decorators.metadata.json +1 -1
- package/esm5/lib/place/route/parameter-decorators.js +67 -83
- package/esm5/lib/place/route/parameter-decorators.js.map +1 -1
- package/fesm2015/coolon-angular-ui-powerups.js +66 -82
- package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
- package/fesm5/coolon-angular-ui-powerups.js +66 -82
- package/fesm5/coolon-angular-ui-powerups.js.map +1 -1
- package/package.json +1 -1
|
@@ -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 { Binding, DebugContext, Logger, MutableListModel, MutableValueModel
|
|
5
|
+
import { Binding, DebugContext, Logger, MutableListModel, MutableValueModel } 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';
|
|
@@ -55,6 +55,57 @@ if (false) {
|
|
|
55
55
|
/** @type {?|undefined} */
|
|
56
56
|
RouteListParameterOptions.prototype.storeInUrl;
|
|
57
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* @template M
|
|
60
|
+
* @param {?} prototype
|
|
61
|
+
* @param {?} propertyKey
|
|
62
|
+
* @param {?} backingModel
|
|
63
|
+
* @param {?} tagPrefix
|
|
64
|
+
* @param {?} isEmpty
|
|
65
|
+
* @return {?}
|
|
66
|
+
*/
|
|
67
|
+
function installMechanics(prototype, propertyKey, backingModel, tagPrefix, isEmpty) {
|
|
68
|
+
/** @type {?} */
|
|
69
|
+
const mechanics = {
|
|
70
|
+
backingModel: backingModel,
|
|
71
|
+
binding: (/** @type {?} */ (null))
|
|
72
|
+
};
|
|
73
|
+
/** @type {?} */
|
|
74
|
+
const tag = `${tagPrefix}(${prototype.constructor.name}.${propertyKey.toString()})`;
|
|
75
|
+
DebugContext.get(mechanics.backingModel).tag(tag);
|
|
76
|
+
Logger.get(mechanics.backingModel).tag(tag);
|
|
77
|
+
Object.defineProperty(prototype, propertyKey, {
|
|
78
|
+
get: (/**
|
|
79
|
+
* @return {?}
|
|
80
|
+
*/
|
|
81
|
+
function () {
|
|
82
|
+
return mechanics.backingModel;
|
|
83
|
+
}),
|
|
84
|
+
set: (/**
|
|
85
|
+
* @param {?} userModel
|
|
86
|
+
* @return {?}
|
|
87
|
+
*/
|
|
88
|
+
function (userModel) {
|
|
89
|
+
// This handles the scenario where we want to push an existing value model (such as a form model)
|
|
90
|
+
// to and from the route.
|
|
91
|
+
if (mechanics.binding) {
|
|
92
|
+
mechanics.binding.dispose();
|
|
93
|
+
}
|
|
94
|
+
if (userModel) {
|
|
95
|
+
mechanics.binding = new Binding(mechanics.backingModel, userModel);
|
|
96
|
+
if (isEmpty(userModel)) {
|
|
97
|
+
mechanics.binding.writeRight(); // push the visit into the user model;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
if (!isEmpty(mechanics.backingModel)) {
|
|
101
|
+
console.warn('Assigning a visit model with an existing value to a visit parameter with an existing value. Visit parameter will be overridden');
|
|
102
|
+
}
|
|
103
|
+
mechanics.binding.writeLeft(); // push the user model into the visit
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
})
|
|
107
|
+
});
|
|
108
|
+
}
|
|
58
109
|
/**
|
|
59
110
|
* @template T
|
|
60
111
|
* @param {?} type
|
|
@@ -71,8 +122,11 @@ export function RouteId(type, options) {
|
|
|
71
122
|
/** @type {?} */
|
|
72
123
|
const param = new ParameterDefinition.RouteId(propertyKey.toString(), options, type);
|
|
73
124
|
Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
|
|
74
|
-
|
|
75
|
-
|
|
125
|
+
installMechanics(prototype, propertyKey, new MutableValueModel(), "@RouteId", (/**
|
|
126
|
+
* @param {?} m
|
|
127
|
+
* @return {?}
|
|
128
|
+
*/
|
|
129
|
+
m => m.query().isNil()));
|
|
76
130
|
});
|
|
77
131
|
}
|
|
78
132
|
/**
|
|
@@ -92,46 +146,11 @@ export function VisitParameter(options) {
|
|
|
92
146
|
/** @type {?} */
|
|
93
147
|
const param = new ParameterDefinition.ValueParameter(propertyKey.toString(), options, opts.getOptional('storeInUrl', null));
|
|
94
148
|
Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
-
});
|
|
149
|
+
installMechanics(prototype, propertyKey, new MutableValueModel(), "@VisitParameter", (/**
|
|
150
|
+
* @param {?} m
|
|
151
|
+
* @return {?}
|
|
152
|
+
*/
|
|
153
|
+
m => m.query().isNil()));
|
|
135
154
|
});
|
|
136
155
|
}
|
|
137
156
|
/**
|
|
@@ -151,46 +170,11 @@ export function VisitParameterList(options) {
|
|
|
151
170
|
/** @type {?} */
|
|
152
171
|
const param = new ParameterDefinition.ArrayParameter(propertyKey.toString(), options, opts.getOptional('storeInUrl', null));
|
|
153
172
|
Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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
|
-
});
|
|
173
|
+
installMechanics(prototype, propertyKey, new MutableListModel(), "@VisitParameterList", (/**
|
|
174
|
+
* @param {?} m
|
|
175
|
+
* @return {?}
|
|
176
|
+
*/
|
|
177
|
+
m => m.query().isEmpty()));
|
|
194
178
|
});
|
|
195
179
|
}
|
|
196
180
|
//# 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,
|
|
1
|
+
{"version":3,"file":"parameter-decorators.js","sourceRoot":"ng://@coolon/angular-ui-powerups/","sources":["lib/place/route/parameter-decorators.ts"],"names":[],"mappings":";;;;AAAA,OAAO,EACL,OAAO,EACP,YAAY,EAEZ,MAAM,EACN,gBAAgB,EAChB,iBAAiB,EAElB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE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BAAoB,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;QAC3E,gBAAgB,CAAC,SAAS,EAAE,WAAW,EAAE,IAAI,iBAAiB,EAAK,EAAE,iBAAiB;;;;QAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,EAAC,CAAC;IAClH,CAAC,EAAC;AACJ,CAAC;;;;;;AAED,MAAM,UAAU,kBAAkB,CAAI,OAAsC;;UACpE,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;IAC9B;;;;;IAAO,CAAC,SAAiB,EAAE,WAA4B,EAAE,EAAE;;cACnD,KAAK,GAAG,IAAI,mBAAmB,CAAC,cAAc,CAAC,WAAW,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;QAC3H,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,oBAAoB,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;QAC3E,gBAAgB,CAAC,SAAS,EAAE,WAAW,EAAE,IAAI,gBAAgB,EAAK,EAAE,qBAAqB;;;;QAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,OAAO,EAAE,EAAC,CAAC;IACvH,CAAC,EAAC;AACJ,CAAC","sourcesContent":["import {\n Binding,\n DebugContext,\n HasValue,\n Logger,\n MutableListModel,\n MutableValueModel,\n UseDelegate\n} 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\n\nfunction installMechanics<M extends HasValue<any>>(prototype: Object, propertyKey: string | symbol, backingModel: M, tagPrefix: string, isEmpty: (mode: M) => boolean) {\n const mechanics = {\n backingModel: backingModel,\n binding: null as Binding<any, any>\n };\n const tag = `${tagPrefix}(${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: M) {\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 (isEmpty(userModel)) {\n mechanics.binding.writeRight(); // push the visit into the user model;\n } else {\n if (!isEmpty(mechanics.backingModel)) {\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\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 installMechanics(prototype, propertyKey, new MutableValueModel<T>(), \"@RouteId\", m => m.query().isNil());\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 installMechanics(prototype, propertyKey, new MutableValueModel<T>(), \"@VisitParameter\", m => m.query().isNil());\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 installMechanics(prototype, propertyKey, new MutableListModel<E>(), \"@VisitParameterList\", m => m.query().isEmpty());\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"RouteIdOptions":{"__symbolic":"interface"},"RouteParameterOptions":{"__symbolic":"interface"},"RouteListParameterOptions":{"__symbolic":"interface"},"RouteId":{"__symbolic":"function","parameters":["type","options"],"value":{"__symbolic":"error","message":"Lambda not supported","line":
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"RouteIdOptions":{"__symbolic":"interface"},"RouteParameterOptions":{"__symbolic":"interface"},"RouteListParameterOptions":{"__symbolic":"interface"},"RouteId":{"__symbolic":"function","parameters":["type","options"],"value":{"__symbolic":"error","message":"Lambda not supported","line":76,"character":9}},"VisitParameter":{"__symbolic":"function"},"VisitParameterList":{"__symbolic":"function"}}}]
|
|
@@ -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 { Binding, DebugContext, Logger, MutableListModel, MutableValueModel
|
|
5
|
+
import { Binding, DebugContext, Logger, MutableListModel, MutableValueModel } 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';
|
|
@@ -55,6 +55,57 @@ if (false) {
|
|
|
55
55
|
/** @type {?|undefined} */
|
|
56
56
|
RouteListParameterOptions.prototype.storeInUrl;
|
|
57
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* @template M
|
|
60
|
+
* @param {?} prototype
|
|
61
|
+
* @param {?} propertyKey
|
|
62
|
+
* @param {?} backingModel
|
|
63
|
+
* @param {?} tagPrefix
|
|
64
|
+
* @param {?} isEmpty
|
|
65
|
+
* @return {?}
|
|
66
|
+
*/
|
|
67
|
+
function installMechanics(prototype, propertyKey, backingModel, tagPrefix, isEmpty) {
|
|
68
|
+
/** @type {?} */
|
|
69
|
+
var mechanics = {
|
|
70
|
+
backingModel: backingModel,
|
|
71
|
+
binding: (/** @type {?} */ (null))
|
|
72
|
+
};
|
|
73
|
+
/** @type {?} */
|
|
74
|
+
var tag = tagPrefix + "(" + prototype.constructor.name + "." + propertyKey.toString() + ")";
|
|
75
|
+
DebugContext.get(mechanics.backingModel).tag(tag);
|
|
76
|
+
Logger.get(mechanics.backingModel).tag(tag);
|
|
77
|
+
Object.defineProperty(prototype, propertyKey, {
|
|
78
|
+
get: (/**
|
|
79
|
+
* @return {?}
|
|
80
|
+
*/
|
|
81
|
+
function () {
|
|
82
|
+
return mechanics.backingModel;
|
|
83
|
+
}),
|
|
84
|
+
set: (/**
|
|
85
|
+
* @param {?} userModel
|
|
86
|
+
* @return {?}
|
|
87
|
+
*/
|
|
88
|
+
function (userModel) {
|
|
89
|
+
// This handles the scenario where we want to push an existing value model (such as a form model)
|
|
90
|
+
// to and from the route.
|
|
91
|
+
if (mechanics.binding) {
|
|
92
|
+
mechanics.binding.dispose();
|
|
93
|
+
}
|
|
94
|
+
if (userModel) {
|
|
95
|
+
mechanics.binding = new Binding(mechanics.backingModel, userModel);
|
|
96
|
+
if (isEmpty(userModel)) {
|
|
97
|
+
mechanics.binding.writeRight(); // push the visit into the user model;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
if (!isEmpty(mechanics.backingModel)) {
|
|
101
|
+
console.warn('Assigning a visit model with an existing value to a visit parameter with an existing value. Visit parameter will be overridden');
|
|
102
|
+
}
|
|
103
|
+
mechanics.binding.writeLeft(); // push the user model into the visit
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
})
|
|
107
|
+
});
|
|
108
|
+
}
|
|
58
109
|
/**
|
|
59
110
|
* @template T
|
|
60
111
|
* @param {?} type
|
|
@@ -71,8 +122,11 @@ export function RouteId(type, options) {
|
|
|
71
122
|
/** @type {?} */
|
|
72
123
|
var param = new ParameterDefinition.RouteId(propertyKey.toString(), options, type);
|
|
73
124
|
Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
|
|
74
|
-
|
|
75
|
-
|
|
125
|
+
installMechanics(prototype, propertyKey, new MutableValueModel(), "@RouteId", (/**
|
|
126
|
+
* @param {?} m
|
|
127
|
+
* @return {?}
|
|
128
|
+
*/
|
|
129
|
+
function (m) { return m.query().isNil(); }));
|
|
76
130
|
});
|
|
77
131
|
}
|
|
78
132
|
/**
|
|
@@ -92,46 +146,11 @@ export function VisitParameter(options) {
|
|
|
92
146
|
/** @type {?} */
|
|
93
147
|
var param = new ParameterDefinition.ValueParameter(propertyKey.toString(), options, opts.getOptional('storeInUrl', null));
|
|
94
148
|
Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
-
});
|
|
149
|
+
installMechanics(prototype, propertyKey, new MutableValueModel(), "@VisitParameter", (/**
|
|
150
|
+
* @param {?} m
|
|
151
|
+
* @return {?}
|
|
152
|
+
*/
|
|
153
|
+
function (m) { return m.query().isNil(); }));
|
|
135
154
|
});
|
|
136
155
|
}
|
|
137
156
|
/**
|
|
@@ -151,46 +170,11 @@ export function VisitParameterList(options) {
|
|
|
151
170
|
/** @type {?} */
|
|
152
171
|
var param = new ParameterDefinition.ArrayParameter(propertyKey.toString(), options, opts.getOptional('storeInUrl', null));
|
|
153
172
|
Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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
|
-
});
|
|
173
|
+
installMechanics(prototype, propertyKey, new MutableListModel(), "@VisitParameterList", (/**
|
|
174
|
+
* @param {?} m
|
|
175
|
+
* @return {?}
|
|
176
|
+
*/
|
|
177
|
+
function (m) { return m.query().isEmpty(); }));
|
|
194
178
|
});
|
|
195
179
|
}
|
|
196
180
|
//# 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,
|
|
1
|
+
{"version":3,"file":"parameter-decorators.js","sourceRoot":"ng://@coolon/angular-ui-powerups/","sources":["lib/place/route/parameter-decorators.ts"],"names":[],"mappings":";;;;AAAA,OAAO,EACL,OAAO,EACP,YAAY,EAEZ,MAAM,EACN,gBAAgB,EAChB,iBAAiB,EAElB,MAAM,gBAAgB,CAAC;AACxB,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;;;;;;AAI3B,+CAOC;;;IANC,uCAAY;;IACZ,6CAAmB;;IACnB,6CAAmB;;IACnB,iDAAmB;;IACnB,+CAAyB;;;;;;;;;;;AAK3B,SAAS,gBAAgB,CAA0B,SAAiB,EAAE,WAA4B,EAAE,YAAe,EAAE,SAAiB,EAAE,OAA6B;;QAC7J,SAAS,GAAG;QAChB,YAAY,EAAE,YAAY;QAC1B,OAAO,EAAE,mBAAA,IAAI,EAAqB;KACnC;;QACK,GAAG,GAAM,SAAS,SAAI,SAAS,CAAC,WAAW,CAAC,IAAI,SAAI,WAAW,CAAC,QAAQ,EAAE,MAAG;IACnF,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAClD,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5C,MAAM,CAAC,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cesContent":["import {\n Binding,\n DebugContext,\n HasValue,\n Logger,\n MutableListModel,\n MutableValueModel,\n UseDelegate\n} 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\n\nfunction installMechanics<M extends HasValue<any>>(prototype: Object, propertyKey: string | symbol, backingModel: M, tagPrefix: string, isEmpty: (mode: M) => boolean) {\n const mechanics = {\n backingModel: backingModel,\n binding: null as Binding<any, any>\n };\n const tag = `${tagPrefix}(${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: M) {\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 (isEmpty(userModel)) {\n mechanics.binding.writeRight(); // push the visit into the user model;\n } else {\n if (!isEmpty(mechanics.backingModel)) {\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\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 installMechanics(prototype, propertyKey, new MutableValueModel<T>(), \"@RouteId\", m => m.query().isNil());\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 installMechanics(prototype, propertyKey, new MutableValueModel<T>(), \"@VisitParameter\", m => m.query().isNil());\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 installMechanics(prototype, propertyKey, new MutableListModel<E>(), \"@VisitParameterList\", m => m.query().isEmpty());\n };\n}\n"]}
|