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


#41

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.


#42

0.4.0 fixed this bug!


#43

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


#44

The 0.4.0 does not stay on page 2 See: http://exmer.com/bloggrcouch/posts?page=2&perPage=5


#45

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


#46

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

http://exmer.com/bloggrcouch/posts?page=1&perPage=10 -> perPage=5 http://exmer.com/bloggrcouch/posts?page=2&perPage=5 -> page=1

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


#47

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


#48

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


#49

Any chance I can see the code behind this bug?


#50

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


#51

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


#52

@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"
});

#53

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"
});

#54

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


#55

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.


#56

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.


#57

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: http://exmer.com/bloggrcouch/posts?page=666


#58

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


#59

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


#60

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.