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 #58

Closed
wants to merge 1 commit into from
Closed
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
25 changes: 12 additions & 13 deletions addon/mixins/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@ export default Ember.Mixin.create({
*/
_perPage: 25,

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

/**
@private
@property _extraParams
Expand Down Expand Up @@ -75,6 +67,13 @@ export default Ember.Mixin.create({
@default 'controller.model'
*/
_modelPath: 'controller.model',

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

/**
* Name of the "per page" param in the
Expand Down Expand Up @@ -106,9 +105,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 +159,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 +183,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 +206,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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ember-infinity",
"version": "0.0.11",
"version": "0.0.12",
"description": "Simple, flexible infinite scroll for Ember CLI Apps.",
"directories": {
"doc": "doc",
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