Skip to content

Commit

Permalink
Merge remote-tracking branch 'ebryn/master' into update
Browse files Browse the repository at this point in the history
# Conflicts:
#	ember-model.js
  • Loading branch information
Paul Oliver committed Apr 3, 2016
2 parents d5a123b + afcd09b commit d4f73d8
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 149 deletions.
9 changes: 6 additions & 3 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "ember-model",
"version": "0.0.16",
"version": "0.0.17",
"main": "ember-model.js",
"dependencies": {
"ember": "~1.13"
"ember": "2.0.3"
},
"devDependencies": {
"qunit": "~1.11"
Expand All @@ -12,5 +12,8 @@
"**/.*",
"node_modules",
"components"
]
],
"resolutions": {
"ember": "2.0.3"
}
}
150 changes: 25 additions & 125 deletions ember-model.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
(function() {

var VERSION = '0.0.16';
var VERSION = '0.0.17';

if (Ember.libraries) {
Ember.libraries.register('Ember Model', VERSION);
}


})();

(function() {



})();

(function() {
Expand Down Expand Up @@ -46,14 +40,6 @@ Ember.Adapter = Ember.Object.extend({

(function() {



})();

(function() {



var get = Ember.get,
set = Ember.set;

Expand Down Expand Up @@ -166,12 +152,6 @@ Ember.FixtureAdapter = Ember.Adapter.extend({
});


})();

(function() {



})();

(function() {
Expand Down Expand Up @@ -233,14 +213,6 @@ Ember.RecordArray = Ember.ArrayProxy.extend(Ember.Evented, {

(function() {



})();

(function() {



var get = Ember.get;

Ember.FilteredRecordArray = Ember.RecordArray.extend({
Expand Down Expand Up @@ -299,12 +271,6 @@ Ember.FilteredRecordArray = Ember.RecordArray.extend({
}
});

})();

(function() {



})();

(function() {
Expand Down Expand Up @@ -350,12 +316,12 @@ Ember.ManyArray = Ember.RecordArray.extend({
var content = get(this, 'content');

if (!content.length) { return; }

// need to add observer if it wasn't materialized before
var observerNeeded = (content[idx].record) ? false : true;

var record = this.materializeRecord(idx, this.container);

if (observerNeeded) {
var isDirtyRecord = record.get('isDirty'), isNewRecord = record.get('isNew');
if (isDirtyRecord || isNewRecord) { this._modifiedRecords.pushObject(content[idx]); }
Expand All @@ -374,9 +340,9 @@ Ember.ManyArray = Ember.RecordArray.extend({
},

replaceContent: function(index, removed, added) {
added = Ember.EnumerableUtils.map(added, function(record) {
added = added.map(function(record) {
return record._reference;
}, this);
});

this._super(index, removed, added);
},
Expand Down Expand Up @@ -418,7 +384,7 @@ Ember.ManyArray = Ember.RecordArray.extend({
var content = item;
for (var i = idx; i < idx+addedCnt; i++) {
var currentItem = content[i];
if (currentItem && currentItem.record) {
if (currentItem && currentItem.record) {
var isDirtyRecord = currentItem.record.get('isDirty'), isNewRecord = currentItem.record.get('isNew'); // why newly created object is not dirty?
if (isDirtyRecord || isNewRecord) { this._modifiedRecords.pushObject(currentItem); }
Ember.addObserver(currentItem, 'record.isDirty', this, 'recordStateChanged');
Expand Down Expand Up @@ -460,15 +426,15 @@ Ember.ManyArray = Ember.RecordArray.extend({
},

recordStateChanged: function(obj, keyName) {
var parent = get(this, 'parent'), relationshipKey = get(this, 'relationshipKey');
var parent = get(this, 'parent'), relationshipKey = get(this, 'relationshipKey');

if (obj.record.get('isDirty')) {
if (this._modifiedRecords.indexOf(obj) === -1) { this._modifiedRecords.pushObject(obj); }
parent._relationshipBecameDirty(relationshipKey);
} else {
if (this._modifiedRecords.indexOf(obj) > -1) { this._modifiedRecords.removeObject(obj); }
if (!this.get('isDirty')) {
parent._relationshipBecameClean(relationshipKey);
parent._relationshipBecameClean(relationshipKey);
}
}
}
Expand Down Expand Up @@ -547,20 +513,6 @@ Ember.EmbeddedHasManyArray = Ember.ManyArray.extend({

(function() {



})();

(function() {



})();

(function() {



var get = Ember.get,
set = Ember.set,
setProperties = Ember.setProperties,
Expand Down Expand Up @@ -682,7 +634,7 @@ Ember.Model = Ember.Object.extend(Ember.Evented, {
load: function(id, hash) {
var data = {};
data[get(this.constructor, 'primaryKey')] = id;
set(this, '_data', Ember.merge(data, hash));
set(this, '_data', Ember.assign(data, hash));
this.getWithDefault('_dirtyAttributes', []).clear();

this._reloadHasManys();
Expand Down Expand Up @@ -943,7 +895,7 @@ Ember.Model = Ember.Object.extend(Ember.Evented, {
} else {
mapFunction = function(id) { return type._getOrCreateReferenceForId(id); };
}
content = Ember.EnumerableUtils.map(content, mapFunction);
content = content.map(mapFunction);
}

return Ember.A(content || []);
Expand Down Expand Up @@ -1405,12 +1357,6 @@ Ember.Model.reopenClass({
});


})();

(function() {



})();

(function() {
Expand Down Expand Up @@ -1463,7 +1409,6 @@ Ember.Model.computed = function() {

(function() {


var get = Ember.get;

function getType(record) {
Expand Down Expand Up @@ -1530,13 +1475,6 @@ Ember.Model.reopen({

(function() {



})();

(function() {


var get = Ember.get,
set = Ember.set;

Expand Down Expand Up @@ -1617,9 +1555,7 @@ Ember.belongsTo = function(type, options) {
}

if (value) {
Ember.assert(Ember.String.fmt('Attempted to set property of type: %@ with a value of type: %@',
[value.constructor, type]),
value instanceof type);
Ember.assert('Attempted to set property of type: ' + value.constructor + ' with a value of type: ' + type, value instanceof type);
}

if (oldValue !== value) {
Expand Down Expand Up @@ -1677,16 +1613,9 @@ Ember.Model.reopen({

(function() {



})();

(function() {


var get = Ember.get,
set = Ember.set,
meta = Ember.meta;
set = Ember.set,
meta = Ember.meta;

Ember.Model.dataTypes = {};

Expand Down Expand Up @@ -1790,14 +1719,6 @@ Ember.attr = function(type, options) {

(function() {



})();

(function() {



var get = Ember.get;

Ember.RESTAdapter = Ember.Adapter.extend({
Expand Down Expand Up @@ -1915,9 +1836,9 @@ Ember.RESTAdapter = Ember.Adapter.extend({

ajaxSettings: function(url, method) {
return {
url : url,
type : method,
dataType : "json"
url: url,
type: method,
dataType: "json"
};
},

Expand All @@ -1938,7 +1859,7 @@ Ember.RESTAdapter = Ember.Adapter.extend({
settings.data = params;
}
}
}
} return new Ember.RSVP.Promise(function(resolve, reject) {

settings.success = function(json, textStatus, jqXHR) {
Ember.run(null, resolve, json);
Expand All @@ -1954,12 +1875,14 @@ Ember.RESTAdapter = Ember.Adapter.extend({
}

self._handleRejections(method, jqXHR, resolve, reject);



if (settings.errorCallback) {
settings.errorCallback.call(this, jqXHR, textStatus, errorThrown);
}
};


Ember.$.ajax(settings);
});
},
Expand All @@ -1986,12 +1909,6 @@ Ember.RESTAdapter = Ember.Adapter.extend({
});


})();

(function() {



})();

(function() {
Expand Down Expand Up @@ -2019,12 +1936,6 @@ Ember.loadPromise = function(target) {
};


})();

(function() {



})();

(function() {
Expand Down Expand Up @@ -2138,19 +2049,14 @@ Ember.onLoad('Ember.Application', function(Application) {
Application.initializer({
name: "data-adapter",

initialize: function(container, application) {
initialize: function() {
var application = arguments[1] || arguments[0];
application.register('data-adapter:main', DebugAdapter);
}
});
});


})();

(function() {



})();

(function() {
Expand Down Expand Up @@ -2182,7 +2088,7 @@ Ember.Model.Store = Ember.Object.extend({
createRecord: function(type, props) {
var klass = this.modelFor(type);
klass.reopenClass({adapter: this.adapterFor(type)});
return klass.create(Ember.merge({container: this.container}, props));
return klass.create(Ember.assign({container: this.container}, props));
},

find: function(type, id) {
Expand Down Expand Up @@ -2218,7 +2124,8 @@ Ember.onLoad('Ember.Application', function(Application) {
Application.initializer({
name: "store",

initialize: function(_, application) {
initialize: function() {
var application = arguments[1] || arguments[0];
var store = application.Store || Ember.Model.Store;
application.register('store:application', store);
application.register('store:main', store);
Expand All @@ -2231,11 +2138,4 @@ Ember.onLoad('Ember.Application', function(Application) {
});


})();

(function() {




})();
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
"grunt-contrib-watch": "~0.4.4",
"grunt-ember-s3": "~1.0.2"
},
"version": "0.0.16"
"version": "0.0.17"
}
Loading

0 comments on commit d4f73d8

Please sign in to comment.