Giter VIP home page Giter VIP logo

aurelia-pager's Introduction

Archived

It was fun while it lasted, but we have to stop maintaining these repositories. We haven't used these projects for quite some time and maintaining them is becoming harder to do.

You deserve better, and for that reason we've decided to archive some repositories, which includes this one.

Feel free to fork and alter the repositories, and go forth making awesome stuff.

Pager

Pagination / pager module for aurelia. Works well with aurelia-paged.

Uses

Aurelia-pager needs following plugins installed and configured:

Used by

Following plugins need an installation of aurelia-pager:

Installation

Aureli-Cli

Run npm i aurelia-pager --save from your project root.

And add the following to the build.bundles.dependencies section of aurelia-project/aurelia.json:

"dependencies": [
  {
    "name": "aurelia-pager",
    "path": "../node_modules/aurelia-pager/dist/amd",
    "main": "aurelia-pager",
    "resources": [
      "bootstrap/pager.html"
    ]
  },
  // ...
],

Jspm

Run jspm i aurelia-pager from your project root.

And add following to the bundles.dist.aurelia.includes section of build/bundles.js:

 "aurelia-pager",
 "[aurelia-pager/**/*.js]",
 "aurelia-pager/**/*.html!text",

If the installation results in having forks, try resolving them by running:

jspm inspect --forks
jspm resolve --only registry:package-name@version

Webpack

Run npm i aurelia-pager --save from your project root.

And add aurelia-pager in the coreBundles.aurelia section of your webpack.config.js.

Webpack - aurelia-pal

If your project is using PLATFORM.moduleName. Then you will need to register the plugin as follows.

aurelia.use.plugin(PLATFORM.moduleName('aurelia-pager'));

In your webpack.config.js you will need to add an import. By default the import looks like this

const { AureliaPlugin } = require('aurelia-webpack-plugin');

You need to change it as follows

const { AureliaPlugin, ModuleDependenciesPlugin } = require('aurelia-webpack-plugin');

Next find the plugins export which currently looks like this

plugins: [
    new AureliaPlugin(),
    new ProvidePlugin({
      'Promise': 'bluebird',
      '$': 'jquery',
      'jQuery': 'jquery',
      'window.jQuery': 'jquery'
    })...

You can then add the following

    new ModuleDependenciesPlugin({
      "aurelia-pager": ['./bootstrap/pager.html', './pager']
    })...

The plugins export would now looks something like this

plugins: [
    new AureliaPlugin(),
    new ProvidePlugin({
      'Promise': 'bluebird',
      '$': 'jquery',
      'jQuery': 'jquery',
      'window.jQuery': 'jquery'
    }),
    new ModuleDependenciesPlugin({
      "aurelia-pager": ['./bootstrap/pager.html', './pager']
    })...

Typescript

Npm-based installations pick up the typings automatically. For Jspm-based installations, run typings i github:spoonx/aurelia-pager or add "aurelia-pager": "github:spoonx/aurelia-pager", to your typings.json and run typings i.

Usage

Bindables

page (optional)

The current page, default is 1.

pages

The amount of pages.

pagerange (optional)

The range of the pages to view, default is 3.

Example:

Range is 2: 3 4 [5] 6 7, [1] 2 3 4 5

Range is 3: 2 3 4 [5] 6 7 8, [1] 2 3 4 5 6 7

The amount of displaying is range * 2 + current page

onPageChanged (optional)

This will be called when the page value changes. The function should match the signature.

HandlePageChanged(newValue, oldValue);

limit (optional)

This will set the amount of items on a page and will be used to calculate the amount of pages, default is 30.

resource (optional)

Will override the pages option.

Using a database

Fetches the count from the DB using aurelia-orm. Expects that the amount of pages is located in the count property.

Using an array

Calculates the pages based on the amount of items in the array and the limit.

criteria (optional)

This option only works when resource is enabled and comes from the DB. Parameter gets passed straight to the query field of .count().

Example (sailsjs/waterline or express):

{
  disabled : 0,
  createdAt: {'>', '2016-01-01'}
}

Changing framework

You can override the framework used for the datatable with any of the supported ones using the aurelia-view-manager.

Examples

<pager pages.bind="$amountOfPages" page.bind="1" pagerange.bind="2"></pager>

Using a resource:

this.localData = [{id: 1, name: 'bob'}, {id: 2, name: 'henk'}, {id: 3, name: 'jan'}];
<pager resource.bind="localData"></pager>

Using criteria (using aurelia-orm:

this.dbData = entityManager.getRepository('users');
<pager repository.bind="dbData" criteria.bind="{disabled: 0}"></pager>

aurelia-pager's People

Contributors

bas080 avatar codeflowee avatar doktordirk avatar louislewis2 avatar rwoverdijk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

aurelia-pager's Issues

onPageChanged not working

Hi,

I have this in my html:
<pager pages.bind="myPages" page.bind="myPage" resourceCount.bind="myResourceCount" limit.bind="limit" onPageChanged.bind="handlePageChange"></pager>

and this in my js:

handlePageChange(oldValue, newValue) { console.log("new value: " + newValue); }

But my function is never called. :(

how to use onPageChanged event in pager tag

Hi there,
I am not able to use onPageChanged property of pager.

i tried
html

 <pager pages.bind="pages" page.bind="page"  onPageChanged.bind="HandlePageChanged"></pager>
<pager pages.bind="pages" page.bind="page"  onPageChanged.bind="HandlePageChanged(newValue, oldValue)">
</pager>
<pager pages.bind="pages" page.bind="page"  onPageChanged.bind="HandlePageChanged()">
</pager>
 <pager pages.bind="pages" page.bind="page"  onPageChanged.delegate="HandlePageChanged"></pager>
<pager pages.bind="pages" page.bind="page"  onPageChanged.delegate="HandlePageChanged(newValue, oldValue)">
</pager>
<pager pages.bind="pages" page.bind="page"  onPageChanged.delegate="HandlePageChanged()">
</pager>

in ts(javascript)

HandlePageChanged(newValue, oldValue)
{
//do your work
}

nothing is working for me

can anyone help me with demo example.

Thanks in Advance

Change "resource"

Think of a better name than "resource". Resource is reserved terminology (by orm)

Not working with latest bits

Hi, I am having an issue when trying to use aurelia-pager with the latest bits.
I am using a typescript / webpack setup.

In my main.ts I have the following code

  aurelia.use.plugin(PLATFORM.moduleName('aurelia-bootstrap'));
  aurelia.use.plugin(PLATFORM.moduleName('aurelia-pager'));
  aurelia.use.plugin(PLATFORM.moduleName('aurelia-validation'));
  aurelia.use.plugin(PLATFORM.moduleName('aurelia-api'), config => {

aurelia-api works as expected, as does validation and bootstrap.
aurelia-pager gives the following error:

Error: Unable to find module with ID: aurelia-pager/pager
Stack trace:
Error: Unable to find module with ID: aurelia-pager/pager
WebpackLoader.prototype._import/</<@webpack-internal:///196:194:35
step@webpack-internal:///196:43:18
verb/<@webpack-internal:///196:24:53
__awaiter</<@webpack-internal:///196:18:15
__awaiter<@webpack-internal:///196:14:12
WebpackLoader.prototype._import@webpack-internal:///196:159:16
WebpackLoader.prototype.loadModule/</<@webpack-internal:///196:259:39
step@webpack-internal:///196:43:18
verb/<@webpack-internal:///196:24:53
__awaiter</<@webpack-internal:///196:18:15

Missing Demo

Hi,

Any plans on releasing a sample/demo?
I'm getting an error: Error: Unable to find module with ID: aurelia-pager/pager
below is my entry in main.js:
aurelia.use.plugin(PLATFORM.moduleName("aurelia-pager"));

Kindly advise. Thanks!

Page Changed Event

Would it be a far stretch to request that the api for the pager be extended,
to include an optional event to be called when the page is changed?

Currently I need to go through effort and use a property observer
and handle the change in that way. It would be much simpler to be able to have a method
called on a class.

I use server side paging, sorting etc...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.