Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

made _currentPage public => is now currentPage #59

Merged
merged 1 commit into from
Jul 27, 2015
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
14 changes: 7 additions & 7 deletions addon/mixins/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ export default Ember.Mixin.create({

/**
@private
@property _currentPage
@property currentPage
@type Integer
@default 0
*/
_currentPage: 0,
currentPage: 0,

/**
@private
Expand Down Expand Up @@ -106,9 +106,9 @@ export default Ember.Mixin.create({
@type Boolean
@default false
*/
_canLoadMore: Ember.computed('_totalPages', '_currentPage', function() {
_canLoadMore: Ember.computed('_totalPages', 'currentPage', function() {
var totalPages = this.get('_totalPages');
var currentPage = this.get('_currentPage');
var currentPage = this.get('currentPage');
return (totalPages && currentPage) ? (currentPage < totalPages) : false;
}),

Expand Down Expand Up @@ -160,7 +160,7 @@ export default Ember.Mixin.create({
promise.then(
infinityModel => {
var totalPages = infinityModel.get(this.get('totalPagesParam'));
this.set('_currentPage', startingPage);
this.set('currentPage', startingPage);
this.set('_totalPages', totalPages);
infinityModel.set('reachedInfinity', !this.get('_canLoadMore'));
Ember.run.scheduleOnce('afterRender', this, 'infinityModelUpdated', {
Expand All @@ -184,7 +184,7 @@ export default Ember.Mixin.create({
@return {Boolean}
*/
_infinityLoad() {
var nextPage = this.get('_currentPage') + 1;
var nextPage = this.get('currentPage') + 1;
var perPage = this.get('_perPage');
var totalPages = this.get('_totalPages');
var modelName = this.get('_infinityModelName');
Expand All @@ -207,7 +207,7 @@ export default Ember.Mixin.create({
newObjects => {
this.updateInfinityModel(newObjects);
this.set('_loadingMore', false);
this.set('_currentPage', nextPage);
this.set('currentPage', nextPage);
Ember.run.scheduleOnce('afterRender', this, 'infinityModelUpdated', {
lastPageLoaded: nextPage,
totalPages: totalPages,
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/mixins/route-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ test('it sets state before it reaches the end', assert => {
});

assert.equal(31, route.get('_totalPages'));
assert.equal(1, route.get('_currentPage'));
assert.equal(1, route.get('currentPage'));
assert.equal(true, route.get('_canLoadMore'));
assert.ok(Ember.$.isEmptyObject(route.get('_extraParams')));
assert.ok(!model.get('reachedInfinity'), 'Should not reach infinity');
Expand Down Expand Up @@ -186,7 +186,7 @@ test('it sets state when it reaches the end', assert => {
});

assert.equal(31, route.get('_totalPages'));
assert.equal(31, route.get('_currentPage'));
assert.equal(31, route.get('currentPage'));
assert.ok(Ember.$.isEmptyObject(route.get('_extraParams')));
assert.equal(false, route.get('_canLoadMore'));
assert.ok(model.get('reachedInfinity'), 'Should reach infinity');
Expand Down Expand Up @@ -244,7 +244,7 @@ test('it uses extra params when loading more data', assert => {

assert.equal('param', route.get('_extraParams.extra'));
assert.equal(false, route.get('_canLoadMore'));
assert.equal(2, route.get('_currentPage'));
assert.equal(2, route.get('currentPage'));
assert.ok(model.get('reachedInfinity'), 'Should reach infinity');

});
Expand Down Expand Up @@ -304,7 +304,7 @@ test('it uses overridden params when loading more data', assert => {
});

assert.equal(false, route.get('_canLoadMore'));
assert.equal(3, route.get('_currentPage'));
assert.equal(3, route.get('currentPage'));
assert.ok(model.get('reachedInfinity'), 'Should reach infinity');

});
Expand Down Expand Up @@ -369,7 +369,7 @@ test('it uses bound params when loading more data', assert => {
});

assert.equal(false, route.get('_canLoadMore'));
assert.equal(3, route.get('_currentPage'));
assert.equal(3, route.get('currentPage'));
assert.ok(model.get('reachedInfinity'), 'Should reach infinity');
});

Expand Down