ember-source 4.4.0-alpha.1 → 4.4.0-alpha.4
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/CHANGELOG.md +5 -1
- package/blueprints/acceptance-test/mocha-files/tests/acceptance/__name__-test.js +4 -4
- package/blueprints/acceptance-test/mocha-rfc-232-files/tests/acceptance/__name__-test.js +3 -3
- package/blueprints/acceptance-test/qunit-files/tests/acceptance/__name__-test.js +2 -2
- package/blueprints/acceptance-test/qunit-rfc-232-files/tests/acceptance/__name__-test.js +3 -3
- package/blueprints/component/index.js +2 -2
- package/blueprints/component-class/index.js +2 -2
- package/blueprints/component-test/mocha-0.12-files/__root__/__testType__/__path__/__test__.js +4 -4
- package/blueprints/component-test/mocha-files/__root__/__testType__/__path__/__test__.js +7 -5
- package/blueprints/component-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js +6 -6
- package/blueprints/component-test/qunit-files/__root__/__testType__/__path__/__test__.js +4 -4
- package/blueprints/component-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js +6 -6
- package/blueprints/controller/files/__root__/__path__/__name__.js +1 -2
- package/blueprints/controller-test/mocha-0.12-files/__root__/__testType__/__path__/__test__.js +2 -2
- package/blueprints/controller-test/mocha-files/__root__/__testType__/__path__/__test__.js +5 -3
- package/blueprints/controller-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js +3 -3
- package/blueprints/controller-test/qunit-files/__root__/__testType__/__path__/__test__.js +1 -1
- package/blueprints/controller-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js +3 -3
- package/blueprints/helper/files/__root__/__collection__/__name__.js +1 -1
- package/blueprints/helper/mu-files/__root__/__collection__/__name__.js +1 -1
- package/blueprints/helper-test/mocha-0.12-files/__root__/__testType__/__collection__/__name__-test.js +3 -3
- package/blueprints/helper-test/mocha-files/__root__/__testType__/__collection__/__name__-test.js +6 -4
- package/blueprints/helper-test/mocha-rfc-232-files/__root__/__testType__/__collection__/__name__-test.js +3 -3
- package/blueprints/helper-test/qunit-files/__root__/__testType__/__collection__/__name__-test.js +2 -2
- package/blueprints/helper-test/qunit-rfc-232-files/__root__/__testType__/__collection__/__name__-test.js +3 -3
- package/blueprints/initializer/files/__root__/initializers/__name__.js +2 -3
- package/blueprints/initializer-test/mocha-files/__root__/__testType__/__path__/__name__-test.js +6 -7
- package/blueprints/initializer-test/mocha-rfc-232-files/__root__/__testType__/__path__/__name__-test.js +5 -5
- package/blueprints/initializer-test/qunit-files/__root__/__testType__/__path__/__name__-test.js +3 -4
- package/blueprints/instance-initializer/files/__root__/instance-initializers/__name__.js +2 -3
- package/blueprints/instance-initializer-test/mocha-files/__root__/__testType__/__path__/__name__-test.js +5 -5
- package/blueprints/instance-initializer-test/mocha-rfc-232-files/__root__/__testType__/__path__/__name__-test.js +5 -5
- package/blueprints/instance-initializer-test/qunit-files/__root__/__testType__/__path__/__name__-test.js +2 -2
- package/blueprints/mixin/files/__root__/mixins/__name__.js +1 -2
- package/blueprints/mixin-test/mocha-files/__root__/__testType__/__name__-test.js +2 -2
- package/blueprints/mixin-test/mocha-rfc-232-files/__root__/__testType__/__name__-test.js +2 -2
- package/blueprints/mixin-test/qunit-files/__root__/__testType__/__name__-test.js +1 -1
- package/blueprints/mixin-test/qunit-rfc-232-files/__root__/__testType__/__name__-test.js +1 -1
- package/blueprints/route/files/__root__/__path__/__name__.js +2 -2
- package/blueprints/route-test/mocha-0.12-files/__root__/__testType__/__path__/__test__.js +2 -2
- package/blueprints/route-test/mocha-files/__root__/__testType__/__path__/__test__.js +5 -3
- package/blueprints/route-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js +3 -3
- package/blueprints/route-test/qunit-files/__root__/__testType__/__path__/__test__.js +1 -1
- package/blueprints/route-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js +3 -3
- package/blueprints/service/files/__root__/__path__/__name__.js +1 -2
- package/blueprints/service-test/mocha-0.12-files/__root__/__testType__/__path__/__test__.js +2 -2
- package/blueprints/service-test/mocha-files/__root__/__testType__/__path__/__test__.js +5 -3
- package/blueprints/service-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js +3 -3
- package/blueprints/service-test/qunit-files/__root__/__testType__/__path__/__test__.js +1 -1
- package/blueprints/service-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js +3 -3
- package/blueprints/util-test/mocha-files/__root__/__testType__/__name__-test.js +2 -2
- package/blueprints/util-test/mocha-rfc-232-files/__root__/__testType__/__name__-test.js +2 -2
- package/blueprints/util-test/qunit-files/__root__/__testType__/__name__-test.js +1 -1
- package/blueprints/util-test/qunit-rfc-232-files/__root__/__testType__/__name__-test.js +2 -3
- package/build-metadata.json +3 -3
- package/dist/dependencies/router_js.js +1 -1
- package/dist/ember-template-compiler.js +20 -143
- package/dist/ember-template-compiler.map +1 -1
- package/dist/ember-testing.js +5 -3
- package/dist/ember-testing.map +1 -1
- package/dist/ember.debug.js +1132 -1719
- package/dist/ember.debug.map +1 -1
- package/dist/header/license.js +1 -1
- package/dist/packages/@ember/-internals/container/index.js +3 -19
- package/dist/packages/@ember/-internals/extension-support/lib/container_debug_adapter.js +10 -19
- package/dist/packages/@ember/-internals/extension-support/lib/data_adapter.js +113 -112
- package/dist/packages/@ember/-internals/glimmer/index.js +163 -773
- package/dist/packages/@ember/-internals/metal/index.js +19 -32
- package/dist/packages/@ember/-internals/routing/lib/location/hash_location.js +1 -1
- package/dist/packages/@ember/-internals/routing/lib/services/router.js +67 -12
- package/dist/packages/@ember/-internals/routing/lib/services/routing.js +2 -0
- package/dist/packages/@ember/-internals/routing/lib/system/generate_controller.js +3 -1
- package/dist/packages/@ember/-internals/routing/lib/system/route.js +15 -7
- package/dist/packages/@ember/-internals/routing/lib/system/router.js +16 -21
- package/dist/packages/@ember/-internals/routing/lib/utils.js +2 -1
- package/dist/packages/@ember/-internals/runtime/lib/compare.js +19 -5
- package/dist/packages/@ember/-internals/runtime/lib/ext/rsvp.js +8 -4
- package/dist/packages/@ember/-internals/runtime/lib/mixins/-proxy.js +1 -1
- package/dist/packages/@ember/-internals/runtime/lib/mixins/array.js +1 -1
- package/dist/packages/@ember/-internals/runtime/lib/mixins/comparable.js +4 -4
- package/dist/packages/@ember/-internals/runtime/lib/mixins/container_proxy.js +29 -29
- package/dist/packages/@ember/-internals/runtime/lib/mixins/promise_proxy.js +16 -16
- package/dist/packages/@ember/-internals/runtime/lib/mixins/registry_proxy.js +51 -50
- package/dist/packages/@ember/-internals/runtime/lib/mixins/target_action_support.js +8 -8
- package/dist/packages/@ember/-internals/utils/index.js +1 -1
- package/dist/packages/@ember/-internals/views/lib/system/utils.js +4 -2
- package/dist/packages/@ember/-internals/views/lib/views/core_view.js +5 -22
- package/dist/packages/@ember/application/instance.js +3 -3
- package/dist/packages/@ember/canary-features/index.js +4 -12
- package/dist/packages/@ember/debug/index.js +1 -1
- package/dist/packages/@ember/debug/lib/capture-render-tree.js +2 -0
- package/dist/packages/@ember/debug/lib/handlers.js +1 -1
- package/dist/packages/@ember/renderer/index.js +21 -0
- package/dist/packages/@ember/runloop/index.js +31 -528
- package/dist/packages/@ember/runloop/type-tests.ts/begin-end.test.js +5 -0
- package/dist/packages/@ember/runloop/type-tests.ts/bind.test.js +59 -0
- package/dist/packages/@ember/runloop/type-tests.ts/cancel.test.js +5 -0
- package/dist/packages/@ember/runloop/type-tests.ts/debounce.test.js +77 -0
- package/dist/packages/@ember/runloop/type-tests.ts/join.test.js +38 -0
- package/dist/packages/@ember/runloop/type-tests.ts/later.test.js +38 -0
- package/dist/packages/@ember/runloop/type-tests.ts/next.test.js +38 -0
- package/dist/packages/@ember/runloop/type-tests.ts/once.test.js +38 -0
- package/dist/packages/@ember/runloop/type-tests.ts/run.test.js +38 -0
- package/dist/packages/@ember/runloop/type-tests.ts/schedule-once.test.js +39 -0
- package/dist/packages/@ember/runloop/type-tests.ts/schedule.test.js +39 -0
- package/dist/packages/@ember/runloop/type-tests.ts/throttle.test.js +77 -0
- package/dist/packages/ember/index.js +4 -14
- package/dist/packages/ember/version.js +1 -1
- package/docs/data.json +658 -383
- package/package.json +10 -10
package/dist/header/license.js
CHANGED
|
@@ -187,8 +187,6 @@ class Container {
|
|
|
187
187
|
@public
|
|
188
188
|
@method factoryFor
|
|
189
189
|
@param {String} fullName
|
|
190
|
-
@param {Object} [options]
|
|
191
|
-
@param {String} [options.source] The fullname of the request source (used for local lookup)
|
|
192
190
|
@return {any}
|
|
193
191
|
*/
|
|
194
192
|
|
|
@@ -199,7 +197,9 @@ class Container {
|
|
|
199
197
|
}
|
|
200
198
|
|
|
201
199
|
let normalizedName = this.registry.normalize(fullName);
|
|
202
|
-
assert('fullName must be a proper full name', this.registry.isValidFullName(normalizedName));
|
|
200
|
+
assert('fullName must be a proper full name', this.registry.isValidFullName(normalizedName)); // TODO: This needs to return a Factory to be compatible with Owner.
|
|
201
|
+
// We should correctly the types so that this cast is not necessary.
|
|
202
|
+
|
|
203
203
|
return factoryFor(this, normalizedName, fullName);
|
|
204
204
|
}
|
|
205
205
|
|
|
@@ -530,22 +530,6 @@ class Registry {
|
|
|
530
530
|
container(options) {
|
|
531
531
|
return new Container(this, options);
|
|
532
532
|
}
|
|
533
|
-
/**
|
|
534
|
-
Registers a factory for later injection.
|
|
535
|
-
Example:
|
|
536
|
-
```javascript
|
|
537
|
-
let registry = new Registry();
|
|
538
|
-
registry.register('model:user', Person, {singleton: false });
|
|
539
|
-
registry.register('fruit:favorite', Orange);
|
|
540
|
-
registry.register('communication:main', Email, {singleton: false});
|
|
541
|
-
```
|
|
542
|
-
@private
|
|
543
|
-
@method register
|
|
544
|
-
@param {String} fullName
|
|
545
|
-
@param {Function} factory
|
|
546
|
-
@param {Object} options
|
|
547
|
-
*/
|
|
548
|
-
|
|
549
533
|
|
|
550
534
|
register(fullName, factory, options = {}) {
|
|
551
535
|
assert('fullName must be a proper full name', this.isValidFullName(fullName));
|
|
@@ -40,23 +40,11 @@ import { getOwner } from '@ember/-internals/owner';
|
|
|
40
40
|
@public
|
|
41
41
|
*/
|
|
42
42
|
|
|
43
|
-
export default EmberObject
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
export default class ContainerDebugAdapter extends EmberObject {
|
|
44
|
+
constructor(owner) {
|
|
45
|
+
super(owner);
|
|
47
46
|
this.resolver = getOwner(this).lookup('resolver-for-debugging:main');
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
The resolver instance of the application
|
|
52
|
-
being debugged. This property will be injected
|
|
53
|
-
on creation.
|
|
54
|
-
@property resolver
|
|
55
|
-
@default null
|
|
56
|
-
@public
|
|
57
|
-
*/
|
|
58
|
-
resolver: null,
|
|
59
|
-
|
|
47
|
+
}
|
|
60
48
|
/**
|
|
61
49
|
Returns true if it is possible to catalog a list of available
|
|
62
50
|
classes in the resolver for a given type.
|
|
@@ -65,14 +53,15 @@ export default EmberObject.extend({
|
|
|
65
53
|
@return {boolean} whether a list is available for this type.
|
|
66
54
|
@public
|
|
67
55
|
*/
|
|
56
|
+
|
|
57
|
+
|
|
68
58
|
canCatalogEntriesByType(type) {
|
|
69
59
|
if (type === 'model' || type === 'template') {
|
|
70
60
|
return false;
|
|
71
61
|
}
|
|
72
62
|
|
|
73
63
|
return true;
|
|
74
|
-
}
|
|
75
|
-
|
|
64
|
+
}
|
|
76
65
|
/**
|
|
77
66
|
Returns the available classes a given type.
|
|
78
67
|
@method catalogEntriesByType
|
|
@@ -80,6 +69,8 @@ export default EmberObject.extend({
|
|
|
80
69
|
@return {Array} An array of strings.
|
|
81
70
|
@public
|
|
82
71
|
*/
|
|
72
|
+
|
|
73
|
+
|
|
83
74
|
catalogEntriesByType(type) {
|
|
84
75
|
let namespaces = emberA(Namespace.NAMESPACES);
|
|
85
76
|
let types = emberA();
|
|
@@ -102,4 +93,4 @@ export default EmberObject.extend({
|
|
|
102
93
|
return types;
|
|
103
94
|
}
|
|
104
95
|
|
|
105
|
-
}
|
|
96
|
+
}
|
|
@@ -17,12 +17,12 @@ function iterate(arr, fn) {
|
|
|
17
17
|
|
|
18
18
|
class RecordsWatcher {
|
|
19
19
|
constructor(records, recordsAdded, recordsUpdated, recordsRemoved, wrapRecord, release) {
|
|
20
|
+
this.wrapRecord = wrapRecord;
|
|
21
|
+
this.release = release;
|
|
20
22
|
this.recordCaches = new Map();
|
|
21
23
|
this.added = [];
|
|
22
24
|
this.updated = [];
|
|
23
25
|
this.removed = [];
|
|
24
|
-
this.release = release;
|
|
25
|
-
this.wrapRecord = wrapRecord;
|
|
26
26
|
this.recordArrayCache = createCache(() => {
|
|
27
27
|
let seen = new Set(); // Track `[]` for legacy support
|
|
28
28
|
|
|
@@ -34,7 +34,7 @@ class RecordsWatcher {
|
|
|
34
34
|
// should not be polled again in the future
|
|
35
35
|
|
|
36
36
|
untrack(() => {
|
|
37
|
-
this.recordCaches.forEach((
|
|
37
|
+
this.recordCaches.forEach((_cache, record) => {
|
|
38
38
|
if (!seen.has(record)) {
|
|
39
39
|
this.removed.push(wrapRecord(record));
|
|
40
40
|
this.recordCaches.delete(record);
|
|
@@ -86,6 +86,7 @@ class RecordsWatcher {
|
|
|
86
86
|
|
|
87
87
|
class TypeWatcher {
|
|
88
88
|
constructor(records, onChange, release) {
|
|
89
|
+
this.release = release;
|
|
89
90
|
let hasBeenAccessed = false;
|
|
90
91
|
this.cache = createCache(() => {
|
|
91
92
|
// Empty iteration, we're doing this just
|
|
@@ -154,49 +155,47 @@ class TypeWatcher {
|
|
|
154
155
|
*/
|
|
155
156
|
|
|
156
157
|
|
|
157
|
-
export default EmberObject
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
this.containerDebugAdapter = getOwner(this).lookup('container-debug-adapter:main');
|
|
158
|
+
export default class DataAdapter extends EmberObject {
|
|
159
|
+
constructor(owner) {
|
|
160
|
+
super(owner);
|
|
162
161
|
this.releaseMethods = emberA();
|
|
163
162
|
this.recordsWatchers = new Map();
|
|
164
163
|
this.typeWatchers = new Map();
|
|
165
164
|
this.flushWatchers = null;
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
165
|
+
/**
|
|
166
|
+
The container-debug-adapter which is used
|
|
167
|
+
to list all models.
|
|
168
|
+
@property containerDebugAdapter
|
|
169
|
+
@default undefined
|
|
170
|
+
@since 1.5.0
|
|
171
|
+
@public
|
|
172
|
+
**/
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
The number of attributes to send
|
|
176
|
+
as columns. (Enough to make the record
|
|
177
|
+
identifiable).
|
|
178
|
+
@private
|
|
179
|
+
@property attributeLimit
|
|
180
|
+
@default 3
|
|
181
|
+
@since 1.3.0
|
|
182
|
+
*/
|
|
183
|
+
|
|
184
|
+
this.attributeLimit = 3;
|
|
185
|
+
/**
|
|
186
|
+
Ember Data > v1.0.0-beta.18
|
|
187
|
+
requires string model names to be passed
|
|
188
|
+
around instead of the actual factories.
|
|
189
|
+
This is a stamp for the Ember Inspector
|
|
190
|
+
to differentiate between the versions
|
|
191
|
+
to be able to support older versions too.
|
|
192
|
+
@public
|
|
193
|
+
@property acceptsModelName
|
|
194
|
+
*/
|
|
195
|
+
|
|
196
|
+
this.acceptsModelName = true;
|
|
197
|
+
this.containerDebugAdapter = getOwner(this).lookup('container-debug-adapter:main');
|
|
198
|
+
}
|
|
200
199
|
/**
|
|
201
200
|
Map from records arrays to RecordsWatcher instances
|
|
202
201
|
@private
|
|
@@ -236,10 +235,11 @@ export default EmberObject.extend({
|
|
|
236
235
|
@return {Array} List of objects defining filters.
|
|
237
236
|
The object should have a `name` and `desc` property.
|
|
238
237
|
*/
|
|
238
|
+
|
|
239
|
+
|
|
239
240
|
getFilters() {
|
|
240
241
|
return emberA();
|
|
241
|
-
}
|
|
242
|
-
|
|
242
|
+
}
|
|
243
243
|
/**
|
|
244
244
|
Fetch the model types and observe them for changes.
|
|
245
245
|
@public
|
|
@@ -250,6 +250,8 @@ export default EmberObject.extend({
|
|
|
250
250
|
Takes an array of objects containing wrapped types.
|
|
251
251
|
@return {Function} Method to call to remove all observers
|
|
252
252
|
*/
|
|
253
|
+
|
|
254
|
+
|
|
253
255
|
watchModelTypes(typesAdded, typesUpdated) {
|
|
254
256
|
let modelTypes = this.getModelTypes();
|
|
255
257
|
let releaseMethods = emberA();
|
|
@@ -269,7 +271,7 @@ export default EmberObject.extend({
|
|
|
269
271
|
|
|
270
272
|
this.releaseMethods.pushObject(release);
|
|
271
273
|
return release;
|
|
272
|
-
}
|
|
274
|
+
}
|
|
273
275
|
|
|
274
276
|
_nameToClass(type) {
|
|
275
277
|
if (typeof type === 'string') {
|
|
@@ -279,8 +281,7 @@ export default EmberObject.extend({
|
|
|
279
281
|
}
|
|
280
282
|
|
|
281
283
|
return type;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
+
}
|
|
284
285
|
/**
|
|
285
286
|
Fetch the records of a given type and observe them for changes.
|
|
286
287
|
@public
|
|
@@ -297,6 +298,8 @@ export default EmberObject.extend({
|
|
|
297
298
|
Takes an array of objects containing wrapped records.
|
|
298
299
|
@return {Function} Method to call to remove all observers.
|
|
299
300
|
*/
|
|
301
|
+
|
|
302
|
+
|
|
300
303
|
watchRecords(modelName, recordsAdded, recordsUpdated, recordsRemoved) {
|
|
301
304
|
let klass = this._nameToClass(modelName);
|
|
302
305
|
|
|
@@ -317,7 +320,7 @@ export default EmberObject.extend({
|
|
|
317
320
|
}
|
|
318
321
|
|
|
319
322
|
return recordsWatcher.release;
|
|
320
|
-
}
|
|
323
|
+
}
|
|
321
324
|
|
|
322
325
|
updateFlushWatchers() {
|
|
323
326
|
if (this.flushWatchers === null) {
|
|
@@ -334,13 +337,14 @@ export default EmberObject.extend({
|
|
|
334
337
|
|
|
335
338
|
this.flushWatchers = null;
|
|
336
339
|
}
|
|
337
|
-
}
|
|
338
|
-
|
|
340
|
+
}
|
|
339
341
|
/**
|
|
340
342
|
Clear all observers before destruction
|
|
341
343
|
@private
|
|
342
344
|
@method willDestroy
|
|
343
345
|
*/
|
|
346
|
+
|
|
347
|
+
|
|
344
348
|
willDestroy() {
|
|
345
349
|
this._super(...arguments);
|
|
346
350
|
|
|
@@ -351,8 +355,7 @@ export default EmberObject.extend({
|
|
|
351
355
|
if (this.flushWatchers) {
|
|
352
356
|
_backburner.off('end', this.flushWatchers);
|
|
353
357
|
}
|
|
354
|
-
}
|
|
355
|
-
|
|
358
|
+
}
|
|
356
359
|
/**
|
|
357
360
|
Detect whether a class is a model.
|
|
358
361
|
Test that against the model class
|
|
@@ -361,10 +364,11 @@ export default EmberObject.extend({
|
|
|
361
364
|
@method detect
|
|
362
365
|
@return boolean Whether the class is a model class or not.
|
|
363
366
|
*/
|
|
364
|
-
detect() {
|
|
365
|
-
return false;
|
|
366
|
-
},
|
|
367
367
|
|
|
368
|
+
|
|
369
|
+
detect(_klass) {
|
|
370
|
+
return false;
|
|
371
|
+
}
|
|
368
372
|
/**
|
|
369
373
|
Get the columns for a given model type.
|
|
370
374
|
@public
|
|
@@ -373,10 +377,11 @@ export default EmberObject.extend({
|
|
|
373
377
|
name: {String} The name of the column.
|
|
374
378
|
desc: {String} Humanized description (what would show in a table column name).
|
|
375
379
|
*/
|
|
376
|
-
columnsForType() {
|
|
377
|
-
return emberA();
|
|
378
|
-
},
|
|
379
380
|
|
|
381
|
+
|
|
382
|
+
columnsForType(_klass) {
|
|
383
|
+
return emberA();
|
|
384
|
+
}
|
|
380
385
|
/**
|
|
381
386
|
Adds observers to a model type class.
|
|
382
387
|
@private
|
|
@@ -385,6 +390,8 @@ export default EmberObject.extend({
|
|
|
385
390
|
@param {Function} typesUpdated Called when a type is modified.
|
|
386
391
|
@return {Function} The function to call to remove observers.
|
|
387
392
|
*/
|
|
393
|
+
|
|
394
|
+
|
|
388
395
|
observeModelType(modelName, typesUpdated) {
|
|
389
396
|
let klass = this._nameToClass(modelName);
|
|
390
397
|
|
|
@@ -410,63 +417,50 @@ export default EmberObject.extend({
|
|
|
410
417
|
}
|
|
411
418
|
|
|
412
419
|
return typeWatcher.release;
|
|
413
|
-
}
|
|
414
|
-
|
|
420
|
+
}
|
|
415
421
|
/**
|
|
416
422
|
Wraps a given model type and observes changes to it.
|
|
417
423
|
@private
|
|
418
424
|
@method wrapModelType
|
|
419
425
|
@param {Class} klass A model class.
|
|
420
426
|
@param {String} modelName Name of the class.
|
|
421
|
-
@return {Object}
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
count: {Integer} The number of records available.
|
|
427
|
-
columns: {Columns} An array of columns to describe the record.
|
|
428
|
-
object: {Class} The actual Model type class.
|
|
429
|
-
release: {Function} The function to remove observers.
|
|
427
|
+
@return {Object} The wrapped type has the following format:
|
|
428
|
+
name: {String} The name of the type.
|
|
429
|
+
count: {Integer} The number of records available.
|
|
430
|
+
columns: {Columns} An array of columns to describe the record.
|
|
431
|
+
object: {Class} The actual Model type class.
|
|
430
432
|
*/
|
|
433
|
+
|
|
434
|
+
|
|
431
435
|
wrapModelType(klass, name) {
|
|
432
436
|
let records = this.getRecords(klass, name);
|
|
433
|
-
|
|
434
|
-
typeToSend = {
|
|
437
|
+
return {
|
|
435
438
|
name,
|
|
436
439
|
count: get(records, 'length'),
|
|
437
440
|
columns: this.columnsForType(klass),
|
|
438
441
|
object: klass
|
|
439
442
|
};
|
|
440
|
-
|
|
441
|
-
},
|
|
442
|
-
|
|
443
|
+
}
|
|
443
444
|
/**
|
|
444
445
|
Fetches all models defined in the application.
|
|
445
446
|
@private
|
|
446
447
|
@method getModelTypes
|
|
447
448
|
@return {Array} Array of model types.
|
|
448
449
|
*/
|
|
449
|
-
getModelTypes() {
|
|
450
|
-
let containerDebugAdapter = this.get('containerDebugAdapter');
|
|
451
|
-
let types;
|
|
452
450
|
|
|
453
|
-
if (containerDebugAdapter.canCatalogEntriesByType('model')) {
|
|
454
|
-
types = containerDebugAdapter.catalogEntriesByType('model');
|
|
455
|
-
} else {
|
|
456
|
-
types = this._getObjectsOnNamespaces();
|
|
457
|
-
} // New adapters return strings instead of classes.
|
|
458
451
|
|
|
452
|
+
getModelTypes() {
|
|
453
|
+
let containerDebugAdapter = this.containerDebugAdapter;
|
|
454
|
+
let stringTypes = containerDebugAdapter.canCatalogEntriesByType('model') ? containerDebugAdapter.catalogEntriesByType('model') : this._getObjectsOnNamespaces(); // New adapters return strings instead of classes.
|
|
459
455
|
|
|
460
|
-
|
|
456
|
+
let klassTypes = emberA(stringTypes).map(name => {
|
|
461
457
|
return {
|
|
462
458
|
klass: this._nameToClass(name),
|
|
463
459
|
name
|
|
464
460
|
};
|
|
465
461
|
});
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
},
|
|
469
|
-
|
|
462
|
+
return emberA(klassTypes).filter(type => this.detect(type.klass));
|
|
463
|
+
}
|
|
470
464
|
/**
|
|
471
465
|
Loops over all namespaces and all objects
|
|
472
466
|
attached to them.
|
|
@@ -474,6 +468,8 @@ export default EmberObject.extend({
|
|
|
474
468
|
@method _getObjectsOnNamespaces
|
|
475
469
|
@return {Array} Array of model type strings.
|
|
476
470
|
*/
|
|
471
|
+
|
|
472
|
+
|
|
477
473
|
_getObjectsOnNamespaces() {
|
|
478
474
|
let namespaces = emberA(Namespace.NAMESPACES);
|
|
479
475
|
let types = emberA();
|
|
@@ -494,8 +490,7 @@ export default EmberObject.extend({
|
|
|
494
490
|
}
|
|
495
491
|
});
|
|
496
492
|
return types;
|
|
497
|
-
}
|
|
498
|
-
|
|
493
|
+
}
|
|
499
494
|
/**
|
|
500
495
|
Fetches all loaded records for a given type.
|
|
501
496
|
@public
|
|
@@ -504,10 +499,11 @@ export default EmberObject.extend({
|
|
|
504
499
|
This array will be observed for changes,
|
|
505
500
|
so it should update when new records are added/removed.
|
|
506
501
|
*/
|
|
507
|
-
getRecords() {
|
|
508
|
-
return emberA();
|
|
509
|
-
},
|
|
510
502
|
|
|
503
|
+
|
|
504
|
+
getRecords(_klass, _name) {
|
|
505
|
+
return emberA();
|
|
506
|
+
}
|
|
511
507
|
/**
|
|
512
508
|
Wraps a record and observers changes to it.
|
|
513
509
|
@private
|
|
@@ -517,17 +513,17 @@ export default EmberObject.extend({
|
|
|
517
513
|
columnValues: {Array}
|
|
518
514
|
searchKeywords: {Array}
|
|
519
515
|
*/
|
|
516
|
+
|
|
517
|
+
|
|
520
518
|
wrapRecord(record) {
|
|
521
|
-
|
|
522
|
-
object: record
|
|
519
|
+
return {
|
|
520
|
+
object: record,
|
|
521
|
+
columnValues: this.getRecordColumnValues(record),
|
|
522
|
+
searchKeywords: this.getRecordKeywords(record),
|
|
523
|
+
filterValues: this.getRecordFilterValues(record),
|
|
524
|
+
color: this.getRecordColor(record)
|
|
523
525
|
};
|
|
524
|
-
|
|
525
|
-
recordToSend.searchKeywords = this.getRecordKeywords(record);
|
|
526
|
-
recordToSend.filterValues = this.getRecordFilterValues(record);
|
|
527
|
-
recordToSend.color = this.getRecordColor(record);
|
|
528
|
-
return recordToSend;
|
|
529
|
-
},
|
|
530
|
-
|
|
526
|
+
}
|
|
531
527
|
/**
|
|
532
528
|
Gets the values for each column.
|
|
533
529
|
@public
|
|
@@ -535,20 +531,22 @@ export default EmberObject.extend({
|
|
|
535
531
|
@return {Object} Keys should match column names defined
|
|
536
532
|
by the model type.
|
|
537
533
|
*/
|
|
538
|
-
getRecordColumnValues() {
|
|
539
|
-
return {};
|
|
540
|
-
},
|
|
541
534
|
|
|
535
|
+
|
|
536
|
+
getRecordColumnValues(_record) {
|
|
537
|
+
return {};
|
|
538
|
+
}
|
|
542
539
|
/**
|
|
543
540
|
Returns keywords to match when searching records.
|
|
544
541
|
@public
|
|
545
542
|
@method getRecordKeywords
|
|
546
543
|
@return {Array} Relevant keywords for search.
|
|
547
544
|
*/
|
|
548
|
-
getRecordKeywords() {
|
|
549
|
-
return emberA();
|
|
550
|
-
},
|
|
551
545
|
|
|
546
|
+
|
|
547
|
+
getRecordKeywords(_record) {
|
|
548
|
+
return emberA();
|
|
549
|
+
}
|
|
552
550
|
/**
|
|
553
551
|
Returns the values of filters defined by `getFilters`.
|
|
554
552
|
@public
|
|
@@ -556,10 +554,11 @@ export default EmberObject.extend({
|
|
|
556
554
|
@param {Object} record The record instance.
|
|
557
555
|
@return {Object} The filter values.
|
|
558
556
|
*/
|
|
559
|
-
getRecordFilterValues() {
|
|
560
|
-
return {};
|
|
561
|
-
},
|
|
562
557
|
|
|
558
|
+
|
|
559
|
+
getRecordFilterValues(_record) {
|
|
560
|
+
return {};
|
|
561
|
+
}
|
|
563
562
|
/**
|
|
564
563
|
Each record can have a color that represents its state.
|
|
565
564
|
@public
|
|
@@ -568,8 +567,10 @@ export default EmberObject.extend({
|
|
|
568
567
|
@return {String} The records color.
|
|
569
568
|
Possible options: black, red, blue, green.
|
|
570
569
|
*/
|
|
571
|
-
|
|
570
|
+
|
|
571
|
+
|
|
572
|
+
getRecordColor(_record) {
|
|
572
573
|
return null;
|
|
573
574
|
}
|
|
574
575
|
|
|
575
|
-
}
|
|
576
|
+
}
|