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


#61

I don’t want to use the space for the first or last page.

Yes make it optional!!


#62

If you click 10
< 1 2 3 4 5 6 7 8 9 10 >
(numPagesToShowBefore: 0, numPagesToShowAfter: 9, numPagesToShow: 10,)
you get:
< 5 6 7 8 9 10 11 12 13 14 >
(numPagesToShowBefore: 5, numPagesToShowAfter: 4, numPagesToShow: 10,)
If you click 13:
< 8 9 10 11 12 13 14 15 16 17>
(numPagesToShowBefore: 5, numPagesToShowAfter: 4, numPagesToShow: 10,)
If you click 8:
< 3 4 5 6 7 8 9 10 11 12 >
(numPagesToShowBefore: 5, numPagesToShowAfter: 4, numPagesToShow: 10,)
If you click 3:
< 1 2 3 4 5 6 7 8 9 10>
(numPagesToShowBefore: 2, numPagesToShowAfter: 7, numPagesToShow: 10,)

Perhaps:

midPos = int(numPagesToShow / 2)

if currentPage - midPod < 1
  numPagesToShowBefore = currentPage - 1
else
  numPagesToShowBefore = midPos

numPagesToShowAfter = numPagesToShow - numPagesToShowBefore - 1

#63

To fix http://exmer.com/bloggrcouch/posts?page=666 I think adding if (this.isValidPage to res.push(currentPage); and // add first and last page will fix this.

If you showFL we can add res.push(after+1);

// add first page if not already there
        if (res[0] !== 1) {
          res = [1].concat(res);
        } else {
          if (this.isValidPage(after + 1)) {
            res.push(after + 1);
          }
        }

but perhaps it is better to change the before and after earlier??


#64

Will respond with coherent thoughts soon


#65

Just uploaded my fixed test version: http://exmer.com/bloggrcouch/


#66

for the http://exmer.com/bloggrcouch/posts?page=666 fix I tried:

if (!this.isValidPage(currentPage)) {
 this.send('pageClicked', totalPages);
}

But I don’t understand calling an action on a component yet ;-(


#67

I think it is better to change the before and after earlier:


#68

I came across this recent blogpost about pagination, might be useful: http://webcloud.info/blog/2014/11/01/building-a-real-world-pagination-with-ember-js-the-right-way


#69

Thanks for the link. I think Mike is building pagination the right way though :wink:


#70

Appreciated! Thanks @broerse


#71

How can I keep my itemcontroller’s functionality with pagedArray()?

Previously I had

import Ember from 'ember';

export default Ember.ArrayController.extend({
  itemController: 'user',
});

Which worked fine. Now that my templates use

{{#each user in pagedContent}}

My itemcontrollers don’t work anymore

{{#if user.hasRoles}}

How do I hook these up?

EDIT: Since it seems the future of Ember is ‘no-controllers’, I moved the code from my ArrayController to a fresh Component. This works really well by the way! Thanks for the awesome plugin!


#72

can you provide source code for this?


#73

Not sure whet source code you like to see. Perhaps this ?:


#74

thanks, i wanted the code for broerse one.


#75

i’m having problem with using pagination on my project which uses firebase to store the data,so i wanted to see some examples on how its done. BTW i’m a newbie :smiley:


#76

Sorry I use ember-pouch everywhere so I don’t know much about firebase. You can take a look at :


#77

Oh, no problem bro.I’ll look into this.Thanks for replying.


#78

Please could you provide the steps to run this application in my local?


#79

I got it working. thank you guys:)