New Addon: Ember CLI Pagination - Looking to help people get setup

If I click page 1 it shows 5 items. Page 2, 14 items and Pages 3, 9 items. If you want I can try to upload a version with this bug.

0.4.0 fixed this bug!

Ah. I think thanks go to venkatesh3007’s PR for that one. Glad it’s fixed :slight_smile:

The 0.4.0 does not stay on page 2 See: Myapp

Perhaps it is my own bug created by the beforeModel in the index route. I will check later.

It is not the beforeModel. The URL must be leading.

Myapp → perPage=5 Myapp → page=1

I am not 100% sure this is a bug in the pagination add-on.

it probably is. My brain seems to be shutting off for the day, but it’s at the top of my list for tomorrow.

Thanks again for all your help

Thanks also for this great add-on. It is 23:14 for me also :wink:

Any chance I can see the code behind this bug?

Never mind, forgot it’s ember-cli-blog

Definitely a bug, exposed a gaping hole in the test coverage. Thanks for the find.

https://github.com/mharris717/ember-cli-pagination/issues/30

@broerse could you give this a try?

export default Ember.ArrayController.extend({
  page: 1,
  perPage: 10,

  pagedContent: pagedArray("content", {pageBinding: "page", perPageBinding: "perPage"}),

  queryParams: ["page", "perPage"],

  totalPagesBinding: "pagedContent.totalPages"
});

I tried and the binding works but the perPage is not shown in url as queryparam anymore? Code used:

import Ember from "ember";
import pagedArray from 'ember-cli-pagination/computed/paged-array';

export default Ember.ArrayController.extend({
  sortProperties: ['date'],
  sortAscending: false,
  
  page: 1,
  perPage: 5,

  pagedContent: pagedArray("arrangedContent", {pageBinding: "page", perPageBinding: "perPage"}),

  queryParams: ["page", "perPage"],

  totalPagesBinding: "pagedContent.totalPages"
});

I believe it doesn’t show in the url if it’s currently the default, but you can still put it there manually.

Yes but I’ve put perPage: 5 and not the default 10 in the code above and it does not show up. Or is this not what you mean with “currently the default”? If I type the url by hand it follows what I type in perPage so this is working fine. I will update my working example later today.

Sorry, my wording was imprecise. By “default,” I mean the value you set for perPage in your controller. So in your case, the default would be 5, and perPage would only show in the url if it is not 5.

I will look into the logic for when to put query params in the url when I get a chance.

I can live with this default. I think the Google search truncating way is more logical than how truncating is done now. Support both ;-). I also think “page” must be reset to the last page when out of range. See: Myapp

Can you elaborate on the differences in the way google does it, and what you like?

If you click 10
< 1 2 3 4 5 6 7 8 9 10 >
you get:
< 5 6 7 8 9 10 11 12 13 14 >
If you click 13:
< 8 9 10 11 12 13 14 15 16 17>
If you click 8:
< 3 4 5 6 7 8 9 10 11 12 >

So you can’t click on last but you walk over pages per 4 pages or more depending how many pageselectors there are. In almost all pagination systems I use I don’t want to be able to click the last page but it can be added as an option just as the perPage=0 to show all pages. See also: New Addon: Ember CLI Pagination - Looking to help people get setup - #35 by broerse

Gotcha. I added the last page cause i thought it looked a bit confusing without it, meaning not at all clear that there were more pages when you were on page one, and it was much easier for now than added ellipses.

Could add optional display of number of total pages instead.

Thanks again, you’re the man.