update ember
This commit is contained in:
parent
7eeb44a9f5
commit
431deae0c6
135
assets/javascripts/vendor/ember-data.js
vendored
135
assets/javascripts/vendor/ember-data.js
vendored
|
@ -1387,6 +1387,10 @@ DS.Store = Ember.Object.extend({
|
|||
return array;
|
||||
},
|
||||
|
||||
recordIsLoaded: function(type, id) {
|
||||
return !Ember.none(this.typeMapFor(type).idToCid[id]);
|
||||
},
|
||||
|
||||
// ............
|
||||
// . UPDATING .
|
||||
// ............
|
||||
|
@ -2387,7 +2391,7 @@ var DirtyState = DS.State.extend({
|
|||
errors = get(record, 'errors'),
|
||||
key = context.key;
|
||||
|
||||
delete errors[key];
|
||||
set(errors, key, null);
|
||||
|
||||
if (!hasDefinedProperties(errors)) {
|
||||
manager.send('becameValid');
|
||||
|
@ -3172,6 +3176,7 @@ var storeAlias = function(methodName) {
|
|||
};
|
||||
|
||||
DS.Model.reopenClass({
|
||||
isLoaded: storeAlias('recordIsLoaded'),
|
||||
find: storeAlias('find'),
|
||||
filter: storeAlias('filter'),
|
||||
|
||||
|
@ -3699,34 +3704,132 @@ Ember.onLoad('application', function(app) {
|
|||
|
||||
|
||||
(function() {
|
||||
DS.fixtureAdapter = DS.Adapter.create({
|
||||
find: function(store, type, id) {
|
||||
var fixtures = type.FIXTURES;
|
||||
var get = Ember.get;
|
||||
|
||||
Ember.assert("Unable to find fixtures for model type "+type.toString(), !!fixtures);
|
||||
if (fixtures.hasLoaded) { return; }
|
||||
DS.FixtureAdapter = DS.Adapter.extend({
|
||||
|
||||
setTimeout(function() {
|
||||
store.loadMany(type, fixtures);
|
||||
fixtures.hasLoaded = true;
|
||||
}, 300);
|
||||
simulateRemoteResponse: true,
|
||||
|
||||
latency: 50,
|
||||
|
||||
/*
|
||||
Implement this method in order to provide data associated with a type
|
||||
*/
|
||||
fixturesForType: function(type) {
|
||||
return type.FIXTURES ? Ember.A(type.FIXTURES) : null;
|
||||
},
|
||||
|
||||
findMany: function() {
|
||||
this.find.apply(this, arguments);
|
||||
/*
|
||||
Implement this method in order to query fixtures data
|
||||
*/
|
||||
queryFixtures: function(fixtures, query) {
|
||||
return fixtures;
|
||||
},
|
||||
|
||||
/*
|
||||
Implement this method in order to provide provide json for CRUD methods
|
||||
*/
|
||||
mockJSON: function(type, record) {
|
||||
return record.toJSON({associations: true});
|
||||
},
|
||||
|
||||
/*
|
||||
Adapter methods
|
||||
*/
|
||||
generateIdForRecord: function(store, record) {
|
||||
return Ember.guidFor(record);
|
||||
},
|
||||
|
||||
find: function(store, type, id) {
|
||||
var fixtures = this.fixturesForType(type);
|
||||
|
||||
if (fixtures) {
|
||||
fixtures = fixtures.findProperty('id', id);
|
||||
}
|
||||
|
||||
Ember.assert("Unable to find fixtures for model type "+type.toString(), !!fixtures);
|
||||
|
||||
this.simulateRemoteCall(function() {
|
||||
store.load(type, fixtures);
|
||||
}, store, type);
|
||||
},
|
||||
|
||||
findMany: function(store, type, ids) {
|
||||
var fixtures = this.fixturesForType(type);
|
||||
|
||||
if (fixtures) {
|
||||
fixtures = fixtures.filter(function(item) {
|
||||
return ids.indexOf(item.id) !== -1;
|
||||
});
|
||||
}
|
||||
|
||||
Ember.assert("Unable to find fixtures for model type "+type.toString(), !!fixtures);
|
||||
|
||||
this.simulateRemoteCall(function() {
|
||||
store.loadMany(type, fixtures);
|
||||
}, store, type);
|
||||
},
|
||||
|
||||
findAll: function(store, type) {
|
||||
var fixtures = type.FIXTURES;
|
||||
var fixtures = this.fixturesForType(type);
|
||||
|
||||
Ember.assert("Unable to find fixtures for model type "+type.toString(), !!fixtures);
|
||||
|
||||
var ids = fixtures.map(function(item, index, self){ return item.id; });
|
||||
store.loadMany(type, ids, fixtures);
|
||||
}
|
||||
this.simulateRemoteCall(function() {
|
||||
store.loadMany(type, fixtures);
|
||||
}, store, type);
|
||||
},
|
||||
|
||||
findQuery: function(store, type, query, array) {
|
||||
var fixtures = this.fixturesForType(type);
|
||||
|
||||
fixtures = this.queryFixtures(fixtures, query);
|
||||
|
||||
Ember.assert("Unable to find fixtures for model type "+type.toString(), !!fixtures);
|
||||
|
||||
this.simulateRemoteCall(function() {
|
||||
array.load(fixtures);
|
||||
}, store, type);
|
||||
},
|
||||
|
||||
createRecord: function(store, type, record) {
|
||||
var fixture = this.mockJSON(type, record);
|
||||
|
||||
fixture.id = this.generateIdForRecord(store, record);
|
||||
|
||||
this.simulateRemoteCall(function() {
|
||||
store.didCreateRecord(record, fixture);
|
||||
}, store, type, record);
|
||||
},
|
||||
|
||||
updateRecord: function(store, type, record) {
|
||||
var fixture = this.mockJSON(type, record);
|
||||
|
||||
this.simulateRemoteCall(function() {
|
||||
store.didUpdateRecord(record, fixture);
|
||||
}, store, type, record);
|
||||
},
|
||||
|
||||
deleteRecord: function(store, type, record) {
|
||||
this.simulateRemoteCall(function() {
|
||||
store.didDeleteRecord(record);
|
||||
}, store, type, record);
|
||||
},
|
||||
|
||||
/*
|
||||
@private
|
||||
*/
|
||||
simulateRemoteCall: function(callback, store, type, record) {
|
||||
if (get(this, 'simulateRemoteResponse')) {
|
||||
setTimeout(callback, get(this, 'latency'));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
DS.fixtureAdapter = DS.FixtureAdapter.create();
|
||||
|
||||
})();
|
||||
|
||||
|
||||
|
|
2310
assets/javascripts/vendor/ember.js
vendored
2310
assets/javascripts/vendor/ember.js
vendored
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user