ember-data-source 2.0.0.beta.1 → 2.0.0.beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/dist/ember-data-tests.js +4228 -4408
- data/dist/ember-data.js +542 -496
- data/dist/ember-data.js.map +1 -1
- data/dist/ember-data.min.js +4 -4
- data/dist/ember-data.prod.js +475 -429
- data/package.json +1 -1
- metadata +2 -2
data/dist/ember-data.js
CHANGED
|
@@ -201,16 +201,21 @@
|
|
|
201
201
|
if (path) {
|
|
202
202
|
// Protocol relative url
|
|
203
203
|
//jscs:disable disallowEmptyBlocks
|
|
204
|
-
if (/^\/\//.test(path)) {
|
|
205
|
-
//
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
204
|
+
if (/^\/\//.test(path)) {
|
|
205
|
+
// Do nothing, the full host is already included. This branch
|
|
206
|
+
// avoids the absolute path logic and the relative path logic.
|
|
207
|
+
|
|
208
|
+
// Absolute path
|
|
209
|
+
} else if (path.charAt(0) === '/') {
|
|
210
|
+
//jscs:enable disallowEmptyBlocks
|
|
211
|
+
if (host) {
|
|
212
|
+
path = path.slice(1);
|
|
213
|
+
url.push(host);
|
|
214
|
+
}
|
|
215
|
+
// Relative path
|
|
216
|
+
} else if (!/^http(s)?:\/\//.test(path)) {
|
|
217
|
+
url.push(parentURL);
|
|
218
|
+
}
|
|
214
219
|
} else {
|
|
215
220
|
if (host) {
|
|
216
221
|
url.push(host);
|
|
@@ -261,8 +266,9 @@
|
|
|
261
266
|
@class AdapterError
|
|
262
267
|
@namespace DS
|
|
263
268
|
*/
|
|
269
|
+
|
|
264
270
|
function ember$data$lib$adapters$errors$$AdapterError(errors) {
|
|
265
|
-
var message = arguments[1] === undefined ? 'Adapter operation failed' : arguments[1];
|
|
271
|
+
var message = arguments.length <= 1 || arguments[1] === undefined ? 'Adapter operation failed' : arguments[1];
|
|
266
272
|
|
|
267
273
|
ember$data$lib$adapters$errors$$EmberError.call(this, message);
|
|
268
274
|
|
|
@@ -332,6 +338,7 @@
|
|
|
332
338
|
@class InvalidError
|
|
333
339
|
@namespace DS
|
|
334
340
|
*/
|
|
341
|
+
|
|
335
342
|
function ember$data$lib$adapters$errors$$InvalidError(errors) {
|
|
336
343
|
if (!Ember.isArray(errors)) {
|
|
337
344
|
Ember.deprecate('`InvalidError` expects json-api formatted errors.', false, { id: 'ds.errors.invalid-error-expects-json-api-format', until: '2.0.0' });
|
|
@@ -346,6 +353,7 @@
|
|
|
346
353
|
@class TimeoutError
|
|
347
354
|
@namespace DS
|
|
348
355
|
*/
|
|
356
|
+
|
|
349
357
|
function ember$data$lib$adapters$errors$$TimeoutError() {
|
|
350
358
|
ember$data$lib$adapters$errors$$AdapterError.call(this, null, 'The adapter operation timed out');
|
|
351
359
|
}
|
|
@@ -356,6 +364,7 @@
|
|
|
356
364
|
@class AbortError
|
|
357
365
|
@namespace DS
|
|
358
366
|
*/
|
|
367
|
+
|
|
359
368
|
function ember$data$lib$adapters$errors$$AbortError() {
|
|
360
369
|
ember$data$lib$adapters$errors$$AdapterError.call(this, null, 'The adapter operation was aborted');
|
|
361
370
|
}
|
|
@@ -366,6 +375,7 @@
|
|
|
366
375
|
@method errorsHashToArray
|
|
367
376
|
@private
|
|
368
377
|
*/
|
|
378
|
+
|
|
369
379
|
function ember$data$lib$adapters$errors$$errorsHashToArray(errors) {
|
|
370
380
|
var out = [];
|
|
371
381
|
|
|
@@ -391,6 +401,7 @@
|
|
|
391
401
|
@method errorsArrayToHash
|
|
392
402
|
@private
|
|
393
403
|
*/
|
|
404
|
+
|
|
394
405
|
function ember$data$lib$adapters$errors$$errorsArrayToHash(errors) {
|
|
395
406
|
var out = {};
|
|
396
407
|
|
|
@@ -872,6 +883,23 @@
|
|
|
872
883
|
|
|
873
884
|
var ember$data$lib$system$adapter$$default = ember$data$lib$system$adapter$$Adapter;
|
|
874
885
|
|
|
886
|
+
/**
|
|
887
|
+
`DS.FixtureAdapter` is an adapter that loads records from memory.
|
|
888
|
+
It's primarily used for development and testing. You can also use
|
|
889
|
+
`DS.FixtureAdapter` while working on the API but is not ready to
|
|
890
|
+
integrate yet. It is a fully functioning adapter. All CRUD methods
|
|
891
|
+
are implemented. You can also implement query logic that a remote
|
|
892
|
+
system would do. It's possible to develop your entire application
|
|
893
|
+
with `DS.FixtureAdapter`.
|
|
894
|
+
|
|
895
|
+
For information on how to use the `FixtureAdapter` in your
|
|
896
|
+
application please see the [FixtureAdapter
|
|
897
|
+
guide](/guides/models/the-fixture-adapter/).
|
|
898
|
+
|
|
899
|
+
@class FixtureAdapter
|
|
900
|
+
@namespace DS
|
|
901
|
+
@extends DS.Adapter
|
|
902
|
+
*/
|
|
875
903
|
/**
|
|
876
904
|
@module ember-data
|
|
877
905
|
*/
|
|
@@ -919,9 +947,9 @@
|
|
|
919
947
|
return typeClass.FIXTURES.map(function (fixture) {
|
|
920
948
|
var fixtureIdType = typeof fixture.id;
|
|
921
949
|
if (fixtureIdType !== "number" && fixtureIdType !== "string") {
|
|
922
|
-
throw new Error(ember$data$lib$adapters$fixture$adapter$$fmt(
|
|
950
|
+
throw new Error(ember$data$lib$adapters$fixture$adapter$$fmt('the id property must be defined as a number or string for fixture %@', [fixture]));
|
|
923
951
|
}
|
|
924
|
-
fixture.id = fixture.id +
|
|
952
|
+
fixture.id = fixture.id + '';
|
|
925
953
|
return fixture;
|
|
926
954
|
});
|
|
927
955
|
}
|
|
@@ -937,7 +965,7 @@
|
|
|
937
965
|
@return {(Promise|Array)}
|
|
938
966
|
*/
|
|
939
967
|
queryFixtures: function (fixtures, query, typeClass) {
|
|
940
|
-
Ember.assert(
|
|
968
|
+
Ember.assert('Not implemented: You must override the DS.FixtureAdapter::queryFixtures method to support querying the fixture store.');
|
|
941
969
|
},
|
|
942
970
|
|
|
943
971
|
/**
|
|
@@ -992,7 +1020,7 @@
|
|
|
992
1020
|
Ember.assert("Unable to find fixtures for model type " + typeClass.toString() + ". If you're defining your fixtures using `Model.FIXTURES = ...`, please change it to `Model.reopenClass({ FIXTURES: ... })`.", fixtures);
|
|
993
1021
|
|
|
994
1022
|
if (fixtures) {
|
|
995
|
-
fixture = Ember.A(fixtures).findBy(
|
|
1023
|
+
fixture = Ember.A(fixtures).findBy('id', id);
|
|
996
1024
|
}
|
|
997
1025
|
|
|
998
1026
|
if (fixture) {
|
|
@@ -1154,7 +1182,7 @@
|
|
|
1154
1182
|
*/
|
|
1155
1183
|
findFixtureById: function (fixtures, id) {
|
|
1156
1184
|
return Ember.A(fixtures).find(function (r) {
|
|
1157
|
-
if (
|
|
1185
|
+
if ('' + ember$data$lib$adapters$fixture$adapter$$get(r, 'id') === '' + id) {
|
|
1158
1186
|
return true;
|
|
1159
1187
|
} else {
|
|
1160
1188
|
return false;
|
|
@@ -1173,14 +1201,14 @@
|
|
|
1173
1201
|
|
|
1174
1202
|
return new Ember.RSVP.Promise(function (resolve) {
|
|
1175
1203
|
var value = Ember.copy(callback.call(context), true);
|
|
1176
|
-
if (ember$data$lib$adapters$fixture$adapter$$get(adapter,
|
|
1204
|
+
if (ember$data$lib$adapters$fixture$adapter$$get(adapter, 'simulateRemoteResponse')) {
|
|
1177
1205
|
// Schedule with setTimeout
|
|
1178
1206
|
Ember.run.later(function () {
|
|
1179
1207
|
return resolve(value);
|
|
1180
|
-
}, ember$data$lib$adapters$fixture$adapter$$get(adapter,
|
|
1208
|
+
}, ember$data$lib$adapters$fixture$adapter$$get(adapter, 'latency'));
|
|
1181
1209
|
} else {
|
|
1182
1210
|
// Asynchronous, but at the of the runloop with zero latency
|
|
1183
|
-
Ember.run.schedule(
|
|
1211
|
+
Ember.run.schedule('actions', null, function () {
|
|
1184
1212
|
return resolve(value);
|
|
1185
1213
|
});
|
|
1186
1214
|
}
|
|
@@ -1193,25 +1221,25 @@
|
|
|
1193
1221
|
|
|
1194
1222
|
var ember$data$lib$system$map$$default = ember$data$lib$system$map$$Map;
|
|
1195
1223
|
|
|
1196
|
-
|
|
1224
|
+
/**
|
|
1197
1225
|
The REST adapter allows your store to communicate with an HTTP server by
|
|
1198
1226
|
transmitting JSON via XHR. Most Ember.js apps that consume a JSON API
|
|
1199
1227
|
should use the REST adapter.
|
|
1200
|
-
|
|
1228
|
+
|
|
1201
1229
|
This adapter is designed around the idea that the JSON exchanged with
|
|
1202
1230
|
the server should be conventional.
|
|
1203
|
-
|
|
1231
|
+
|
|
1204
1232
|
## JSON Structure
|
|
1205
|
-
|
|
1233
|
+
|
|
1206
1234
|
The REST adapter expects the JSON returned from your server to follow
|
|
1207
1235
|
these conventions.
|
|
1208
|
-
|
|
1236
|
+
|
|
1209
1237
|
### Object Root
|
|
1210
|
-
|
|
1238
|
+
|
|
1211
1239
|
The JSON payload should be an object that contains the record inside a
|
|
1212
1240
|
root property. For example, in response to a `GET` request for
|
|
1213
1241
|
`/posts/1`, the JSON should look like this:
|
|
1214
|
-
|
|
1242
|
+
|
|
1215
1243
|
```js
|
|
1216
1244
|
{
|
|
1217
1245
|
"post": {
|
|
@@ -1221,10 +1249,10 @@
|
|
|
1221
1249
|
}
|
|
1222
1250
|
}
|
|
1223
1251
|
```
|
|
1224
|
-
|
|
1252
|
+
|
|
1225
1253
|
Similarly, in response to a `GET` request for `/posts`, the JSON should
|
|
1226
1254
|
look like this:
|
|
1227
|
-
|
|
1255
|
+
|
|
1228
1256
|
```js
|
|
1229
1257
|
{
|
|
1230
1258
|
"posts": [
|
|
@@ -1241,26 +1269,26 @@
|
|
|
1241
1269
|
]
|
|
1242
1270
|
}
|
|
1243
1271
|
```
|
|
1244
|
-
|
|
1272
|
+
|
|
1245
1273
|
### Conventional Names
|
|
1246
|
-
|
|
1274
|
+
|
|
1247
1275
|
Attribute names in your JSON payload should be the camelCased versions of
|
|
1248
1276
|
the attributes in your Ember.js models.
|
|
1249
|
-
|
|
1277
|
+
|
|
1250
1278
|
For example, if you have a `Person` model:
|
|
1251
|
-
|
|
1279
|
+
|
|
1252
1280
|
```app/models/person.js
|
|
1253
1281
|
import DS from 'ember-data';
|
|
1254
|
-
|
|
1282
|
+
|
|
1255
1283
|
export default DS.Model.extend({
|
|
1256
1284
|
firstName: DS.attr('string'),
|
|
1257
1285
|
lastName: DS.attr('string'),
|
|
1258
1286
|
occupation: DS.attr('string')
|
|
1259
1287
|
});
|
|
1260
1288
|
```
|
|
1261
|
-
|
|
1289
|
+
|
|
1262
1290
|
The JSON returned should look like this:
|
|
1263
|
-
|
|
1291
|
+
|
|
1264
1292
|
```js
|
|
1265
1293
|
{
|
|
1266
1294
|
"person": {
|
|
@@ -1271,45 +1299,45 @@
|
|
|
1271
1299
|
}
|
|
1272
1300
|
}
|
|
1273
1301
|
```
|
|
1274
|
-
|
|
1302
|
+
|
|
1275
1303
|
## Customization
|
|
1276
|
-
|
|
1304
|
+
|
|
1277
1305
|
### Endpoint path customization
|
|
1278
|
-
|
|
1306
|
+
|
|
1279
1307
|
Endpoint paths can be prefixed with a `namespace` by setting the namespace
|
|
1280
1308
|
property on the adapter:
|
|
1281
|
-
|
|
1309
|
+
|
|
1282
1310
|
```app/adapters/application.js
|
|
1283
1311
|
import DS from 'ember-data';
|
|
1284
|
-
|
|
1312
|
+
|
|
1285
1313
|
export default DS.RESTAdapter.extend({
|
|
1286
1314
|
namespace: 'api/1'
|
|
1287
1315
|
});
|
|
1288
1316
|
```
|
|
1289
1317
|
Requests for `App.Person` would now target `/api/1/people/1`.
|
|
1290
|
-
|
|
1318
|
+
|
|
1291
1319
|
### Host customization
|
|
1292
|
-
|
|
1320
|
+
|
|
1293
1321
|
An adapter can target other hosts by setting the `host` property.
|
|
1294
|
-
|
|
1322
|
+
|
|
1295
1323
|
```app/adapters/application.js
|
|
1296
1324
|
import DS from 'ember-data';
|
|
1297
|
-
|
|
1325
|
+
|
|
1298
1326
|
export default DS.RESTAdapter.extend({
|
|
1299
1327
|
host: 'https://api.example.com'
|
|
1300
1328
|
});
|
|
1301
1329
|
```
|
|
1302
|
-
|
|
1330
|
+
|
|
1303
1331
|
### Headers customization
|
|
1304
|
-
|
|
1332
|
+
|
|
1305
1333
|
Some APIs require HTTP headers, e.g. to provide an API key. Arbitrary
|
|
1306
1334
|
headers can be set as key/value pairs on the `RESTAdapter`'s `headers`
|
|
1307
1335
|
object and Ember Data will send them along with each ajax request.
|
|
1308
|
-
|
|
1309
|
-
|
|
1336
|
+
|
|
1337
|
+
|
|
1310
1338
|
```app/adapters/application.js
|
|
1311
1339
|
import DS from 'ember-data';
|
|
1312
|
-
|
|
1340
|
+
|
|
1313
1341
|
export default DS.RESTAdapter.extend({
|
|
1314
1342
|
headers: {
|
|
1315
1343
|
"API_KEY": "secret key",
|
|
@@ -1317,14 +1345,14 @@
|
|
|
1317
1345
|
}
|
|
1318
1346
|
});
|
|
1319
1347
|
```
|
|
1320
|
-
|
|
1348
|
+
|
|
1321
1349
|
`headers` can also be used as a computed property to support dynamic
|
|
1322
1350
|
headers. In the example below, the `session` object has been
|
|
1323
1351
|
injected into an adapter by Ember's container.
|
|
1324
|
-
|
|
1352
|
+
|
|
1325
1353
|
```app/adapters/application.js
|
|
1326
1354
|
import DS from 'ember-data';
|
|
1327
|
-
|
|
1355
|
+
|
|
1328
1356
|
export default DS.RESTAdapter.extend({
|
|
1329
1357
|
headers: function() {
|
|
1330
1358
|
return {
|
|
@@ -1334,17 +1362,17 @@
|
|
|
1334
1362
|
}.property("session.authToken")
|
|
1335
1363
|
});
|
|
1336
1364
|
```
|
|
1337
|
-
|
|
1365
|
+
|
|
1338
1366
|
In some cases, your dynamic headers may require data from some
|
|
1339
1367
|
object outside of Ember's observer system (for example
|
|
1340
1368
|
`document.cookie`). You can use the
|
|
1341
1369
|
[volatile](/api/classes/Ember.ComputedProperty.html#method_volatile)
|
|
1342
1370
|
function to set the property into a non-cached mode causing the headers to
|
|
1343
1371
|
be recomputed with every request.
|
|
1344
|
-
|
|
1372
|
+
|
|
1345
1373
|
```app/adapters/application.js
|
|
1346
1374
|
import DS from 'ember-data';
|
|
1347
|
-
|
|
1375
|
+
|
|
1348
1376
|
export default DS.RESTAdapter.extend({
|
|
1349
1377
|
headers: function() {
|
|
1350
1378
|
return {
|
|
@@ -1354,15 +1382,15 @@
|
|
|
1354
1382
|
}.property().volatile()
|
|
1355
1383
|
});
|
|
1356
1384
|
```
|
|
1357
|
-
|
|
1385
|
+
|
|
1358
1386
|
@class RESTAdapter
|
|
1359
1387
|
@constructor
|
|
1360
1388
|
@namespace DS
|
|
1361
1389
|
@extends DS.Adapter
|
|
1362
1390
|
@uses DS.BuildURLMixin
|
|
1363
1391
|
*/
|
|
1364
|
-
var ember$data$lib$adapters$rest$adapter$$RESTAdapter = ember$data$lib$system$adapter$$default.extend(ember$data$lib$adapters$build$url$mixin$$default, {
|
|
1365
|
-
defaultSerializer:
|
|
1392
|
+
var ember$data$lib$adapters$rest$adapter$$get = Ember.get;var ember$data$lib$adapters$rest$adapter$$RESTAdapter = ember$data$lib$system$adapter$$default.extend(ember$data$lib$adapters$build$url$mixin$$default, {
|
|
1393
|
+
defaultSerializer: '-rest',
|
|
1366
1394
|
|
|
1367
1395
|
/**
|
|
1368
1396
|
By default, the RESTAdapter will send the query params sorted alphabetically to the
|
|
@@ -1508,7 +1536,7 @@
|
|
|
1508
1536
|
@return {Promise} promise
|
|
1509
1537
|
*/
|
|
1510
1538
|
findRecord: function (store, type, id, snapshot) {
|
|
1511
|
-
return this.ajax(this.buildURL(type.modelName, id, snapshot,
|
|
1539
|
+
return this.ajax(this.buildURL(type.modelName, id, snapshot, 'findRecord'), 'GET');
|
|
1512
1540
|
},
|
|
1513
1541
|
|
|
1514
1542
|
/**
|
|
@@ -1530,9 +1558,9 @@
|
|
|
1530
1558
|
query = { since: sinceToken };
|
|
1531
1559
|
}
|
|
1532
1560
|
|
|
1533
|
-
url = this.buildURL(type.modelName, null, null,
|
|
1561
|
+
url = this.buildURL(type.modelName, null, null, 'findAll');
|
|
1534
1562
|
|
|
1535
|
-
return this.ajax(url,
|
|
1563
|
+
return this.ajax(url, 'GET', { data: query });
|
|
1536
1564
|
},
|
|
1537
1565
|
|
|
1538
1566
|
/**
|
|
@@ -1551,13 +1579,13 @@
|
|
|
1551
1579
|
@return {Promise} promise
|
|
1552
1580
|
*/
|
|
1553
1581
|
query: function (store, type, query) {
|
|
1554
|
-
var url = this.buildURL(type.modelName, null, null,
|
|
1582
|
+
var url = this.buildURL(type.modelName, null, null, 'query', query);
|
|
1555
1583
|
|
|
1556
1584
|
if (this.sortQueryParams) {
|
|
1557
1585
|
query = this.sortQueryParams(query);
|
|
1558
1586
|
}
|
|
1559
1587
|
|
|
1560
|
-
return this.ajax(url,
|
|
1588
|
+
return this.ajax(url, 'GET', { data: query });
|
|
1561
1589
|
},
|
|
1562
1590
|
|
|
1563
1591
|
/**
|
|
@@ -1576,13 +1604,13 @@
|
|
|
1576
1604
|
@return {Promise} promise
|
|
1577
1605
|
*/
|
|
1578
1606
|
queryRecord: function (store, type, query) {
|
|
1579
|
-
var url = this.buildURL(type.modelName, null, null,
|
|
1607
|
+
var url = this.buildURL(type.modelName, null, null, 'queryRecord', query);
|
|
1580
1608
|
|
|
1581
1609
|
if (this.sortQueryParams) {
|
|
1582
1610
|
query = this.sortQueryParams(query);
|
|
1583
1611
|
}
|
|
1584
1612
|
|
|
1585
|
-
return this.ajax(url,
|
|
1613
|
+
return this.ajax(url, 'GET', { data: query });
|
|
1586
1614
|
},
|
|
1587
1615
|
|
|
1588
1616
|
/**
|
|
@@ -1612,8 +1640,8 @@
|
|
|
1612
1640
|
@return {Promise} promise
|
|
1613
1641
|
*/
|
|
1614
1642
|
findMany: function (store, type, ids, snapshots) {
|
|
1615
|
-
var url = this.buildURL(type.modelName, ids, snapshots,
|
|
1616
|
-
return this.ajax(url,
|
|
1643
|
+
var url = this.buildURL(type.modelName, ids, snapshots, 'findMany');
|
|
1644
|
+
return this.ajax(url, 'GET', { data: { ids: ids } });
|
|
1617
1645
|
},
|
|
1618
1646
|
|
|
1619
1647
|
/**
|
|
@@ -1642,9 +1670,9 @@
|
|
|
1642
1670
|
var id = snapshot.id;
|
|
1643
1671
|
var type = snapshot.modelName;
|
|
1644
1672
|
|
|
1645
|
-
url = this.urlPrefix(url, this.buildURL(type, id, null,
|
|
1673
|
+
url = this.urlPrefix(url, this.buildURL(type, id, null, 'findHasMany'));
|
|
1646
1674
|
|
|
1647
|
-
return this.ajax(url,
|
|
1675
|
+
return this.ajax(url, 'GET');
|
|
1648
1676
|
},
|
|
1649
1677
|
|
|
1650
1678
|
/**
|
|
@@ -1673,8 +1701,8 @@
|
|
|
1673
1701
|
var id = snapshot.id;
|
|
1674
1702
|
var type = snapshot.modelName;
|
|
1675
1703
|
|
|
1676
|
-
url = this.urlPrefix(url, this.buildURL(type, id, null,
|
|
1677
|
-
return this.ajax(url,
|
|
1704
|
+
url = this.urlPrefix(url, this.buildURL(type, id, null, 'findBelongsTo'));
|
|
1705
|
+
return this.ajax(url, 'GET');
|
|
1678
1706
|
},
|
|
1679
1707
|
|
|
1680
1708
|
/**
|
|
@@ -1693,7 +1721,7 @@
|
|
|
1693
1721
|
createRecord: function (store, type, snapshot) {
|
|
1694
1722
|
var data = {};
|
|
1695
1723
|
var serializer = store.serializerFor(type.modelName);
|
|
1696
|
-
var url = this.buildURL(type.modelName, null, snapshot,
|
|
1724
|
+
var url = this.buildURL(type.modelName, null, snapshot, 'createRecord');
|
|
1697
1725
|
|
|
1698
1726
|
serializer.serializeIntoHash(data, type, snapshot, { includeId: true });
|
|
1699
1727
|
|
|
@@ -1720,7 +1748,7 @@
|
|
|
1720
1748
|
serializer.serializeIntoHash(data, type, snapshot);
|
|
1721
1749
|
|
|
1722
1750
|
var id = snapshot.id;
|
|
1723
|
-
var url = this.buildURL(type.modelName, id, snapshot,
|
|
1751
|
+
var url = this.buildURL(type.modelName, id, snapshot, 'updateRecord');
|
|
1724
1752
|
|
|
1725
1753
|
return this.ajax(url, "PUT", { data: data });
|
|
1726
1754
|
},
|
|
@@ -1737,24 +1765,24 @@
|
|
|
1737
1765
|
deleteRecord: function (store, type, snapshot) {
|
|
1738
1766
|
var id = snapshot.id;
|
|
1739
1767
|
|
|
1740
|
-
return this.ajax(this.buildURL(type.modelName, id, snapshot,
|
|
1768
|
+
return this.ajax(this.buildURL(type.modelName, id, snapshot, 'deleteRecord'), "DELETE");
|
|
1741
1769
|
},
|
|
1742
1770
|
|
|
1743
1771
|
_stripIDFromURL: function (store, snapshot) {
|
|
1744
1772
|
var url = this.buildURL(snapshot.modelName, snapshot.id, snapshot);
|
|
1745
1773
|
|
|
1746
|
-
var expandedURL = url.split(
|
|
1774
|
+
var expandedURL = url.split('/');
|
|
1747
1775
|
//Case when the url is of the format ...something/:id
|
|
1748
1776
|
var lastSegment = expandedURL[expandedURL.length - 1];
|
|
1749
1777
|
var id = snapshot.id;
|
|
1750
1778
|
if (lastSegment === id) {
|
|
1751
1779
|
expandedURL[expandedURL.length - 1] = "";
|
|
1752
|
-
} else if (ember$data$lib$adapters$rest$adapter$$endsWith(lastSegment,
|
|
1780
|
+
} else if (ember$data$lib$adapters$rest$adapter$$endsWith(lastSegment, '?id=' + id)) {
|
|
1753
1781
|
//Case when the url is of the format ...something?id=:id
|
|
1754
1782
|
expandedURL[expandedURL.length - 1] = lastSegment.substring(0, lastSegment.length - id.length - 1);
|
|
1755
1783
|
}
|
|
1756
1784
|
|
|
1757
|
-
return expandedURL.join(
|
|
1785
|
+
return expandedURL.join('/');
|
|
1758
1786
|
},
|
|
1759
1787
|
|
|
1760
1788
|
// http://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers
|
|
@@ -1813,7 +1841,7 @@
|
|
|
1813
1841
|
|
|
1814
1842
|
var groupsArray = [];
|
|
1815
1843
|
groups.forEach(function (group, key) {
|
|
1816
|
-
var paramNameLength =
|
|
1844
|
+
var paramNameLength = '&ids%5B%5D='.length;
|
|
1817
1845
|
var splitGroups = splitGroupToFitInUrl(group, maxURLLength, paramNameLength);
|
|
1818
1846
|
|
|
1819
1847
|
splitGroups.forEach(function (splitGroup) {
|
|
@@ -1930,9 +1958,9 @@
|
|
|
1930
1958
|
if (!(error instanceof Error)) {
|
|
1931
1959
|
if (errorThrown instanceof Error) {
|
|
1932
1960
|
error = errorThrown;
|
|
1933
|
-
} else if (textStatus ===
|
|
1961
|
+
} else if (textStatus === 'timeout') {
|
|
1934
1962
|
error = new ember$data$lib$adapters$errors$$TimeoutError();
|
|
1935
|
-
} else if (textStatus ===
|
|
1963
|
+
} else if (textStatus === 'abort') {
|
|
1936
1964
|
error = new ember$data$lib$adapters$errors$$AbortError();
|
|
1937
1965
|
} else {
|
|
1938
1966
|
error = adapter.handleResponse(jqXHR.status, ember$data$lib$adapters$rest$adapter$$parseResponseHeaders(jqXHR.getAllResponseHeaders()), adapter.parseErrorResponse(jqXHR.responseText) || errorThrown);
|
|
@@ -1943,7 +1971,7 @@
|
|
|
1943
1971
|
};
|
|
1944
1972
|
|
|
1945
1973
|
Ember.$.ajax(hash);
|
|
1946
|
-
},
|
|
1974
|
+
}, 'DS: RESTAdapter#ajax ' + type + ' to ' + url);
|
|
1947
1975
|
},
|
|
1948
1976
|
|
|
1949
1977
|
/**
|
|
@@ -1958,15 +1986,15 @@
|
|
|
1958
1986
|
var hash = options || {};
|
|
1959
1987
|
hash.url = url;
|
|
1960
1988
|
hash.type = type;
|
|
1961
|
-
hash.dataType =
|
|
1989
|
+
hash.dataType = 'json';
|
|
1962
1990
|
hash.context = this;
|
|
1963
1991
|
|
|
1964
|
-
if (hash.data && type !==
|
|
1965
|
-
hash.contentType =
|
|
1992
|
+
if (hash.data && type !== 'GET') {
|
|
1993
|
+
hash.contentType = 'application/json; charset=utf-8';
|
|
1966
1994
|
hash.data = JSON.stringify(hash.data);
|
|
1967
1995
|
}
|
|
1968
1996
|
|
|
1969
|
-
var headers = ember$data$lib$adapters$rest$adapter$$get(this,
|
|
1997
|
+
var headers = ember$data$lib$adapters$rest$adapter$$get(this, 'headers');
|
|
1970
1998
|
if (headers !== undefined) {
|
|
1971
1999
|
hash.beforeSend = function (xhr) {
|
|
1972
2000
|
Object.keys(headers).forEach(function (key) {
|
|
@@ -2003,7 +2031,7 @@
|
|
|
2003
2031
|
@return {Object} errors payload
|
|
2004
2032
|
*/
|
|
2005
2033
|
normalizeErrorResponse: function (status, headers, payload) {
|
|
2006
|
-
if (payload && typeof payload ===
|
|
2034
|
+
if (payload && typeof payload === 'object' && payload.errors) {
|
|
2007
2035
|
return payload.errors;
|
|
2008
2036
|
} else {
|
|
2009
2037
|
return [{
|
|
@@ -2021,12 +2049,12 @@
|
|
|
2021
2049
|
return headers;
|
|
2022
2050
|
}
|
|
2023
2051
|
|
|
2024
|
-
var headerPairs = headerStr.split(
|
|
2052
|
+
var headerPairs = headerStr.split('\u000d\u000a');
|
|
2025
2053
|
for (var i = 0; i < headerPairs.length; i++) {
|
|
2026
2054
|
var headerPair = headerPairs[i];
|
|
2027
2055
|
// Can't use split() here because it does the wrong thing
|
|
2028
2056
|
// if the header value has the string ": " in it.
|
|
2029
|
-
var index = headerPair.indexOf(
|
|
2057
|
+
var index = headerPair.indexOf('\u003a\u0020');
|
|
2030
2058
|
if (index > 0) {
|
|
2031
2059
|
var key = headerPair.substring(0, index);
|
|
2032
2060
|
var val = headerPair.substring(index + 2);
|
|
@@ -2039,7 +2067,7 @@
|
|
|
2039
2067
|
|
|
2040
2068
|
//From http://stackoverflow.com/questions/280634/endswith-in-javascript
|
|
2041
2069
|
function ember$data$lib$adapters$rest$adapter$$endsWith(string, suffix) {
|
|
2042
|
-
if (typeof String.prototype.endsWith !==
|
|
2070
|
+
if (typeof String.prototype.endsWith !== 'function') {
|
|
2043
2071
|
return string.indexOf(suffix, string.length - suffix.length) !== -1;
|
|
2044
2072
|
} else {
|
|
2045
2073
|
return string.endsWith(suffix);
|
|
@@ -2122,7 +2150,7 @@
|
|
|
2122
2150
|
});
|
|
2123
2151
|
|
|
2124
2152
|
var ember$data$lib$core$$DS = Ember.Namespace.create({
|
|
2125
|
-
VERSION: '2.0.0-beta.
|
|
2153
|
+
VERSION: '2.0.0-beta.2'
|
|
2126
2154
|
});
|
|
2127
2155
|
|
|
2128
2156
|
if (Ember.libraries) {
|
|
@@ -2278,6 +2306,7 @@
|
|
|
2278
2306
|
};
|
|
2279
2307
|
|
|
2280
2308
|
var ember$data$lib$system$store$common$$get = Ember.get;
|
|
2309
|
+
|
|
2281
2310
|
function ember$data$lib$system$store$common$$_bind(fn) {
|
|
2282
2311
|
var args = Array.prototype.slice.call(arguments, 1);
|
|
2283
2312
|
|
|
@@ -2287,7 +2316,7 @@
|
|
|
2287
2316
|
}
|
|
2288
2317
|
|
|
2289
2318
|
function ember$data$lib$system$store$common$$_guard(promise, test) {
|
|
2290
|
-
var guarded = promise[
|
|
2319
|
+
var guarded = promise['finally'](function () {
|
|
2291
2320
|
if (!test()) {
|
|
2292
2321
|
guarded._subscribers.length = 0;
|
|
2293
2322
|
}
|
|
@@ -2300,6 +2329,92 @@
|
|
|
2300
2329
|
return !(ember$data$lib$system$store$common$$get(object, "isDestroyed") || ember$data$lib$system$store$common$$get(object, "isDestroying"));
|
|
2301
2330
|
}
|
|
2302
2331
|
|
|
2332
|
+
/**
|
|
2333
|
+
@module ember-data
|
|
2334
|
+
*/
|
|
2335
|
+
|
|
2336
|
+
/**
|
|
2337
|
+
Holds validation errors for a given record organized by attribute names.
|
|
2338
|
+
|
|
2339
|
+
Every DS.Model has an `errors` property that is an instance of
|
|
2340
|
+
`DS.Errors`. This can be used to display validation error
|
|
2341
|
+
messages returned from the server when a `record.save()` rejects.
|
|
2342
|
+
This works automatically with `DS.ActiveModelAdapter`, but you
|
|
2343
|
+
can implement [ajaxError](/api/data/classes/DS.RESTAdapter.html#method_ajaxError)
|
|
2344
|
+
in other adapters as well.
|
|
2345
|
+
|
|
2346
|
+
For Example, if you had an `User` model that looked like this:
|
|
2347
|
+
|
|
2348
|
+
```app/models/user.js
|
|
2349
|
+
import DS from 'ember-data';
|
|
2350
|
+
|
|
2351
|
+
export default DS.Model.extend({
|
|
2352
|
+
username: attr('string'),
|
|
2353
|
+
email: attr('string')
|
|
2354
|
+
});
|
|
2355
|
+
```
|
|
2356
|
+
And you attempted to save a record that did not validate on the backend.
|
|
2357
|
+
|
|
2358
|
+
```javascript
|
|
2359
|
+
var user = store.createRecord('user', {
|
|
2360
|
+
username: 'tomster',
|
|
2361
|
+
email: 'invalidEmail'
|
|
2362
|
+
});
|
|
2363
|
+
user.save();
|
|
2364
|
+
```
|
|
2365
|
+
|
|
2366
|
+
Your backend data store might return a response that looks like
|
|
2367
|
+
this. This response will be used to populate the error object.
|
|
2368
|
+
|
|
2369
|
+
```javascript
|
|
2370
|
+
{
|
|
2371
|
+
"errors": {
|
|
2372
|
+
"username": ["This username is already taken!"],
|
|
2373
|
+
"email": ["Doesn't look like a valid email."]
|
|
2374
|
+
}
|
|
2375
|
+
}
|
|
2376
|
+
```
|
|
2377
|
+
|
|
2378
|
+
Errors can be displayed to the user by accessing their property name
|
|
2379
|
+
to get an array of all the error objects for that property. Each
|
|
2380
|
+
error object is a JavaScript object with two keys:
|
|
2381
|
+
|
|
2382
|
+
- `message` A string containing the error message from the backend
|
|
2383
|
+
- `attribute` The name of the property associated with this error message
|
|
2384
|
+
|
|
2385
|
+
```handlebars
|
|
2386
|
+
<label>Username: {{input value=username}} </label>
|
|
2387
|
+
{{#each model.errors.username as |error|}}
|
|
2388
|
+
<div class="error">
|
|
2389
|
+
{{error.message}}
|
|
2390
|
+
</div>
|
|
2391
|
+
{{/each}}
|
|
2392
|
+
|
|
2393
|
+
<label>Email: {{input value=email}} </label>
|
|
2394
|
+
{{#each model.errors.email as |error|}}
|
|
2395
|
+
<div class="error">
|
|
2396
|
+
{{error.message}}
|
|
2397
|
+
</div>
|
|
2398
|
+
{{/each}}
|
|
2399
|
+
```
|
|
2400
|
+
|
|
2401
|
+
You can also access the special `messages` property on the error
|
|
2402
|
+
object to get an array of all the error strings.
|
|
2403
|
+
|
|
2404
|
+
```handlebars
|
|
2405
|
+
{{#each model.errors.messages as |message|}}
|
|
2406
|
+
<div class="error">
|
|
2407
|
+
{{message}}
|
|
2408
|
+
</div>
|
|
2409
|
+
{{/each}}
|
|
2410
|
+
```
|
|
2411
|
+
|
|
2412
|
+
@class Errors
|
|
2413
|
+
@namespace DS
|
|
2414
|
+
@extends Ember.Object
|
|
2415
|
+
@uses Ember.Enumerable
|
|
2416
|
+
@uses Ember.Evented
|
|
2417
|
+
*/
|
|
2303
2418
|
var ember$data$lib$system$model$errors$$get = Ember.get;
|
|
2304
2419
|
var ember$data$lib$system$model$errors$$set = Ember.set;
|
|
2305
2420
|
var ember$data$lib$system$model$errors$$isEmpty = Ember.isEmpty;
|
|
@@ -2569,9 +2684,9 @@
|
|
|
2569
2684
|
return result;
|
|
2570
2685
|
}
|
|
2571
2686
|
|
|
2572
|
-
var ember$data$lib$system$model$model$$RESERVED_MODEL_PROPS = [
|
|
2687
|
+
var ember$data$lib$system$model$model$$RESERVED_MODEL_PROPS = ['currentState', 'data', 'store'];
|
|
2573
2688
|
|
|
2574
|
-
var ember$data$lib$system$model$model$$retrieveFromCurrentState = Ember.computed(
|
|
2689
|
+
var ember$data$lib$system$model$model$$retrieveFromCurrentState = Ember.computed('currentState', function (key) {
|
|
2575
2690
|
return ember$data$lib$system$model$model$$get(this._internalModel.currentState, key);
|
|
2576
2691
|
}).readOnly();
|
|
2577
2692
|
|
|
@@ -2655,8 +2770,8 @@
|
|
|
2655
2770
|
@type {Boolean}
|
|
2656
2771
|
@readOnly
|
|
2657
2772
|
*/
|
|
2658
|
-
hasDirtyAttributes: Ember.computed(
|
|
2659
|
-
return this.get(
|
|
2773
|
+
hasDirtyAttributes: Ember.computed('currentState.isDirty', function () {
|
|
2774
|
+
return this.get('currentState.isDirty');
|
|
2660
2775
|
}),
|
|
2661
2776
|
/**
|
|
2662
2777
|
If this property is `true` the record is in the `saving` state. A
|
|
@@ -2858,9 +2973,9 @@
|
|
|
2858
2973
|
var errors = ember$data$lib$system$model$errors$$default.create();
|
|
2859
2974
|
|
|
2860
2975
|
errors.registerHandlers(this._internalModel, function () {
|
|
2861
|
-
this.send(
|
|
2976
|
+
this.send('becameInvalid');
|
|
2862
2977
|
}, function () {
|
|
2863
|
-
this.send(
|
|
2978
|
+
this.send('becameValid');
|
|
2864
2979
|
});
|
|
2865
2980
|
|
|
2866
2981
|
return errors;
|
|
@@ -2902,7 +3017,7 @@
|
|
|
2902
3017
|
*/
|
|
2903
3018
|
toJSON: function (options) {
|
|
2904
3019
|
// container is for lazy transform lookups
|
|
2905
|
-
var serializer = this.store.serializerFor(
|
|
3020
|
+
var serializer = this.store.serializerFor('-default');
|
|
2906
3021
|
var snapshot = this._internalModel.createSnapshot();
|
|
2907
3022
|
|
|
2908
3023
|
return serializer.serialize(snapshot, options);
|
|
@@ -2962,7 +3077,7 @@
|
|
|
2962
3077
|
@private
|
|
2963
3078
|
@type {Object}
|
|
2964
3079
|
*/
|
|
2965
|
-
data: Ember.computed.readOnly(
|
|
3080
|
+
data: Ember.computed.readOnly('_internalModel._data'),
|
|
2966
3081
|
|
|
2967
3082
|
//TODO Do we want to deprecate these?
|
|
2968
3083
|
/**
|
|
@@ -3084,9 +3199,9 @@
|
|
|
3084
3199
|
and value is an [oldProp, newProp] array.
|
|
3085
3200
|
*/
|
|
3086
3201
|
changedAttributes: function () {
|
|
3087
|
-
var oldData = ember$data$lib$system$model$model$$get(this._internalModel,
|
|
3088
|
-
var currentData = ember$data$lib$system$model$model$$get(this._internalModel,
|
|
3089
|
-
var inFlightData = ember$data$lib$system$model$model$$get(this._internalModel,
|
|
3202
|
+
var oldData = ember$data$lib$system$model$model$$get(this._internalModel, '_data');
|
|
3203
|
+
var currentData = ember$data$lib$system$model$model$$get(this._internalModel, '_attributes');
|
|
3204
|
+
var inFlightData = ember$data$lib$system$model$model$$get(this._internalModel, '_inFlightAttributes');
|
|
3090
3205
|
var newData = ember$data$lib$system$model$model$$merge(ember$data$lib$system$model$model$$copy(inFlightData), currentData);
|
|
3091
3206
|
var diffData = Object.create(null);
|
|
3092
3207
|
|
|
@@ -3143,7 +3258,7 @@
|
|
|
3143
3258
|
},
|
|
3144
3259
|
|
|
3145
3260
|
toStringExtension: function () {
|
|
3146
|
-
return ember$data$lib$system$model$model$$get(this,
|
|
3261
|
+
return ember$data$lib$system$model$model$$get(this, 'id');
|
|
3147
3262
|
},
|
|
3148
3263
|
|
|
3149
3264
|
/**
|
|
@@ -3237,7 +3352,7 @@
|
|
|
3237
3352
|
// rely on the data property.
|
|
3238
3353
|
willMergeMixin: function (props) {
|
|
3239
3354
|
var constructor = this.constructor;
|
|
3240
|
-
Ember.assert(
|
|
3355
|
+
Ember.assert('`' + ember$data$lib$system$model$model$$intersection(Object.keys(props), ember$data$lib$system$model$model$$RESERVED_MODEL_PROPS)[0] + '` is a reserved property name on DS.Model objects. Please choose a different property name for ' + constructor.toString(), !ember$data$lib$system$model$model$$intersection(Object.keys(props), ember$data$lib$system$model$model$$RESERVED_MODEL_PROPS)[0]);
|
|
3241
3356
|
},
|
|
3242
3357
|
|
|
3243
3358
|
attr: function () {
|
|
@@ -3317,6 +3432,7 @@
|
|
|
3317
3432
|
@param {Object} doc JSON API document
|
|
3318
3433
|
@return {array} An array of errors found in the document structure
|
|
3319
3434
|
*/
|
|
3435
|
+
|
|
3320
3436
|
function ember$data$lib$system$store$serializer$response$$validateDocumentStructure(doc) {
|
|
3321
3437
|
var errors = [];
|
|
3322
3438
|
if (!doc || typeof doc !== 'object') {
|
|
@@ -3376,6 +3492,7 @@
|
|
|
3376
3492
|
@param {String} requestType
|
|
3377
3493
|
@return {Object} JSON-API Document
|
|
3378
3494
|
*/
|
|
3495
|
+
|
|
3379
3496
|
function ember$data$lib$system$store$serializer$response$$normalizeResponseHelper(serializer, store, modelClass, payload, id, requestType) {
|
|
3380
3497
|
var normalizedResponse = serializer.normalizeResponse(store, modelClass, payload, id, requestType);
|
|
3381
3498
|
var validationErrors = [];
|
|
@@ -3400,6 +3517,7 @@
|
|
|
3400
3517
|
@param {Object} payload
|
|
3401
3518
|
@return {Object} JSON-API Document
|
|
3402
3519
|
*/
|
|
3520
|
+
|
|
3403
3521
|
function ember$data$lib$system$store$serializer$response$$_normalizeSerializerPayload(modelClass, payload) {
|
|
3404
3522
|
var data = null;
|
|
3405
3523
|
|
|
@@ -3426,6 +3544,7 @@
|
|
|
3426
3544
|
@param {Object} payload
|
|
3427
3545
|
@return {Object} JSON-API Resource Object
|
|
3428
3546
|
*/
|
|
3547
|
+
|
|
3429
3548
|
function ember$data$lib$system$store$serializer$response$$_normalizeSerializerPayloadItem(modelClass, itemPayload) {
|
|
3430
3549
|
var item = {};
|
|
3431
3550
|
|
|
@@ -3511,6 +3630,7 @@
|
|
|
3511
3630
|
@param {Object} payload
|
|
3512
3631
|
@return {Object} an object formatted the way DS.Store understands
|
|
3513
3632
|
*/
|
|
3633
|
+
|
|
3514
3634
|
function ember$data$lib$system$store$serializer$response$$convertResourceObject(payload) {
|
|
3515
3635
|
if (!payload) {
|
|
3516
3636
|
return payload;
|
|
@@ -3561,6 +3681,7 @@
|
|
|
3561
3681
|
}
|
|
3562
3682
|
|
|
3563
3683
|
var ember$data$lib$system$store$finders$$Promise = Ember.RSVP.Promise;
|
|
3684
|
+
|
|
3564
3685
|
function ember$data$lib$system$store$finders$$_find(adapter, store, typeClass, id, internalModel, options) {
|
|
3565
3686
|
var snapshot = internalModel.createSnapshot(options);
|
|
3566
3687
|
var promise = adapter.findRecord(store, typeClass, id, snapshot);
|
|
@@ -3573,7 +3694,7 @@
|
|
|
3573
3694
|
return promise.then(function (adapterPayload) {
|
|
3574
3695
|
Ember.assert("You made a request for a " + typeClass.typeClassKey + " with id " + id + ", but the adapter's response did not have any data", adapterPayload);
|
|
3575
3696
|
return store._adapterRun(function () {
|
|
3576
|
-
var payload = ember$data$lib$system$store$serializer$response$$normalizeResponseHelper(serializer, store, typeClass, adapterPayload, id,
|
|
3697
|
+
var payload = ember$data$lib$system$store$serializer$response$$normalizeResponseHelper(serializer, store, typeClass, adapterPayload, id, 'findRecord');
|
|
3577
3698
|
//TODO Optimize
|
|
3578
3699
|
var record = store.push(payload);
|
|
3579
3700
|
return record._internalModel;
|
|
@@ -3589,13 +3710,13 @@
|
|
|
3589
3710
|
}
|
|
3590
3711
|
|
|
3591
3712
|
function ember$data$lib$system$store$finders$$_findMany(adapter, store, typeClass, ids, internalModels) {
|
|
3592
|
-
var snapshots = Ember.A(internalModels).invoke(
|
|
3713
|
+
var snapshots = Ember.A(internalModels).invoke('createSnapshot');
|
|
3593
3714
|
var promise = adapter.findMany(store, typeClass, ids, snapshots);
|
|
3594
3715
|
var serializer = ember$data$lib$system$store$serializers$$serializerForAdapter(store, adapter, typeClass.modelName);
|
|
3595
3716
|
var label = "DS: Handle Adapter#findMany of " + typeClass;
|
|
3596
3717
|
|
|
3597
3718
|
if (promise === undefined) {
|
|
3598
|
-
throw new Error(
|
|
3719
|
+
throw new Error('adapter.findMany returned undefined, this was very likely a mistake');
|
|
3599
3720
|
}
|
|
3600
3721
|
|
|
3601
3722
|
promise = ember$data$lib$system$store$finders$$Promise.resolve(promise, label);
|
|
@@ -3603,7 +3724,7 @@
|
|
|
3603
3724
|
|
|
3604
3725
|
return promise.then(function (adapterPayload) {
|
|
3605
3726
|
return store._adapterRun(function () {
|
|
3606
|
-
var payload = ember$data$lib$system$store$serializer$response$$normalizeResponseHelper(serializer, store, typeClass, adapterPayload, null,
|
|
3727
|
+
var payload = ember$data$lib$system$store$serializer$response$$normalizeResponseHelper(serializer, store, typeClass, adapterPayload, null, 'findMany');
|
|
3607
3728
|
//TODO Optimize, no need to materialize here
|
|
3608
3729
|
var records = store.push(payload);
|
|
3609
3730
|
return records.map(function (record) {
|
|
@@ -3626,7 +3747,7 @@
|
|
|
3626
3747
|
|
|
3627
3748
|
return promise.then(function (adapterPayload) {
|
|
3628
3749
|
return store._adapterRun(function () {
|
|
3629
|
-
var payload = ember$data$lib$system$store$serializer$response$$normalizeResponseHelper(serializer, store, typeClass, adapterPayload, null,
|
|
3750
|
+
var payload = ember$data$lib$system$store$serializer$response$$normalizeResponseHelper(serializer, store, typeClass, adapterPayload, null, 'findHasMany');
|
|
3630
3751
|
//TODO Use a non record creating push
|
|
3631
3752
|
var records = store.push(payload);
|
|
3632
3753
|
var recordArray = records.map(function (record) {
|
|
@@ -3651,7 +3772,7 @@
|
|
|
3651
3772
|
|
|
3652
3773
|
return promise.then(function (adapterPayload) {
|
|
3653
3774
|
return store._adapterRun(function () {
|
|
3654
|
-
var payload = ember$data$lib$system$store$serializer$response$$normalizeResponseHelper(serializer, store, typeClass, adapterPayload, null,
|
|
3775
|
+
var payload = ember$data$lib$system$store$serializer$response$$normalizeResponseHelper(serializer, store, typeClass, adapterPayload, null, 'findBelongsTo');
|
|
3655
3776
|
|
|
3656
3777
|
if (!payload.data) {
|
|
3657
3778
|
return null;
|
|
@@ -3677,7 +3798,7 @@
|
|
|
3677
3798
|
|
|
3678
3799
|
return promise.then(function (adapterPayload) {
|
|
3679
3800
|
store._adapterRun(function () {
|
|
3680
|
-
var payload = ember$data$lib$system$store$serializer$response$$normalizeResponseHelper(serializer, store, typeClass, adapterPayload, null,
|
|
3801
|
+
var payload = ember$data$lib$system$store$serializer$response$$normalizeResponseHelper(serializer, store, typeClass, adapterPayload, null, 'findAll');
|
|
3681
3802
|
//TODO Optimize
|
|
3682
3803
|
store.push(payload);
|
|
3683
3804
|
});
|
|
@@ -3700,7 +3821,7 @@
|
|
|
3700
3821
|
return promise.then(function (adapterPayload) {
|
|
3701
3822
|
var records;
|
|
3702
3823
|
store._adapterRun(function () {
|
|
3703
|
-
var payload = ember$data$lib$system$store$serializer$response$$normalizeResponseHelper(serializer, store, typeClass, adapterPayload, null,
|
|
3824
|
+
var payload = ember$data$lib$system$store$serializer$response$$normalizeResponseHelper(serializer, store, typeClass, adapterPayload, null, 'query');
|
|
3704
3825
|
//TODO Optimize
|
|
3705
3826
|
records = store.push(payload);
|
|
3706
3827
|
});
|
|
@@ -3722,7 +3843,7 @@
|
|
|
3722
3843
|
return promise.then(function (adapterPayload) {
|
|
3723
3844
|
var record;
|
|
3724
3845
|
store._adapterRun(function () {
|
|
3725
|
-
var payload = ember$data$lib$system$store$serializer$response$$normalizeResponseHelper(serializer, store, typeClass, adapterPayload, null,
|
|
3846
|
+
var payload = ember$data$lib$system$store$serializer$response$$normalizeResponseHelper(serializer, store, typeClass, adapterPayload, null, 'queryRecord');
|
|
3726
3847
|
//TODO Optimize
|
|
3727
3848
|
record = store.push(payload);
|
|
3728
3849
|
});
|
|
@@ -3809,24 +3930,7 @@
|
|
|
3809
3930
|
this._snapshots = recordArray.invoke('createSnapshot');
|
|
3810
3931
|
|
|
3811
3932
|
return this._snapshots;
|
|
3812
|
-
};
|
|
3813
|
-
init: function () {
|
|
3814
|
-
this._super.apply(this, arguments);
|
|
3815
|
-
|
|
3816
|
-
var _getProperties = this.getProperties('filterByArgs', 'recordArray');
|
|
3817
|
-
|
|
3818
|
-
var filterByArgs = _getProperties.filterByArgs;
|
|
3819
|
-
var recordArray = _getProperties.recordArray;
|
|
3820
|
-
var key = filterByArgs[0];
|
|
3821
|
-
|
|
3822
|
-
var path = 'recordArray.@each.' + key;
|
|
3823
|
-
Ember.defineProperty(this, 'content', Ember.computed(path, function () {
|
|
3824
|
-
return this.filterBy.apply(recordArray, filterByArgs);
|
|
3825
|
-
}));
|
|
3826
|
-
}
|
|
3827
|
-
});
|
|
3828
|
-
|
|
3829
|
-
var ember$data$lib$system$record$arrays$filtered$subset$$default = ember$data$lib$system$record$arrays$filtered$subset$$FilteredSubset;
|
|
3933
|
+
};
|
|
3830
3934
|
|
|
3831
3935
|
var ember$data$lib$system$record$arrays$record$array$$get = Ember.get;
|
|
3832
3936
|
var ember$data$lib$system$record$arrays$record$array$$set = Ember.set;
|
|
@@ -3891,42 +3995,11 @@
|
|
|
3891
3995
|
@return {DS.Model} record
|
|
3892
3996
|
*/
|
|
3893
3997
|
objectAtContent: function (index) {
|
|
3894
|
-
var content = ember$data$lib$system$record$arrays$record$array$$get(this,
|
|
3998
|
+
var content = ember$data$lib$system$record$arrays$record$array$$get(this, 'content');
|
|
3895
3999
|
var internalModel = content.objectAt(index);
|
|
3896
4000
|
return internalModel && internalModel.getRecord();
|
|
3897
4001
|
},
|
|
3898
4002
|
|
|
3899
|
-
/**
|
|
3900
|
-
Get a filtered subset of the underlying `RecordArray`.
|
|
3901
|
-
The subset updates when a record would match or mismatch the
|
|
3902
|
-
specified filter parameters.
|
|
3903
|
-
Example
|
|
3904
|
-
```javascript
|
|
3905
|
-
var allToms = store.all('person').filterBy('name', 'Tom');
|
|
3906
|
-
allToms.get('length'); // 0, since no toms yet in store
|
|
3907
|
-
var tom = store.push('person', { id: 1, name: 'Tom' });
|
|
3908
|
-
allToms.get('length'); // Tom is added
|
|
3909
|
-
tom.set('name', 'Thomas');
|
|
3910
|
-
allToms.get('length'); // 0, since no more records with name === 'Tom'
|
|
3911
|
-
```
|
|
3912
|
-
@method filterBy
|
|
3913
|
-
@param {String} key property path
|
|
3914
|
-
@param {*} value optional
|
|
3915
|
-
*/
|
|
3916
|
-
filterBy: function (key, value) {
|
|
3917
|
-
// only pass value to the arguments if it is present; this mimics the same
|
|
3918
|
-
// behavior for `filterBy`: http://git.io/vIurH
|
|
3919
|
-
var filterByArgs = [key];
|
|
3920
|
-
if (arguments.length === 2) {
|
|
3921
|
-
filterByArgs.push(value);
|
|
3922
|
-
}
|
|
3923
|
-
|
|
3924
|
-
return ember$data$lib$system$record$arrays$filtered$subset$$default.create({
|
|
3925
|
-
filterByArgs: filterByArgs,
|
|
3926
|
-
recordArray: this
|
|
3927
|
-
});
|
|
3928
|
-
},
|
|
3929
|
-
|
|
3930
4003
|
/**
|
|
3931
4004
|
Used to get the latest version of all of the records in this array
|
|
3932
4005
|
from the adapter.
|
|
@@ -3940,12 +4013,12 @@
|
|
|
3940
4013
|
@method update
|
|
3941
4014
|
*/
|
|
3942
4015
|
update: function () {
|
|
3943
|
-
if (ember$data$lib$system$record$arrays$record$array$$get(this,
|
|
4016
|
+
if (ember$data$lib$system$record$arrays$record$array$$get(this, 'isUpdating')) {
|
|
3944
4017
|
return;
|
|
3945
4018
|
}
|
|
3946
4019
|
|
|
3947
|
-
var store = ember$data$lib$system$record$arrays$record$array$$get(this,
|
|
3948
|
-
var modelName = ember$data$lib$system$record$arrays$record$array$$get(this,
|
|
4020
|
+
var store = ember$data$lib$system$record$arrays$record$array$$get(this, 'store');
|
|
4021
|
+
var modelName = ember$data$lib$system$record$arrays$record$array$$get(this, 'type.modelName');
|
|
3949
4022
|
|
|
3950
4023
|
return store.findAll(modelName, { reload: true });
|
|
3951
4024
|
},
|
|
@@ -3958,7 +4031,7 @@
|
|
|
3958
4031
|
@param {number} an optional index to insert at
|
|
3959
4032
|
*/
|
|
3960
4033
|
addInternalModel: function (internalModel, idx) {
|
|
3961
|
-
var content = ember$data$lib$system$record$arrays$record$array$$get(this,
|
|
4034
|
+
var content = ember$data$lib$system$record$arrays$record$array$$get(this, 'content');
|
|
3962
4035
|
if (idx === undefined) {
|
|
3963
4036
|
content.addObject(internalModel);
|
|
3964
4037
|
} else if (!content.contains(internalModel)) {
|
|
@@ -3973,7 +4046,7 @@
|
|
|
3973
4046
|
@param {InternalModel} internalModel
|
|
3974
4047
|
*/
|
|
3975
4048
|
removeInternalModel: function (internalModel) {
|
|
3976
|
-
ember$data$lib$system$record$arrays$record$array$$get(this,
|
|
4049
|
+
ember$data$lib$system$record$arrays$record$array$$get(this, 'content').removeObject(internalModel);
|
|
3977
4050
|
},
|
|
3978
4051
|
|
|
3979
4052
|
/**
|
|
@@ -3991,7 +4064,7 @@
|
|
|
3991
4064
|
*/
|
|
3992
4065
|
save: function () {
|
|
3993
4066
|
var recordArray = this;
|
|
3994
|
-
var promiseLabel = "DS: RecordArray#save " + ember$data$lib$system$record$arrays$record$array$$get(this,
|
|
4067
|
+
var promiseLabel = "DS: RecordArray#save " + ember$data$lib$system$record$arrays$record$array$$get(this, 'type');
|
|
3995
4068
|
var promise = Ember.RSVP.all(this.invoke("save"), promiseLabel).then(function (array) {
|
|
3996
4069
|
return recordArray;
|
|
3997
4070
|
}, null, "DS: RecordArray#save return RecordArray");
|
|
@@ -4002,7 +4075,7 @@
|
|
|
4002
4075
|
_dissociateFromOwnRecords: function () {
|
|
4003
4076
|
var _this = this;
|
|
4004
4077
|
|
|
4005
|
-
this.get(
|
|
4078
|
+
this.get('content').forEach(function (record) {
|
|
4006
4079
|
var recordArrays = record._recordArrays;
|
|
4007
4080
|
|
|
4008
4081
|
if (recordArrays) {
|
|
@@ -4016,20 +4089,20 @@
|
|
|
4016
4089
|
@private
|
|
4017
4090
|
*/
|
|
4018
4091
|
_unregisterFromManager: function () {
|
|
4019
|
-
var manager = ember$data$lib$system$record$arrays$record$array$$get(this,
|
|
4092
|
+
var manager = ember$data$lib$system$record$arrays$record$array$$get(this, 'manager');
|
|
4020
4093
|
manager.unregisterRecordArray(this);
|
|
4021
4094
|
},
|
|
4022
4095
|
|
|
4023
4096
|
willDestroy: function () {
|
|
4024
4097
|
this._unregisterFromManager();
|
|
4025
4098
|
this._dissociateFromOwnRecords();
|
|
4026
|
-
ember$data$lib$system$record$arrays$record$array$$set(this,
|
|
4099
|
+
ember$data$lib$system$record$arrays$record$array$$set(this, 'content', undefined);
|
|
4027
4100
|
this._super.apply(this, arguments);
|
|
4028
4101
|
},
|
|
4029
4102
|
|
|
4030
4103
|
createSnapshot: function (options) {
|
|
4031
4104
|
var adapterOptions = options && options.adapterOptions;
|
|
4032
|
-
var meta = this.get(
|
|
4105
|
+
var meta = this.get('meta');
|
|
4033
4106
|
return new ember$data$lib$system$snapshot$record$array$$default(this, meta, adapterOptions);
|
|
4034
4107
|
}
|
|
4035
4108
|
});
|
|
@@ -4066,7 +4139,7 @@
|
|
|
4066
4139
|
isLoaded: true,
|
|
4067
4140
|
|
|
4068
4141
|
replace: function () {
|
|
4069
|
-
var type = ember$data$lib$system$record$arrays$filtered$record$array$$get(this,
|
|
4142
|
+
var type = ember$data$lib$system$record$arrays$filtered$record$array$$get(this, 'type').toString();
|
|
4070
4143
|
throw new Error("The result of a client-side filter (on " + type + ") is immutable.");
|
|
4071
4144
|
},
|
|
4072
4145
|
|
|
@@ -4075,11 +4148,11 @@
|
|
|
4075
4148
|
@private
|
|
4076
4149
|
*/
|
|
4077
4150
|
_updateFilter: function () {
|
|
4078
|
-
var manager = ember$data$lib$system$record$arrays$filtered$record$array$$get(this,
|
|
4079
|
-
manager.updateFilter(this, ember$data$lib$system$record$arrays$filtered$record$array$$get(this,
|
|
4151
|
+
var manager = ember$data$lib$system$record$arrays$filtered$record$array$$get(this, 'manager');
|
|
4152
|
+
manager.updateFilter(this, ember$data$lib$system$record$arrays$filtered$record$array$$get(this, 'type'), ember$data$lib$system$record$arrays$filtered$record$array$$get(this, 'filterFunction'));
|
|
4080
4153
|
},
|
|
4081
4154
|
|
|
4082
|
-
updateFilter: Ember.observer(
|
|
4155
|
+
updateFilter: Ember.observer('filterFunction', function () {
|
|
4083
4156
|
Ember.run.once(this, this._updateFilter);
|
|
4084
4157
|
})
|
|
4085
4158
|
});
|
|
@@ -4104,7 +4177,7 @@
|
|
|
4104
4177
|
query: null,
|
|
4105
4178
|
|
|
4106
4179
|
replace: function () {
|
|
4107
|
-
var type = ember$data$lib$system$record$arrays$adapter$populated$record$array$$get(this,
|
|
4180
|
+
var type = ember$data$lib$system$record$arrays$adapter$populated$record$array$$get(this, 'type').toString();
|
|
4108
4181
|
throw new Error("The result of a server query (on " + type + ") is immutable.");
|
|
4109
4182
|
},
|
|
4110
4183
|
|
|
@@ -4114,8 +4187,8 @@
|
|
|
4114
4187
|
@param {Array} data
|
|
4115
4188
|
*/
|
|
4116
4189
|
load: function (data) {
|
|
4117
|
-
var store = ember$data$lib$system$record$arrays$adapter$populated$record$array$$get(this,
|
|
4118
|
-
var type = ember$data$lib$system$record$arrays$adapter$populated$record$array$$get(this,
|
|
4190
|
+
var store = ember$data$lib$system$record$arrays$adapter$populated$record$array$$get(this, 'store');
|
|
4191
|
+
var type = ember$data$lib$system$record$arrays$adapter$populated$record$array$$get(this, 'type');
|
|
4119
4192
|
var modelName = type.modelName;
|
|
4120
4193
|
var records = store.pushMany(modelName, data);
|
|
4121
4194
|
|
|
@@ -4130,13 +4203,13 @@
|
|
|
4130
4203
|
loadRecords: function (records) {
|
|
4131
4204
|
var _this = this;
|
|
4132
4205
|
|
|
4133
|
-
var store = ember$data$lib$system$record$arrays$adapter$populated$record$array$$get(this,
|
|
4134
|
-
var type = ember$data$lib$system$record$arrays$adapter$populated$record$array$$get(this,
|
|
4206
|
+
var store = ember$data$lib$system$record$arrays$adapter$populated$record$array$$get(this, 'store');
|
|
4207
|
+
var type = ember$data$lib$system$record$arrays$adapter$populated$record$array$$get(this, 'type');
|
|
4135
4208
|
var modelName = type.modelName;
|
|
4136
4209
|
var meta = store._metadataFor(modelName);
|
|
4137
4210
|
|
|
4138
4211
|
//TODO Optimize
|
|
4139
|
-
var internalModels = Ember.A(records).mapBy(
|
|
4212
|
+
var internalModels = Ember.A(records).mapBy('_internalModel');
|
|
4140
4213
|
this.setProperties({
|
|
4141
4214
|
content: Ember.A(internalModels),
|
|
4142
4215
|
isLoaded: true,
|
|
@@ -4148,7 +4221,7 @@
|
|
|
4148
4221
|
});
|
|
4149
4222
|
|
|
4150
4223
|
// TODO: should triggering didLoad event be the last action of the runLoop?
|
|
4151
|
-
Ember.run.once(this,
|
|
4224
|
+
Ember.run.once(this, 'trigger', 'didLoad');
|
|
4152
4225
|
}
|
|
4153
4226
|
});
|
|
4154
4227
|
|
|
@@ -4217,7 +4290,7 @@
|
|
|
4217
4290
|
return;
|
|
4218
4291
|
}
|
|
4219
4292
|
|
|
4220
|
-
Ember.run.schedule(
|
|
4293
|
+
Ember.run.schedule('actions', this, this.updateRecordArrays);
|
|
4221
4294
|
},
|
|
4222
4295
|
|
|
4223
4296
|
recordArraysForRecord: function (record) {
|
|
@@ -4236,7 +4309,7 @@
|
|
|
4236
4309
|
var _this2 = this;
|
|
4237
4310
|
|
|
4238
4311
|
this.changedRecords.forEach(function (internalModel) {
|
|
4239
|
-
if (ember$data$lib$system$record$array$manager$$get(internalModel,
|
|
4312
|
+
if (ember$data$lib$system$record$array$manager$$get(internalModel, 'record.isDestroyed') || ember$data$lib$system$record$array$manager$$get(internalModel, 'record.isDestroying') || ember$data$lib$system$record$array$manager$$get(internalModel, 'currentState.stateName') === 'root.deleted.saved') {
|
|
4240
4313
|
_this2._recordWasDeleted(internalModel);
|
|
4241
4314
|
} else {
|
|
4242
4315
|
_this2._recordWasChanged(internalModel);
|
|
@@ -4267,7 +4340,7 @@
|
|
|
4267
4340
|
var recordArrays = this.filteredRecordArrays.get(typeClass);
|
|
4268
4341
|
var filter;
|
|
4269
4342
|
recordArrays.forEach(function (array) {
|
|
4270
|
-
filter = ember$data$lib$system$record$array$manager$$get(array,
|
|
4343
|
+
filter = ember$data$lib$system$record$array$manager$$get(array, 'filterFunction');
|
|
4271
4344
|
_this3.updateFilterRecordArray(array, filter, typeClass, record);
|
|
4272
4345
|
});
|
|
4273
4346
|
},
|
|
@@ -4281,7 +4354,7 @@
|
|
|
4281
4354
|
var filter;
|
|
4282
4355
|
|
|
4283
4356
|
recordArrays.forEach(function (array) {
|
|
4284
|
-
filter = ember$data$lib$system$record$array$manager$$get(array,
|
|
4357
|
+
filter = ember$data$lib$system$record$array$manager$$get(array, 'filterFunction');
|
|
4285
4358
|
_this4.updateFilterRecordArray(array, filter, typeClass, record);
|
|
4286
4359
|
});
|
|
4287
4360
|
|
|
@@ -4462,11 +4535,11 @@
|
|
|
4462
4535
|
|
|
4463
4536
|
// unregister live record array
|
|
4464
4537
|
} else if (this.liveRecordArrays.has(typeClass)) {
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4538
|
+
var liveRecordArrayForType = this.liveRecordArrayFor(typeClass);
|
|
4539
|
+
if (array === liveRecordArrayForType) {
|
|
4540
|
+
this.liveRecordArrays["delete"](typeClass);
|
|
4541
|
+
}
|
|
4468
4542
|
}
|
|
4469
|
-
}
|
|
4470
4543
|
},
|
|
4471
4544
|
|
|
4472
4545
|
willDestroy: function () {
|
|
@@ -5024,7 +5097,7 @@
|
|
|
5024
5097
|
ember$data$lib$system$model$states$$createdState.uncommitted.propertyWasReset = Ember.K;
|
|
5025
5098
|
|
|
5026
5099
|
function ember$data$lib$system$model$states$$assertAgainstUnloadRecord(internalModel) {
|
|
5027
|
-
Ember.assert(
|
|
5100
|
+
Ember.assert("You can only unload a record which is not inFlight. `" + internalModel + "`", false);
|
|
5028
5101
|
}
|
|
5029
5102
|
|
|
5030
5103
|
ember$data$lib$system$model$states$$updatedState.inFlight.unloadRecord = ember$data$lib$system$model$states$$assertAgainstUnloadRecord;
|
|
@@ -5342,14 +5415,14 @@
|
|
|
5342
5415
|
continue;
|
|
5343
5416
|
}
|
|
5344
5417
|
if (typeof object[prop] === 'object') {
|
|
5345
|
-
object[prop] = ember$data$lib$system$model$states$$wireState(object[prop], object, name +
|
|
5418
|
+
object[prop] = ember$data$lib$system$model$states$$wireState(object[prop], object, name + "." + prop);
|
|
5346
5419
|
}
|
|
5347
5420
|
}
|
|
5348
5421
|
|
|
5349
5422
|
return object;
|
|
5350
5423
|
}
|
|
5351
5424
|
|
|
5352
|
-
ember$data$lib$system$model$states$$RootState = ember$data$lib$system$model$states$$wireState(ember$data$lib$system$model$states$$RootState, null,
|
|
5425
|
+
ember$data$lib$system$model$states$$RootState = ember$data$lib$system$model$states$$wireState(ember$data$lib$system$model$states$$RootState, null, "root");
|
|
5353
5426
|
|
|
5354
5427
|
var ember$data$lib$system$model$states$$default = ember$data$lib$system$model$states$$RootState;
|
|
5355
5428
|
var ember$data$lib$system$relationships$state$relationship$$default = ember$data$lib$system$relationships$state$relationship$$Relationship;
|
|
@@ -5549,7 +5622,7 @@
|
|
|
5549
5622
|
Ember.warn('You have pushed a record of type \'' + this.record.type.modelName + '\' with \'' + this.key + '\' as a link, but the association is not an async relationship.', this.isAsync, {
|
|
5550
5623
|
id: 'ds.store.push-link-for-sync-relationship'
|
|
5551
5624
|
});
|
|
5552
|
-
Ember.assert(
|
|
5625
|
+
Ember.assert("You have pushed a record of type '" + this.record.type.modelName + "' with '" + this.key + "' as a link, but the value of that link is not a string.", typeof link === 'string' || link === null);
|
|
5553
5626
|
if (link !== this.link) {
|
|
5554
5627
|
this.link = link;
|
|
5555
5628
|
this.linkPromise = null;
|
|
@@ -5622,7 +5695,7 @@
|
|
|
5622
5695
|
toSet = toSet.concat(newRecords);
|
|
5623
5696
|
var oldLength = this.length;
|
|
5624
5697
|
this.arrayContentWillChange(0, this.length, toSet.length);
|
|
5625
|
-
this.set(
|
|
5698
|
+
this.set('length', toSet.length);
|
|
5626
5699
|
this.currentState = toSet;
|
|
5627
5700
|
this.arrayContentDidChange(0, oldLength, this.length);
|
|
5628
5701
|
//TODO Figure out to notify only on additions and maybe only if unloaded
|
|
@@ -5687,7 +5760,7 @@
|
|
|
5687
5760
|
}
|
|
5688
5761
|
this.arrayContentWillChange(idx, amt, objects.length);
|
|
5689
5762
|
this.currentState.splice.apply(this.currentState, [idx, amt].concat(objects));
|
|
5690
|
-
this.set(
|
|
5763
|
+
this.set('length', this.currentState.length);
|
|
5691
5764
|
this.arrayContentDidChange(idx, amt, objects.length);
|
|
5692
5765
|
if (objects) {
|
|
5693
5766
|
//TODO(Igor) probably needed only for unloaded records
|
|
@@ -5717,10 +5790,10 @@
|
|
|
5717
5790
|
var records;
|
|
5718
5791
|
if (amt > 0) {
|
|
5719
5792
|
records = this.currentState.slice(idx, idx + amt);
|
|
5720
|
-
this.get(
|
|
5793
|
+
this.get('relationship').removeRecords(records);
|
|
5721
5794
|
}
|
|
5722
5795
|
if (objects) {
|
|
5723
|
-
this.get(
|
|
5796
|
+
this.get('relationship').addRecords(objects.map(function (obj) {
|
|
5724
5797
|
return obj._internalModel;
|
|
5725
5798
|
}), idx);
|
|
5726
5799
|
}
|
|
@@ -5749,8 +5822,8 @@
|
|
|
5749
5822
|
loadedRecord: function () {
|
|
5750
5823
|
this.loadingRecordsCount--;
|
|
5751
5824
|
if (this.loadingRecordsCount === 0) {
|
|
5752
|
-
ember$data$lib$system$many$array$$set(this,
|
|
5753
|
-
this.trigger(
|
|
5825
|
+
ember$data$lib$system$many$array$$set(this, 'isLoaded', true);
|
|
5826
|
+
this.trigger('didLoad');
|
|
5754
5827
|
}
|
|
5755
5828
|
},
|
|
5756
5829
|
|
|
@@ -5780,7 +5853,7 @@
|
|
|
5780
5853
|
*/
|
|
5781
5854
|
save: function () {
|
|
5782
5855
|
var manyArray = this;
|
|
5783
|
-
var promiseLabel = "DS: ManyArray#save " + ember$data$lib$system$many$array$$get(this,
|
|
5856
|
+
var promiseLabel = "DS: ManyArray#save " + ember$data$lib$system$many$array$$get(this, 'type');
|
|
5784
5857
|
var promise = Ember.RSVP.all(this.invoke("save"), promiseLabel).then(function (array) {
|
|
5785
5858
|
return manyArray;
|
|
5786
5859
|
}, null, "DS: ManyArray#save return ManyArray");
|
|
@@ -5796,43 +5869,15 @@
|
|
|
5796
5869
|
@return {DS.Model} record
|
|
5797
5870
|
*/
|
|
5798
5871
|
createRecord: function (hash) {
|
|
5799
|
-
var store = ember$data$lib$system$many$array$$get(this,
|
|
5800
|
-
var type = ember$data$lib$system$many$array$$get(this,
|
|
5872
|
+
var store = ember$data$lib$system$many$array$$get(this, 'store');
|
|
5873
|
+
var type = ember$data$lib$system$many$array$$get(this, 'type');
|
|
5801
5874
|
var record;
|
|
5802
5875
|
|
|
5803
|
-
Ember.assert("You cannot add '" + type.modelName + "' records to this polymorphic relationship.", !ember$data$lib$system$many$array$$get(this,
|
|
5876
|
+
Ember.assert("You cannot add '" + type.modelName + "' records to this polymorphic relationship.", !ember$data$lib$system$many$array$$get(this, 'isPolymorphic'));
|
|
5804
5877
|
record = store.createRecord(type.modelName, hash);
|
|
5805
5878
|
this.pushObject(record);
|
|
5806
5879
|
|
|
5807
5880
|
return record;
|
|
5808
|
-
},
|
|
5809
|
-
|
|
5810
|
-
/**
|
|
5811
|
-
Get a filtered subset of the underlying `ManyArray`.
|
|
5812
|
-
The subset updates when a record would match or mismatch the
|
|
5813
|
-
specified filter parameters.
|
|
5814
|
-
Example
|
|
5815
|
-
```javascript
|
|
5816
|
-
var post = store.peekRecord('post', 1)
|
|
5817
|
-
// All the comments that are deleted locally but not yet saved to the server.
|
|
5818
|
-
var deletedComments = post.get('comments').filterBy('isDeleted');
|
|
5819
|
-
```
|
|
5820
|
-
@method filterBy
|
|
5821
|
-
@param {String} key property path
|
|
5822
|
-
@param {*} value optional
|
|
5823
|
-
*/
|
|
5824
|
-
filterBy: function (key, value) {
|
|
5825
|
-
// only pass value to the arguments if it is present; this mimics the same
|
|
5826
|
-
// behavior for `filterBy`: http://git.io/vIurH
|
|
5827
|
-
var filterByArgs = [key];
|
|
5828
|
-
if (arguments.length === 2) {
|
|
5829
|
-
filterByArgs.push(value);
|
|
5830
|
-
}
|
|
5831
|
-
|
|
5832
|
-
return ember$data$lib$system$record$arrays$filtered$subset$$default.create({
|
|
5833
|
-
filterByArgs: filterByArgs,
|
|
5834
|
-
recordArray: this
|
|
5835
|
-
});
|
|
5836
5881
|
}
|
|
5837
5882
|
});
|
|
5838
5883
|
|
|
@@ -5905,7 +5950,7 @@
|
|
|
5905
5950
|
ember$data$lib$system$relationships$state$has$many$$ManyRelationship.prototype._super$updateMeta = ember$data$lib$system$relationships$state$relationship$$default.prototype.updateMeta;
|
|
5906
5951
|
ember$data$lib$system$relationships$state$has$many$$ManyRelationship.prototype.updateMeta = function (meta) {
|
|
5907
5952
|
this._super$updateMeta(meta);
|
|
5908
|
-
this.manyArray.set(
|
|
5953
|
+
this.manyArray.set('meta', meta);
|
|
5909
5954
|
};
|
|
5910
5955
|
|
|
5911
5956
|
ember$data$lib$system$relationships$state$has$many$$ManyRelationship.prototype._super$addCanonicalRecord = ember$data$lib$system$relationships$state$relationship$$default.prototype.addCanonicalRecord;
|
|
@@ -5978,7 +6023,7 @@
|
|
|
5978
6023
|
} else {
|
|
5979
6024
|
return this.store.scheduleFetchMany(this.manyArray.toArray()).then(function () {
|
|
5980
6025
|
//Goes away after the manyArray refactor
|
|
5981
|
-
self.manyArray.set(
|
|
6026
|
+
self.manyArray.set('isLoaded', true);
|
|
5982
6027
|
return self.manyArray;
|
|
5983
6028
|
});
|
|
5984
6029
|
}
|
|
@@ -6020,7 +6065,7 @@
|
|
|
6020
6065
|
var _this = this;
|
|
6021
6066
|
|
|
6022
6067
|
return this.store.findHasMany(this.record, this.link, this.relationshipMeta).then(function (records) {
|
|
6023
|
-
if (records.hasOwnProperty(
|
|
6068
|
+
if (records.hasOwnProperty('meta')) {
|
|
6024
6069
|
_this.updateMeta(records.meta);
|
|
6025
6070
|
}
|
|
6026
6071
|
_this.store._backburner.join(function () {
|
|
@@ -6037,9 +6082,9 @@
|
|
|
6037
6082
|
return this.store.findMany(this.manyArray.toArray().map(function (rec) {
|
|
6038
6083
|
return rec._internalModel;
|
|
6039
6084
|
})).then(function () {
|
|
6040
|
-
if (!_this2.manyArray.get(
|
|
6085
|
+
if (!_this2.manyArray.get('isDestroyed')) {
|
|
6041
6086
|
//Goes away after the manyArray refactor
|
|
6042
|
-
_this2.manyArray.set(
|
|
6087
|
+
_this2.manyArray.set('isLoaded', true);
|
|
6043
6088
|
}
|
|
6044
6089
|
return _this2.manyArray;
|
|
6045
6090
|
});
|
|
@@ -6066,11 +6111,11 @@
|
|
|
6066
6111
|
promise: promise
|
|
6067
6112
|
});
|
|
6068
6113
|
} else {
|
|
6069
|
-
Ember.assert("You looked up the '" + this.key + "' relationship on a '" + this.record.type.modelName + "' with id " + this.record.id + " but some of the associated records were not loaded. Either make sure they are all loaded together with the parent record, or specify that the relationship is async (`DS.hasMany({ async: true })`)", this.manyArray.isEvery(
|
|
6114
|
+
Ember.assert("You looked up the '" + this.key + "' relationship on a '" + this.record.type.modelName + "' with id " + this.record.id + " but some of the associated records were not loaded. Either make sure they are all loaded together with the parent record, or specify that the relationship is async (`DS.hasMany({ async: true })`)", this.manyArray.isEvery('isEmpty', false));
|
|
6070
6115
|
|
|
6071
6116
|
//TODO(Igor) WTF DO I DO HERE?
|
|
6072
|
-
if (!this.manyArray.get(
|
|
6073
|
-
this.manyArray.set(
|
|
6117
|
+
if (!this.manyArray.get('isDestroyed')) {
|
|
6118
|
+
this.manyArray.set('isLoaded', true);
|
|
6074
6119
|
}
|
|
6075
6120
|
return this.manyArray;
|
|
6076
6121
|
}
|
|
@@ -6162,7 +6207,7 @@
|
|
|
6162
6207
|
};
|
|
6163
6208
|
|
|
6164
6209
|
ember$data$lib$system$relationships$state$belongs$to$$BelongsToRelationship.prototype.setRecordPromise = function (newPromise) {
|
|
6165
|
-
var content = newPromise.get && newPromise.get(
|
|
6210
|
+
var content = newPromise.get && newPromise.get('content');
|
|
6166
6211
|
Ember.assert("You passed in a promise that did not originate from an EmberData relationship. You can only pass promises that come from a belongsTo or hasMany relationship to the get call.", content !== undefined);
|
|
6167
6212
|
this.setRecord(content ? content._internalModel : content);
|
|
6168
6213
|
};
|
|
@@ -6228,7 +6273,7 @@
|
|
|
6228
6273
|
return null;
|
|
6229
6274
|
}
|
|
6230
6275
|
var toReturn = this.inverseRecord.getRecord();
|
|
6231
|
-
Ember.assert("You looked up the '" + this.key + "' relationship on a '" + this.record.type.modelName + "' with id " + this.record.id + " but some of the associated records were not loaded. Either make sure they are all loaded together with the parent record, or specify that the relationship is async (`DS.belongsTo({ async: true })`)", toReturn === null || !toReturn.get(
|
|
6276
|
+
Ember.assert("You looked up the '" + this.key + "' relationship on a '" + this.record.type.modelName + "' with id " + this.record.id + " but some of the associated records were not loaded. Either make sure they are all loaded together with the parent record, or specify that the relationship is async (`DS.belongsTo({ async: true })`)", toReturn === null || !toReturn.get('isEmpty'));
|
|
6232
6277
|
return toReturn;
|
|
6233
6278
|
}
|
|
6234
6279
|
};
|
|
@@ -6244,7 +6289,7 @@
|
|
|
6244
6289
|
inverseKey = inverse.name;
|
|
6245
6290
|
}
|
|
6246
6291
|
|
|
6247
|
-
if (relationshipMeta.kind ===
|
|
6292
|
+
if (relationshipMeta.kind === 'hasMany') {
|
|
6248
6293
|
return new ember$data$lib$system$relationships$state$has$many$$default(store, record, inverseKey, relationshipMeta);
|
|
6249
6294
|
} else {
|
|
6250
6295
|
return new ember$data$lib$system$relationships$state$belongs$to$$default(store, record, inverseKey, relationshipMeta);
|
|
@@ -6261,7 +6306,7 @@
|
|
|
6261
6306
|
|
|
6262
6307
|
ember$data$lib$system$relationships$state$create$$Relationships.prototype.get = function (key) {
|
|
6263
6308
|
var relationships = this.initializedRelationships;
|
|
6264
|
-
var relationshipsByName = ember$data$lib$system$relationships$state$create$$get(this.record.type,
|
|
6309
|
+
var relationshipsByName = ember$data$lib$system$relationships$state$create$$get(this.record.type, 'relationshipsByName');
|
|
6265
6310
|
if (!relationships[key] && relationshipsByName.get(key)) {
|
|
6266
6311
|
relationships[key] = ember$data$lib$system$relationships$state$create$$createRelationshipFor(this.record, relationshipsByName.get(key), this.record.store);
|
|
6267
6312
|
}
|
|
@@ -6444,17 +6489,17 @@
|
|
|
6444
6489
|
}
|
|
6445
6490
|
|
|
6446
6491
|
relationship = this._internalModel._relationships.get(keyName);
|
|
6447
|
-
if (!(relationship && relationship.relationshipMeta.kind ===
|
|
6492
|
+
if (!(relationship && relationship.relationshipMeta.kind === 'belongsTo')) {
|
|
6448
6493
|
throw new Ember.Error("Model '" + Ember.inspect(this.record) + "' has no belongsTo relationship named '" + keyName + "' defined.");
|
|
6449
6494
|
}
|
|
6450
6495
|
|
|
6451
|
-
hasData = ember$data$lib$system$snapshot$$get(relationship,
|
|
6452
|
-
inverseRecord = ember$data$lib$system$snapshot$$get(relationship,
|
|
6496
|
+
hasData = ember$data$lib$system$snapshot$$get(relationship, 'hasData');
|
|
6497
|
+
inverseRecord = ember$data$lib$system$snapshot$$get(relationship, 'inverseRecord');
|
|
6453
6498
|
|
|
6454
6499
|
if (hasData) {
|
|
6455
6500
|
if (inverseRecord && !inverseRecord.isDeleted()) {
|
|
6456
6501
|
if (id) {
|
|
6457
|
-
result = ember$data$lib$system$snapshot$$get(inverseRecord,
|
|
6502
|
+
result = ember$data$lib$system$snapshot$$get(inverseRecord, 'id');
|
|
6458
6503
|
} else {
|
|
6459
6504
|
result = inverseRecord.createSnapshot();
|
|
6460
6505
|
}
|
|
@@ -6508,12 +6553,12 @@
|
|
|
6508
6553
|
}
|
|
6509
6554
|
|
|
6510
6555
|
relationship = this._internalModel._relationships.get(keyName);
|
|
6511
|
-
if (!(relationship && relationship.relationshipMeta.kind ===
|
|
6556
|
+
if (!(relationship && relationship.relationshipMeta.kind === 'hasMany')) {
|
|
6512
6557
|
throw new Ember.Error("Model '" + Ember.inspect(this.record) + "' has no hasMany relationship named '" + keyName + "' defined.");
|
|
6513
6558
|
}
|
|
6514
6559
|
|
|
6515
|
-
hasData = ember$data$lib$system$snapshot$$get(relationship,
|
|
6516
|
-
members = ember$data$lib$system$snapshot$$get(relationship,
|
|
6560
|
+
hasData = ember$data$lib$system$snapshot$$get(relationship, 'hasData');
|
|
6561
|
+
members = ember$data$lib$system$snapshot$$get(relationship, 'members');
|
|
6517
6562
|
|
|
6518
6563
|
if (hasData) {
|
|
6519
6564
|
results = [];
|
|
@@ -6592,7 +6637,7 @@
|
|
|
6592
6637
|
var ember$data$lib$system$model$internal$model$$_splitOnDotCache = Object.create(null);
|
|
6593
6638
|
|
|
6594
6639
|
function ember$data$lib$system$model$internal$model$$splitOnDot(name) {
|
|
6595
|
-
return ember$data$lib$system$model$internal$model$$_splitOnDotCache[name] || (ember$data$lib$system$model$internal$model$$_splitOnDotCache[name] = name.split(
|
|
6640
|
+
return ember$data$lib$system$model$internal$model$$_splitOnDotCache[name] || (ember$data$lib$system$model$internal$model$$_splitOnDotCache[name] = name.split('.'));
|
|
6596
6641
|
}
|
|
6597
6642
|
|
|
6598
6643
|
function ember$data$lib$system$model$internal$model$$extractPivotName(name) {
|
|
@@ -6662,15 +6707,15 @@
|
|
|
6662
6707
|
}
|
|
6663
6708
|
|
|
6664
6709
|
ember$data$lib$system$model$internal$model$$InternalModel.prototype = {
|
|
6665
|
-
isEmpty: ember$data$lib$system$model$internal$model$$retrieveFromCurrentState(
|
|
6666
|
-
isLoading: ember$data$lib$system$model$internal$model$$retrieveFromCurrentState(
|
|
6667
|
-
isLoaded: ember$data$lib$system$model$internal$model$$retrieveFromCurrentState(
|
|
6668
|
-
hasDirtyAttributes: ember$data$lib$system$model$internal$model$$retrieveFromCurrentState(
|
|
6669
|
-
isSaving: ember$data$lib$system$model$internal$model$$retrieveFromCurrentState(
|
|
6670
|
-
isDeleted: ember$data$lib$system$model$internal$model$$retrieveFromCurrentState(
|
|
6671
|
-
isNew: ember$data$lib$system$model$internal$model$$retrieveFromCurrentState(
|
|
6672
|
-
isValid: ember$data$lib$system$model$internal$model$$retrieveFromCurrentState(
|
|
6673
|
-
dirtyType: ember$data$lib$system$model$internal$model$$retrieveFromCurrentState(
|
|
6710
|
+
isEmpty: ember$data$lib$system$model$internal$model$$retrieveFromCurrentState('isEmpty'),
|
|
6711
|
+
isLoading: ember$data$lib$system$model$internal$model$$retrieveFromCurrentState('isLoading'),
|
|
6712
|
+
isLoaded: ember$data$lib$system$model$internal$model$$retrieveFromCurrentState('isLoaded'),
|
|
6713
|
+
hasDirtyAttributes: ember$data$lib$system$model$internal$model$$retrieveFromCurrentState('hasDirtyAttributes'),
|
|
6714
|
+
isSaving: ember$data$lib$system$model$internal$model$$retrieveFromCurrentState('isSaving'),
|
|
6715
|
+
isDeleted: ember$data$lib$system$model$internal$model$$retrieveFromCurrentState('isDeleted'),
|
|
6716
|
+
isNew: ember$data$lib$system$model$internal$model$$retrieveFromCurrentState('isNew'),
|
|
6717
|
+
isValid: ember$data$lib$system$model$internal$model$$retrieveFromCurrentState('isValid'),
|
|
6718
|
+
dirtyType: ember$data$lib$system$model$internal$model$$retrieveFromCurrentState('dirtyType'),
|
|
6674
6719
|
|
|
6675
6720
|
constructor: ember$data$lib$system$model$internal$model$$InternalModel,
|
|
6676
6721
|
materializeRecord: function () {
|
|
@@ -6682,7 +6727,7 @@
|
|
|
6682
6727
|
store: this.store,
|
|
6683
6728
|
container: this.container,
|
|
6684
6729
|
_internalModel: this,
|
|
6685
|
-
currentState: ember$data$lib$system$model$internal$model$$get(this,
|
|
6730
|
+
currentState: ember$data$lib$system$model$internal$model$$get(this, 'currentState'),
|
|
6686
6731
|
isError: this.isError,
|
|
6687
6732
|
adapterError: this.error
|
|
6688
6733
|
});
|
|
@@ -6694,7 +6739,7 @@
|
|
|
6694
6739
|
},
|
|
6695
6740
|
|
|
6696
6741
|
deleteRecord: function () {
|
|
6697
|
-
this.send(
|
|
6742
|
+
this.send('deleteRecord');
|
|
6698
6743
|
},
|
|
6699
6744
|
|
|
6700
6745
|
save: function (options) {
|
|
@@ -6708,14 +6753,14 @@
|
|
|
6708
6753
|
startedReloading: function () {
|
|
6709
6754
|
this.isReloading = true;
|
|
6710
6755
|
if (this.record) {
|
|
6711
|
-
ember$data$lib$system$model$internal$model$$set(this.record,
|
|
6756
|
+
ember$data$lib$system$model$internal$model$$set(this.record, 'isReloading', true);
|
|
6712
6757
|
}
|
|
6713
6758
|
},
|
|
6714
6759
|
|
|
6715
6760
|
finishedReloading: function () {
|
|
6716
6761
|
this.isReloading = false;
|
|
6717
6762
|
if (this.record) {
|
|
6718
|
-
ember$data$lib$system$model$internal$model$$set(this.record,
|
|
6763
|
+
ember$data$lib$system$model$internal$model$$set(this.record, 'isReloading', false);
|
|
6719
6764
|
}
|
|
6720
6765
|
},
|
|
6721
6766
|
|
|
@@ -6724,7 +6769,7 @@
|
|
|
6724
6769
|
var record = this;
|
|
6725
6770
|
var promiseLabel = "DS: Model#reload of " + this;
|
|
6726
6771
|
return new ember$data$lib$system$model$internal$model$$Promise(function (resolve) {
|
|
6727
|
-
record.send(
|
|
6772
|
+
record.send('reloadRecord', resolve);
|
|
6728
6773
|
}, promiseLabel).then(function () {
|
|
6729
6774
|
record.didCleanError();
|
|
6730
6775
|
return record;
|
|
@@ -6745,7 +6790,7 @@
|
|
|
6745
6790
|
},
|
|
6746
6791
|
|
|
6747
6792
|
unloadRecord: function () {
|
|
6748
|
-
this.send(
|
|
6793
|
+
this.send('unloadRecord');
|
|
6749
6794
|
},
|
|
6750
6795
|
|
|
6751
6796
|
eachRelationship: function (callback, binding) {
|
|
@@ -6771,7 +6816,7 @@
|
|
|
6771
6816
|
},
|
|
6772
6817
|
|
|
6773
6818
|
becameReady: function () {
|
|
6774
|
-
Ember.run.schedule(
|
|
6819
|
+
Ember.run.schedule('actions', this.store.recordArrayManager, this.store.recordArrayManager.recordWasLoaded, this);
|
|
6775
6820
|
},
|
|
6776
6821
|
|
|
6777
6822
|
didInitalizeData: function () {
|
|
@@ -6804,7 +6849,7 @@
|
|
|
6804
6849
|
@param {Promise} promise
|
|
6805
6850
|
*/
|
|
6806
6851
|
loadingData: function (promise) {
|
|
6807
|
-
this.send(
|
|
6852
|
+
this.send('loadingData', promise);
|
|
6808
6853
|
},
|
|
6809
6854
|
|
|
6810
6855
|
/**
|
|
@@ -6812,7 +6857,7 @@
|
|
|
6812
6857
|
@private
|
|
6813
6858
|
*/
|
|
6814
6859
|
loadedData: function () {
|
|
6815
|
-
this.send(
|
|
6860
|
+
this.send('loadedData');
|
|
6816
6861
|
this.didInitalizeData();
|
|
6817
6862
|
},
|
|
6818
6863
|
|
|
@@ -6821,7 +6866,7 @@
|
|
|
6821
6866
|
@private
|
|
6822
6867
|
*/
|
|
6823
6868
|
notFound: function () {
|
|
6824
|
-
this.send(
|
|
6869
|
+
this.send('notFound');
|
|
6825
6870
|
},
|
|
6826
6871
|
|
|
6827
6872
|
/**
|
|
@@ -6829,7 +6874,7 @@
|
|
|
6829
6874
|
@private
|
|
6830
6875
|
*/
|
|
6831
6876
|
pushedData: function () {
|
|
6832
|
-
this.send(
|
|
6877
|
+
this.send('pushedData');
|
|
6833
6878
|
},
|
|
6834
6879
|
|
|
6835
6880
|
flushChangedAttributes: function () {
|
|
@@ -6842,7 +6887,7 @@
|
|
|
6842
6887
|
@private
|
|
6843
6888
|
*/
|
|
6844
6889
|
adapterWillCommit: function () {
|
|
6845
|
-
this.send(
|
|
6890
|
+
this.send('willCommit');
|
|
6846
6891
|
},
|
|
6847
6892
|
|
|
6848
6893
|
/**
|
|
@@ -6850,7 +6895,7 @@
|
|
|
6850
6895
|
@private
|
|
6851
6896
|
*/
|
|
6852
6897
|
adapterDidDirty: function () {
|
|
6853
|
-
this.send(
|
|
6898
|
+
this.send('becomeDirty');
|
|
6854
6899
|
this.updateRecordArraysLater();
|
|
6855
6900
|
},
|
|
6856
6901
|
|
|
@@ -6861,7 +6906,7 @@
|
|
|
6861
6906
|
@param {Object} context
|
|
6862
6907
|
*/
|
|
6863
6908
|
send: function (name, context) {
|
|
6864
|
-
var currentState = ember$data$lib$system$model$internal$model$$get(this,
|
|
6909
|
+
var currentState = ember$data$lib$system$model$internal$model$$get(this, 'currentState');
|
|
6865
6910
|
|
|
6866
6911
|
if (!currentState[name]) {
|
|
6867
6912
|
this._unhandledEvent(currentState, name, context);
|
|
@@ -6899,7 +6944,7 @@
|
|
|
6899
6944
|
|
|
6900
6945
|
this._attributes = Object.create(null);
|
|
6901
6946
|
|
|
6902
|
-
if (ember$data$lib$system$model$internal$model$$get(this,
|
|
6947
|
+
if (ember$data$lib$system$model$internal$model$$get(this, 'isError')) {
|
|
6903
6948
|
this._inFlightAttributes = Object.create(null);
|
|
6904
6949
|
this.didCleanError();
|
|
6905
6950
|
}
|
|
@@ -6920,7 +6965,7 @@
|
|
|
6920
6965
|
this._inFlightAttributes = Object.create(null);
|
|
6921
6966
|
}
|
|
6922
6967
|
|
|
6923
|
-
this.send(
|
|
6968
|
+
this.send('rolledBack');
|
|
6924
6969
|
|
|
6925
6970
|
this.record._notifyProperties(dirtyKeys);
|
|
6926
6971
|
},
|
|
@@ -6934,7 +6979,7 @@
|
|
|
6934
6979
|
// always having direct reference to state objects
|
|
6935
6980
|
|
|
6936
6981
|
var pivotName = ember$data$lib$system$model$internal$model$$extractPivotName(name);
|
|
6937
|
-
var currentState = ember$data$lib$system$model$internal$model$$get(this,
|
|
6982
|
+
var currentState = ember$data$lib$system$model$internal$model$$get(this, 'currentState');
|
|
6938
6983
|
var state = currentState;
|
|
6939
6984
|
|
|
6940
6985
|
do {
|
|
@@ -6964,10 +7009,10 @@
|
|
|
6964
7009
|
enters[i].enter(this);
|
|
6965
7010
|
}
|
|
6966
7011
|
|
|
6967
|
-
ember$data$lib$system$model$internal$model$$set(this,
|
|
7012
|
+
ember$data$lib$system$model$internal$model$$set(this, 'currentState', state);
|
|
6968
7013
|
//TODO Consider whether this is the best approach for keeping these two in sync
|
|
6969
7014
|
if (this.record) {
|
|
6970
|
-
ember$data$lib$system$model$internal$model$$set(this.record,
|
|
7015
|
+
ember$data$lib$system$model$internal$model$$set(this.record, 'currentState', state);
|
|
6971
7016
|
}
|
|
6972
7017
|
|
|
6973
7018
|
for (i = 0, l = setups.length; i < l; i++) {
|
|
@@ -7000,7 +7045,7 @@
|
|
|
7000
7045
|
if (this._deferredTriggers.push(args) !== 1) {
|
|
7001
7046
|
return;
|
|
7002
7047
|
}
|
|
7003
|
-
Ember.run.scheduleOnce(
|
|
7048
|
+
Ember.run.scheduleOnce('actions', this, '_triggerDeferredTriggers');
|
|
7004
7049
|
},
|
|
7005
7050
|
|
|
7006
7051
|
_triggerDeferredTriggers: function () {
|
|
@@ -7067,7 +7112,7 @@
|
|
|
7067
7112
|
_preloadRelationship: function (key, preloadValue) {
|
|
7068
7113
|
var relationshipMeta = this.type.metaForProperty(key);
|
|
7069
7114
|
var type = relationshipMeta.type;
|
|
7070
|
-
if (relationshipMeta.kind ===
|
|
7115
|
+
if (relationshipMeta.kind === 'hasMany') {
|
|
7071
7116
|
this._preloadHasMany(key, preloadValue, type);
|
|
7072
7117
|
} else {
|
|
7073
7118
|
this._preloadBelongsTo(key, preloadValue, type);
|
|
@@ -7095,7 +7140,7 @@
|
|
|
7095
7140
|
},
|
|
7096
7141
|
|
|
7097
7142
|
_convertStringOrNumberIntoInternalModel: function (value, type) {
|
|
7098
|
-
if (typeof value ===
|
|
7143
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
|
7099
7144
|
return this.store._internalModelForId(type, value);
|
|
7100
7145
|
}
|
|
7101
7146
|
if (value._internalModel) {
|
|
@@ -7116,7 +7161,7 @@
|
|
|
7116
7161
|
setId: function (id) {
|
|
7117
7162
|
this.id = id;
|
|
7118
7163
|
//TODO figure out whether maybe we should proxy
|
|
7119
|
-
ember$data$lib$system$model$internal$model$$set(this.record,
|
|
7164
|
+
ember$data$lib$system$model$internal$model$$set(this.record, 'id', id);
|
|
7120
7165
|
},
|
|
7121
7166
|
|
|
7122
7167
|
didError: function (error) {
|
|
@@ -7163,7 +7208,7 @@
|
|
|
7163
7208
|
|
|
7164
7209
|
this._inFlightAttributes = Object.create(null);
|
|
7165
7210
|
|
|
7166
|
-
this.send(
|
|
7211
|
+
this.send('didCommit');
|
|
7167
7212
|
this.updateRecordArraysLater();
|
|
7168
7213
|
|
|
7169
7214
|
if (!data) {
|
|
@@ -7183,22 +7228,22 @@
|
|
|
7183
7228
|
return;
|
|
7184
7229
|
}
|
|
7185
7230
|
this._updatingRecordArraysLater = true;
|
|
7186
|
-
Ember.run.schedule(
|
|
7231
|
+
Ember.run.schedule('actions', this, this.updateRecordArrays);
|
|
7187
7232
|
},
|
|
7188
7233
|
|
|
7189
7234
|
addErrorMessageToAttribute: function (attribute, message) {
|
|
7190
7235
|
var record = this.getRecord();
|
|
7191
|
-
ember$data$lib$system$model$internal$model$$get(record,
|
|
7236
|
+
ember$data$lib$system$model$internal$model$$get(record, 'errors').add(attribute, message);
|
|
7192
7237
|
},
|
|
7193
7238
|
|
|
7194
7239
|
removeErrorMessageFromAttribute: function (attribute) {
|
|
7195
7240
|
var record = this.getRecord();
|
|
7196
|
-
ember$data$lib$system$model$internal$model$$get(record,
|
|
7241
|
+
ember$data$lib$system$model$internal$model$$get(record, 'errors').remove(attribute);
|
|
7197
7242
|
},
|
|
7198
7243
|
|
|
7199
7244
|
clearErrorMessages: function () {
|
|
7200
7245
|
var record = this.getRecord();
|
|
7201
|
-
ember$data$lib$system$model$internal$model$$get(record,
|
|
7246
|
+
ember$data$lib$system$model$internal$model$$get(record, 'errors').clear();
|
|
7202
7247
|
},
|
|
7203
7248
|
|
|
7204
7249
|
// FOR USE DURING COMMIT PROCESS
|
|
@@ -7224,7 +7269,7 @@
|
|
|
7224
7269
|
@private
|
|
7225
7270
|
*/
|
|
7226
7271
|
adapterDidError: function (error) {
|
|
7227
|
-
this.send(
|
|
7272
|
+
this.send('becameError');
|
|
7228
7273
|
this.didError(error);
|
|
7229
7274
|
this._saveWasRejected();
|
|
7230
7275
|
},
|
|
@@ -7312,15 +7357,15 @@
|
|
|
7312
7357
|
}
|
|
7313
7358
|
};
|
|
7314
7359
|
|
|
7315
|
-
var ember$data$lib$system$store$$Backburner = Ember._Backburner || Ember.Backburner || Ember.__loader.require(
|
|
7360
|
+
var ember$data$lib$system$store$$Backburner = Ember._Backburner || Ember.Backburner || Ember.__loader.require('backburner')['default'] || Ember.__loader.require('backburner')['Backburner'];
|
|
7316
7361
|
|
|
7317
7362
|
//Shim Backburner.join
|
|
7318
7363
|
if (!ember$data$lib$system$store$$Backburner.prototype.join) {
|
|
7319
7364
|
var ember$data$lib$system$store$$isString = function (suspect) {
|
|
7320
|
-
return typeof suspect ===
|
|
7365
|
+
return typeof suspect === 'string';
|
|
7321
7366
|
};
|
|
7322
7367
|
|
|
7323
|
-
ember$data$lib$system$store$$Backburner.prototype.join = function () {
|
|
7368
|
+
ember$data$lib$system$store$$Backburner.prototype.join = function () /*target, method, args */{
|
|
7324
7369
|
var method, target;
|
|
7325
7370
|
|
|
7326
7371
|
if (this.currentInstance) {
|
|
@@ -7473,7 +7518,7 @@
|
|
|
7473
7518
|
*/
|
|
7474
7519
|
init: function () {
|
|
7475
7520
|
this._super.apply(this, arguments);
|
|
7476
|
-
this._backburner = new ember$data$lib$system$store$$Backburner([
|
|
7521
|
+
this._backburner = new ember$data$lib$system$store$$Backburner(['normalizeRelationships', 'syncRelationships', 'finished']);
|
|
7477
7522
|
// internal bookkeeping; not observable
|
|
7478
7523
|
this.typeMaps = {};
|
|
7479
7524
|
this.recordArrayManager = ember$data$lib$system$record$array$manager$$default.create({
|
|
@@ -7496,7 +7541,7 @@
|
|
|
7496
7541
|
@default DS.RESTAdapter
|
|
7497
7542
|
@type {(DS.Adapter|String)}
|
|
7498
7543
|
*/
|
|
7499
|
-
adapter:
|
|
7544
|
+
adapter: '-json-api',
|
|
7500
7545
|
|
|
7501
7546
|
/**
|
|
7502
7547
|
Returns a JSON representation of the record using a custom
|
|
@@ -7526,12 +7571,12 @@
|
|
|
7526
7571
|
@private
|
|
7527
7572
|
@return DS.Adapter
|
|
7528
7573
|
*/
|
|
7529
|
-
defaultAdapter: Ember.computed(
|
|
7530
|
-
var adapter = ember$data$lib$system$store$$get(this,
|
|
7574
|
+
defaultAdapter: Ember.computed('adapter', function () {
|
|
7575
|
+
var adapter = ember$data$lib$system$store$$get(this, 'adapter');
|
|
7531
7576
|
|
|
7532
|
-
Ember.assert(
|
|
7577
|
+
Ember.assert('You tried to set `adapter` property to an instance of `DS.Adapter`, where it should be a name', typeof adapter === 'string');
|
|
7533
7578
|
|
|
7534
|
-
adapter = this.retrieveManagedInstance(
|
|
7579
|
+
adapter = this.retrieveManagedInstance('adapter', adapter);
|
|
7535
7580
|
|
|
7536
7581
|
return adapter;
|
|
7537
7582
|
}),
|
|
@@ -7564,7 +7609,7 @@
|
|
|
7564
7609
|
@return {DS.Model} record
|
|
7565
7610
|
*/
|
|
7566
7611
|
createRecord: function (modelName, inputProperties) {
|
|
7567
|
-
Ember.assert("Passing classes to store methods has been removed. Please pass a dasherized string instead of " + Ember.inspect(modelName), typeof modelName ===
|
|
7612
|
+
Ember.assert("Passing classes to store methods has been removed. Please pass a dasherized string instead of " + Ember.inspect(modelName), typeof modelName === 'string');
|
|
7568
7613
|
var typeClass = this.modelFor(modelName);
|
|
7569
7614
|
var properties = ember$data$lib$system$store$$copy(inputProperties) || Object.create(null);
|
|
7570
7615
|
|
|
@@ -7670,20 +7715,20 @@
|
|
|
7670
7715
|
// the public way to get a record by modelName and id.
|
|
7671
7716
|
|
|
7672
7717
|
if (arguments.length === 1) {
|
|
7673
|
-
Ember.assert(
|
|
7718
|
+
Ember.assert('Using store.find(type) has been removed. Use store.findAll(type) to retrieve all records for a given type.');
|
|
7674
7719
|
}
|
|
7675
7720
|
|
|
7676
|
-
if (Ember.typeOf(id) ===
|
|
7677
|
-
Ember.assert(
|
|
7721
|
+
if (Ember.typeOf(id) === 'object') {
|
|
7722
|
+
Ember.assert('Calling store.find() with a query object is no longer supported. Use store.query() instead.');
|
|
7678
7723
|
}
|
|
7679
7724
|
|
|
7680
7725
|
if (options) {
|
|
7681
|
-
Ember.assert(
|
|
7726
|
+
Ember.assert('Calling store.find(type, id, { preload: preload }) is no longer supported. Use store.findRecord(type, id, { preload: preload }) instead.');
|
|
7682
7727
|
}
|
|
7683
7728
|
|
|
7684
7729
|
Ember.assert("You need to pass the model name and id to the store's find method", arguments.length === 2);
|
|
7685
|
-
Ember.assert("You cannot pass `" + Ember.inspect(id) + "` as id to the store's find method", Ember.typeOf(id) ===
|
|
7686
|
-
Ember.assert(
|
|
7730
|
+
Ember.assert("You cannot pass `" + Ember.inspect(id) + "` as id to the store's find method", Ember.typeOf(id) === 'string' || Ember.typeOf(id) === 'number');
|
|
7731
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
|
7687
7732
|
|
|
7688
7733
|
return this.findRecord(modelName, id);
|
|
7689
7734
|
},
|
|
@@ -7723,7 +7768,7 @@
|
|
|
7723
7768
|
@return {Promise} promise
|
|
7724
7769
|
*/
|
|
7725
7770
|
findRecord: function (modelName, id, options) {
|
|
7726
|
-
Ember.assert(
|
|
7771
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
|
7727
7772
|
var internalModel = this._internalModelForId(modelName, id);
|
|
7728
7773
|
options = options || {};
|
|
7729
7774
|
|
|
@@ -7733,7 +7778,7 @@
|
|
|
7733
7778
|
|
|
7734
7779
|
var fetchedInternalModel = this._findRecord(internalModel, options);
|
|
7735
7780
|
|
|
7736
|
-
return ember$data$lib$system$store$$promiseRecord(fetchedInternalModel, "DS: Store#findRecord " + internalModel.typeKey + " with id: " + ember$data$lib$system$store$$get(internalModel,
|
|
7781
|
+
return ember$data$lib$system$store$$promiseRecord(fetchedInternalModel, "DS: Store#findRecord " + internalModel.typeKey + " with id: " + ember$data$lib$system$store$$get(internalModel, 'id'));
|
|
7737
7782
|
},
|
|
7738
7783
|
|
|
7739
7784
|
_findRecord: function (internalModel, options) {
|
|
@@ -7769,7 +7814,7 @@
|
|
|
7769
7814
|
|
|
7770
7815
|
var fetchedInternalModel = this._findEmptyInternalModel(internalModel, options);
|
|
7771
7816
|
|
|
7772
|
-
return ember$data$lib$system$store$$promiseRecord(fetchedInternalModel, "DS: Store#findRecord " + internalModel.typeKey + " with id: " + ember$data$lib$system$store$$get(internalModel,
|
|
7817
|
+
return ember$data$lib$system$store$$promiseRecord(fetchedInternalModel, "DS: Store#findRecord " + internalModel.typeKey + " with id: " + ember$data$lib$system$store$$get(internalModel, 'id'));
|
|
7773
7818
|
},
|
|
7774
7819
|
|
|
7775
7820
|
_findEmptyInternalModel: function (internalModel, options) {
|
|
@@ -7795,7 +7840,7 @@
|
|
|
7795
7840
|
@return {Promise} promise
|
|
7796
7841
|
*/
|
|
7797
7842
|
findByIds: function (modelName, ids) {
|
|
7798
|
-
Ember.assert(
|
|
7843
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
|
7799
7844
|
var store = this;
|
|
7800
7845
|
|
|
7801
7846
|
return ember$data$lib$system$promise$proxies$$promiseArray(Ember.RSVP.all(ids.map(function (id) {
|
|
@@ -7819,7 +7864,7 @@
|
|
|
7819
7864
|
var adapter = this.adapterFor(typeClass.modelName);
|
|
7820
7865
|
|
|
7821
7866
|
Ember.assert("You tried to find a record but you have no adapter (for " + typeClass + ")", adapter);
|
|
7822
|
-
Ember.assert("You tried to find a record but your adapter (for " + typeClass + ") does not implement 'findRecord'", typeof adapter.findRecord ===
|
|
7867
|
+
Ember.assert("You tried to find a record but your adapter (for " + typeClass + ") does not implement 'findRecord'", typeof adapter.findRecord === 'function' || typeof adapter.find === 'function');
|
|
7823
7868
|
|
|
7824
7869
|
var promise = ember$data$lib$system$store$finders$$_find(adapter, this, typeClass, id, internalModel, options);
|
|
7825
7870
|
return promise;
|
|
@@ -7839,7 +7884,7 @@
|
|
|
7839
7884
|
return internalModel._loadingPromise;
|
|
7840
7885
|
}
|
|
7841
7886
|
|
|
7842
|
-
var resolver = Ember.RSVP.defer(
|
|
7887
|
+
var resolver = Ember.RSVP.defer('Fetching ' + typeClass + 'with id: ' + internalModel.id);
|
|
7843
7888
|
var pendingFetchItem = {
|
|
7844
7889
|
record: internalModel,
|
|
7845
7890
|
resolver: resolver,
|
|
@@ -7854,7 +7899,7 @@
|
|
|
7854
7899
|
} else {
|
|
7855
7900
|
this._pendingFetch.get(typeClass).push(pendingFetchItem);
|
|
7856
7901
|
}
|
|
7857
|
-
Ember.run.scheduleOnce(
|
|
7902
|
+
Ember.run.scheduleOnce('afterRender', this, this.flushAllPendingFetches);
|
|
7858
7903
|
|
|
7859
7904
|
return promise;
|
|
7860
7905
|
},
|
|
@@ -7872,7 +7917,7 @@
|
|
|
7872
7917
|
var store = this;
|
|
7873
7918
|
var adapter = store.adapterFor(typeClass.modelName);
|
|
7874
7919
|
var shouldCoalesce = !!adapter.findMany && adapter.coalesceFindRequests;
|
|
7875
|
-
var records = Ember.A(pendingFetchItems).mapBy(
|
|
7920
|
+
var records = Ember.A(pendingFetchItems).mapBy('record');
|
|
7876
7921
|
|
|
7877
7922
|
function _fetchRecord(recordResolverPair) {
|
|
7878
7923
|
recordResolverPair.resolver.resolve(store.fetchRecord(recordResolverPair.record, recordResolverPair.options)); // TODO adapter options
|
|
@@ -7880,7 +7925,7 @@
|
|
|
7880
7925
|
|
|
7881
7926
|
function resolveFoundRecords(records) {
|
|
7882
7927
|
records.forEach(function (record) {
|
|
7883
|
-
var pair = Ember.A(pendingFetchItems).findBy(
|
|
7928
|
+
var pair = Ember.A(pendingFetchItems).findBy('record', record);
|
|
7884
7929
|
if (pair) {
|
|
7885
7930
|
var resolver = pair.resolver;
|
|
7886
7931
|
resolver.resolve(record);
|
|
@@ -7896,8 +7941,8 @@
|
|
|
7896
7941
|
return resolvedRecords.contains(record);
|
|
7897
7942
|
});
|
|
7898
7943
|
if (missingRecords.length) {
|
|
7899
|
-
Ember.warn(
|
|
7900
|
-
id:
|
|
7944
|
+
Ember.warn('Ember Data expected to find records with the following ids in the adapter response but they were missing: ' + Ember.inspect(Ember.A(missingRecords).mapBy('id')), false, {
|
|
7945
|
+
id: 'ds.store.missing-records-from-adapter'
|
|
7901
7946
|
});
|
|
7902
7947
|
}
|
|
7903
7948
|
rejectRecords(missingRecords);
|
|
@@ -7912,7 +7957,7 @@
|
|
|
7912
7957
|
|
|
7913
7958
|
function rejectRecords(records, error) {
|
|
7914
7959
|
records.forEach(function (record) {
|
|
7915
|
-
var pair = Ember.A(pendingFetchItems).findBy(
|
|
7960
|
+
var pair = Ember.A(pendingFetchItems).findBy('record', record);
|
|
7916
7961
|
if (pair) {
|
|
7917
7962
|
var resolver = pair.resolver;
|
|
7918
7963
|
resolver.reject(error);
|
|
@@ -7935,16 +7980,16 @@
|
|
|
7935
7980
|
// records from the grouped snapshots even though the _findMany() finder
|
|
7936
7981
|
// will once again convert the records to snapshots for adapter.findMany()
|
|
7937
7982
|
|
|
7938
|
-
var snapshots = Ember.A(records).invoke(
|
|
7983
|
+
var snapshots = Ember.A(records).invoke('createSnapshot');
|
|
7939
7984
|
var groups = adapter.groupRecordsForFindMany(this, snapshots);
|
|
7940
7985
|
groups.forEach(function (groupOfSnapshots) {
|
|
7941
|
-
var groupOfRecords = Ember.A(groupOfSnapshots).mapBy(
|
|
7986
|
+
var groupOfRecords = Ember.A(groupOfSnapshots).mapBy('_internalModel');
|
|
7942
7987
|
var requestedRecords = Ember.A(groupOfRecords);
|
|
7943
|
-
var ids = requestedRecords.mapBy(
|
|
7988
|
+
var ids = requestedRecords.mapBy('id');
|
|
7944
7989
|
if (ids.length > 1) {
|
|
7945
7990
|
ember$data$lib$system$store$finders$$_findMany(adapter, store, typeClass, ids, requestedRecords).then(resolveFoundRecords).then(makeMissingRecordsRejector(requestedRecords)).then(null, makeRecordsRejector(requestedRecords));
|
|
7946
7991
|
} else if (ids.length === 1) {
|
|
7947
|
-
var pair = Ember.A(pendingFetchItems).findBy(
|
|
7992
|
+
var pair = Ember.A(pendingFetchItems).findBy('record', groupOfRecords[0]);
|
|
7948
7993
|
_fetchRecord(pair);
|
|
7949
7994
|
} else {
|
|
7950
7995
|
Ember.assert("You cannot return an empty array from adapter's method groupRecordsForFindMany", false);
|
|
@@ -7971,7 +8016,7 @@
|
|
|
7971
8016
|
@return {DS.Model|null} record
|
|
7972
8017
|
*/
|
|
7973
8018
|
peekRecord: function (modelName, id) {
|
|
7974
|
-
Ember.assert(
|
|
8019
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
|
7975
8020
|
if (this.hasRecordForId(modelName, id)) {
|
|
7976
8021
|
return this._internalModelForId(modelName, id).getRecord();
|
|
7977
8022
|
} else {
|
|
@@ -7996,7 +8041,7 @@
|
|
|
7996
8041
|
|
|
7997
8042
|
Ember.assert("You cannot reload a record without an ID", id);
|
|
7998
8043
|
Ember.assert("You tried to reload a record but you have no adapter (for " + modelName + ")", adapter);
|
|
7999
|
-
Ember.assert("You tried to reload a record but your adapter does not implement `findRecord`", typeof adapter.findRecord ===
|
|
8044
|
+
Ember.assert("You tried to reload a record but your adapter does not implement `findRecord`", typeof adapter.findRecord === 'function' || typeof adapter.find === 'function');
|
|
8000
8045
|
|
|
8001
8046
|
return this.scheduleFetch(internalModel);
|
|
8002
8047
|
},
|
|
@@ -8009,7 +8054,7 @@
|
|
|
8009
8054
|
@return {Boolean}
|
|
8010
8055
|
*/
|
|
8011
8056
|
hasRecordForId: function (modelName, inputId) {
|
|
8012
|
-
Ember.assert(
|
|
8057
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
|
8013
8058
|
var typeClass = this.modelFor(modelName);
|
|
8014
8059
|
var id = ember$data$lib$system$coerce$id$$default(inputId);
|
|
8015
8060
|
var internalModel = this.typeMapFor(typeClass).idToRecord[id];
|
|
@@ -8026,7 +8071,7 @@
|
|
|
8026
8071
|
@return {DS.Model} record
|
|
8027
8072
|
*/
|
|
8028
8073
|
recordForId: function (modelName, id) {
|
|
8029
|
-
Ember.assert(
|
|
8074
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
|
8030
8075
|
return this._internalModelForId(modelName, id).getRecord();
|
|
8031
8076
|
},
|
|
8032
8077
|
|
|
@@ -8076,7 +8121,7 @@
|
|
|
8076
8121
|
var adapter = this.adapterFor(owner.type.modelName);
|
|
8077
8122
|
|
|
8078
8123
|
Ember.assert("You tried to load a hasMany relationship but you have no adapter (for " + owner.type + ")", adapter);
|
|
8079
|
-
Ember.assert("You tried to load a hasMany relationship from a specified `link` in the original payload but your adapter does not implement `findHasMany`", typeof adapter.findHasMany ===
|
|
8124
|
+
Ember.assert("You tried to load a hasMany relationship from a specified `link` in the original payload but your adapter does not implement `findHasMany`", typeof adapter.findHasMany === 'function');
|
|
8080
8125
|
|
|
8081
8126
|
return ember$data$lib$system$store$finders$$_findHasMany(adapter, this, owner, link, relationship);
|
|
8082
8127
|
},
|
|
@@ -8093,7 +8138,7 @@
|
|
|
8093
8138
|
var adapter = this.adapterFor(owner.type.modelName);
|
|
8094
8139
|
|
|
8095
8140
|
Ember.assert("You tried to load a belongsTo relationship but you have no adapter (for " + owner.type + ")", adapter);
|
|
8096
|
-
Ember.assert("You tried to load a belongsTo relationship from a specified `link` in the original payload but your adapter does not implement `findBelongsTo`", typeof adapter.findBelongsTo ===
|
|
8141
|
+
Ember.assert("You tried to load a belongsTo relationship from a specified `link` in the original payload but your adapter does not implement `findBelongsTo`", typeof adapter.findBelongsTo === 'function');
|
|
8097
8142
|
|
|
8098
8143
|
return ember$data$lib$system$store$finders$$_findBelongsTo(adapter, this, owner, link, relationship);
|
|
8099
8144
|
},
|
|
@@ -8134,14 +8179,14 @@
|
|
|
8134
8179
|
@return {Promise} promise
|
|
8135
8180
|
*/
|
|
8136
8181
|
query: function (modelName, query) {
|
|
8137
|
-
Ember.assert(
|
|
8182
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
|
8138
8183
|
var typeClass = this.modelFor(modelName);
|
|
8139
8184
|
var array = this.recordArrayManager.createAdapterPopulatedRecordArray(typeClass, query);
|
|
8140
8185
|
|
|
8141
8186
|
var adapter = this.adapterFor(modelName);
|
|
8142
8187
|
|
|
8143
8188
|
Ember.assert("You tried to load a query but you have no adapter (for " + typeClass + ")", adapter);
|
|
8144
|
-
Ember.assert("You tried to load a query but your adapter does not implement `query`", typeof adapter.query ===
|
|
8189
|
+
Ember.assert("You tried to load a query but your adapter does not implement `query`", typeof adapter.query === 'function' || typeof adapter.findQuery === 'function');
|
|
8145
8190
|
|
|
8146
8191
|
return ember$data$lib$system$promise$proxies$$promiseArray(ember$data$lib$system$store$finders$$_query(adapter, this, typeClass, query, array));
|
|
8147
8192
|
},
|
|
@@ -8162,13 +8207,13 @@
|
|
|
8162
8207
|
queryRecord: function (modelName, query) {
|
|
8163
8208
|
Ember.assert("You need to pass a type to the store's queryRecord method", modelName);
|
|
8164
8209
|
Ember.assert("You need to pass a query hash to the store's queryRecord method", query);
|
|
8165
|
-
Ember.assert(
|
|
8210
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
|
8166
8211
|
|
|
8167
8212
|
var typeClass = this.modelFor(modelName);
|
|
8168
8213
|
var adapter = this.adapterFor(modelName);
|
|
8169
8214
|
|
|
8170
8215
|
Ember.assert("You tried to make a query but you have no adapter (for " + typeClass + ")", adapter);
|
|
8171
|
-
Ember.assert("You tried to make a query but your adapter does not implement `queryRecord`", typeof adapter.queryRecord ===
|
|
8216
|
+
Ember.assert("You tried to make a query but your adapter does not implement `queryRecord`", typeof adapter.queryRecord === 'function');
|
|
8172
8217
|
|
|
8173
8218
|
return ember$data$lib$system$promise$proxies$$promiseObject(ember$data$lib$system$store$finders$$_queryRecord(adapter, this, typeClass, query));
|
|
8174
8219
|
},
|
|
@@ -8193,7 +8238,7 @@
|
|
|
8193
8238
|
@return {DS.AdapterPopulatedRecordArray}
|
|
8194
8239
|
*/
|
|
8195
8240
|
findAll: function (modelName, options) {
|
|
8196
|
-
Ember.assert(
|
|
8241
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
|
8197
8242
|
var typeClass = this.modelFor(modelName);
|
|
8198
8243
|
|
|
8199
8244
|
return this._fetchAll(typeClass, this.peekAll(modelName), options);
|
|
@@ -8211,10 +8256,10 @@
|
|
|
8211
8256
|
var adapter = this.adapterFor(typeClass.modelName);
|
|
8212
8257
|
var sinceToken = this.typeMapFor(typeClass).metadata.since;
|
|
8213
8258
|
|
|
8214
|
-
ember$data$lib$system$store$$set(array,
|
|
8259
|
+
ember$data$lib$system$store$$set(array, 'isUpdating', true);
|
|
8215
8260
|
|
|
8216
8261
|
Ember.assert("You tried to load all records but you have no adapter (for " + typeClass + ")", adapter);
|
|
8217
|
-
Ember.assert("You tried to load all records but your adapter does not implement `findAll`", typeof adapter.findAll ===
|
|
8262
|
+
Ember.assert("You tried to load all records but your adapter does not implement `findAll`", typeof adapter.findAll === 'function');
|
|
8218
8263
|
if (options.reload) {
|
|
8219
8264
|
return ember$data$lib$system$promise$proxies$$promiseArray(ember$data$lib$system$store$finders$$_findAll(adapter, this, typeClass, sinceToken, options));
|
|
8220
8265
|
}
|
|
@@ -8235,7 +8280,7 @@
|
|
|
8235
8280
|
*/
|
|
8236
8281
|
didUpdateAll: function (typeClass) {
|
|
8237
8282
|
var liveRecordArray = this.recordArrayManager.liveRecordArrayFor(typeClass);
|
|
8238
|
-
ember$data$lib$system$store$$set(liveRecordArray,
|
|
8283
|
+
ember$data$lib$system$store$$set(liveRecordArray, 'isUpdating', false);
|
|
8239
8284
|
},
|
|
8240
8285
|
|
|
8241
8286
|
/**
|
|
@@ -8257,7 +8302,7 @@
|
|
|
8257
8302
|
@return {DS.RecordArray}
|
|
8258
8303
|
*/
|
|
8259
8304
|
peekAll: function (modelName) {
|
|
8260
|
-
Ember.assert(
|
|
8305
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
|
8261
8306
|
var typeClass = this.modelFor(modelName);
|
|
8262
8307
|
|
|
8263
8308
|
var liveRecordArray = this.recordArrayManager.liveRecordArrayFor(typeClass);
|
|
@@ -8277,7 +8322,7 @@
|
|
|
8277
8322
|
@param {String=} modelName
|
|
8278
8323
|
*/
|
|
8279
8324
|
unloadAll: function (modelName) {
|
|
8280
|
-
Ember.assert(
|
|
8325
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), !modelName || typeof modelName === 'string');
|
|
8281
8326
|
if (arguments.length === 0) {
|
|
8282
8327
|
var typeMaps = this.typeMaps;
|
|
8283
8328
|
var keys = Object.keys(typeMaps);
|
|
@@ -8301,7 +8346,7 @@
|
|
|
8301
8346
|
}
|
|
8302
8347
|
|
|
8303
8348
|
function byType(entry) {
|
|
8304
|
-
return typeMaps[entry][
|
|
8349
|
+
return typeMaps[entry]['type'].modelName;
|
|
8305
8350
|
}
|
|
8306
8351
|
},
|
|
8307
8352
|
|
|
@@ -8348,13 +8393,13 @@
|
|
|
8348
8393
|
@return {DS.PromiseArray}
|
|
8349
8394
|
*/
|
|
8350
8395
|
filter: function (modelName, query, filter) {
|
|
8351
|
-
Ember.assert(
|
|
8396
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
|
8352
8397
|
|
|
8353
8398
|
if (!Ember.ENV.ENABLE_DS_FILTER) {
|
|
8354
|
-
Ember.deprecate(
|
|
8355
|
-
url:
|
|
8356
|
-
id:
|
|
8357
|
-
until:
|
|
8399
|
+
Ember.deprecate('The filter API will be moved into a plugin soon. To enable store.filter using an environment flag, or to use an alternative, you can visit the ember-data-filter addon page', false, {
|
|
8400
|
+
url: 'https://github.com/ember-data/ember-data-filter',
|
|
8401
|
+
id: 'ds.store.filter-deprecated',
|
|
8402
|
+
until: '2.0.0'
|
|
8358
8403
|
});
|
|
8359
8404
|
}
|
|
8360
8405
|
|
|
@@ -8382,7 +8427,7 @@
|
|
|
8382
8427
|
|
|
8383
8428
|
return ember$data$lib$system$promise$proxies$$promiseArray(promise.then(function () {
|
|
8384
8429
|
return array;
|
|
8385
|
-
}, null,
|
|
8430
|
+
}, null, 'DS: Store#filter of ' + modelName));
|
|
8386
8431
|
},
|
|
8387
8432
|
|
|
8388
8433
|
/**
|
|
@@ -8402,7 +8447,7 @@
|
|
|
8402
8447
|
@return {boolean}
|
|
8403
8448
|
*/
|
|
8404
8449
|
recordIsLoaded: function (modelName, id) {
|
|
8405
|
-
Ember.assert(
|
|
8450
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
|
8406
8451
|
return this.hasRecordForId(modelName, id);
|
|
8407
8452
|
},
|
|
8408
8453
|
|
|
@@ -8413,7 +8458,7 @@
|
|
|
8413
8458
|
@private
|
|
8414
8459
|
*/
|
|
8415
8460
|
_metadataFor: function (modelName) {
|
|
8416
|
-
Ember.assert(
|
|
8461
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
|
8417
8462
|
var typeClass = this.modelFor(modelName);
|
|
8418
8463
|
return this.typeMapFor(typeClass).metadata;
|
|
8419
8464
|
},
|
|
@@ -8425,7 +8470,7 @@
|
|
|
8425
8470
|
@private
|
|
8426
8471
|
*/
|
|
8427
8472
|
_setMetadataFor: function (modelName, metadata) {
|
|
8428
|
-
Ember.assert(
|
|
8473
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
|
8429
8474
|
var typeClass = this.modelFor(modelName);
|
|
8430
8475
|
Ember.merge(this.typeMapFor(typeClass).metadata, metadata);
|
|
8431
8476
|
},
|
|
@@ -8470,7 +8515,7 @@
|
|
|
8470
8515
|
snapshot: snapshot,
|
|
8471
8516
|
resolver: resolver
|
|
8472
8517
|
});
|
|
8473
|
-
ember$data$lib$system$store$$once(this,
|
|
8518
|
+
ember$data$lib$system$store$$once(this, 'flushPendingSave');
|
|
8474
8519
|
},
|
|
8475
8520
|
|
|
8476
8521
|
/**
|
|
@@ -8492,14 +8537,14 @@
|
|
|
8492
8537
|
var adapter = _this2.adapterFor(record.type.modelName);
|
|
8493
8538
|
var operation;
|
|
8494
8539
|
|
|
8495
|
-
if (ember$data$lib$system$store$$get(record,
|
|
8540
|
+
if (ember$data$lib$system$store$$get(record, 'currentState.stateName') === 'root.deleted.saved') {
|
|
8496
8541
|
return resolver.resolve();
|
|
8497
8542
|
} else if (record.isNew()) {
|
|
8498
|
-
operation =
|
|
8543
|
+
operation = 'createRecord';
|
|
8499
8544
|
} else if (record.isDeleted()) {
|
|
8500
|
-
operation =
|
|
8545
|
+
operation = 'deleteRecord';
|
|
8501
8546
|
} else {
|
|
8502
|
-
operation =
|
|
8547
|
+
operation = 'updateRecord';
|
|
8503
8548
|
}
|
|
8504
8549
|
|
|
8505
8550
|
resolver.resolve(ember$data$lib$system$store$$_commit(adapter, _this2, operation, snapshot));
|
|
@@ -8524,7 +8569,7 @@
|
|
|
8524
8569
|
}
|
|
8525
8570
|
if (data) {
|
|
8526
8571
|
// normalize relationship IDs into records
|
|
8527
|
-
this._backburner.schedule(
|
|
8572
|
+
this._backburner.schedule('normalizeRelationships', this, '_setupRelationships', internalModel, internalModel.type, data);
|
|
8528
8573
|
this.updateId(internalModel, data);
|
|
8529
8574
|
}
|
|
8530
8575
|
|
|
@@ -8587,7 +8632,7 @@
|
|
|
8587
8632
|
@return {Object} typeMap
|
|
8588
8633
|
*/
|
|
8589
8634
|
typeMapFor: function (typeClass) {
|
|
8590
|
-
var typeMaps = ember$data$lib$system$store$$get(this,
|
|
8635
|
+
var typeMaps = ember$data$lib$system$store$$get(this, 'typeMaps');
|
|
8591
8636
|
var guid = Ember.guidFor(typeClass);
|
|
8592
8637
|
var typeMap = typeMaps[guid];
|
|
8593
8638
|
|
|
@@ -8648,10 +8693,10 @@
|
|
|
8648
8693
|
_modelForMixin: function (modelName) {
|
|
8649
8694
|
var normalizedModelName = ember$data$lib$system$normalize$model$name$$default(modelName);
|
|
8650
8695
|
var registry = this.container._registry ? this.container._registry : this.container;
|
|
8651
|
-
var mixin = registry.resolve(
|
|
8696
|
+
var mixin = registry.resolve('mixin:' + normalizedModelName);
|
|
8652
8697
|
if (mixin) {
|
|
8653
8698
|
//Cache the class as a model
|
|
8654
|
-
registry.register(
|
|
8699
|
+
registry.register('model:' + normalizedModelName, DS.Model.extend(mixin));
|
|
8655
8700
|
}
|
|
8656
8701
|
var factory = this.modelFactoryFor(normalizedModelName);
|
|
8657
8702
|
if (factory) {
|
|
@@ -8671,7 +8716,7 @@
|
|
|
8671
8716
|
@return {DS.Model}
|
|
8672
8717
|
*/
|
|
8673
8718
|
modelFor: function (modelName) {
|
|
8674
|
-
Ember.assert(
|
|
8719
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
|
8675
8720
|
|
|
8676
8721
|
var factory = this.modelFactoryFor(modelName);
|
|
8677
8722
|
if (!factory) {
|
|
@@ -8687,9 +8732,9 @@
|
|
|
8687
8732
|
},
|
|
8688
8733
|
|
|
8689
8734
|
modelFactoryFor: function (modelName) {
|
|
8690
|
-
Ember.assert(
|
|
8735
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
|
8691
8736
|
var normalizedKey = ember$data$lib$system$normalize$model$name$$default(modelName);
|
|
8692
|
-
return this.container.lookupFactory(
|
|
8737
|
+
return this.container.lookupFactory('model:' + normalizedKey);
|
|
8693
8738
|
},
|
|
8694
8739
|
|
|
8695
8740
|
/**
|
|
@@ -8755,7 +8800,7 @@
|
|
|
8755
8800
|
});
|
|
8756
8801
|
}
|
|
8757
8802
|
|
|
8758
|
-
if (Ember.typeOf(data.data) ===
|
|
8803
|
+
if (Ember.typeOf(data.data) === 'array') {
|
|
8759
8804
|
var internalModels = data.data.map(function (recordData) {
|
|
8760
8805
|
return _this3._pushInternalModel(recordData);
|
|
8761
8806
|
});
|
|
@@ -8777,8 +8822,8 @@
|
|
|
8777
8822
|
var _this4 = this;
|
|
8778
8823
|
|
|
8779
8824
|
var modelName = data.type;
|
|
8780
|
-
Ember.assert("Expected an object as 'data' in a call to 'push' for " + modelName + ", but was " + Ember.typeOf(data), Ember.typeOf(data) ===
|
|
8781
|
-
Ember.assert("You must include an 'id' for " + modelName + " in an object passed to 'push'", data.id != null && data.id !==
|
|
8825
|
+
Ember.assert("Expected an object as 'data' in a call to 'push' for " + modelName + ", but was " + Ember.typeOf(data), Ember.typeOf(data) === 'object');
|
|
8826
|
+
Ember.assert("You must include an 'id' for " + modelName + " in an object passed to 'push'", data.id != null && data.id !== '');
|
|
8782
8827
|
Ember.assert("You tried to push data with a type '" + modelName + "' but no model could be found with that name.", this._hasModelFor(modelName));
|
|
8783
8828
|
|
|
8784
8829
|
var type = this.modelFor(modelName);
|
|
@@ -8788,17 +8833,17 @@
|
|
|
8788
8833
|
|
|
8789
8834
|
if (Ember.ENV.DS_WARN_ON_UNKNOWN_KEYS) {
|
|
8790
8835
|
Ember.warn("The payload for '" + type.modelName + "' contains these unknown keys: " + Ember.inspect(Object.keys(data).forEach(function (key) {
|
|
8791
|
-
return !(key ===
|
|
8836
|
+
return !(key === 'id' || key === 'links' || ember$data$lib$system$store$$get(type, 'fields').has(key) || key.match(/Type$/));
|
|
8792
8837
|
})) + ". Make sure they've been defined in your model.", Object.keys(data).filter(function (key) {
|
|
8793
|
-
return !(key ===
|
|
8794
|
-
}).length === 0, { id:
|
|
8838
|
+
return !(key === 'id' || key === 'links' || ember$data$lib$system$store$$get(type, 'fields').has(key) || key.match(/Type$/));
|
|
8839
|
+
}).length === 0, { id: 'ds.store.unknown-keys-in-payload' });
|
|
8795
8840
|
}
|
|
8796
8841
|
|
|
8797
8842
|
// Actually load the record into the store.
|
|
8798
8843
|
var internalModel = this._load(data);
|
|
8799
8844
|
|
|
8800
8845
|
this._backburner.join(function () {
|
|
8801
|
-
_this4._backburner.schedule(
|
|
8846
|
+
_this4._backburner.schedule('normalizeRelationships', _this4, '_setupRelationships', internalModel, type, data);
|
|
8802
8847
|
});
|
|
8803
8848
|
|
|
8804
8849
|
return internalModel;
|
|
@@ -8871,10 +8916,10 @@
|
|
|
8871
8916
|
if (!inputPayload) {
|
|
8872
8917
|
payload = modelName;
|
|
8873
8918
|
serializer = ember$data$lib$system$store$$defaultSerializer(this);
|
|
8874
|
-
Ember.assert("You cannot use `store#pushPayload` without a modelName unless your default serializer defines `pushPayload`", typeof serializer.pushPayload ===
|
|
8919
|
+
Ember.assert("You cannot use `store#pushPayload` without a modelName unless your default serializer defines `pushPayload`", typeof serializer.pushPayload === 'function');
|
|
8875
8920
|
} else {
|
|
8876
8921
|
payload = inputPayload;
|
|
8877
|
-
Ember.assert("Passing classes to store methods has been removed. Please pass a dasherized string instead of " + Ember.inspect(modelName), typeof modelName ===
|
|
8922
|
+
Ember.assert("Passing classes to store methods has been removed. Please pass a dasherized string instead of " + Ember.inspect(modelName), typeof modelName === 'string');
|
|
8878
8923
|
serializer = this.serializerFor(modelName);
|
|
8879
8924
|
}
|
|
8880
8925
|
this._adapterRun(function () {
|
|
@@ -8899,7 +8944,7 @@
|
|
|
8899
8944
|
@return {Object} The normalized payload
|
|
8900
8945
|
*/
|
|
8901
8946
|
normalize: function (modelName, payload) {
|
|
8902
|
-
Ember.assert("Passing classes to store methods has been removed. Please pass a dasherized string instead of " + Ember.inspect(modelName), typeof modelName ===
|
|
8947
|
+
Ember.assert("Passing classes to store methods has been removed. Please pass a dasherized string instead of " + Ember.inspect(modelName), typeof modelName === 'string');
|
|
8903
8948
|
var serializer = this.serializerFor(modelName);
|
|
8904
8949
|
var model = this.modelFor(modelName);
|
|
8905
8950
|
return serializer.normalize(model, payload);
|
|
@@ -8920,7 +8965,7 @@
|
|
|
8920
8965
|
var idToRecord = typeMap.idToRecord;
|
|
8921
8966
|
|
|
8922
8967
|
Ember.assert("The id " + id + " has already been used with another record of type " + type.toString() + ".", !id || !idToRecord[id]);
|
|
8923
|
-
Ember.assert("'" + Ember.inspect(type) + "' does not appear to be an ember-data model", typeof type._create ===
|
|
8968
|
+
Ember.assert("'" + Ember.inspect(type) + "' does not appear to be an ember-data model", typeof type._create === 'function');
|
|
8924
8969
|
|
|
8925
8970
|
// lookupFactory should really return an object that creates
|
|
8926
8971
|
// instances with the injections applied
|
|
@@ -8989,10 +9034,10 @@
|
|
|
8989
9034
|
adapterFor: function (modelOrClass) {
|
|
8990
9035
|
var modelName;
|
|
8991
9036
|
|
|
8992
|
-
if (typeof modelOrClass ===
|
|
9037
|
+
if (typeof modelOrClass === 'string') {
|
|
8993
9038
|
modelName = modelOrClass;
|
|
8994
9039
|
} else {
|
|
8995
|
-
Ember.deprecate("Passing classes to store methods has been removed. Please pass a dasherized string instead of " + Ember.inspect(modelName), false, { id:
|
|
9040
|
+
Ember.deprecate("Passing classes to store methods has been removed. Please pass a dasherized string instead of " + Ember.inspect(modelName), false, { id: 'ds.store.passing-classes-deprecated', until: '2.0.0' });
|
|
8996
9041
|
modelName = modelOrClass.modelName;
|
|
8997
9042
|
}
|
|
8998
9043
|
|
|
@@ -9027,14 +9072,14 @@
|
|
|
9027
9072
|
serializerFor: function (modelOrClass) {
|
|
9028
9073
|
var modelName;
|
|
9029
9074
|
|
|
9030
|
-
if (typeof modelOrClass ===
|
|
9075
|
+
if (typeof modelOrClass === 'string') {
|
|
9031
9076
|
modelName = modelOrClass;
|
|
9032
9077
|
} else {
|
|
9033
|
-
Ember.deprecate("Passing classes to store methods has been removed. Please pass a dasherized string instead of " + Ember.inspect(modelName), false, { id:
|
|
9078
|
+
Ember.deprecate("Passing classes to store methods has been removed. Please pass a dasherized string instead of " + Ember.inspect(modelName), false, { id: 'ds.store.passing-classes-deprecated', until: '2.0.0' });
|
|
9034
9079
|
modelName = modelOrClass.modelName;
|
|
9035
9080
|
}
|
|
9036
9081
|
|
|
9037
|
-
var fallbacks = [
|
|
9082
|
+
var fallbacks = ['application', this.adapterFor(modelName).get('defaultSerializer'), '-default'];
|
|
9038
9083
|
|
|
9039
9084
|
var serializer = this.lookupSerializer(modelName, fallbacks);
|
|
9040
9085
|
return serializer;
|
|
@@ -9057,21 +9102,21 @@
|
|
|
9057
9102
|
var normalizedModelName = ember$data$lib$system$normalize$model$name$$default(modelName);
|
|
9058
9103
|
|
|
9059
9104
|
var instance = this._instanceCache.get(type, normalizedModelName, fallbacks);
|
|
9060
|
-
ember$data$lib$system$store$$set(instance,
|
|
9105
|
+
ember$data$lib$system$store$$set(instance, 'store', this);
|
|
9061
9106
|
return instance;
|
|
9062
9107
|
},
|
|
9063
9108
|
|
|
9064
9109
|
lookupAdapter: function (name) {
|
|
9065
|
-
return this.retrieveManagedInstance(
|
|
9110
|
+
return this.retrieveManagedInstance('adapter', name, this.get('_adapterFallbacks'));
|
|
9066
9111
|
},
|
|
9067
9112
|
|
|
9068
|
-
_adapterFallbacks: Ember.computed(
|
|
9069
|
-
var adapter = this.get(
|
|
9070
|
-
return [
|
|
9113
|
+
_adapterFallbacks: Ember.computed('adapter', function () {
|
|
9114
|
+
var adapter = this.get('adapter');
|
|
9115
|
+
return ['application', adapter, '-json-api'];
|
|
9071
9116
|
}),
|
|
9072
9117
|
|
|
9073
9118
|
lookupSerializer: function (name, fallbacks) {
|
|
9074
|
-
return this.retrieveManagedInstance(
|
|
9119
|
+
return this.retrieveManagedInstance('serializer', name, fallbacks);
|
|
9075
9120
|
},
|
|
9076
9121
|
|
|
9077
9122
|
willDestroy: function () {
|
|
@@ -9097,9 +9142,9 @@
|
|
|
9097
9142
|
var value;
|
|
9098
9143
|
if (data.relationships[key] && data.relationships[key].data) {
|
|
9099
9144
|
value = data.relationships[key].data;
|
|
9100
|
-
if (kind ===
|
|
9145
|
+
if (kind === 'belongsTo') {
|
|
9101
9146
|
data.relationships[key].data = ember$data$lib$system$store$$deserializeRecordId(store, key, relationship, value);
|
|
9102
|
-
} else if (kind ===
|
|
9147
|
+
} else if (kind === 'hasMany') {
|
|
9103
9148
|
data.relationships[key].data = ember$data$lib$system$store$$deserializeRecordIds(store, key, relationship, value);
|
|
9104
9149
|
}
|
|
9105
9150
|
}
|
|
@@ -9133,7 +9178,7 @@
|
|
|
9133
9178
|
// Delegation to the adapter and promise management
|
|
9134
9179
|
|
|
9135
9180
|
function ember$data$lib$system$store$$defaultSerializer(store) {
|
|
9136
|
-
return store.serializerFor(
|
|
9181
|
+
return store.serializerFor('application');
|
|
9137
9182
|
}
|
|
9138
9183
|
|
|
9139
9184
|
function ember$data$lib$system$store$$_commit(adapter, store, operation, snapshot) {
|
|
@@ -9202,10 +9247,10 @@
|
|
|
9202
9247
|
var value = data.relationships[key].data;
|
|
9203
9248
|
|
|
9204
9249
|
if (value !== undefined) {
|
|
9205
|
-
if (kind ===
|
|
9250
|
+
if (kind === 'belongsTo') {
|
|
9206
9251
|
relationship = record._relationships.get(key);
|
|
9207
9252
|
relationship.setCanonicalRecord(value);
|
|
9208
|
-
} else if (kind ===
|
|
9253
|
+
} else if (kind === 'hasMany') {
|
|
9209
9254
|
relationship = record._relationships.get(key);
|
|
9210
9255
|
relationship.updateRecordsFromAdapter(value);
|
|
9211
9256
|
}
|
|
@@ -9355,7 +9400,7 @@
|
|
|
9355
9400
|
@type {String}
|
|
9356
9401
|
@default 'id'
|
|
9357
9402
|
*/
|
|
9358
|
-
primaryKey:
|
|
9403
|
+
primaryKey: 'id',
|
|
9359
9404
|
|
|
9360
9405
|
/**
|
|
9361
9406
|
The `attrs` object can be used to declare a simple mapping between
|
|
@@ -9406,7 +9451,7 @@
|
|
|
9406
9451
|
@property attrs
|
|
9407
9452
|
@type {Object}
|
|
9408
9453
|
*/
|
|
9409
|
-
mergedProperties: [
|
|
9454
|
+
mergedProperties: ['attrs'],
|
|
9410
9455
|
|
|
9411
9456
|
/**
|
|
9412
9457
|
Given a subclass of `DS.Model` and a JSON object this method will
|
|
@@ -9464,25 +9509,25 @@
|
|
|
9464
9509
|
*/
|
|
9465
9510
|
normalizeResponse: function (store, primaryModelClass, payload, id, requestType) {
|
|
9466
9511
|
switch (requestType) {
|
|
9467
|
-
case
|
|
9512
|
+
case 'findRecord':
|
|
9468
9513
|
return this.normalizeFindRecordResponse.apply(this, arguments);
|
|
9469
|
-
case
|
|
9514
|
+
case 'queryRecord':
|
|
9470
9515
|
return this.normalizeQueryRecordResponse.apply(this, arguments);
|
|
9471
|
-
case
|
|
9516
|
+
case 'findAll':
|
|
9472
9517
|
return this.normalizeFindAllResponse.apply(this, arguments);
|
|
9473
|
-
case
|
|
9518
|
+
case 'findBelongsTo':
|
|
9474
9519
|
return this.normalizeFindBelongsToResponse.apply(this, arguments);
|
|
9475
|
-
case
|
|
9520
|
+
case 'findHasMany':
|
|
9476
9521
|
return this.normalizeFindHasManyResponse.apply(this, arguments);
|
|
9477
|
-
case
|
|
9522
|
+
case 'findMany':
|
|
9478
9523
|
return this.normalizeFindManyResponse.apply(this, arguments);
|
|
9479
|
-
case
|
|
9524
|
+
case 'query':
|
|
9480
9525
|
return this.normalizeQueryResponse.apply(this, arguments);
|
|
9481
|
-
case
|
|
9526
|
+
case 'createRecord':
|
|
9482
9527
|
return this.normalizeCreateRecordResponse.apply(this, arguments);
|
|
9483
|
-
case
|
|
9528
|
+
case 'deleteRecord':
|
|
9484
9529
|
return this.normalizeDeleteRecordResponse.apply(this, arguments);
|
|
9485
|
-
case
|
|
9530
|
+
case 'updateRecord':
|
|
9486
9531
|
return this.normalizeUpdateRecordResponse.apply(this, arguments);
|
|
9487
9532
|
}
|
|
9488
9533
|
},
|
|
@@ -9677,7 +9722,7 @@
|
|
|
9677
9722
|
|
|
9678
9723
|
var meta = this.extractMeta(store, primaryModelClass, payload);
|
|
9679
9724
|
if (meta) {
|
|
9680
|
-
Ember.assert(
|
|
9725
|
+
Ember.assert('The `meta` returned from `extractMeta` has to be an object, not "' + Ember.typeOf(meta) + '".', Ember.typeOf(meta) === 'object');
|
|
9681
9726
|
documentHash.meta = meta;
|
|
9682
9727
|
}
|
|
9683
9728
|
|
|
@@ -9767,7 +9812,7 @@
|
|
|
9767
9812
|
@return {String}
|
|
9768
9813
|
*/
|
|
9769
9814
|
extractId: function (modelClass, resourceHash) {
|
|
9770
|
-
var primaryKey = ember$data$lib$serializers$json$serializer$$get(this,
|
|
9815
|
+
var primaryKey = ember$data$lib$serializers$json$serializer$$get(this, 'primaryKey');
|
|
9771
9816
|
var id = resourceHash[primaryKey];
|
|
9772
9817
|
return ember$data$lib$system$coerce$id$$default(id);
|
|
9773
9818
|
},
|
|
@@ -9787,7 +9832,7 @@
|
|
|
9787
9832
|
var attributes = {};
|
|
9788
9833
|
|
|
9789
9834
|
modelClass.eachAttribute(function (key) {
|
|
9790
|
-
attributeKey = _this3.keyForAttribute(key,
|
|
9835
|
+
attributeKey = _this3.keyForAttribute(key, 'deserialize');
|
|
9791
9836
|
if (resourceHash.hasOwnProperty(attributeKey)) {
|
|
9792
9837
|
attributes[key] = resourceHash[attributeKey];
|
|
9793
9838
|
}
|
|
@@ -9813,7 +9858,7 @@
|
|
|
9813
9858
|
is polymorphic. It could however also be embedded resources that the
|
|
9814
9859
|
EmbeddedRecordsMixin has be able to process.
|
|
9815
9860
|
*/
|
|
9816
|
-
if (Ember.typeOf(relationshipHash) ===
|
|
9861
|
+
if (Ember.typeOf(relationshipHash) === 'object') {
|
|
9817
9862
|
if (relationshipHash.id) {
|
|
9818
9863
|
relationshipHash.id = ember$data$lib$system$coerce$id$$default(relationshipHash.id);
|
|
9819
9864
|
}
|
|
@@ -9840,13 +9885,13 @@
|
|
|
9840
9885
|
|
|
9841
9886
|
modelClass.eachRelationship(function (key, relationshipMeta) {
|
|
9842
9887
|
var relationship = null;
|
|
9843
|
-
var relationshipKey = _this4.keyForRelationship(key, relationshipMeta.kind,
|
|
9888
|
+
var relationshipKey = _this4.keyForRelationship(key, relationshipMeta.kind, 'deserialize');
|
|
9844
9889
|
if (resourceHash.hasOwnProperty(relationshipKey)) {
|
|
9845
9890
|
var data = null;
|
|
9846
9891
|
var relationshipHash = resourceHash[relationshipKey];
|
|
9847
|
-
if (relationshipMeta.kind ===
|
|
9892
|
+
if (relationshipMeta.kind === 'belongsTo') {
|
|
9848
9893
|
data = _this4.extractRelationship(relationshipMeta.type, relationshipHash);
|
|
9849
|
-
} else if (relationshipMeta.kind ===
|
|
9894
|
+
} else if (relationshipMeta.kind === 'hasMany') {
|
|
9850
9895
|
data = relationshipHash.map(function (item) {
|
|
9851
9896
|
return _this4.extractRelationship(relationshipMeta.type, item);
|
|
9852
9897
|
});
|
|
@@ -9911,7 +9956,7 @@
|
|
|
9911
9956
|
|
|
9912
9957
|
if (this.keyForAttribute) {
|
|
9913
9958
|
typeClass.eachAttribute(function (key) {
|
|
9914
|
-
payloadKey = _this5.keyForAttribute(key,
|
|
9959
|
+
payloadKey = _this5.keyForAttribute(key, 'deserialize');
|
|
9915
9960
|
if (key === payloadKey) {
|
|
9916
9961
|
return;
|
|
9917
9962
|
}
|
|
@@ -9936,7 +9981,7 @@
|
|
|
9936
9981
|
|
|
9937
9982
|
if (this.keyForRelationship) {
|
|
9938
9983
|
typeClass.eachRelationship(function (key, relationship) {
|
|
9939
|
-
payloadKey = _this6.keyForRelationship(key, relationship.kind,
|
|
9984
|
+
payloadKey = _this6.keyForRelationship(key, relationship.kind, 'deserialize');
|
|
9940
9985
|
if (key === payloadKey) {
|
|
9941
9986
|
return;
|
|
9942
9987
|
}
|
|
@@ -9955,7 +10000,7 @@
|
|
|
9955
10000
|
@private
|
|
9956
10001
|
*/
|
|
9957
10002
|
normalizeUsingDeclaredMapping: function (typeClass, hash) {
|
|
9958
|
-
var attrs = ember$data$lib$serializers$json$serializer$$get(this,
|
|
10003
|
+
var attrs = ember$data$lib$serializers$json$serializer$$get(this, 'attrs');
|
|
9959
10004
|
var payloadKey, key;
|
|
9960
10005
|
|
|
9961
10006
|
if (attrs) {
|
|
@@ -9978,9 +10023,9 @@
|
|
|
9978
10023
|
@private
|
|
9979
10024
|
*/
|
|
9980
10025
|
normalizeId: function (hash) {
|
|
9981
|
-
var primaryKey = ember$data$lib$serializers$json$serializer$$get(this,
|
|
10026
|
+
var primaryKey = ember$data$lib$serializers$json$serializer$$get(this, 'primaryKey');
|
|
9982
10027
|
|
|
9983
|
-
if (primaryKey ===
|
|
10028
|
+
if (primaryKey === 'id') {
|
|
9984
10029
|
return;
|
|
9985
10030
|
}
|
|
9986
10031
|
|
|
@@ -9997,7 +10042,7 @@
|
|
|
9997
10042
|
@return {String} key
|
|
9998
10043
|
*/
|
|
9999
10044
|
_getMappedKey: function (key) {
|
|
10000
|
-
var attrs = ember$data$lib$serializers$json$serializer$$get(this,
|
|
10045
|
+
var attrs = ember$data$lib$serializers$json$serializer$$get(this, 'attrs');
|
|
10001
10046
|
var mappedKey;
|
|
10002
10047
|
if (attrs && attrs[key]) {
|
|
10003
10048
|
mappedKey = attrs[key];
|
|
@@ -10006,7 +10051,7 @@
|
|
|
10006
10051
|
if (mappedKey.key) {
|
|
10007
10052
|
mappedKey = mappedKey.key;
|
|
10008
10053
|
}
|
|
10009
|
-
if (typeof mappedKey ===
|
|
10054
|
+
if (typeof mappedKey === 'string') {
|
|
10010
10055
|
key = mappedKey;
|
|
10011
10056
|
}
|
|
10012
10057
|
}
|
|
@@ -10023,7 +10068,7 @@
|
|
|
10023
10068
|
@return {boolean} true if the key can be serialized
|
|
10024
10069
|
*/
|
|
10025
10070
|
_canSerialize: function (key) {
|
|
10026
|
-
var attrs = ember$data$lib$serializers$json$serializer$$get(this,
|
|
10071
|
+
var attrs = ember$data$lib$serializers$json$serializer$$get(this, 'attrs');
|
|
10027
10072
|
|
|
10028
10073
|
return !attrs || !attrs[key] || attrs[key].serialize !== false;
|
|
10029
10074
|
},
|
|
@@ -10038,7 +10083,7 @@
|
|
|
10038
10083
|
@return {boolean} true if the key must be serialized
|
|
10039
10084
|
*/
|
|
10040
10085
|
_mustSerialize: function (key) {
|
|
10041
|
-
var attrs = ember$data$lib$serializers$json$serializer$$get(this,
|
|
10086
|
+
var attrs = ember$data$lib$serializers$json$serializer$$get(this, 'attrs');
|
|
10042
10087
|
|
|
10043
10088
|
return attrs && attrs[key] && attrs[key].serialize === true;
|
|
10044
10089
|
},
|
|
@@ -10057,7 +10102,7 @@
|
|
|
10057
10102
|
if (this._mustSerialize(key)) {
|
|
10058
10103
|
return true;
|
|
10059
10104
|
}
|
|
10060
|
-
return this._canSerialize(key) && (relationshipType ===
|
|
10105
|
+
return this._canSerialize(key) && (relationshipType === 'manyToNone' || relationshipType === 'manyToMany');
|
|
10061
10106
|
},
|
|
10062
10107
|
|
|
10063
10108
|
// SERIALIZE
|
|
@@ -10183,7 +10228,7 @@
|
|
|
10183
10228
|
var id = snapshot.id;
|
|
10184
10229
|
|
|
10185
10230
|
if (id) {
|
|
10186
|
-
json[ember$data$lib$serializers$json$serializer$$get(this,
|
|
10231
|
+
json[ember$data$lib$serializers$json$serializer$$get(this, 'primaryKey')] = id;
|
|
10187
10232
|
}
|
|
10188
10233
|
}
|
|
10189
10234
|
|
|
@@ -10192,9 +10237,9 @@
|
|
|
10192
10237
|
});
|
|
10193
10238
|
|
|
10194
10239
|
snapshot.eachRelationship(function (key, relationship) {
|
|
10195
|
-
if (relationship.kind ===
|
|
10240
|
+
if (relationship.kind === 'belongsTo') {
|
|
10196
10241
|
_this7.serializeBelongsTo(snapshot, json, relationship);
|
|
10197
|
-
} else if (relationship.kind ===
|
|
10242
|
+
} else if (relationship.kind === 'hasMany') {
|
|
10198
10243
|
_this7.serializeHasMany(snapshot, json, relationship);
|
|
10199
10244
|
}
|
|
10200
10245
|
});
|
|
@@ -10264,7 +10309,7 @@
|
|
|
10264
10309
|
var payloadKey = this._getMappedKey(key);
|
|
10265
10310
|
|
|
10266
10311
|
if (payloadKey === key && this.keyForAttribute) {
|
|
10267
|
-
payloadKey = this.keyForAttribute(key,
|
|
10312
|
+
payloadKey = this.keyForAttribute(key, 'serialize');
|
|
10268
10313
|
}
|
|
10269
10314
|
|
|
10270
10315
|
json[payloadKey] = value;
|
|
@@ -10406,7 +10451,7 @@
|
|
|
10406
10451
|
@param {Object} payload
|
|
10407
10452
|
*/
|
|
10408
10453
|
extractMeta: function (store, modelClass, payload) {
|
|
10409
|
-
if (payload && payload.hasOwnProperty(
|
|
10454
|
+
if (payload && payload.hasOwnProperty('meta')) {
|
|
10410
10455
|
var meta = payload.meta;
|
|
10411
10456
|
delete payload.meta;
|
|
10412
10457
|
return meta;
|
|
@@ -10441,13 +10486,13 @@
|
|
|
10441
10486
|
extractErrors: function (store, typeClass, payload, id) {
|
|
10442
10487
|
var _this8 = this;
|
|
10443
10488
|
|
|
10444
|
-
if (payload && typeof payload ===
|
|
10489
|
+
if (payload && typeof payload === 'object' && payload.errors) {
|
|
10445
10490
|
payload = ember$data$lib$adapters$errors$$errorsArrayToHash(payload.errors);
|
|
10446
10491
|
|
|
10447
10492
|
this.normalizeUsingDeclaredMapping(typeClass, payload);
|
|
10448
10493
|
|
|
10449
10494
|
typeClass.eachAttribute(function (name) {
|
|
10450
|
-
var key = _this8.keyForAttribute(name,
|
|
10495
|
+
var key = _this8.keyForAttribute(name, 'deserialize');
|
|
10451
10496
|
if (key !== name && payload.hasOwnProperty(key)) {
|
|
10452
10497
|
payload[name] = payload[key];
|
|
10453
10498
|
delete payload[key];
|
|
@@ -10455,7 +10500,7 @@
|
|
|
10455
10500
|
});
|
|
10456
10501
|
|
|
10457
10502
|
typeClass.eachRelationship(function (name) {
|
|
10458
|
-
var key = _this8.keyForRelationship(name,
|
|
10503
|
+
var key = _this8.keyForRelationship(name, 'deserialize');
|
|
10459
10504
|
if (key !== name && payload.hasOwnProperty(key)) {
|
|
10460
10505
|
payload[name] = payload[key];
|
|
10461
10506
|
delete payload[key];
|
|
@@ -10532,7 +10577,7 @@
|
|
|
10532
10577
|
@return {DS.Transform} transform
|
|
10533
10578
|
*/
|
|
10534
10579
|
transformFor: function (attributeType, skipAssertion) {
|
|
10535
|
-
var transform = this.container.lookup(
|
|
10580
|
+
var transform = this.container.lookup('transform:' + attributeType);
|
|
10536
10581
|
Ember.assert("Unable to find transform for '" + attributeType + "'", skipAssertion || !!transform);
|
|
10537
10582
|
return transform;
|
|
10538
10583
|
}
|
|
@@ -10647,7 +10692,7 @@
|
|
|
10647
10692
|
}
|
|
10648
10693
|
|
|
10649
10694
|
if (!Object.create && !Object.create(null).hasOwnProperty) {
|
|
10650
|
-
throw new Error(
|
|
10695
|
+
throw new Error("This browser does not support Object.create(null), please polyfil with es5-sham: http://git.io/yBU2rg");
|
|
10651
10696
|
}
|
|
10652
10697
|
|
|
10653
10698
|
function ember$inflector$lib$lib$system$inflector$$makeDictionary() {
|
|
@@ -10788,7 +10833,7 @@
|
|
|
10788
10833
|
isBlank = !word || ember$inflector$lib$lib$system$inflector$$BLANK_REGEX.test(word);
|
|
10789
10834
|
|
|
10790
10835
|
isCamelized = ember$inflector$lib$lib$system$inflector$$CAMELIZED_REGEX.test(word);
|
|
10791
|
-
firstPhrase =
|
|
10836
|
+
firstPhrase = "";
|
|
10792
10837
|
|
|
10793
10838
|
if (isBlank) {
|
|
10794
10839
|
return word;
|
|
@@ -10803,13 +10848,13 @@
|
|
|
10803
10848
|
}
|
|
10804
10849
|
|
|
10805
10850
|
for (rule in this.rules.uncountable) {
|
|
10806
|
-
if (lowercase.match(rule +
|
|
10851
|
+
if (lowercase.match(rule + "$")) {
|
|
10807
10852
|
return word;
|
|
10808
10853
|
}
|
|
10809
10854
|
}
|
|
10810
10855
|
|
|
10811
10856
|
for (rule in this.rules.irregular) {
|
|
10812
|
-
if (lowercase.match(rule +
|
|
10857
|
+
if (lowercase.match(rule + "$")) {
|
|
10813
10858
|
substitution = irregular[rule];
|
|
10814
10859
|
|
|
10815
10860
|
if (isCamelized && irregular[lastWord]) {
|
|
@@ -11371,7 +11416,7 @@
|
|
|
11371
11416
|
|
|
11372
11417
|
var meta = this.extractMeta(store, primaryModelClass, payload);
|
|
11373
11418
|
if (meta) {
|
|
11374
|
-
Ember.assert(
|
|
11419
|
+
Ember.assert('The `meta` returned from `extractMeta` has to be an object, not "' + Ember.typeOf(meta) + '".', Ember.typeOf(meta) === 'object');
|
|
11375
11420
|
documentHash.meta = meta;
|
|
11376
11421
|
}
|
|
11377
11422
|
|
|
@@ -11399,7 +11444,7 @@
|
|
|
11399
11444
|
```
|
|
11400
11445
|
This forces `_users` to be added to `included` instead of `data`.
|
|
11401
11446
|
*/
|
|
11402
|
-
if (prop.charAt(0) ===
|
|
11447
|
+
if (prop.charAt(0) === '_') {
|
|
11403
11448
|
forcedSecondary = true;
|
|
11404
11449
|
modelName = prop.substr(1);
|
|
11405
11450
|
}
|
|
@@ -11407,7 +11452,7 @@
|
|
|
11407
11452
|
var typeName = this.modelNameFromPayloadKey(modelName);
|
|
11408
11453
|
if (!store.modelFactoryFor(typeName)) {
|
|
11409
11454
|
Ember.warn(this.warnMessageNoModelForKey(modelName, typeName), false, {
|
|
11410
|
-
id:
|
|
11455
|
+
id: 'ds.serializer.model-for-key-missing'
|
|
11411
11456
|
});
|
|
11412
11457
|
continue;
|
|
11413
11458
|
}
|
|
@@ -11428,7 +11473,7 @@
|
|
|
11428
11473
|
}
|
|
11429
11474
|
```
|
|
11430
11475
|
*/
|
|
11431
|
-
if (isPrimary && Ember.typeOf(value) !==
|
|
11476
|
+
if (isPrimary && Ember.typeOf(value) !== 'array') {
|
|
11432
11477
|
var _normalize = this.normalize(primaryModelClass, value, prop);
|
|
11433
11478
|
|
|
11434
11479
|
var _data = _normalize.data;
|
|
@@ -11533,7 +11578,7 @@
|
|
|
11533
11578
|
var modelName = this.modelNameFromPayloadKey(prop);
|
|
11534
11579
|
if (!store.modelFactoryFor(modelName)) {
|
|
11535
11580
|
Ember.warn(this.warnMessageNoModelForKey(prop, modelName), false, {
|
|
11536
|
-
id:
|
|
11581
|
+
id: 'ds.serializer.model-for-key-missing'
|
|
11537
11582
|
});
|
|
11538
11583
|
continue;
|
|
11539
11584
|
}
|
|
@@ -11819,7 +11864,7 @@
|
|
|
11819
11864
|
Ember.runInDebug(function () {
|
|
11820
11865
|
ember$data$lib$serializers$rest$serializer$$RESTSerializer.reopen({
|
|
11821
11866
|
warnMessageNoModelForKey: function (prop, typeKey) {
|
|
11822
|
-
return
|
|
11867
|
+
return 'Encountered "' + prop + '" in payload, but no model was found for model name "' + typeKey + '" (resolved model name using ' + this.constructor.toString() + '.modelNameFromPayloadKey("' + prop + '"))';
|
|
11823
11868
|
}
|
|
11824
11869
|
});
|
|
11825
11870
|
});
|
|
@@ -11836,18 +11881,18 @@
|
|
|
11836
11881
|
@param {Object} [application] an application namespace
|
|
11837
11882
|
*/
|
|
11838
11883
|
function ember$data$lib$initializers$store$$initializeStore(registry, application) {
|
|
11839
|
-
registry.optionsForType(
|
|
11840
|
-
registry.optionsForType(
|
|
11884
|
+
registry.optionsForType('serializer', { singleton: false });
|
|
11885
|
+
registry.optionsForType('adapter', { singleton: false });
|
|
11841
11886
|
|
|
11842
|
-
registry.register(
|
|
11843
|
-
registry.register(
|
|
11844
|
-
registry.register(
|
|
11887
|
+
registry.register('serializer:-default', ember$data$lib$serializers$json$serializer$$default);
|
|
11888
|
+
registry.register('serializer:-rest', ember$data$lib$serializers$rest$serializer$$default);
|
|
11889
|
+
registry.register('adapter:-rest', ember$data$lib$adapters$rest$adapter$$default);
|
|
11845
11890
|
|
|
11846
|
-
registry.register(
|
|
11847
|
-
registry.register(
|
|
11891
|
+
registry.register('adapter:-json-api', ember$data$lib$adapters$json$api$adapter$$default);
|
|
11892
|
+
registry.register('serializer:-json-api', ember$data$lib$serializers$json$api$serializer$$default);
|
|
11848
11893
|
|
|
11849
|
-
if (!registry.has(
|
|
11850
|
-
registry.register(
|
|
11894
|
+
if (!registry.has('service:store')) {
|
|
11895
|
+
registry.register('service:store', ember$data$lib$system$store$$default);
|
|
11851
11896
|
}
|
|
11852
11897
|
}
|
|
11853
11898
|
|
|
@@ -12050,7 +12095,7 @@
|
|
|
12050
12095
|
|
|
12051
12096
|
this.eachComputedProperty(function (name, meta) {
|
|
12052
12097
|
if (meta.isAttribute) {
|
|
12053
|
-
Ember.assert("You may not set `id` as an attribute on your model. Please remove any lines that look like: `id: DS.attr('<type>')` from " + _this.toString(), name !==
|
|
12098
|
+
Ember.assert("You may not set `id` as an attribute on your model. Please remove any lines that look like: `id: DS.attr('<type>')` from " + _this.toString(), name !== 'id');
|
|
12054
12099
|
|
|
12055
12100
|
meta.name = name;
|
|
12056
12101
|
map.set(name, meta);
|
|
@@ -12136,7 +12181,7 @@
|
|
|
12136
12181
|
@static
|
|
12137
12182
|
*/
|
|
12138
12183
|
eachAttribute: function (callback, binding) {
|
|
12139
|
-
ember$data$lib$system$model$attributes$$get(this,
|
|
12184
|
+
ember$data$lib$system$model$attributes$$get(this, 'attributes').forEach(function (meta, name) {
|
|
12140
12185
|
callback.call(binding, name, meta);
|
|
12141
12186
|
});
|
|
12142
12187
|
},
|
|
@@ -12176,7 +12221,7 @@
|
|
|
12176
12221
|
@static
|
|
12177
12222
|
*/
|
|
12178
12223
|
eachTransformedAttribute: function (callback, binding) {
|
|
12179
|
-
ember$data$lib$system$model$attributes$$get(this,
|
|
12224
|
+
ember$data$lib$system$model$attributes$$get(this, 'transformedAttributes').forEach(function (type, name) {
|
|
12180
12225
|
callback.call(binding, name, type);
|
|
12181
12226
|
});
|
|
12182
12227
|
}
|
|
@@ -12261,7 +12306,7 @@
|
|
|
12261
12306
|
@return {Attribute}
|
|
12262
12307
|
*/
|
|
12263
12308
|
function ember$data$lib$system$model$attributes$$attr(type, options) {
|
|
12264
|
-
if (typeof type ===
|
|
12309
|
+
if (typeof type === 'object') {
|
|
12265
12310
|
options = type;
|
|
12266
12311
|
type = undefined;
|
|
12267
12312
|
} else {
|
|
@@ -12284,7 +12329,7 @@
|
|
|
12284
12329
|
}
|
|
12285
12330
|
},
|
|
12286
12331
|
set: function (key, value) {
|
|
12287
|
-
Ember.assert("You may not set `id` as an attribute on your model. Please remove any lines that look like: `id: DS.attr('<type>')` from " + this.constructor.toString(), key !==
|
|
12332
|
+
Ember.assert("You may not set `id` as an attribute on your model. Please remove any lines that look like: `id: DS.attr('<type>')` from " + this.constructor.toString(), key !== 'id');
|
|
12288
12333
|
var internalModel = this._internalModel;
|
|
12289
12334
|
var oldValue = ember$data$lib$system$model$attributes$$getValue(internalModel, key);
|
|
12290
12335
|
|
|
@@ -12293,7 +12338,7 @@
|
|
|
12293
12338
|
// the 'didSetProperty' handler if it is no different from the original value
|
|
12294
12339
|
internalModel._attributes[key] = value;
|
|
12295
12340
|
|
|
12296
|
-
this._internalModel.send(
|
|
12341
|
+
this._internalModel.send('didSetProperty', {
|
|
12297
12342
|
name: key,
|
|
12298
12343
|
oldValue: oldValue,
|
|
12299
12344
|
originalValue: internalModel._data[key],
|
|
@@ -12349,7 +12394,7 @@
|
|
|
12349
12394
|
}
|
|
12350
12395
|
}
|
|
12351
12396
|
}
|
|
12352
|
-
ember$data$lib$system$debug$debug$adapter$$assert(
|
|
12397
|
+
ember$data$lib$system$debug$debug$adapter$$assert("Cannot find model name. Please upgrade to Ember.js >= 1.13 for Ember Inspector support", !!modelName);
|
|
12353
12398
|
return this.get('store').peekAll(modelName);
|
|
12354
12399
|
},
|
|
12355
12400
|
|
|
@@ -12438,7 +12483,7 @@
|
|
|
12438
12483
|
@param {Ember.Registry} registry
|
|
12439
12484
|
*/
|
|
12440
12485
|
function ember$data$lib$initializers$data$adapter$$initializeDebugAdapter(registry) {
|
|
12441
|
-
registry.register(
|
|
12486
|
+
registry.register('data-adapter:main', ember$data$lib$system$debug$debug$adapter$$default);
|
|
12442
12487
|
}
|
|
12443
12488
|
var ember$data$lib$setup$container$$default = ember$data$lib$setup$container$$setupContainer;
|
|
12444
12489
|
function ember$data$lib$setup$container$$setupContainer(registry, application) {
|
|
@@ -12506,37 +12551,37 @@
|
|
|
12506
12551
|
Ember.onLoad('Ember.Application', function (Application) {
|
|
12507
12552
|
|
|
12508
12553
|
Application.initializer({
|
|
12509
|
-
name:
|
|
12554
|
+
name: "ember-data",
|
|
12510
12555
|
initialize: ember$data$lib$setup$container$$default
|
|
12511
12556
|
});
|
|
12512
12557
|
|
|
12513
12558
|
Application.instanceInitializer({
|
|
12514
|
-
name:
|
|
12559
|
+
name: "ember-data",
|
|
12515
12560
|
initialize: ember$data$lib$instance$initializers$initialize$store$service$$default
|
|
12516
12561
|
});
|
|
12517
12562
|
|
|
12518
12563
|
// Deprecated initializers to satisfy old code that depended on them
|
|
12519
12564
|
Application.initializer({
|
|
12520
|
-
name:
|
|
12521
|
-
after:
|
|
12565
|
+
name: "store",
|
|
12566
|
+
after: "ember-data",
|
|
12522
12567
|
initialize: ember$data$lib$ember$initializer$$K
|
|
12523
12568
|
});
|
|
12524
12569
|
|
|
12525
12570
|
Application.initializer({
|
|
12526
|
-
name:
|
|
12527
|
-
before:
|
|
12571
|
+
name: "transforms",
|
|
12572
|
+
before: "store",
|
|
12528
12573
|
initialize: ember$data$lib$ember$initializer$$K
|
|
12529
12574
|
});
|
|
12530
12575
|
|
|
12531
12576
|
Application.initializer({
|
|
12532
|
-
name:
|
|
12533
|
-
before:
|
|
12577
|
+
name: "data-adapter",
|
|
12578
|
+
before: "store",
|
|
12534
12579
|
initialize: ember$data$lib$ember$initializer$$K
|
|
12535
12580
|
});
|
|
12536
12581
|
|
|
12537
12582
|
Application.initializer({
|
|
12538
|
-
name:
|
|
12539
|
-
before:
|
|
12583
|
+
name: "injectStore",
|
|
12584
|
+
before: "store",
|
|
12540
12585
|
initialize: ember$data$lib$ember$initializer$$K
|
|
12541
12586
|
});
|
|
12542
12587
|
});
|
|
@@ -12688,13 +12733,13 @@
|
|
|
12688
12733
|
ember$lib$main$$default.String.singularize = ember$inflector$lib$lib$system$string$$singularize;
|
|
12689
12734
|
var ember$inflector$lib$main$$default = ember$inflector$lib$lib$system$inflector$$default;
|
|
12690
12735
|
|
|
12691
|
-
if (typeof define !==
|
|
12692
|
-
define(
|
|
12693
|
-
__exports__[
|
|
12736
|
+
if (typeof define !== 'undefined' && define.amd) {
|
|
12737
|
+
define('ember-inflector', ['exports'], function (__exports__) {
|
|
12738
|
+
__exports__['default'] = ember$inflector$lib$lib$system$inflector$$default;
|
|
12694
12739
|
return ember$inflector$lib$lib$system$inflector$$default;
|
|
12695
12740
|
});
|
|
12696
|
-
} else if (typeof module !==
|
|
12697
|
-
module[
|
|
12741
|
+
} else if (typeof module !== 'undefined' && module['exports']) {
|
|
12742
|
+
module['exports'] = ember$inflector$lib$lib$system$inflector$$default;
|
|
12698
12743
|
}var ember$data$lib$serializers$embedded$records$mixin$$get = Ember.get;
|
|
12699
12744
|
var ember$data$lib$serializers$embedded$records$mixin$$set = Ember.set;
|
|
12700
12745
|
var ember$data$lib$serializers$embedded$records$mixin$$camelize = Ember.String.camelize;
|
|
@@ -13074,10 +13119,10 @@
|
|
|
13074
13119
|
|
|
13075
13120
|
typeClass.eachRelationship(function (key, relationship) {
|
|
13076
13121
|
if (serializer.hasDeserializeRecordsOption(key)) {
|
|
13077
|
-
if (relationship.kind ===
|
|
13122
|
+
if (relationship.kind === "hasMany") {
|
|
13078
13123
|
_this2._extractEmbeddedHasMany(store, key, partial, relationship);
|
|
13079
13124
|
}
|
|
13080
|
-
if (relationship.kind ===
|
|
13125
|
+
if (relationship.kind === "belongsTo") {
|
|
13081
13126
|
_this2._extractEmbeddedBelongsTo(store, key, partial, relationship);
|
|
13082
13127
|
}
|
|
13083
13128
|
}
|
|
@@ -13251,7 +13296,7 @@
|
|
|
13251
13296
|
userEnteredModelName = ember$data$lib$system$normalize$model$name$$default(userEnteredModelName);
|
|
13252
13297
|
}
|
|
13253
13298
|
|
|
13254
|
-
Ember.assert(
|
|
13299
|
+
Ember.assert("The first argument to DS.belongsTo must be a string representing a model type key, not an instance of " + Ember.inspect(userEnteredModelName) + ". E.g., to define a relation to the Person model, use DS.belongsTo('person')", typeof userEnteredModelName === 'string' || typeof userEnteredModelName === 'undefined');
|
|
13255
13300
|
|
|
13256
13301
|
opts = opts || {};
|
|
13257
13302
|
|
|
@@ -13446,16 +13491,16 @@
|
|
|
13446
13491
|
@return {Ember.computed} relationship
|
|
13447
13492
|
*/
|
|
13448
13493
|
function ember$data$lib$system$relationships$has$many$$hasMany(type, options) {
|
|
13449
|
-
if (typeof type ===
|
|
13494
|
+
if (typeof type === 'object') {
|
|
13450
13495
|
options = type;
|
|
13451
13496
|
type = undefined;
|
|
13452
13497
|
}
|
|
13453
13498
|
|
|
13454
|
-
Ember.assert("The first argument to DS.hasMany must be a string representing a model type key, not an instance of " + Ember.inspect(type) + ". E.g., to define a relation to the Comment model, use DS.hasMany('comment')", typeof type ===
|
|
13499
|
+
Ember.assert("The first argument to DS.hasMany must be a string representing a model type key, not an instance of " + Ember.inspect(type) + ". E.g., to define a relation to the Comment model, use DS.hasMany('comment')", typeof type === 'string' || typeof type === 'undefined');
|
|
13455
13500
|
|
|
13456
13501
|
options = options || {};
|
|
13457
13502
|
|
|
13458
|
-
if (typeof type ===
|
|
13503
|
+
if (typeof type === 'string') {
|
|
13459
13504
|
type = ember$data$lib$system$normalize$model$name$$default(type);
|
|
13460
13505
|
}
|
|
13461
13506
|
|
|
@@ -13467,7 +13512,7 @@
|
|
|
13467
13512
|
type: type,
|
|
13468
13513
|
isRelationship: true,
|
|
13469
13514
|
options: options,
|
|
13470
|
-
kind:
|
|
13515
|
+
kind: 'hasMany',
|
|
13471
13516
|
key: null
|
|
13472
13517
|
};
|
|
13473
13518
|
|
|
@@ -13480,7 +13525,7 @@
|
|
|
13480
13525
|
var relationship = this._internalModel._relationships.get(key);
|
|
13481
13526
|
relationship.clear();
|
|
13482
13527
|
Ember.assert("You must pass an array of records to set a hasMany relationship", ember$data$lib$system$is$array$like$$default(records));
|
|
13483
|
-
relationship.addRecords(Ember.A(records).mapBy(
|
|
13528
|
+
relationship.addRecords(Ember.A(records).mapBy('_internalModel'));
|
|
13484
13529
|
return relationship.getRecords();
|
|
13485
13530
|
}
|
|
13486
13531
|
}).meta(meta);
|
|
@@ -13498,6 +13543,7 @@
|
|
|
13498
13543
|
});
|
|
13499
13544
|
|
|
13500
13545
|
var ember$data$lib$system$relationships$has$many$$default = ember$data$lib$system$relationships$has$many$$hasMany;
|
|
13546
|
+
|
|
13501
13547
|
function ember$data$lib$system$relationship$meta$$typeForRelationshipMeta(meta) {
|
|
13502
13548
|
var modelName;
|
|
13503
13549
|
|
|
@@ -13685,7 +13731,7 @@
|
|
|
13685
13731
|
@return {DS.Model} the type of the relationship, or undefined
|
|
13686
13732
|
*/
|
|
13687
13733
|
typeForRelationship: function (name, store) {
|
|
13688
|
-
var relationship = ember$data$lib$system$relationships$ext$$get(this,
|
|
13734
|
+
var relationship = ember$data$lib$system$relationships$ext$$get(this, 'relationshipsByName').get(name);
|
|
13689
13735
|
return relationship && store.modelFor(relationship.type);
|
|
13690
13736
|
},
|
|
13691
13737
|
|
|
@@ -13716,7 +13762,7 @@
|
|
|
13716
13762
|
@return {Object} the inverse relationship, or null
|
|
13717
13763
|
*/
|
|
13718
13764
|
inverseFor: function (name, store) {
|
|
13719
|
-
var inverseMap = ember$data$lib$system$relationships$ext$$get(this,
|
|
13765
|
+
var inverseMap = ember$data$lib$system$relationships$ext$$get(this, 'inverseMap');
|
|
13720
13766
|
if (inverseMap[name]) {
|
|
13721
13767
|
return inverseMap[name];
|
|
13722
13768
|
} else {
|
|
@@ -13746,7 +13792,7 @@
|
|
|
13746
13792
|
//If inverse is specified manually, return the inverse
|
|
13747
13793
|
if (options.inverse) {
|
|
13748
13794
|
inverseName = options.inverse;
|
|
13749
|
-
inverse = Ember.get(inverseType,
|
|
13795
|
+
inverse = Ember.get(inverseType, 'relationshipsByName').get(inverseName);
|
|
13750
13796
|
|
|
13751
13797
|
Ember.assert("We found no inverse relationships by the name of '" + inverseName + "' on the '" + inverseType.modelName + "' model. This is most likely due to a missing attribute on your model definition.", !Ember.isNone(inverse));
|
|
13752
13798
|
|
|
@@ -13755,7 +13801,7 @@
|
|
|
13755
13801
|
//No inverse was specified manually, we need to use a heuristic to guess one
|
|
13756
13802
|
if (propertyMeta.type === propertyMeta.parentType.modelName) {
|
|
13757
13803
|
Ember.warn("Detected a reflexive relationship by the name of '" + name + "' without an inverse option. Look at http://emberjs.com/guides/models/defining-models/#toc_reflexive-relation for how to explicitly specify inverses.", false, {
|
|
13758
|
-
id:
|
|
13804
|
+
id: 'ds.model.reflexive-relationship-without-inverse'
|
|
13759
13805
|
});
|
|
13760
13806
|
}
|
|
13761
13807
|
|
|
@@ -13785,7 +13831,7 @@
|
|
|
13785
13831
|
function findPossibleInverses(type, inverseType, relationshipsSoFar) {
|
|
13786
13832
|
var possibleRelationships = relationshipsSoFar || [];
|
|
13787
13833
|
|
|
13788
|
-
var relationshipMap = ember$data$lib$system$relationships$ext$$get(inverseType,
|
|
13834
|
+
var relationshipMap = ember$data$lib$system$relationships$ext$$get(inverseType, 'relationships');
|
|
13789
13835
|
if (!relationshipMap) {
|
|
13790
13836
|
return possibleRelationships;
|
|
13791
13837
|
}
|
|
@@ -13993,7 +14039,7 @@
|
|
|
13993
14039
|
if (meta.isRelationship) {
|
|
13994
14040
|
map.set(name, meta.kind);
|
|
13995
14041
|
} else if (meta.isAttribute) {
|
|
13996
|
-
map.set(name,
|
|
14042
|
+
map.set(name, 'attribute');
|
|
13997
14043
|
}
|
|
13998
14044
|
});
|
|
13999
14045
|
|
|
@@ -14010,7 +14056,7 @@
|
|
|
14010
14056
|
@param {any} binding the value to which the callback's `this` should be bound
|
|
14011
14057
|
*/
|
|
14012
14058
|
eachRelationship: function (callback, binding) {
|
|
14013
|
-
ember$data$lib$system$relationships$ext$$get(this,
|
|
14059
|
+
ember$data$lib$system$relationships$ext$$get(this, 'relationshipsByName').forEach(function (relationship, name) {
|
|
14014
14060
|
callback.call(binding, name, relationship);
|
|
14015
14061
|
});
|
|
14016
14062
|
},
|
|
@@ -14026,7 +14072,7 @@
|
|
|
14026
14072
|
@param {any} binding the value to which the callback's `this` should be bound
|
|
14027
14073
|
*/
|
|
14028
14074
|
eachRelatedType: function (callback, binding) {
|
|
14029
|
-
ember$data$lib$system$relationships$ext$$get(this,
|
|
14075
|
+
ember$data$lib$system$relationships$ext$$get(this, 'relatedTypes').forEach(function (type) {
|
|
14030
14076
|
callback.call(binding, type);
|
|
14031
14077
|
});
|
|
14032
14078
|
},
|
|
@@ -14038,16 +14084,16 @@
|
|
|
14038
14084
|
var key, otherKind;
|
|
14039
14085
|
|
|
14040
14086
|
if (!inverse) {
|
|
14041
|
-
return knownKind ===
|
|
14087
|
+
return knownKind === 'belongsTo' ? 'oneToNone' : 'manyToNone';
|
|
14042
14088
|
}
|
|
14043
14089
|
|
|
14044
14090
|
key = inverse.name;
|
|
14045
14091
|
otherKind = inverse.kind;
|
|
14046
14092
|
|
|
14047
|
-
if (otherKind ===
|
|
14048
|
-
return knownKind ===
|
|
14093
|
+
if (otherKind === 'belongsTo') {
|
|
14094
|
+
return knownKind === 'belongsTo' ? 'oneToOne' : 'manyToOne';
|
|
14049
14095
|
} else {
|
|
14050
|
-
return knownKind ===
|
|
14096
|
+
return knownKind === 'belongsTo' ? 'oneToMany' : 'manyToMany';
|
|
14051
14097
|
}
|
|
14052
14098
|
}
|
|
14053
14099
|
|
|
@@ -14098,7 +14144,7 @@
|
|
|
14098
14144
|
},
|
|
14099
14145
|
|
|
14100
14146
|
relationshipFor: function (name) {
|
|
14101
|
-
return ember$data$lib$system$relationships$ext$$get(this.constructor,
|
|
14147
|
+
return ember$data$lib$system$relationships$ext$$get(this.constructor, 'relationshipsByName').get(name);
|
|
14102
14148
|
},
|
|
14103
14149
|
|
|
14104
14150
|
inverseFor: function (key) {
|
|
@@ -14236,7 +14282,7 @@
|
|
|
14236
14282
|
|
|
14237
14283
|
ember$data$lib$core$$default._setupContainer = ember$data$lib$setup$container$$default;
|
|
14238
14284
|
|
|
14239
|
-
Object.defineProperty(ember$data$lib$core$$default,
|
|
14285
|
+
Object.defineProperty(ember$data$lib$core$$default, 'normalizeModelName', {
|
|
14240
14286
|
enumerable: true,
|
|
14241
14287
|
writable: false,
|
|
14242
14288
|
configurable: false,
|
|
@@ -14245,12 +14291,12 @@
|
|
|
14245
14291
|
|
|
14246
14292
|
var ember$data$lib$main$$_FixtureAdapter = ember$data$lib$adapters$fixture$adapter$$default;
|
|
14247
14293
|
|
|
14248
|
-
Object.defineProperty(ember$data$lib$core$$default,
|
|
14294
|
+
Object.defineProperty(ember$data$lib$core$$default, 'FixtureAdapter', {
|
|
14249
14295
|
get: function () {
|
|
14250
14296
|
if (ember$data$lib$main$$_FixtureAdapter === ember$data$lib$adapters$fixture$adapter$$default) {
|
|
14251
|
-
Ember.deprecate(
|
|
14252
|
-
id:
|
|
14253
|
-
until:
|
|
14297
|
+
Ember.deprecate('DS.FixtureAdapter has been deprecated and moved into an unsupported addon: https://github.com/emberjs/ember-data-fixture-adapter/tree/master', false, {
|
|
14298
|
+
id: 'ds.adapter.fixture-adapter-deprecated',
|
|
14299
|
+
until: '2.0.0'
|
|
14254
14300
|
});
|
|
14255
14301
|
}
|
|
14256
14302
|
return ember$data$lib$main$$_FixtureAdapter;
|
|
@@ -14372,7 +14418,7 @@
|
|
|
14372
14418
|
if ((count | 0) !== 1) {
|
|
14373
14419
|
word = ember$inflector$lib$lib$system$string$$pluralize(word);
|
|
14374
14420
|
}
|
|
14375
|
-
return count +
|
|
14421
|
+
return count + " " + word;
|
|
14376
14422
|
}
|
|
14377
14423
|
});
|
|
14378
14424
|
|