Commit 258e1720 authored by Pascal Hartig's avatar Pascal Hartig

Ember: Soft-upgrade 1.6 dependencies

parent 12b68729
......@@ -60,7 +60,7 @@ var define, requireModule, require, requirejs;
};
})();
define("activemodel-adapter/lib/initializers",
define("activemodel-adapter/lib/initializers",
["../../ember-data/lib/system/container_proxy","./system/active_model_serializer","./system/active_model_adapter"],
function(__dependency1__, __dependency2__, __dependency3__) {
"use strict";
......@@ -85,7 +85,7 @@ define("activemodel-adapter/lib/initializers",
});
});
});
define("activemodel-adapter/lib/main",
define("activemodel-adapter/lib/main",
["./system","./initializers","exports"],
function(__dependency1__, __dependency2__, __exports__) {
"use strict";
......@@ -98,7 +98,7 @@ define("activemodel-adapter/lib/main",
__exports__.ActiveModelSerializer = ActiveModelSerializer;
__exports__.EmbeddedRecordsMixin = EmbeddedRecordsMixin;
});
define("activemodel-adapter/lib/system",
define("activemodel-adapter/lib/system",
["./system/embedded_records_mixin","./system/active_model_adapter","./system/active_model_serializer","exports"],
function(__dependency1__, __dependency2__, __dependency3__, __exports__) {
"use strict";
......@@ -110,7 +110,7 @@ define("activemodel-adapter/lib/system",
__exports__.ActiveModelAdapter = ActiveModelAdapter;
__exports__.ActiveModelSerializer = ActiveModelSerializer;
});
define("activemodel-adapter/lib/system/active_model_adapter",
define("activemodel-adapter/lib/system/active_model_adapter",
["../../../ember-data/lib/adapters","../../../ember-data/lib/system/adapter","../../../ember-inflector/lib/main","./active_model_serializer","./embedded_records_mixin","exports"],
function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __exports__) {
"use strict";
......@@ -238,7 +238,7 @@ define("activemodel-adapter/lib/system/active_model_adapter",
__exports__["default"] = ActiveModelAdapter;
});
define("activemodel-adapter/lib/system/active_model_serializer",
define("activemodel-adapter/lib/system/active_model_serializer",
["../../../ember-inflector/lib/main","../../../ember-data/lib/serializers/rest_serializer","exports"],
function(__dependency1__, __dependency2__, __exports__) {
"use strict";
......@@ -454,7 +454,7 @@ define("activemodel-adapter/lib/system/active_model_serializer",
__exports__["default"] = ActiveModelSerializer;
});
define("activemodel-adapter/lib/system/embedded_records_mixin",
define("activemodel-adapter/lib/system/embedded_records_mixin",
["../../../ember-inflector/lib/main","exports"],
function(__dependency1__, __exports__) {
"use strict";
......@@ -585,7 +585,7 @@ define("activemodel-adapter/lib/system/embedded_records_mixin",
__exports__["default"] = EmbeddedRecordsMixin;
});
define("ember-data/lib/adapters",
define("ember-data/lib/adapters",
["./adapters/fixture_adapter","./adapters/rest_adapter","exports"],
function(__dependency1__, __dependency2__, __exports__) {
"use strict";
......@@ -599,7 +599,7 @@ define("ember-data/lib/adapters",
__exports__.RESTAdapter = RESTAdapter;
__exports__.FixtureAdapter = FixtureAdapter;
});
define("ember-data/lib/adapters/fixture_adapter",
define("ember-data/lib/adapters/fixture_adapter",
["../system/adapter","exports"],
function(__dependency1__, __exports__) {
"use strict";
......@@ -946,7 +946,7 @@ define("ember-data/lib/adapters/fixture_adapter",
__exports__["default"] = FixtureAdapter;
});
define("ember-data/lib/adapters/rest_adapter",
define("ember-data/lib/adapters/rest_adapter",
["../system/adapter","exports"],
function(__dependency1__, __exports__) {
"use strict";
......@@ -1568,7 +1568,7 @@ define("ember-data/lib/adapters/rest_adapter",
__exports__["default"] = RESTAdapter;
});
define("ember-data/lib/core",
define("ember-data/lib/core",
["exports"],
function(__exports__) {
"use strict";
......@@ -1605,7 +1605,7 @@ define("ember-data/lib/core",
__exports__["default"] = DS;
});
define("ember-data/lib/ext/date",
define("ember-data/lib/ext/date",
[],
function() {
"use strict";
......@@ -1670,7 +1670,7 @@ define("ember-data/lib/ext/date",
Date.parse = Ember.Date.parse;
}
});
define("ember-data/lib/initializers",
define("ember-data/lib/initializers",
["./system/store","./serializers","./adapters","./system/debug/debug_adapter","./system/container_proxy","./transforms"],
function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__) {
"use strict";
......@@ -1783,7 +1783,7 @@ define("ember-data/lib/initializers",
});
});
define("ember-data/lib/main",
define("ember-data/lib/main",
["./core","./ext/date","./system/store","./system/model","./system/changes","./system/adapter","./system/debug","./system/record_arrays","./system/record_array_manager","./adapters","./serializers/json_serializer","./serializers/rest_serializer","../../ember-inflector/lib/main","../../activemodel-adapter/lib/main","./transforms","./system/relationships","./initializers","./system/container_proxy","exports"],
function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__, __dependency12__, __dependency13__, __dependency14__, __dependency15__, __dependency16__, __dependency17__, __dependency18__, __exports__) {
"use strict";
......@@ -1893,7 +1893,7 @@ define("ember-data/lib/main",
__exports__["default"] = DS;
});
define("ember-data/lib/serializers",
define("ember-data/lib/serializers",
["./serializers/json_serializer","./serializers/rest_serializer","exports"],
function(__dependency1__, __dependency2__, __exports__) {
"use strict";
......@@ -1903,7 +1903,7 @@ define("ember-data/lib/serializers",
__exports__.JSONSerializer = JSONSerializer;
__exports__.RESTSerializer = RESTSerializer;
});
define("ember-data/lib/serializers/json_serializer",
define("ember-data/lib/serializers/json_serializer",
["exports"],
function(__exports__) {
"use strict";
......@@ -2650,7 +2650,7 @@ define("ember-data/lib/serializers/json_serializer",
__exports__["default"] = JSONSerializer;
});
define("ember-data/lib/serializers/rest_serializer",
define("ember-data/lib/serializers/rest_serializer",
["./json_serializer","exports"],
function(__dependency1__, __exports__) {
"use strict";
......@@ -3452,7 +3452,7 @@ define("ember-data/lib/serializers/rest_serializer",
__exports__["default"] = RESTSerializer;
});
define("ember-data/lib/system/adapter",
define("ember-data/lib/system/adapter",
["exports"],
function(__exports__) {
"use strict";
......@@ -3490,11 +3490,11 @@ define("ember-data/lib/system/adapter",
}
});
```
The `DS.InvalidError` must be constructed with a single object whose
keys are the invalid model properties, and whose values are the
corresponding error messages. For example:
```javascript
return new DS.InvalidError({
length: 'Must be less than 15',
......@@ -3902,7 +3902,7 @@ define("ember-data/lib/system/adapter",
__exports__.Adapter = Adapter;
__exports__["default"] = Adapter;
});
define("ember-data/lib/system/changes",
define("ember-data/lib/system/changes",
["./changes/attribute_change","./changes/relationship_change","exports"],
function(__dependency1__, __dependency2__, __exports__) {
"use strict";
......@@ -3929,7 +3929,7 @@ define("ember-data/lib/system/changes",
__exports__.OneToOneChange = OneToOneChange;
__exports__.ManyToManyChange = ManyToManyChange;
});
define("ember-data/lib/system/changes/attribute_change",
define("ember-data/lib/system/changes/attribute_change",
["exports"],
function(__exports__) {
"use strict";
......@@ -3984,7 +3984,7 @@ define("ember-data/lib/system/changes/attribute_change",
__exports__["default"] = AttributeChange;
});
define("ember-data/lib/system/changes/relationship_change",
define("ember-data/lib/system/changes/relationship_change",
["../model","exports"],
function(__dependency1__, __exports__) {
"use strict";
......@@ -4443,7 +4443,7 @@ define("ember-data/lib/system/changes/relationship_change",
__exports__.OneToOneChange = OneToOneChange;
__exports__.ManyToManyChange = ManyToManyChange;
});
define("ember-data/lib/system/container_proxy",
define("ember-data/lib/system/container_proxy",
["exports"],
function(__exports__) {
"use strict";
......@@ -4462,10 +4462,10 @@ define("ember-data/lib/system/container_proxy",
ContainerProxy.prototype.aliasedFactory = function(path, preLookup) {
var _this = this;
return {create: function(){
return {create: function(){
if (preLookup) { preLookup(); }
return _this.container.lookup(path);
return _this.container.lookup(path);
}};
};
......@@ -4496,7 +4496,7 @@ define("ember-data/lib/system/container_proxy",
__exports__["default"] = ContainerProxy;
});
define("ember-data/lib/system/debug",
define("ember-data/lib/system/debug",
["./debug/debug_info","./debug/debug_adapter","exports"],
function(__dependency1__, __dependency2__, __exports__) {
"use strict";
......@@ -4508,7 +4508,7 @@ define("ember-data/lib/system/debug",
__exports__["default"] = DebugAdapter;
});
define("ember-data/lib/system/debug/debug_adapter",
define("ember-data/lib/system/debug/debug_adapter",
["../model","exports"],
function(__dependency1__, __exports__) {
"use strict";
......@@ -4625,7 +4625,7 @@ define("ember-data/lib/system/debug/debug_adapter",
__exports__["default"] = DebugAdapter;
});
define("ember-data/lib/system/debug/debug_info",
define("ember-data/lib/system/debug/debug_info",
["../model","exports"],
function(__dependency1__, __exports__) {
"use strict";
......@@ -4699,7 +4699,7 @@ define("ember-data/lib/system/debug/debug_info",
__exports__["default"] = Model;
});
define("ember-data/lib/system/model",
define("ember-data/lib/system/model",
["./model/model","./model/attributes","./model/states","./model/errors","exports"],
function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __exports__) {
"use strict";
......@@ -4717,7 +4717,7 @@ define("ember-data/lib/system/model",
__exports__.attr = attr;
__exports__.Errors = Errors;
});
define("ember-data/lib/system/model/attributes",
define("ember-data/lib/system/model/attributes",
["./model","exports"],
function(__dependency1__, __exports__) {
"use strict";
......@@ -5027,7 +5027,7 @@ define("ember-data/lib/system/model/attributes",
__exports__["default"] = attr;
});
define("ember-data/lib/system/model/errors",
define("ember-data/lib/system/model/errors",
["exports"],
function(__exports__) {
"use strict";
......@@ -5232,7 +5232,7 @@ define("ember-data/lib/system/model/errors",
__exports__["default"] = Errors;
});
define("ember-data/lib/system/model/model",
define("ember-data/lib/system/model/model",
["./states","./errors","exports"],
function(__dependency1__, __dependency2__, __exports__) {
"use strict";
......@@ -6279,7 +6279,7 @@ define("ember-data/lib/system/model/model",
__exports__["default"] = Model;
});
define("ember-data/lib/system/model/states",
define("ember-data/lib/system/model/states",
["exports"],
function(__exports__) {
"use strict";
......@@ -7000,7 +7000,7 @@ define("ember-data/lib/system/model/states",
__exports__["default"] = RootState;
});
define("ember-data/lib/system/record_array_manager",
define("ember-data/lib/system/record_array_manager",
["./record_arrays","exports"],
function(__dependency1__, __exports__) {
"use strict";
......@@ -7303,7 +7303,7 @@ define("ember-data/lib/system/record_array_manager",
__exports__["default"] = RecordArrayManager;
});
define("ember-data/lib/system/record_arrays",
define("ember-data/lib/system/record_arrays",
["./record_arrays/record_array","./record_arrays/filtered_record_array","./record_arrays/adapter_populated_record_array","./record_arrays/many_array","exports"],
function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __exports__) {
"use strict";
......@@ -7321,7 +7321,7 @@ define("ember-data/lib/system/record_arrays",
__exports__.AdapterPopulatedRecordArray = AdapterPopulatedRecordArray;
__exports__.ManyArray = ManyArray;
});
define("ember-data/lib/system/record_arrays/adapter_populated_record_array",
define("ember-data/lib/system/record_arrays/adapter_populated_record_array",
["./record_array","exports"],
function(__dependency1__, __exports__) {
"use strict";
......@@ -7374,7 +7374,7 @@ define("ember-data/lib/system/record_arrays/adapter_populated_record_array",
__exports__["default"] = AdapterPopulatedRecordArray;
});
define("ember-data/lib/system/record_arrays/filtered_record_array",
define("ember-data/lib/system/record_arrays/filtered_record_array",
["./record_array","exports"],
function(__dependency1__, __exports__) {
"use strict";
......@@ -7443,7 +7443,7 @@ define("ember-data/lib/system/record_arrays/filtered_record_array",
__exports__["default"] = FilteredRecordArray;
});
define("ember-data/lib/system/record_arrays/many_array",
define("ember-data/lib/system/record_arrays/many_array",
["./record_array","../changes","exports"],
function(__dependency1__, __dependency2__, __exports__) {
"use strict";
......@@ -7683,7 +7683,7 @@ define("ember-data/lib/system/record_arrays/many_array",
__exports__["default"] = ManyArray;
});
define("ember-data/lib/system/record_arrays/record_array",
define("ember-data/lib/system/record_arrays/record_array",
["../store","exports"],
function(__dependency1__, __exports__) {
"use strict";
......@@ -7873,7 +7873,7 @@ define("ember-data/lib/system/record_arrays/record_array",
__exports__["default"] = RecordArray;
});
define("ember-data/lib/system/relationships",
define("ember-data/lib/system/relationships",
["./relationships/belongs_to","./relationships/has_many","../system/relationships/ext","exports"],
function(__dependency1__, __dependency2__, __dependency3__, __exports__) {
"use strict";
......@@ -7888,7 +7888,7 @@ define("ember-data/lib/system/relationships",
__exports__.belongsTo = belongsTo;
__exports__.hasMany = hasMany;
});
define("ember-data/lib/system/relationships/belongs_to",
define("ember-data/lib/system/relationships/belongs_to",
["../model","exports"],
function(__dependency1__, __exports__) {
"use strict";
......@@ -8084,7 +8084,7 @@ define("ember-data/lib/system/relationships/belongs_to",
__exports__["default"] = belongsTo;
});
define("ember-data/lib/system/relationships/ext",
define("ember-data/lib/system/relationships/ext",
["../../../../ember-inflector/lib/system","../model"],
function(__dependency1__, __dependency2__) {
"use strict";
......@@ -8551,7 +8551,7 @@ define("ember-data/lib/system/relationships/ext",
}
});
});
define("ember-data/lib/system/relationships/has_many",
define("ember-data/lib/system/relationships/has_many",
["exports"],
function(__exports__) {
"use strict";
......@@ -8722,7 +8722,7 @@ define("ember-data/lib/system/relationships/has_many",
__exports__["default"] = hasMany;
});
define("ember-data/lib/system/store",
define("ember-data/lib/system/store",
["exports"],
function(__exports__) {
"use strict";
......@@ -10453,7 +10453,7 @@ define("ember-data/lib/system/store",
__exports__.PromiseObject = PromiseObject;
__exports__["default"] = Store;
});
define("ember-data/lib/transforms",
define("ember-data/lib/transforms",
["./transforms/base","./transforms/number","./transforms/date","./transforms/string","./transforms/boolean","exports"],
function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __exports__) {
"use strict";
......@@ -10469,7 +10469,7 @@ define("ember-data/lib/transforms",
__exports__.StringTransform = StringTransform;
__exports__.BooleanTransform = BooleanTransform;
});
define("ember-data/lib/transforms/base",
define("ember-data/lib/transforms/base",
["exports"],
function(__exports__) {
"use strict";
......@@ -10547,7 +10547,7 @@ define("ember-data/lib/transforms/base",
__exports__["default"] = Transform;
});
define("ember-data/lib/transforms/boolean",
define("ember-data/lib/transforms/boolean",
["./base","exports"],
function(__dependency1__, __exports__) {
"use strict";
......@@ -10595,7 +10595,7 @@ define("ember-data/lib/transforms/boolean",
});
__exports__["default"] = BooleanTransform;
});
define("ember-data/lib/transforms/date",
define("ember-data/lib/transforms/date",
["./base","exports"],
function(__dependency1__, __exports__) {
"use strict";
......@@ -10664,13 +10664,13 @@ define("ember-data/lib/transforms/date",
} else {
return null;
}
}
}
});
__exports__["default"] = DateTransform;
});
define("ember-data/lib/transforms/number",
define("ember-data/lib/transforms/number",
["./base","exports"],
function(__dependency1__, __exports__) {
"use strict";
......@@ -10712,7 +10712,7 @@ define("ember-data/lib/transforms/number",
__exports__["default"] = NumberTransform;
});
define("ember-data/lib/transforms/string",
define("ember-data/lib/transforms/string",
["./base","exports"],
function(__dependency1__, __exports__) {
"use strict";
......@@ -10754,7 +10754,7 @@ define("ember-data/lib/transforms/string",
__exports__["default"] = StringTransform;
});
define("ember-inflector/lib/ext/string",
define("ember-inflector/lib/ext/string",
["../system/string"],
function(__dependency1__) {
"use strict";
......@@ -10783,7 +10783,7 @@ define("ember-inflector/lib/ext/string",
};
}
});
define("ember-inflector/lib/main",
define("ember-inflector/lib/main",
["./system","./ext/string","exports"],
function(__dependency1__, __dependency2__, __exports__) {
"use strict";
......@@ -10804,7 +10804,7 @@ define("ember-inflector/lib/main",
__exports__.pluralize = pluralize;
__exports__.singularize = singularize;
});
define("ember-inflector/lib/system",
define("ember-inflector/lib/system",
["./system/inflector","./system/string","./system/inflections","exports"],
function(__dependency1__, __dependency2__, __dependency3__, __exports__) {
"use strict";
......@@ -10815,15 +10815,15 @@ define("ember-inflector/lib/system",
var defaultRules = __dependency3__["default"];
Inflector.inflector = new Inflector(defaultRules);
__exports__.Inflector = Inflector;
__exports__.singularize = singularize;
__exports__.pluralize = pluralize;
__exports__.defaultRules = defaultRules;
});
define("ember-inflector/lib/system/inflections",
define("ember-inflector/lib/system/inflections",
["exports"],
function(__exports__) {
"use strict";
......@@ -10908,7 +10908,7 @@ define("ember-inflector/lib/system/inflections",
__exports__["default"] = defaultRules;
});
define("ember-inflector/lib/system/inflector",
define("ember-inflector/lib/system/inflector",
["exports"],
function(__exports__) {
"use strict";
......@@ -11112,7 +11112,7 @@ define("ember-inflector/lib/system/inflector",
__exports__["default"] = Inflector;
});
define("ember-inflector/lib/system/string",
define("ember-inflector/lib/system/string",
["./inflector","exports"],
function(__dependency1__, __exports__) {
"use strict";
......
......@@ -6,14 +6,15 @@
DS.LSSerializer = DS.JSONSerializer.extend({
serializeHasMany: function(record, json, relationship) {
var key = relationship.key,
relationshipType = DS.RelationshipChange.determineRelationshipType(record.constructor, relationship);
var key = relationship.key;
var payloadKey = this.keyForRelationship ? this.keyForRelationship(key, "hasMany") : key;
var relationshipType = DS.RelationshipChange.determineRelationshipType(record.constructor, relationship);
if (relationshipType === 'manyToNone' ||
relationshipType === 'manyToMany' ||
relationshipType === 'manyToOne') {
json[key] = record.get(key).mapBy('id');
// TODO support for polymorphic manyToNone and manyToMany relationships
json[payloadKey] = record.get(key).mapBy('id');
// TODO support for polymorphic manyToNone and manyToMany relationships
}
},
......@@ -84,12 +85,9 @@
* @param {Array} payload returned JSONs
*/
extractArray: function(store, type, payload) {
var serializer = this;
return payload.map(function(record) {
var extracted = serializer.extractSingle(store, type, record);
return serializer.normalize(type, record);
});
return payload.map(function(json) {
return this.extractSingle(store, type, json);
}, this);
}
});
......@@ -104,9 +102,9 @@
@param {Object|String|Integer|null} id
*/
find: function(store, type, id, opts) {
var adapter = this;
var allowRecursive = true;
var namespace = this._namespaceForType(type);
var record = Ember.A(namespace.records[id]);
/**
* In the case where there are relationships, this method is called again
......@@ -120,44 +118,51 @@
allowRecursive = opts.allowRecursive;
}
return new Ember.RSVP.Promise(function(resolve, reject) {
var record = Ember.A(namespace.records[id]);
if (!record || !record.hasOwnProperty('id')) {
store.dematerializeRecord(store.typeMapFor(type).idToRecord[id]);
reject();
return;
}
if (!record || !record.hasOwnProperty('id')) {
return Ember.RSVP.reject(new Error("Couldn't find record of"
+ " type '" + type.typeKey
+ "' for the id '" + id + "'."));
}
if (allowRecursive) {
adapter.loadRelationships(type, record).then(function(finalRecord) {
resolve(finalRecord);
});
} else {
resolve(record);
}
});
if (allowRecursive) {
return this.loadRelationships(type, record);
} else {
return Ember.RSVP.resolve(record);
}
},
findMany: function (store, type, ids) {
var adapter = this;
findMany: function (store, type, ids, opts) {
var namespace = this._namespaceForType(type);
var adapter = this,
allowRecursive = true,
results = [], record;
return new Ember.RSVP.Promise(function(resolve, reject) {
var results = [];
/**
* In the case where there are relationships, this method is called again
* for each relation. Given the relations have references to the main
* object, we use allowRecursive to avoid going further into infinite
* recursiveness.
*
* Concept from ember-indexdb-adapter
*/
if (opts && typeof opts.allowRecursive !== 'undefined') {
allowRecursive = opts.allowRecursive;
}
for (var i = 0; i < ids.length; i++) {
results.push(Ember.copy(namespace.records[ids[i]]));
for (var i = 0; i < ids.length; i++) {
record = namespace.records[ids[i]];
if (!record || !record.hasOwnProperty('id')) {
return Ember.RSVP.reject(new Error("Couldn't find record of type '" + type.typeKey
+ "' for the id '" + ids[i] + "'."));
}
results.push(Ember.copy(record));
}
resolve(results);
}).then(function(records) {
if (records.get('length')) {
return adapter.loadRelationshipsForMany(type, records);
} else {
return records;
}
});
if (results.get('length') && allowRecursive) {
return this.loadRelationshipsForMany(type, results);
} else {
return Ember.RSVP.resolve(results);
}
},
// Supports queries that look like this:
......@@ -175,33 +180,34 @@
//
// { complete: true, name: /foo|bar/ }
findQuery: function (store, type, query, recordArray) {
var namespace = this._namespaceForType(type),
results = this.query(namespace.records, query);
var namespace = this._namespaceForType(type);
var results = this.query(namespace.records, query);
if (results.get('length')) {
results = this.loadRelationshipsForMany(type, results);
return Ember.RSVP.resolve(results);
return this.loadRelationshipsForMany(type, results);
} else {
return Ember.RSVP.reject();
}
},
query: function (records, query) {
var results = [],
id, record, property, test, push;
for (id in records) {
record = records[id];
for (property in query) {
test = query[property];
push = false;
var results = [], record;
function recordMatchesQuery(record) {
return Ember.keys(query).every(function(property) {
var test = query[property];
if (Object.prototype.toString.call(test) === '[object RegExp]') {
push = test.test(record[property]);
return test.test(record[property]);
} else {
push = record[property] === test;
return record[property] === test;
}
}
if (push) {
results.push(record);
});
}
for (var id in records) {
record = records[id];
if (recordMatchesQuery(record)) {
results.push(Ember.copy(record));
}
}
return results;
......@@ -218,8 +224,8 @@
},
createRecord: function (store, type, record) {
var namespaceRecords = this._namespaceForType(type),
recordHash = record.serialize({includeId: true});
var namespaceRecords = this._namespaceForType(type);
var recordHash = record.serialize({includeId: true});
namespaceRecords.records[recordHash.id] = recordHash;
......@@ -228,8 +234,8 @@
},
updateRecord: function (store, type, record) {
var namespaceRecords = this._namespaceForType(type),
id = record.get('id');
var namespaceRecords = this._namespaceForType(type);
var id = record.get('id');
namespaceRecords.records[id] = record.serialize({ includeId: true });
......@@ -238,8 +244,8 @@
},
deleteRecord: function (store, type, record) {
var namespaceRecords = this._namespaceForType(type),
id = record.get('id');
var namespaceRecords = this._namespaceForType(type);
var id = record.get('id');
delete namespaceRecords.records[id];
......@@ -263,8 +269,8 @@
},
persistData: function(type, data) {
var modelNamespace = this.modelNamespace(type),
localStorageData = this.loadData();
var modelNamespace = this.modelNamespace(type);
var localStorageData = this.loadData();
localStorageData[modelNamespace] = data;
......@@ -272,10 +278,10 @@
},
_namespaceForType: function (type) {
var namespace = this.modelNamespace(type),
storage = localStorage.getItem(this.adapterNamespace());
var namespace = this.modelNamespace(type);
var storage = this.loadData();
return storage ? JSON.parse(storage)[namespace] || {records: {}} : {records: {}};
return storage[namespace] || {records: {}};
},
modelNamespace: function(type) {
......@@ -326,66 +332,64 @@
* @param {Object} record
*/
loadRelationships: function(type, record) {
var adapter = this;
return new Ember.RSVP.Promise(function(resolve, reject) {
var resultJSON = {},
typeKey = type.typeKey,
relationshipNames, relationships,
relationshipPromises = [];
relationshipNames = Ember.get(type, 'relationshipNames');
relationships = relationshipNames.belongsTo;
relationships = relationships.concat(relationshipNames.hasMany);
relationships.forEach(function(relationName) {
var relationModel = type.typeForRelationship(relationName),
relationEmbeddedId = record[relationName],
relationProp = adapter.relationshipProperties(type, relationName),
relationType = relationProp.kind,
/**
* This is the relationship field.
*/
promise, embedPromise;
var opts = {allowRecursive: false};
/**
* embeddedIds are ids of relations that are included in the main
* payload, such as:
*
* {
* cart: {
* id: "s85fb",
* customer: "rld9u"
* }
* }
*
* In this case, cart belongsTo customer and its id is present in the
* main payload. We find each of these records and add them to _embedded.
*/
if (relationEmbeddedId) {
if (relationType == 'belongsTo' || relationType == 'hasOne') {
promise = adapter.find(null, relationModel, relationEmbeddedId, opts)
var adapter = this,
resultJSON = {},
typeKey = type.typeKey,
relationshipNames, relationships,
relationshipPromises = [];
/**
* Create a chain of promises, so the relationships are
* loaded sequentially. Think of the variable
* `recordPromise` as of the accumulator in a left fold.
*/
var recordPromise = Ember.RSVP.resolve(record);
relationshipNames = Ember.get(type, 'relationshipNames');
relationships = relationshipNames.belongsTo
.concat(relationshipNames.hasMany);
relationships.forEach(function(relationName) {
var relationModel = type.typeForRelationship(relationName);
var relationEmbeddedId = record[relationName];
var relationProp = adapter.relationshipProperties(type, relationName);
var relationType = relationProp.kind;
var foreignAdapter = type.store.adapterFor(relationModel);
var opts = {allowRecursive: false};
/**
* embeddedIds are ids of relations that are included in the main
* payload, such as:
*
* {
* cart: {
* id: "s85fb",
* customer: "rld9u"
* }
* }
*
* In this case, cart belongsTo customer and its id is present in the
* main payload. We find each of these records and add them to _embedded.
*/
if (relationEmbeddedId && foreignAdapter === adapter)
{
recordPromise = recordPromise.then(function(recordPayload) {
var promise;
if (relationType === 'belongsTo' || relationType === 'hasOne') {
promise = adapter.find(null, relationModel, relationEmbeddedId, opts);
} else if (relationType == 'hasMany') {
promise = adapter.findMany(null, relationModel, relationEmbeddedId, opts)
promise = adapter.findMany(null, relationModel, relationEmbeddedId, opts);
}
embedPromise = new Ember.RSVP.Promise(function(resolve, reject) {
promise.then(function(relationRecord) {
var finalPayload = adapter.addEmbeddedPayload(record, relationName, relationRecord)
resolve(finalPayload);
});
return promise.then(function(relationRecord) {
return adapter.addEmbeddedPayload(recordPayload, relationName, relationRecord);
});
relationshipPromises.push(embedPromise);
}
});
Ember.RSVP.all(relationshipPromises).then(function() {
resolve(record);
});
});
}
});
return recordPromise;
},
......@@ -427,13 +431,13 @@
* @param {Object} relationshipRecord
*/
addEmbeddedPayload: function(payload, relationshipName, relationshipRecord) {
var objectHasId = (relationshipRecord && relationshipRecord.id),
arrayHasIds = (relationshipRecord.length && relationshipRecord.everyBy("id")),
isValidRelationship = (objectHasId || arrayHasIds);
var objectHasId = (relationshipRecord && relationshipRecord.id);
var arrayHasIds = (relationshipRecord.length && relationshipRecord.everyBy("id"));
var isValidRelationship = (objectHasId || arrayHasIds);
if (isValidRelationship) {
if (!payload['_embedded']) {
payload['_embedded'] = {}
payload['_embedded'] = {};
}
payload['_embedded'][relationshipName] = relationshipRecord;
......@@ -467,47 +471,24 @@
* @param {Object} recordsArray
*/
loadRelationshipsForMany: function(type, recordsArray) {
var adapter = this;
var adapter = this,
promise = Ember.RSVP.resolve([]);
return new Ember.RSVP.Promise(function(resolve, reject) {
var recordsWithRelationships = [],
recordsToBeLoaded = [],
promises = [];
/**
* Some times Ember puts some stuff in arrays. We want to clean it so
* we know exactly what to iterate over.
*/
for (var i in recordsArray) {
if (recordsArray.hasOwnProperty(i)) {
recordsToBeLoaded.push(recordsArray[i]);
}
}
var loadNextRecord = function(record) {
/**
* Removes the first item from recordsToBeLoaded
*/
recordsToBeLoaded = recordsToBeLoaded.slice(1);
var promise = adapter.loadRelationships(type, record);
promise.then(function(recordWithRelationships) {
recordsWithRelationships.push(recordWithRelationships);
if (recordsToBeLoaded[0]) {
loadNextRecord(recordsToBeLoaded[0]);
} else {
resolve(recordsWithRelationships);
}
});
}
/**
* We start by the first record
*/
loadNextRecord(recordsToBeLoaded[0]);
/**
* Create a chain of promises, so the records are loaded sequentially.
* Think of the variable promise as of the accumulator in a left fold.
*/
recordsArray.forEach(function(record) {
promise = promise.then(function(records) {
return adapter.loadRelationships(type, record)
.then(function(loadedRecord) {
records.push(loadedRecord);
return records;
});
});
});
return promise;
},
......
......@@ -5,7 +5,7 @@
* Portions Copyright 2008-2011 Apple Inc. All rights reserved.
* @license Licensed under MIT license
* See https://raw.github.com/emberjs/ember.js/master/LICENSE
* @version 1.6.0
* @version 1.6.1
*/
......@@ -2410,7 +2410,7 @@ define("ember-metal/computed",
});
};
/**
Where `computed.oneWay` provides oneWay bindings, `computed.readOnly` provides
a readOnly one way binding. Very often when using `computed.oneWay` one does
......@@ -2518,7 +2518,7 @@ define("ember-metal/core",
@class Ember
@static
@version 1.6.0
@version 1.6.1
*/
if ('undefined' === typeof Ember) {
......@@ -2545,10 +2545,10 @@ define("ember-metal/core",
/**
@property VERSION
@type String
@default '1.6.0'
@default '1.6.1'
@static
*/
Ember.VERSION = '1.6.0';
Ember.VERSION = '1.6.1';
/**
Standard environmental variables. You can define these in a global `EmberENV`
......@@ -3451,7 +3451,7 @@ define("ember-metal/expand_properties",
var match, prefix, list;
if (pattern.indexOf(' ') > -1) {
throw new EmberError('Brace expanded properties cannot contain spaces, ' +
throw new EmberError('Brace expanded properties cannot contain spaces, ' +
'e.g. `user.{firstName, lastName}` should be `user.{firstName,lastName}`');
}
......@@ -5290,7 +5290,7 @@ define("ember-metal/mixin",
});
var goodGuy = App.Person.create();
goodGuy.name(); // 'Tomhuda Katzdale'
goodGuy.moniker(); // 'Tomhuda Katzdale'
```
......@@ -13659,12 +13659,12 @@ define("ember-runtime/computed/reduce_computed_macros",
})
});
var hamster = Hamster.create({
var hamster = Hamster.create({
chores: [
{ name: 'cook', done: true },
{ name: 'clean', done: true },
{ name: 'write more unit tests', done: false }
]
]
});
hamster.get('remainingChores'); // [{name: 'write more unit tests', done: false}]
......@@ -14686,7 +14686,7 @@ define("ember-runtime/core",
if (a && 'function'===typeof a.isEqual) return a.isEqual(b);
if (a instanceof Date && b instanceof Date) {
return a.getTime() === b.getTime();
}
}
return a === b;
};
......@@ -25819,10 +25819,10 @@ define("ember-views/views/view",
```html
<a id="ember1" class="ember-view" href="http://google.com"></a>
```
One property can be mapped on to another by placing a ":" between
One property can be mapped on to another by placing a ":" between
the source property and the destination property:
```javascript
AnchorView = Ember.View.extend({
tagName: 'a',
......@@ -25830,13 +25830,13 @@ define("ember-views/views/view",
url: 'http://google.com'
});
```
Will result in view instances with an HTML representation of:
```html
<a id="ember1" class="ember-view" href="http://google.com"></a>
```
If the return value of an `attributeBindings` monitored property is a boolean
the property will follow HTML's pattern of repeating the attribute's name as
its value:
......@@ -27811,9 +27811,9 @@ define("ember-views/views/view",
*/
_classStringForValue: function(path, val, className, falsyClassName) {
if(isArray(val)) {
val = get(val, 'length') !== 0;
val = get(val, 'length') !== 0;
}
// When using the colon syntax, evaluate the truthiness or falsiness
// of the value to determine which className to return
if (className || falsyClassName) {
......@@ -29073,7 +29073,7 @@ define("ember-handlebars/controls",
Internally, `{{textarea}}` creates an instance of `Ember.TextArea`, passing
arguments from the helper to `Ember.TextArea`'s `create` method. You can
extend the capabilities of text areas in your application by reopening this
class. For example, if you are building a Bootstrap project where `data-*`
class. For example, if you are building a Bootstrap project where `data-*`
attributes are used, you can globally add support for a `data-*` attribute
on all `{{textarea}}`s' in your app by reopening `Ember.TextArea` or
`Ember.TextSupport` and adding it to the `attributeBindings` concatenated
......@@ -29534,7 +29534,7 @@ helpers = this.merge(helpers, Ember.Handlebars.helpers); data = data || {};
var buffer = '', stack1, escapeExpression=this.escapeExpression, self=this;
function program1(depth0,data) {
var buffer = '', stack1;
data.buffer.push("<option value=\"\">");
stack1 = helpers._triageMustache.call(depth0, "view.prompt", {hash:{},hashTypes:{},hashContexts:{},contexts:[depth0],types:["ID"],data:data});
......@@ -29544,15 +29544,15 @@ function program1(depth0,data) {
}
function program3(depth0,data) {
var stack1;
stack1 = helpers.each.call(depth0, "view.groupedContent", {hash:{},hashTypes:{},hashContexts:{},inverse:self.noop,fn:self.program(4, program4, data),contexts:[depth0],types:["ID"],data:data});
if(stack1 || stack1 === 0) { data.buffer.push(stack1); }
else { data.buffer.push(''); }
}
function program4(depth0,data) {
data.buffer.push(escapeExpression(helpers.view.call(depth0, "view.groupView", {hash:{
'content': ("content"),
'label': ("label")
......@@ -29560,15 +29560,15 @@ function program4(depth0,data) {
}
function program6(depth0,data) {
var stack1;
stack1 = helpers.each.call(depth0, "view.content", {hash:{},hashTypes:{},hashContexts:{},inverse:self.noop,fn:self.program(7, program7, data),contexts:[depth0],types:["ID"],data:data});
if(stack1 || stack1 === 0) { data.buffer.push(stack1); }
else { data.buffer.push(''); }
}
function program7(depth0,data) {
data.buffer.push(escapeExpression(helpers.view.call(depth0, "view.optionView", {hash:{
'content': ("")
},hashTypes:{'content': "ID"},hashContexts:{'content': depth0},contexts:[depth0],types:["ID"],data:data})));
......@@ -29579,7 +29579,7 @@ function program7(depth0,data) {
stack1 = helpers['if'].call(depth0, "view.optionGroupPath", {hash:{},hashTypes:{},hashContexts:{},inverse:self.program(6, program6, data),fn:self.program(3, program3, data),contexts:[depth0],types:["ID"],data:data});
if(stack1 || stack1 === 0) { data.buffer.push(stack1); }
return buffer;
}),
attributeBindings: ['multiple', 'disabled', 'tabindex', 'name', 'required', 'autofocus',
'form', 'size'],
......@@ -30308,7 +30308,7 @@ define("ember-handlebars/ext",
normalizedPath = normalizePath(root, path, data),
value;
root = normalizedPath.root;
path = normalizedPath.path;
......@@ -30317,7 +30317,7 @@ define("ember-handlebars/ext",
if (value === undefined && root !== Ember.lookup && isGlobalPath(path)) {
value = get(Ember.lookup, path);
}
return value;
}
......@@ -32602,7 +32602,7 @@ define("ember-handlebars/helpers/loc",
Take note that `"welcome"` is a string and not an object
reference.
See [Ember.String.loc](/api/classes/Ember.String.html#method_loc) for how to
See [Ember.String.loc](/api/classes/Ember.String.html#method_loc) for how to
set up localized string references.
@method loc
......@@ -34353,7 +34353,7 @@ define("ember-routing/ext/controller",
}
});
__exports__["default"] = ControllerMixin;
});
define("ember-routing/ext/run_loop",
......@@ -35431,7 +35431,7 @@ define("ember-routing/helpers/link_to",
}
}
return resolvedParams;
}).property('resolvedParams', 'queryParams'),
......@@ -35459,7 +35459,7 @@ define("ember-routing/helpers/link_to",
return get(this, 'loadingHref');
}
return router.generate.apply(router, routeArgs);
}).property('routeArgs'),
......@@ -35777,7 +35777,7 @@ define("ember-routing/helpers/link_to",
};
/**
See [link-to](/api/classes/Ember.Handlebars.helpers.html#method_link-to)
......@@ -36975,7 +36975,7 @@ define("ember-routing/location/history_location",
baseURL = baseURL.replace(/\/$/, '');
var url = path.replace(baseURL, '').replace(rootURL, '');
return url;
},
......@@ -38093,15 +38093,15 @@ define("ember-routing/system/route",
// referenced in action handlers
this.controller = controller;
if (this.setupControllers) {
Ember.deprecate("Ember.Route.setupControllers is deprecated. Please use Ember.Route.setupController(controller, model) instead.");
this.setupControllers(controller, context);
} else {
this.setupController(controller, context);
}
if (this.renderTemplates) {
......@@ -38343,9 +38343,9 @@ define("ember-routing/system/route",
Router.js hook.
*/
deserialize: function(params, transition) {
return this.model(params, transition);
},
/**
......@@ -38851,7 +38851,7 @@ define("ember-routing/system/route",
});
function parentRoute(route) {
var handlerInfos = route.router.router.state.handlerInfos;
......@@ -39333,7 +39333,7 @@ define("ember-routing/system/router",
var name = args[0], self = this,
isQueryParamsOnly = false, queryParams;
if (!isQueryParamsOnly && name.charAt(0) !== '/') {
Ember.assert("The route " + name + " was not found", this.router.hasRoute(name));
}
......@@ -39379,7 +39379,7 @@ define("ember-routing/system/router",
} else if (error.name === 'TransitionAborted') {
// just ignore TransitionAborted here
} else {
throw error;
logError(error);
}
return error;
......@@ -39522,16 +39522,7 @@ define("ember-routing/system/router",
return;
}
var errorArgs = ['Error while processing route: ' + transition.targetName];
if (error) {
if (error.message) { errorArgs.push(error.message); }
if (error.stack) { errorArgs.push(error.stack); }
if (typeof error === "string") { errorArgs.push(error); }
}
Ember.Logger.error.apply(this, errorArgs);
logError(error, 'Error while processing route: ' + transition.targetName);
},
loading: function(transition, originRoute) {
......@@ -39562,13 +39553,28 @@ define("ember-routing/system/router",
}
};
function logError(error, initialMessage) {
var errorArgs = [];
if (initialMessage) { errorArgs.push(initialMessage); }
if (error) {
if (error.message) { errorArgs.push(error.message); }
if (error.stack) { errorArgs.push(error.stack); }
if (typeof error === "string") { errorArgs.push(error); }
}
Ember.Logger.error.apply(this, errorArgs);
}
function findChildRouteName(parentRoute, originatingChildRoute, name) {
var router = parentRoute.router,
childName,
targetChildRouteName = originatingChildRoute.routeName.split('.').pop(),
namespace = parentRoute.routeName === 'application' ? '' : parentRoute.routeName + '.';
// Second, try general loading state, e.g. 'loading'
childName = namespace + name;
if (routeHasBeenDefined(router, childName)) {
......@@ -40333,7 +40339,7 @@ define("route-recognizer",
};
});
define("router/handler-info",
define("router/handler-info",
["./utils","rsvp/promise","exports"],
function(__dependency1__, __dependency2__, __exports__) {
"use strict";
......@@ -40510,7 +40516,7 @@ define("router/handler-info",
__exports__["default"] = HandlerInfo;
});
define("router/handler-info/factory",
define("router/handler-info/factory",
["router/handler-info/resolved-handler-info","router/handler-info/unresolved-handler-info-by-object","router/handler-info/unresolved-handler-info-by-param","exports"],
function(__dependency1__, __dependency2__, __dependency3__, __exports__) {
"use strict";
......@@ -40533,7 +40539,7 @@ define("router/handler-info/factory",
__exports__["default"] = handlerInfoFactory;
});
define("router/handler-info/resolved-handler-info",
define("router/handler-info/resolved-handler-info",
["../handler-info","router/utils","rsvp/promise","exports"],
function(__dependency1__, __dependency2__, __dependency3__, __exports__) {
"use strict";
......@@ -40564,7 +40570,7 @@ define("router/handler-info/resolved-handler-info",
__exports__["default"] = ResolvedHandlerInfo;
});
define("router/handler-info/unresolved-handler-info-by-object",
define("router/handler-info/unresolved-handler-info-by-object",
["../handler-info","router/utils","rsvp/promise","exports"],
function(__dependency1__, __dependency2__, __dependency3__, __exports__) {
"use strict";
......@@ -40626,7 +40632,7 @@ define("router/handler-info/unresolved-handler-info-by-object",
__exports__["default"] = UnresolvedHandlerInfoByObject;
});
define("router/handler-info/unresolved-handler-info-by-param",
define("router/handler-info/unresolved-handler-info-by-param",
["../handler-info","router/utils","exports"],
function(__dependency1__, __dependency2__, __exports__) {
"use strict";
......@@ -40658,7 +40664,7 @@ define("router/handler-info/unresolved-handler-info-by-param",
__exports__["default"] = UnresolvedHandlerInfoByParam;
});
define("router/router",
define("router/router",
["route-recognizer","rsvp/promise","./utils","./transition-state","./transition","./transition-intent/named-transition-intent","./transition-intent/url-transition-intent","exports"],
function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __exports__) {
"use strict";
......@@ -41382,7 +41388,7 @@ define("router/router",
__exports__["default"] = Router;
});
define("router/transition-intent",
define("router/transition-intent",
["./utils","exports"],
function(__dependency1__, __exports__) {
"use strict";
......@@ -41402,7 +41408,7 @@ define("router/transition-intent",
__exports__["default"] = TransitionIntent;
});
define("router/transition-intent/named-transition-intent",
define("router/transition-intent/named-transition-intent",
["../transition-intent","../transition-state","../handler-info/factory","../utils","exports"],
function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __exports__) {
"use strict";
......@@ -41604,7 +41610,7 @@ define("router/transition-intent/named-transition-intent",
}
});
});
define("router/transition-intent/url-transition-intent",
define("router/transition-intent/url-transition-intent",
["../transition-intent","../transition-state","../handler-info/factory","../utils","exports"],
function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __exports__) {
"use strict";
......@@ -41674,7 +41680,7 @@ define("router/transition-intent/url-transition-intent",
this.name = "UnrecognizedURLError";
}
});
define("router/transition-state",
define("router/transition-state",
["./handler-info","./utils","rsvp/promise","exports"],
function(__dependency1__, __dependency2__, __dependency3__, __exports__) {
"use strict";
......@@ -41791,7 +41797,7 @@ define("router/transition-state",
__exports__["default"] = TransitionState;
});
define("router/transition",
define("router/transition",
["rsvp/promise","./handler-info","./utils","exports"],
function(__dependency1__, __dependency2__, __dependency3__, __exports__) {
"use strict";
......@@ -42052,7 +42058,7 @@ define("router/transition",
__exports__.logAbort = logAbort;
__exports__.TransitionAborted = TransitionAborted;
});
define("router/utils",
define("router/utils",
["exports"],
function(__exports__) {
"use strict";
......@@ -42249,7 +42255,7 @@ define("router/utils",
__exports__.isParam = isParam;
__exports__.coerceQueryParamsToString = coerceQueryParamsToString;
});
define("router",
define("router",
["./router/router","exports"],
function(__dependency1__, __exports__) {
"use strict";
......@@ -265,8 +265,8 @@ var __module2__ = (function(__dependency1__, __dependency2__) {
} else {
for(var key in context) {
if(context.hasOwnProperty(key)) {
if(data) {
data.key = key;
if(data) {
data.key = key;
data.index = i;
data.first = (i === 0);
}
......@@ -775,9 +775,9 @@ var __module9__ = (function() {
var $0 = $$.length - 1;
switch (yystate) {
case 1: return new yy.ProgramNode($$[$0-1], this._$);
case 1: return new yy.ProgramNode($$[$0-1], this._$);
break;
case 2: return new yy.ProgramNode([], this._$);
case 2: return new yy.ProgramNode([], this._$);
break;
case 3:this.$ = new yy.ProgramNode([], $$[$0-1], $$[$0], this._$);
break;
......@@ -793,7 +793,7 @@ var __module9__ = (function() {
break;
case 9:this.$ = [$$[$0]];
break;
case 10: $$[$0-1].push($$[$0]); this.$ = $$[$0-1];
case 10: $$[$0-1].push($$[$0]); this.$ = $$[$0-1];
break;
case 11:this.$ = new yy.BlockNode($$[$0-2], $$[$0-1].inverse, $$[$0-1], $$[$0], this._$);
break;
......@@ -851,7 +851,7 @@ var __module9__ = (function() {
break;
case 38:this.$ = new yy.IdNode($$[$0], this._$);
break;
case 39: $$[$0-2].push({part: $$[$0], separator: $$[$0-1]}); this.$ = $$[$0-2];
case 39: $$[$0-2].push({part: $$[$0], separator: $$[$0-1]}); this.$ = $$[$0-2];
break;
case 40:this.$ = [{part: $$[$0]}];
break;
......@@ -1173,14 +1173,14 @@ var __module9__ = (function() {
this.begin("mu");
}
if(yy_.yytext) return 14;
break;
case 1:return 14;
break;
case 2:
this.popState();
return 14;
break;
case 3:strip(0,4); this.popState(); return 15;
break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment