Skip to content
This repository was archived by the owner on Jun 10, 2021. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: coderdiaz/vue-datasource
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.0.5
Choose a base ref
...
head repository: coderdiaz/vue-datasource
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Oct 15, 2017

  1. Update README.md

    coderdiaz authored Oct 15, 2017
    Copy the full SHA
    18b1a61 View commit details

Commits on Oct 17, 2017

  1. Update README.md

    coderdiaz authored Oct 17, 2017
    Copy the full SHA
    396ce83 View commit details

Commits on Oct 30, 2017

  1. Removed client version

    coderdiaz committed Oct 30, 2017
    Copy the full SHA
    3d9f3d7 View commit details
  2. Copy the full SHA
    cba788e View commit details
  3. Copy the full SHA
    663af0a View commit details
  4. Added icons for sorting

    coderdiaz committed Oct 30, 2017
    Copy the full SHA
    5de2d7c View commit details
  5. Copy the full SHA
    c88ed22 View commit details
  6. Fixed dependencies

    coderdiaz committed Oct 30, 2017
    Copy the full SHA
    748fe22 View commit details
  7. Removed png sort images

    coderdiaz committed Oct 30, 2017
    Copy the full SHA
    96f7dcc View commit details
  8. Added svg sort images

    coderdiaz committed Oct 30, 2017
    Copy the full SHA
    637cd80 View commit details
  9. Added other sort event

    coderdiaz committed Oct 30, 2017
    Copy the full SHA
    0bbb445 View commit details
  10. Copy the full SHA
    e5080fe View commit details
  11. Emitting name event sort

    coderdiaz committed Oct 30, 2017
    Copy the full SHA
    7ec819c View commit details
  12. Merge pull request #56 from coderdiaz/feature/sort-columns

    feature/sort-columns
    coderdiaz authored Oct 30, 2017

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    2a4c835 View commit details
  13. Added new screenshot

    coderdiaz committed Oct 30, 2017
    Copy the full SHA
    a500405 View commit details
  14. Updated README.md

    coderdiaz committed Oct 30, 2017
    Copy the full SHA
    002f701 View commit details
  15. 2.0.6

    coderdiaz committed Oct 30, 2017
    Copy the full SHA
    37fcedd View commit details

Commits on Nov 10, 2017

  1. Add Beerpay's badge

    coderdiaz committed Nov 10, 2017
    Copy the full SHA
    76b4a9b View commit details
  2. Update README.md

    coderdiaz authored Nov 10, 2017

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    f486969 View commit details
  3. Update README.md

    coderdiaz authored Nov 10, 2017

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    58b1c7a View commit details

Commits on Jan 17, 2018

  1. Added component for SvgIcon

    coderdiaz committed Jan 17, 2018
    Copy the full SHA
    fc281ca View commit details
  2. Copy the full SHA
    8333e52 View commit details
  3. 2.0.7

    coderdiaz committed Jan 17, 2018
    Copy the full SHA
    8fdba93 View commit details

Commits on Mar 12, 2018

  1. Update README.md

    coderdiaz authored Mar 12, 2018

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    76279dc View commit details

Commits on Jul 7, 2018

  1. chore: deprecated

    coderdiaz authored Jul 7, 2018

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    d1fc762 View commit details

Commits on Oct 9, 2018

  1. chore: updated readme.md

    coderdiaz committed Oct 9, 2018
    Copy the full SHA
    88992d9 View commit details
36 changes: 35 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[WIP] Vue Datasource go back renew. Coming soon V3.

<p align="center">
<a href="https://github.com/coderdiaz/vue-datasource">
<img src="logo.png" width="120">
@@ -10,10 +12,12 @@
</p>

<p align="center">
<a href="https://npmjs.com/package/vue-datasource"><img src="https://img.shields.io/npm/dt/vue-datasource.svg?style=flat-square"></a>
<a href="https://github.com/coderdiaz/vue-datasource/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square"></a>
<a href="https://github.com/coderdiaz/vue-datasource/stargazers"><img src="https://img.shields.io/github/stars/coderdiaz/vue-datasource.svg?style=flat-square"></a>
<a href="http://npmjs.com/package/vue-datasource"><img src="https://img.shields.io/npm/dm/vue-datasource.svg?style=flat-square"></a>
<a href="http://npmjs.com/package/vue-datasource"><img src="https://img.shields.io/npm/v/vue-datasource.svg?style=flat-square"></a>
<a href="http://npmjs.com/package/vue-datasource"><img src="https://img.shields.io/npm/dm/vue-datasource.svg?style=flat-square"></a>
<a href="https://www.paypal.me/coderdiaz"><img src="https://img.shields.io/badge/invite-coffee-red.svg?style=flat-square"></a>
</p>

---
@@ -23,6 +27,10 @@
<img src="screenshot.png">
</p>

### Donate

<a class="bmc-button" target="_blank" href="https://www.buymeacoffee.com/coderdiaz"><img src="https://www.buymeacoffee.com/assets/img/BMC-btn-logo.svg" alt="Buy me a coffee"><span style="margin-left:5px">Buy me a coffee</span></a>

### Install/Usage
For use this package is necessary install [babel-plugin-transform-vue-jsx](https://github.com/vuejs/babel-plugin-transform-vue-jsx) dependency.

@@ -76,6 +84,7 @@ new Vue({
|-------------|-----------------------------------------------------------------------------------------------------|
| change | Handle show limit changed. Gets object with new show limit and current page `{perpage: 10, page: 2}`|
| searching | Handles search input. Gets string as parameter |
| column-sort | Only if `order` is defined in column array. Return the current column sorted with metadata ([Sort Column](#sort-column))

### Columns
Each column object needs `name` and `key` attributes.
@@ -120,6 +129,31 @@ To get the user role we would need to define in our columns array:
}
```

### Sort column
**[New]** You only need a `order` property in column defined for use this feature.
```javascript
{
...,
columns: [
{
name: 'Name',
key: 'name',
order: true
}
]
}
```

This feature emit a event `column-sort` with this data object
```javascript
{
sort: {
key: 'name',
order: false
},
type: 'DESC'
}
```

### Render column
This callback will modify the data for various operations. Such as applying a specific format or an arithmetic operation to the column value and return it.
11 changes: 6 additions & 5 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-datasource",
"version": "2.0.5",
"version": "2.0.7",
"description": "A vue server side component to create dynamic tables",
"author": "Javier Diaz <coderdiaz@gmail.com>",
"private": false,
@@ -35,6 +35,7 @@
],
"homepage": "https://github.com/coderdiaz/vue-datasource#readme",
"dependencies": {
"axios": "^0.17.0",
"vue": "^2.2.6"
},
"devDependencies": {
Binary file modified screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -23,11 +23,13 @@ export default {
columns: [
{
name: 'Id',
key: 'id'
key: 'id',
order: true
},
{
name: 'First Name',
key: 'first_name'
key: 'first_name',
order: true
},
{
name: 'Last Name',
3 changes: 3 additions & 0 deletions src/assets/icon-sort-asc.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/icon-sort-desc.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 0 additions & 47 deletions src/components/ClientDatasource.vue

This file was deleted.

79 changes: 71 additions & 8 deletions src/components/ServerDatasource.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<script>
import DatasourceUtils from '../utils/DatasourceUtils'
import DatasourceUtils from '@/utils/DatasourceUtils'
import Pagination from './Pagination'
import {EventBus} from '../utils/EventBus'
import {EventBus} from '@/utils/EventBus'
import SvgIcon from '@/components/SvgIcon'
export default {
name: 'ServerDatasource',
components: {Pagination},
components: {Pagination, SvgIcon},
render (h) {
return (
<div class="vue-server-datasource">
@@ -124,7 +125,11 @@ export default {
current_page: 1,
selected: null, // row and Object selected on click event
indexSelected: -1, // index row selected on click event
search: '' // word to search in the table,
search: '', // word to search in the table,
columnSortSelected: { // Object to set a column sort data
key: null,
order: true
}
}
},
computed: {
@@ -134,8 +139,30 @@ export default {
})
},
columnItems () {
let showArrows = (key) => {
if (this.columnSortSelected.key) {
return (this.shouldShowUpArrow(key)) ? <span class="icon-asc">
<SvgIcon/>
</span>
: <span class="icon-desc">
<SvgIcon/>
</span>
} else {
return <span class="icon-desc">
<SvgIcon/>
</span>
}
}
return this.columns.map((column, index) => {
return <th>{column.name}</th>
if (column.order) {
return <th class="vue-server-ordering" on-click={(e) => this.sortColumn(e, column.key)}>
{column.name}
<span class="vue-server-arrows">{showArrows(column.key)}</span>
</th>
} else {
return <th>{column.name}</th>
}
})
},
columnObjects () {
@@ -182,7 +209,10 @@ export default {
this.indexSelected = -1
this.current_page = 1
this.$emit('searching', e.target.value)
}
},
sortColumn: DatasourceUtils.sortColumn,
shouldShowUpArrow: DatasourceUtils.shouldShowUpArrow,
shouldShowDownArrow: DatasourceUtils.shouldShowDownArrow
},
watch: {
/**
@@ -208,8 +238,29 @@ export default {
position: relative;
padding: 0;
}
.vue-server-arrows {
position: absolute;
right: 5px;
top: 6px;
}
table {
margin-bottom: 0;
th {
position: relative;
&.vue-server-ordering {
cursor: pointer;
.vue-server-arrows {
img {
opacity: .3;
&.arrow-active {
opacity: 1;
}
}
}
}
}
}
.panel-footer {
.btn-group-actions {
@@ -222,15 +273,27 @@ export default {
width: 100%;
height: 100%;
background: rgba(229, 229, 229, 0.5);
.v-spinner {
position: absolute;
position: absolute;
top: 50%;
left: 50%;
margin-left: -25px;
margin-top: -50px;
}
}
.icon-asc,
.icon-desc {
svg {
fill: #a3a3a3;
width: 1em;
}
}
.icon-asc {
svg {
transform: rotate(180deg);
}
}
}
.pr1 {
8 changes: 8 additions & 0 deletions src/components/SvgIcon.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<script>
export default {
name: 'SvgIcon',
render (h) {
return (<svg id="lnr-sort-amount-asc" viewBox="0 0 1024 1024" width="100%" height="100%"><title>sort-amount-asc</title><path class="path1" d="M453.301 749.899c-9.997-9.997-26.206-9.997-36.203 0l-161.098 161.098v-885.397c0-14.138-11.462-25.6-25.6-25.6s-25.6 11.462-25.6 25.6v885.397l-161.099-161.098c-9.997-9.997-26.206-9.997-36.203 0s-9.998 26.206 0 36.203l204.8 204.8c5 4.998 11.55 7.498 18.102 7.498s13.102-2.499 18.101-7.499l204.8-204.8c9.998-9.997 9.998-26.205 0-36.202z"></path><path class="path2" d="M691.2 256h-102.4c-14.139 0-25.6-11.462-25.6-25.6v-102.4c0-14.138 11.461-25.6 25.6-25.6h102.4c14.139 0 25.6 11.462 25.6 25.6v102.4c0 14.138-11.461 25.6-25.6 25.6zM614.4 204.8h51.2v-51.2h-51.2v51.2z"></path><path class="path3" d="M793.6 460.8h-204.8c-14.139 0-25.6-11.462-25.6-25.6v-102.4c0-14.138 11.461-25.6 25.6-25.6h204.8c14.139 0 25.6 11.462 25.6 25.6v102.4c0 14.138-11.461 25.6-25.6 25.6zM614.4 409.6h153.6v-51.2h-153.6v51.2z"></path><path class="path4" d="M896 665.6h-307.2c-14.139 0-25.6-11.461-25.6-25.6v-102.4c0-14.139 11.461-25.6 25.6-25.6h307.2c14.139 0 25.6 11.461 25.6 25.6v102.4c0 14.139-11.461 25.6-25.6 25.6zM614.4 614.4h256v-51.2h-256v51.2z"></path><path class="path5" d="M998.4 870.4h-409.6c-14.139 0-25.6-11.461-25.6-25.6v-102.4c0-14.139 11.461-25.6 25.6-25.6h409.6c14.139 0 25.6 11.461 25.6 25.6v102.4c0 14.139-11.461 25.6-25.6 25.6zM614.4 819.2h358.4v-51.2h-358.4v51.2z"></path></svg>)
}
}
</script>
41 changes: 41 additions & 0 deletions src/utils/DatasourceUtils.js
Original file line number Diff line number Diff line change
@@ -82,6 +82,47 @@ export default {
return temp
},

/**
* Function to $emit a sort event
* @param {Exception} e
* @param {String} key
* @return void
*/
sortColumn (e, key) {
if (this.columnSortSelected.key === key) {
this.columnSortSelected.order = !this.columnSortSelected.order
} else {
this.columnSortSelected.order = false
this.columnSortSelected.key = key
}
let sortType = (this.columnSortSelected.order) ? 'ASC' : 'DESC'
this.$emit('column-sort', { sort: this.columnSortSelected, type: sortType })
},

/**
* Function to show up arrow
* @param {String} key
* @return Boolean
*/
shouldShowUpArrow (key) {
return (this.columnSortSelected.key === key) && (this.columnSortSelected.order === true)
},

/**
* Function to show down arrow
* @param {String} key
* @return Boolean
*/
shouldShowDownArrow (key) {
return (this.columnSortSelected.key === key) && (this.columnSortSelected.order === false)
},

/**
* Function to get a value rounded
* @param {Number} value
* @param {Number} precision
* @return Number
*/
roundNumber (value, precision) {
let multiplier = Math.pow(10, precision || 0)
return Math.round(value * multiplier) / multiplier