Skip to content

Commit

Permalink
Merge pull request #75 from gnarf/ember-1.13
Browse files Browse the repository at this point in the history
Ember 1.13
  • Loading branch information
dgeb committed Jun 15, 2015
2 parents 37b343f + 1049014 commit 3accace
Show file tree
Hide file tree
Showing 25 changed files with 100 additions and 105 deletions.
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

# Defaults for all types of files
[*.{js,styl,css,hbs,html,json,yml}]
indent_style = space
indent_size = 2
charset = utf-8
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ node_modules
*.log
tmp
build
dist
docs
1 change: 1 addition & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"plusplus": false,
"regexp": false,
"undef": true,
"unused": true,
"sub": true,
"strict": false,
"white": false,
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"dependencies": {
"jquery": "~1.11.1",
"qunit": "~1.17.1",
"ember": "~1.10.0",
"ember": "~1.13.0",
"orbit.js": "~0.6.0",
"loader": "stefanpenner/loader.js#1.0.1"
}
Expand Down
20 changes: 9 additions & 11 deletions lib/ember-orbit/fields/attr.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,23 @@ var attr = function(type, options) {
options = options || {};
options.type = type;

var meta = {
options: options,
isAttribute: true
};

return Ember.computed(function(key, value) {
if (arguments.length > 1) {
return Ember.computed({
get: function(key) {
return this.getAttribute(key);
},
set: function(key, value) {
var oldValue = this.getAttribute(key);

if (value !== oldValue) {
this.patch(key, value);
}

return value;

} else {
return this.getAttribute(key);
}
}).meta(meta);
}).meta({
options: options,
isAttribute: true
});
};

export default attr;
12 changes: 6 additions & 6 deletions lib/ember-orbit/fields/has-many.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ var hasMany = function(model, options) {
options.type = 'hasMany';
options.model = model;

var meta = {
return Ember.computed({
get: function(key) {
return this.getLinks(key);
}
}).meta({
options: options,
isLink: true
};

return Ember.computed(function(key) {
return this.getLinks(key);
}).meta(meta).readOnly();
}).readOnly();
};

export default hasMany;
18 changes: 10 additions & 8 deletions lib/ember-orbit/fields/has-one.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ var hasOne = function(model, options) {
isLink: true
};

return Ember.computed(function(key, value) {
var proxy = this.getLink(key);

if (arguments.length > 1) {
var currentValue = get(proxy, 'content');
return Ember.computed({
get: function(key) {
return this.getLink(key);
},
set: function(key, value) {
var proxy = this.getLink(key),
currentValue = get(proxy, 'content');

if (value === null) {
value = undefined;
Expand All @@ -33,11 +35,11 @@ var hasOne = function(model, options) {
}
set(proxy, 'content', value);
}
}

return proxy;

return proxy;
}
}).meta(meta);

};

export default hasOne;
10 changes: 5 additions & 5 deletions lib/ember-orbit/fields/key.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ var key = function(type, options) {
isKey: true
};

return Ember.computed(function(name, value) {
if (arguments.length > 1) {
return Ember.computed({
get: function(name) {
return this.getKey(name);
},
set: function(name, value) {
var oldValue = this.getKey(name);

if (value !== oldValue) {
this.patch(name, value);
}

return value;

} else {
return this.getKey(name);
}
}).meta(meta);
};
Expand Down
7 changes: 2 additions & 5 deletions lib/ember-orbit/links/has-many-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import LinkProxyMixin from './link-proxy-mixin';
@module ember-orbit
*/

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

var forEach = Ember.EnumerableUtils.forEach;
var get = Ember.get;

/**
A `HasManyArray` is a `RecordArray` that represents the contents of a has-many
Expand All @@ -20,7 +17,7 @@ var forEach = Ember.EnumerableUtils.forEach;
*/
var HasManyArray = RecordArray.extend(LinkProxyMixin, {

arrayContentWillChange: function(index, removed, added) {
arrayContentWillChange: function(index, removed) {
var store = get(this, 'store');
var ownerType = get(this, '_ownerType');
var ownerId = get(this, '_ownerId');
Expand Down
3 changes: 1 addition & 2 deletions lib/ember-orbit/links/link-proxy-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
@module ember-orbit
*/

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

var LinkProxyMixin = Ember.Mixin.create({
store: null,
Expand Down
2 changes: 1 addition & 1 deletion lib/ember-orbit/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ var Model = Ember.Object.extend(Ember.Evented, {
var type = this.constructor.typeKey;
var id = get(this, 'primaryId');

var relatedRecords = store.retrieveLinks(type, id, field) || Ember.A();
var relatedRecords = Ember.A(store.retrieveLinks(type, id, field) || []);

var hasManyArray = HasManyArray.create({
content: relatedRecords,
Expand Down
19 changes: 7 additions & 12 deletions lib/ember-orbit/record-array-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import FilteredRecordArray from './record-arrays/filtered-record-array';
@module ember-orbit
*/

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

var forEach = Ember.EnumerableUtils.forEach;
var get = Ember.get;

/**
@class RecordArrayManager
Expand Down Expand Up @@ -46,8 +43,7 @@ var RecordArrayManager = Ember.Object.extend({
// console.log('_processChange', record, operation);

var path = operation.path,
op = operation.op,
value = operation.value;
op = operation.op;

if (path.length === 2) {
if (op === 'add') {
Expand Down Expand Up @@ -81,11 +77,10 @@ var RecordArrayManager = Ember.Object.extend({
var recordArrays = record._recordArrays;

if (recordArrays) {
recordArrays = recordArrays.toArray();

forEach(recordArrays, function(array) {
array.removeObject(record);
});
recordArrays.toArray()
.forEach(function(array) {
array.removeObject(record);
});
}

record.destroy();
Expand All @@ -97,7 +92,7 @@ var RecordArrayManager = Ember.Object.extend({
filter;

if (recordArrays) {
forEach(recordArrays, function(array) {
recordArrays.forEach(function(array) {
filter = get(array, 'filterFunction');
this.updateRecordArray(array, filter, type, record);
}, this);
Expand Down
3 changes: 1 addition & 2 deletions lib/ember-orbit/record-arrays/record-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
@module ember-orbit
*/

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

var forEach = Ember.EnumerableUtils.forEach;

Expand Down
32 changes: 19 additions & 13 deletions lib/ember-orbit/schema.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import OrbitSchema from 'orbit-common/schema';
import key from 'ember-orbit/fields/key';
import { uuid } from 'orbit/lib/uuid';

/**
@module ember-orbit
Expand All @@ -11,18 +9,26 @@ var get = Ember.get;
var proxyProperty = function(source, property, defaultValue) {
var _property = '_' + property;

return function(key, value) {
if (arguments.length > 1) {
this[_property] = value;
if (this[source]) {
this[source][property] = value;
return Ember.computed({
set: function(key, value) {
if (arguments.length > 1) {
this[_property] = value;
if (this[source]) {
this[source][property] = value;
}
}
if (!this[_property]) {
this[_property] = defaultValue;
}
return this[_property];
},
get: function() {
if (!this[_property]) {
this[_property] = defaultValue;
}
return this[_property];
}
if (!this[_property]) {
this[_property] = defaultValue;
}
return this[_property];
}.property();
});
};

var Schema = Ember.Object.extend({
Expand Down Expand Up @@ -109,7 +115,7 @@ var Schema = Ember.Object.extend({
return this._schema.models[type].primaryKey.name;
},

primaryKeyProperties: function(type, name) {
primaryKeyProperties: function(type) {
return this._schema.models[type].primaryKey;
},

Expand Down
3 changes: 1 addition & 2 deletions lib/ember-orbit/source.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Schema from './schema';
import OCSource from 'orbit-common/source';

/**
Expand Down Expand Up @@ -47,4 +46,4 @@ var Source = Ember.Object.extend({
}
});

export default Source;
export default Source;
10 changes: 3 additions & 7 deletions lib/ember-orbit/store.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import Source from './source';
import Model from './model';
import RecordArrayManager from './record-array-manager';
import OCMemorySource from 'orbit-common/memory-source';

/**
@module ember-orbit
*/

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

var RSVP = Ember.RSVP;

Expand Down Expand Up @@ -284,12 +282,10 @@ var Store = Source.extend({
Ember.assert("`type` must be registered as a model in the container", get(this, 'schema').modelFor(type));
},

_didTransform: function(operation, inverse) {
_didTransform: function(operation) {
// console.log('_didTransform', operation, inverse);

var op = operation.op,
path = operation.path,
value = operation.value,
var path = operation.path,
record = this._lookupRecord(path[0], path[1]);

if (path.length === 3) {
Expand Down
1 change: 1 addition & 0 deletions test/ember-env.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
window.EmberENV = { EXTEND_PROTOTYPES: false };
1 change: 1 addition & 0 deletions test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script src="ember-env.js"></script>
<script src="/assets/loader.js"></script>
<script src="/assets/vendor.js"></script>
<script src="/assets/qunit.js"></script>
Expand Down
Loading

0 comments on commit 3accace

Please sign in to comment.