Skip to content
This repository was archived by the owner on Apr 24, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions ember-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ Ember.RecordArray = Ember.ArrayProxy.extend(Ember.Evented, {
var modelClass = this.get('modelClass'),
self = this,
promises;

set(this, 'isLoaded', false);
if (modelClass._findAllRecordArray === this) {
return modelClass.adapter.findAll(modelClass, this);
Expand Down Expand Up @@ -340,29 +340,29 @@ 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);
},

_contentWillChange: function() {
_contentDidChange: function() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there tests covering these functions? If not, perhaps we could add them?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there no tests? 😱

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, package/tests I had the same thought awhile ago. I'll dig into the tests a bit now and confirm there's coverage here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I should say, these changes were already in upstream, they'd just never been built.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there is an open PR on ember-model for this or that they have already been merged? If merged, any reason why we didn't branch off master?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They've been merged. We did branch off master.

They were merged without running grunt release so the changes are in the packages directory but not in the concated release file that we actually use through bower.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

👍

var content = get(this, 'content');
var contentPrev = this._content;

if (content) {
this.arrayWillChange(content, 0, get(content, 'length'), 0);
content.removeArrayObserver(this);
if (contentPrev && contentPrev !== content) {
this.arrayWillChange(contentPrev, 0, get(contentPrev, 'length'), 0);
contentPrev.removeArrayObserver(this);
this._setupOriginalContent(content);
}
}.observesBefore('content'),

_contentDidChange: function() {
var content = get(this, 'content');
if (content) {
content.addArrayObserver(this);
this.arrayDidChange(content, 0, 0, get(content, 'length'));
}

this._content = content;
}.observes('content'),

arrayWillChange: function(item, idx, removedCnt, addedCnt) {
Expand Down Expand Up @@ -891,7 +891,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 @@ -2111,4 +2111,4 @@ Ember.onLoad('Ember.Application', function(Application) {
});


})();
})();
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"
}
12 changes: 6 additions & 6 deletions packages/ember-model/lib/has_many_array.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,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 @@ -63,7 +63,7 @@ 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);

Expand Down Expand Up @@ -107,7 +107,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 @@ -149,15 +149,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
2 changes: 1 addition & 1 deletion packages/ember-model/lib/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,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