Use ember-data from drogus fork, easier-overrides branch
This commit is contained in:
parent
395c818a64
commit
0a09c96eb1
125
assets/scripts/vendor/ember-data.js
vendored
125
assets/scripts/vendor/ember-data.js
vendored
|
@ -1,4 +1,4 @@
|
||||||
// Last commit: 8801f2e (2013-02-15 13:53:27 -0800)
|
// Last commit: 6d9eeaf (2013-02-20 22:27:54 +0100)
|
||||||
|
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
@ -151,7 +151,7 @@ DS.AdapterPopulatedRecordArray = DS.RecordArray.extend({
|
||||||
set(this, 'isLoaded', true);
|
set(this, 'isLoaded', true);
|
||||||
this.endPropertyChanges();
|
this.endPropertyChanges();
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
// TODO: does triggering didLoad event should be the last action of the runLoop?
|
// TODO: does triggering didLoad event should be the last action of the runLoop?
|
||||||
Ember.run.once(function() {
|
Ember.run.once(function() {
|
||||||
self.trigger('didLoad');
|
self.trigger('didLoad');
|
||||||
|
@ -3918,19 +3918,19 @@ DS.Model.reopen({
|
||||||
|
|
||||||
attributeDidChange: Ember.observer(function(record, key) {
|
attributeDidChange: Ember.observer(function(record, key) {
|
||||||
record.send('didSetProperty', { name: key });
|
record.send('didSetProperty', { name: key });
|
||||||
})
|
}),
|
||||||
});
|
|
||||||
|
|
||||||
function getAttr(record, options, key) {
|
getAttr: function(key, options) {
|
||||||
var attributes = get(record, 'data').attributes;
|
var attributes = get(this, 'data').attributes;
|
||||||
var value = attributes[key];
|
var value = attributes[key];
|
||||||
|
|
||||||
if (value === undefined) {
|
if (value === undefined) {
|
||||||
value = options.defaultValue;
|
value = options.defaultValue ;
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
DS.attr = function(type, options) {
|
DS.attr = function(type, options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
|
@ -3947,7 +3947,7 @@ DS.attr = function(type, options) {
|
||||||
if (arguments.length > 1) {
|
if (arguments.length > 1) {
|
||||||
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');
|
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');
|
||||||
} else {
|
} else {
|
||||||
value = getAttr(this, options, key);
|
value = this.getAttr(key, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
|
@ -3972,18 +3972,8 @@ DS.attr = function(type, options) {
|
||||||
var get = Ember.get, set = Ember.set,
|
var get = Ember.get, set = Ember.set,
|
||||||
none = Ember.isNone;
|
none = Ember.isNone;
|
||||||
|
|
||||||
DS.belongsTo = function(type, options) {
|
DS.Model.reopen({
|
||||||
Ember.assert("The first argument DS.belongsTo must be a model type or string, like DS.belongsTo(App.Person)", !!type && (typeof type === 'string' || DS.Model.detect(type)));
|
getBelongsTo: function(key, type, meta) {
|
||||||
|
|
||||||
options = options || {};
|
|
||||||
|
|
||||||
var meta = { type: type, isRelationship: true, options: options, kind: 'belongsTo' };
|
|
||||||
|
|
||||||
return Ember.computed(function(key, value) {
|
|
||||||
if (arguments.length === 2) {
|
|
||||||
return value === undefined ? null : value;
|
|
||||||
}
|
|
||||||
|
|
||||||
var data = get(this, 'data').belongsTo,
|
var data = get(this, 'data').belongsTo,
|
||||||
store = get(this, 'store'), id;
|
store = get(this, 'store'), id;
|
||||||
|
|
||||||
|
@ -4000,6 +3990,22 @@ DS.belongsTo = function(type, options) {
|
||||||
} else {
|
} else {
|
||||||
return store.find(type, id);
|
return store.find(type, id);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
DS.belongsTo = function(type, options) {
|
||||||
|
Ember.assert("The first argument DS.belongsTo must be a model type or string, like DS.belongsTo(App.Person)", !!type && (typeof type === 'string' || DS.Model.detect(type)));
|
||||||
|
|
||||||
|
options = options || {};
|
||||||
|
|
||||||
|
var meta = { type: type, isRelationship: true, options: options, kind: 'belongsTo' };
|
||||||
|
|
||||||
|
return Ember.computed(function(key, value) {
|
||||||
|
if (arguments.length === 2) {
|
||||||
|
return value === undefined ? null : value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.getBelongsTo(key, type, meta);
|
||||||
}).property('data').meta(meta);
|
}).property('data').meta(meta);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4049,12 +4055,8 @@ DS.Model.reopen({
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var get = Ember.get, set = Ember.set;
|
var get = Ember.get, set = Ember.set;
|
||||||
var hasRelationship = function(type, options) {
|
DS.Model.reopen({
|
||||||
options = options || {};
|
getHasMany: function(key, type, meta) {
|
||||||
|
|
||||||
var meta = { type: type, isRelationship: true, options: options, kind: 'hasMany' };
|
|
||||||
|
|
||||||
return Ember.computed(function(key, value) {
|
|
||||||
var data = get(this, 'data').hasMany,
|
var data = get(this, 'data').hasMany,
|
||||||
store = get(this, 'store'),
|
store = get(this, 'store'),
|
||||||
ids, relationship;
|
ids, relationship;
|
||||||
|
@ -4069,6 +4071,16 @@ var hasRelationship = function(type, options) {
|
||||||
set(relationship, 'name', key);
|
set(relationship, 'name', key);
|
||||||
|
|
||||||
return relationship;
|
return relationship;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var hasRelationship = function(type, options) {
|
||||||
|
options = options || {};
|
||||||
|
|
||||||
|
var meta = { type: type, isRelationship: true, options: options, kind: 'hasMany' };
|
||||||
|
|
||||||
|
return Ember.computed(function(key, value) {
|
||||||
|
return this.getHasMany(key, type, meta);
|
||||||
}).property().meta(meta);
|
}).property().meta(meta);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4508,12 +4520,12 @@ DS.RelationshipChange.determineRelationshipType = function(recordType, knownSide
|
||||||
|
|
||||||
if(options.inverse){
|
if(options.inverse){
|
||||||
key = options.inverse;
|
key = options.inverse;
|
||||||
otherContainerType = get(otherType, 'relationshipsByName').get(key).kind;
|
otherContainerType = get(otherType, 'relationshipsByName').get(key).kind;
|
||||||
}
|
}
|
||||||
else if(assoc = DS._inverseRelationshipFor(otherType, recordType)){
|
else if(assoc = DS._inverseRelationshipFor(otherType, recordType)){
|
||||||
key = assoc.name;
|
key = assoc.name;
|
||||||
otherContainerType = assoc.kind;
|
otherContainerType = assoc.kind;
|
||||||
}
|
}
|
||||||
if(!key){
|
if(!key){
|
||||||
return knownContainerType === "belongsTo" ? "oneToNone" : "manyToNone";
|
return knownContainerType === "belongsTo" ? "oneToNone" : "manyToNone";
|
||||||
}
|
}
|
||||||
|
@ -4524,8 +4536,8 @@ DS.RelationshipChange.determineRelationshipType = function(recordType, knownSide
|
||||||
else{
|
else{
|
||||||
return knownContainerType === "belongsTo" ? "oneToMany" : "manyToMany";
|
return knownContainerType === "belongsTo" ? "oneToMany" : "manyToMany";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
DS.RelationshipChange.createChange = function(firstRecordReference, secondRecordReference, store, options){
|
DS.RelationshipChange.createChange = function(firstRecordReference, secondRecordReference, store, options){
|
||||||
|
@ -4933,7 +4945,9 @@ DS.RelationshipChangeRemove.prototype.sync = function() {
|
||||||
|
|
||||||
if (secondRecord && firstRecord) {
|
if (secondRecord && firstRecord) {
|
||||||
if(this.secondRecordKind === "belongsTo"){
|
if(this.secondRecordKind === "belongsTo"){
|
||||||
|
secondRecord.suspendRelationshipObservers(function(){
|
||||||
set(secondRecord, secondRecordName, null);
|
set(secondRecord, secondRecordName, null);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else if(this.secondRecordKind === "hasMany"){
|
else if(this.secondRecordKind === "hasMany"){
|
||||||
secondRecord.suspendRelationshipObservers(function(){
|
secondRecord.suspendRelationshipObservers(function(){
|
||||||
|
@ -6469,7 +6483,6 @@ DS.JSONSerializer = DS.Serializer.extend({
|
||||||
|
|
||||||
sideloadedType = type.typeForRelationship(prop);
|
sideloadedType = type.typeForRelationship(prop);
|
||||||
|
|
||||||
console.log('sideloadedType', type, prop, sideloadedType);
|
|
||||||
if (!sideloadedType) {
|
if (!sideloadedType) {
|
||||||
sideloadedType = this.sideloadMapping.get(prop);
|
sideloadedType = this.sideloadMapping.get(prop);
|
||||||
|
|
||||||
|
@ -6676,7 +6689,7 @@ DS.Adapter = Ember.Object.extend(DS._Mappable, {
|
||||||
occupations: [{
|
occupations: [{
|
||||||
id: 345,
|
id: 345,
|
||||||
title: "Tricycle Mechanic"
|
title: "Tricycle Mechanic"
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -6706,12 +6719,12 @@ DS.Adapter = Ember.Object.extend(DS._Mappable, {
|
||||||
For example, the `RESTAdapter` saves newly created records by
|
For example, the `RESTAdapter` saves newly created records by
|
||||||
making an Ajax request. When the server returns, the adapter
|
making an Ajax request. When the server returns, the adapter
|
||||||
calls didCreateRecord. If the server returns a response body,
|
calls didCreateRecord. If the server returns a response body,
|
||||||
it is passed as the payload.
|
it is passed as the payload.
|
||||||
|
|
||||||
@param {DS.Store} store
|
@param {DS.Store} store
|
||||||
@param {subclass of DS.Model} type
|
@param {subclass of DS.Model} type
|
||||||
@param {DS.Model} record
|
@param {DS.Model} record
|
||||||
@param {any} payload
|
@param {any} payload
|
||||||
*/
|
*/
|
||||||
didCreateRecord: function(store, type, record, payload) {
|
didCreateRecord: function(store, type, record, payload) {
|
||||||
store.didSaveRecord(record);
|
store.didSaveRecord(record);
|
||||||
|
@ -6733,7 +6746,7 @@ DS.Adapter = Ember.Object.extend(DS._Mappable, {
|
||||||
Acknowledges that the adapter has finished creating several records.
|
Acknowledges that the adapter has finished creating several records.
|
||||||
|
|
||||||
Your adapter should call this method from `createRecords` when it
|
Your adapter should call this method from `createRecords` when it
|
||||||
has saved multiple created records to its persistent storage
|
has saved multiple created records to its persistent storage
|
||||||
received an acknowledgement.
|
received an acknowledgement.
|
||||||
|
|
||||||
If the persistent storage returns a new payload in response to the
|
If the persistent storage returns a new payload in response to the
|
||||||
|
@ -6743,7 +6756,7 @@ DS.Adapter = Ember.Object.extend(DS._Mappable, {
|
||||||
@param {DS.Store} store
|
@param {DS.Store} store
|
||||||
@param {subclass of DS.Model} type
|
@param {subclass of DS.Model} type
|
||||||
@param {DS.Model} record
|
@param {DS.Model} record
|
||||||
@param {any} payload
|
@param {any} payload
|
||||||
*/
|
*/
|
||||||
didCreateRecords: function(store, type, records, payload) {
|
didCreateRecords: function(store, type, records, payload) {
|
||||||
records.forEach(function(record) {
|
records.forEach(function(record) {
|
||||||
|
@ -6772,7 +6785,7 @@ DS.Adapter = Ember.Object.extend(DS._Mappable, {
|
||||||
@param {DS.Store} store
|
@param {DS.Store} store
|
||||||
@param {subclass of DS.Model} type
|
@param {subclass of DS.Model} type
|
||||||
@param {DS.Model} record
|
@param {DS.Model} record
|
||||||
@param {any} payload
|
@param {any} payload
|
||||||
*/
|
*/
|
||||||
didSaveRecord: function(store, type, record, payload) {
|
didSaveRecord: function(store, type, record, payload) {
|
||||||
store.didSaveRecord(record);
|
store.didSaveRecord(record);
|
||||||
|
@ -6805,7 +6818,7 @@ DS.Adapter = Ember.Object.extend(DS._Mappable, {
|
||||||
@param {DS.Store} store
|
@param {DS.Store} store
|
||||||
@param {subclass of DS.Model} type
|
@param {subclass of DS.Model} type
|
||||||
@param {DS.Model} record
|
@param {DS.Model} record
|
||||||
@param {any} payload
|
@param {any} payload
|
||||||
*/
|
*/
|
||||||
didUpdateRecord: function() {
|
didUpdateRecord: function() {
|
||||||
this.didSaveRecord.apply(this, arguments);
|
this.didSaveRecord.apply(this, arguments);
|
||||||
|
@ -6824,14 +6837,14 @@ DS.Adapter = Ember.Object.extend(DS._Mappable, {
|
||||||
@param {DS.Store} store
|
@param {DS.Store} store
|
||||||
@param {subclass of DS.Model} type
|
@param {subclass of DS.Model} type
|
||||||
@param {DS.Model} record
|
@param {DS.Model} record
|
||||||
@param {any} payload
|
@param {any} payload
|
||||||
*/
|
*/
|
||||||
didDeleteRecord: function() {
|
didDeleteRecord: function() {
|
||||||
this.didSaveRecord.apply(this, arguments);
|
this.didSaveRecord.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Acknowledges that the adapter has finished updating or deleting
|
Acknowledges that the adapter has finished updating or deleting
|
||||||
multiple records.
|
multiple records.
|
||||||
|
|
||||||
Your adapter should call this method from its `updateRecords` or
|
Your adapter should call this method from its `updateRecords` or
|
||||||
|
@ -6844,7 +6857,7 @@ DS.Adapter = Ember.Object.extend(DS._Mappable, {
|
||||||
@param {DS.Store} store
|
@param {DS.Store} store
|
||||||
@param {subclass of DS.Model} type
|
@param {subclass of DS.Model} type
|
||||||
@param {DS.Model} records
|
@param {DS.Model} records
|
||||||
@param {any} payload
|
@param {any} payload
|
||||||
*/
|
*/
|
||||||
didSaveRecords: function(store, type, records, payload) {
|
didSaveRecords: function(store, type, records, payload) {
|
||||||
records.forEach(function(record) {
|
records.forEach(function(record) {
|
||||||
|
@ -6870,7 +6883,7 @@ DS.Adapter = Ember.Object.extend(DS._Mappable, {
|
||||||
@param {DS.Store} store
|
@param {DS.Store} store
|
||||||
@param {subclass of DS.Model} type
|
@param {subclass of DS.Model} type
|
||||||
@param {DS.Model} records
|
@param {DS.Model} records
|
||||||
@param {any} payload
|
@param {any} payload
|
||||||
*/
|
*/
|
||||||
didUpdateRecords: function() {
|
didUpdateRecords: function() {
|
||||||
this.didSaveRecords.apply(this, arguments);
|
this.didSaveRecords.apply(this, arguments);
|
||||||
|
@ -6889,7 +6902,7 @@ DS.Adapter = Ember.Object.extend(DS._Mappable, {
|
||||||
@param {DS.Store} store
|
@param {DS.Store} store
|
||||||
@param {subclass of DS.Model} type
|
@param {subclass of DS.Model} type
|
||||||
@param {DS.Model} records
|
@param {DS.Model} records
|
||||||
@param {any} payload
|
@param {any} payload
|
||||||
*/
|
*/
|
||||||
didDeleteRecords: function() {
|
didDeleteRecords: function() {
|
||||||
this.didSaveRecords.apply(this, arguments);
|
this.didSaveRecords.apply(this, arguments);
|
||||||
|
@ -6907,7 +6920,7 @@ DS.Adapter = Ember.Object.extend(DS._Mappable, {
|
||||||
|
|
||||||
@param {DS.Store} store
|
@param {DS.Store} store
|
||||||
@param {subclass of DS.Model} type
|
@param {subclass of DS.Model} type
|
||||||
@param {any} payload
|
@param {any} payload
|
||||||
@param {String} id
|
@param {String} id
|
||||||
*/
|
*/
|
||||||
didFindRecord: function(store, type, payload, id) {
|
didFindRecord: function(store, type, payload, id) {
|
||||||
|
@ -6931,7 +6944,7 @@ DS.Adapter = Ember.Object.extend(DS._Mappable, {
|
||||||
|
|
||||||
@param {DS.Store} store
|
@param {DS.Store} store
|
||||||
@param {subclass of DS.Model} type
|
@param {subclass of DS.Model} type
|
||||||
@param {any} payload
|
@param {any} payload
|
||||||
*/
|
*/
|
||||||
didFindAll: function(store, type, payload) {
|
didFindAll: function(store, type, payload) {
|
||||||
var loader = DS.loaderFor(store),
|
var loader = DS.loaderFor(store),
|
||||||
|
@ -6950,7 +6963,7 @@ DS.Adapter = Ember.Object.extend(DS._Mappable, {
|
||||||
|
|
||||||
@param {DS.Store} store
|
@param {DS.Store} store
|
||||||
@param {subclass of DS.Model} type
|
@param {subclass of DS.Model} type
|
||||||
@param {any} payload
|
@param {any} payload
|
||||||
@param {DS.AdapterPopulatedRecordArray} recordArray
|
@param {DS.AdapterPopulatedRecordArray} recordArray
|
||||||
*/
|
*/
|
||||||
didFindQuery: function(store, type, payload, recordArray) {
|
didFindQuery: function(store, type, payload, recordArray) {
|
||||||
|
@ -6971,7 +6984,7 @@ DS.Adapter = Ember.Object.extend(DS._Mappable, {
|
||||||
|
|
||||||
@param {DS.Store} store
|
@param {DS.Store} store
|
||||||
@param {subclass of DS.Model} type
|
@param {subclass of DS.Model} type
|
||||||
@param {any} payload
|
@param {any} payload
|
||||||
*/
|
*/
|
||||||
didFindMany: function(store, type, payload) {
|
didFindMany: function(store, type, payload) {
|
||||||
var loader = DS.loaderFor(store);
|
var loader = DS.loaderFor(store);
|
||||||
|
@ -7095,7 +7108,7 @@ DS.Adapter = Ember.Object.extend(DS._Mappable, {
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
A public method that allows you to register an enumerated
|
A public method that allows you to register an enumerated
|
||||||
type on your adapter. This is useful if you want to utilize
|
type on your adapter. This is useful if you want to utilize
|
||||||
a text representation of an integer value.
|
a text representation of an integer value.
|
||||||
|
|
||||||
|
@ -7107,7 +7120,7 @@ DS.Adapter = Ember.Object.extend(DS._Mappable, {
|
||||||
|
|
||||||
You would then refer to the 'priority' DS.attr in your model:
|
You would then refer to the 'priority' DS.attr in your model:
|
||||||
App.Task = DS.Model.extend({
|
App.Task = DS.Model.extend({
|
||||||
priority: DS.attr('priority')
|
priority: DS.attr('priority')
|
||||||
});
|
});
|
||||||
|
|
||||||
And lastly, you would set/get the text representation on your model instance,
|
And lastly, you would set/get the text representation on your model instance,
|
||||||
|
@ -7117,7 +7130,7 @@ DS.Adapter = Ember.Object.extend(DS._Mappable, {
|
||||||
Server Response / Load: { myTask: {priority: 0} }
|
Server Response / Load: { myTask: {priority: 0} }
|
||||||
|
|
||||||
@param {String} type of the transform
|
@param {String} type of the transform
|
||||||
@param {Array} array of String objects to use for the enumerated values.
|
@param {Array} array of String objects to use for the enumerated values.
|
||||||
This is an ordered list and the index values will be used for the transform.
|
This is an ordered list and the index values will be used for the transform.
|
||||||
*/
|
*/
|
||||||
registerEnumTransform: function(attributeType, objects) {
|
registerEnumTransform: function(attributeType, objects) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user