Skip to content

Commit

Permalink
Upgrade to Vue 2 (#9)
Browse files Browse the repository at this point in the history
* init

* migrate to Vue 2

* remove jasmine

* remove blank

* update readme
  • Loading branch information
hootlex authored Oct 2, 2016
1 parent a688d69 commit 7169f8e
Show file tree
Hide file tree
Showing 20 changed files with 54 additions and 1,733 deletions.
36 changes: 21 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# Vue.js Paginator [![CircleCI](https://circleci.com/gh/hootlex/vuejs-paginator.svg?style=shield&circle-token=:circle-ci-badge-token)](https://circleci.com/gh/hootlex/vuejs-paginator) [![npm downloads](https://img.shields.io/npm/dt/vuejs-paginator.svg)](https://www.npmjs.com/package/vuejs-paginator) <a href="https://www.npmjs.com/package/vuejs-paginator"><img src="https://img.shields.io/npm/v/vuejs-paginator.svg" alt="Version"></a> [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](LICENSE)
> A Vue.js plugin to easily integrate pagination to your projects.
> A Vue.js plugin to easily integrate pagination in your projects.
VueJs Paginator is a simple but powerful plugin, since it gives you access on how to render the data, instead of using a predefined table.
VueJs Paginator is a simple but powerful plugin since it gives you access on how to render the data, instead of using a predefined table.

Just give it a variable where you want the returned data to be stored. Every time the user changes page, your variable will update immediately.
![vue paginator preview](http://i.imgur.com/2jah1qt.gif)

The way you use it is similar to Laravel's paginator.

>Vuejs Paginator takes a `resource_url` and a `resource` empty variable and it fetches the data from the provided URL. When the call is done, it adds the returned data to the `resource` variable.
## Installation
### Through npm
``` bash
Expand All @@ -23,29 +21,37 @@ npm install vuejs-paginator --save-dev
```

## Usage
Register VPaginator component inside your Vue instance.
Use VPaginator in the HTML.
```html
<v-paginator resource_url="api/animals" @update="updateResource"></v-paginator>
```

Prepare the Vue instance.
```js
// if you are not using the cdn version you have to import VuePaginator.
// import VuePaginator from 'vuejs-paginator'
new Vue({
...
data () {
return {
animals: []
}
},
components: {
VPaginator: VuePaginator
},
methods: {
updateResource(data){
this.animals = data
}
}
...
});
```

Use it in your HTML.

```html
<v-paginator :resource.sync="animals" resource_url="api/animals"></v-paginator>
```
### Thats it

### THATS IT
Every time a page is changed or fetched, resource variable will contain the returned data.

Then you will have access to the returned data inside your `resource` variable, in this example **animals**, and you'll be able to render it as you would normally do.
```html
<ul>
<li v-for="animal in animals">
Expand All @@ -55,7 +61,7 @@ Then you will have access to the returned data inside your `resource` variable,
```

### Documentation
[Here you can find a more detailed Documentation along with a few examples.](http://hootlex.github.io/vuejs-paginator/)
[Here you can find the detailed Documentation](http://hootlex.github.io/vuejs-paginator/)

## Build Setup

Expand Down
30 changes: 14 additions & 16 deletions dist/vuejs-paginator.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/vuejs-paginator.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/vuejs-paginator.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"src": "src/"
},
"dependencies": {
"vue": "^1.0.8",
"vue-resource": "^0.9.0"
"vue": "^2.0.0",
"vue-resource": "^1.0.3"
},
"files": [
"LICENSE",
Expand All @@ -39,6 +39,7 @@
"css-loader": "^0.23.1",
"function-bind": "^1.1.0",
"isparta-loader": "^2.0.0",
"karma": "^1.3.0",
"karma-coverage": "^0.5.5",
"karma-mocha": "^0.2.2",
"karma-phantomjs-launcher": "^1.0.0",
Expand Down
7 changes: 2 additions & 5 deletions src/VPaginator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
import {utils} from './utils'
export default {
props: {
resource: {
required: true,
twoWay: true
},
resource_url: {
type: String,
required: true
Expand Down Expand Up @@ -61,7 +57,8 @@ export default {
},
handleResponseData (response) {
this.makePagination(response)
this.$set('resource', utils.getNestedValue(response, this.config.remote_data))
let data = utils.getNestedValue(response, this.config.remote_data)
this.$emit('update', data)
},
makePagination (data) {
this.current_page = utils.getNestedValue(data, this.config.remote_current_page)
Expand Down
212 changes: 0 additions & 212 deletions test/unit/coverage/lcov-report/base.css

This file was deleted.

Loading

0 comments on commit 7169f8e

Please sign in to comment.