Skip to content

Commit

Permalink
Merge branch 'develop' for v1.7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ratiw committed Jan 1, 2018
2 parents b8f0495 + 683268f commit d99d93c
Show file tree
Hide file tree
Showing 8 changed files with 1,806 additions and 402 deletions.
2 changes: 1 addition & 1 deletion dist/stats.json

Large diffs are not rendered by default.

2,116 changes: 1,745 additions & 371 deletions dist/vuetable-2-full.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/vuetable-2.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/Vuetable-Properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
- [reactive-api-url](#-reactive-api-url)
- [render-icon](#-render-icon)
- [row-class](#-row-class)
- [show-sort-icons](#-show-sort-icons)
- [sort-order](#-sort-order)
- [table-height](#-table-height)
- [track-by](#-track-by)
Expand Down
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">

<title>vue2</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.2/semantic.min.css" media="screen" title="no title" charset="utf-8">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.min.css">
Expand Down Expand Up @@ -106,6 +106,7 @@ <h3 class="ui header">List of Users</h3>
:sort-order="sortOrder"
:multi-sort="multiSort"
:per-page="perPage"
:query-params="queryParams"
:append-params="moreParams"
detail-row-component="my-detail-row"
detail-row-transition="expand"
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vuetable-2",
"version": "1.7.1",
"version": "1.7.2",
"description": "Datatable component for Vue 2.x",
"main": "dist/vuetable-2.js",
"license": "MIT",
Expand Down Expand Up @@ -34,7 +34,7 @@
"scripts": {
"dev": "node build/dev-server.js",
"start": "node build/dev-server.js",
"build": "node build/build.js",
"build": "node build/build.js && npm run bundle",
"bundle:min": "cross-env MINIFY=true webpack --progress --config build/webpack.build.config.js",
"bundle:full": "cross-env MINIFY=false webpack --progress --config build/webpack.build.config.js",
"bundle": "npm run bundle:min && npm run bundle:full",
Expand Down
66 changes: 44 additions & 22 deletions src/components/Vuetable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
<th v-if="extractName(field.name) == '__component'"
@click="orderBy(field, $event)"
:style="{width: field.width}"
:class="['vuetable-th-component-'+trackBy, field.titleClass, {'sortable': isSortable(field)}]"
:class="['vuetable-th-component-'+trackBy, field.titleClass, sortClass(field), {'sortable': isSortable(field)}]"
v-html="renderTitle(field)"
></th>
<th v-if="extractName(field.name) == '__slot'"
@click="orderBy(field, $event)"
:style="{width: field.width}"
:class="['vuetable-th-slot-'+extractArgs(field.name), field.titleClass, {'sortable': isSortable(field)}]"
:class="['vuetable-th-slot-'+extractArgs(field.name), field.titleClass, sortClass(field), {'sortable': isSortable(field)}]"
v-html="renderTitle(field)"
></th>
<th v-if="extractName(field.name) == '__sequence'"
Expand All @@ -38,7 +38,7 @@
<th @click="orderBy(field, $event)"
:id="'_' + field.name"
:style="{width: field.width}"
:class="['vuetable-th-'+field.name, field.titleClass, {'sortable': isSortable(field)}]"
:class="['vuetable-th-'+field.name, field.titleClass, sortClass(field), {'sortable': isSortable(field)}]"
v-html="renderTitle(field)"
></th>
</template>
Expand Down Expand Up @@ -105,16 +105,16 @@
</template>
</tr>
<template v-if="useDetailRow">
<tr v-if="isVisibleDetailRow(item[trackBy])"
@click="onDetailRowClick(item, $event)"
:class="[css.detailRowClass]"
>
<transition :name="detailRowTransition">
<td :colspan="countVisibleFields">
<component :is="detailRowComponent" :row-data="item" :row-index="index"></component>
</td>
</transition>
</tr>
<transition :name="detailRowTransition">
<tr v-if="isVisibleDetailRow(item[trackBy])"
@click="onDetailRowClick(item, $event)"
:class="[css.detailRowClass]"
>
<td :colspan="countVisibleFields">
<component :is="detailRowComponent" :row-data="item" :row-index="index"></component>
</td>
</tr>
</transition>
</template>
</template>
<template v-if="displayEmptyDataRow">
Expand Down Expand Up @@ -211,12 +211,14 @@
<td v-if="hasCallback(field)" :class="field.dataClass"
@click="onCellClicked(item, field, $event)"
@dblclick="onCellDoubleClicked(item, field, $event)"
@contextmenu="onCellRightClicked(item, field, $event)"
v-html="callCallback(field, item)"
>
</td>
<td v-else :class="field.dataClass"
@click="onCellClicked(item, field, $event)"
@dblclick="onCellDoubleClicked(item, field, $event)"
@contextmenu="onCellRightClicked(item, field, $event)"
v-html="getObjectValue(item, field.name, '')"
>
</td>
Expand Down Expand Up @@ -310,7 +312,7 @@ export default {
default: 'links.pagination'
},
queryParams: {
type: Object,
type: [Object, Function],
default () {
return {
sort: 'sort',
Expand Down Expand Up @@ -592,7 +594,7 @@ export default {
})
},
setData (data) {
this.apiMode = false
// this.apiMode = false
if (Array.isArray(data)) {
this.tableData = data
return
Expand Down Expand Up @@ -627,7 +629,8 @@ export default {
if (title.length > 0 && this.isInCurrentSortGroup(field) || this.hasSortableIcon(field)) {
let style = `opacity:${this.sortIconOpacity(field)};position:relative;float:right`
return title + ' ' + this.renderIconTag(['sort-icon', this.sortIcon(field)], `style="${style}"`)
let iconTag = this.showSortIcons ? this.renderIconTag(['sort-icon', this.sortIcon(field)], `style="${style}"`) : ''
return title + ' ' + iconTag
}
return title
Expand Down Expand Up @@ -667,7 +670,7 @@ export default {
this.fireEvent('loading')
this.httpOptions['params'] = this.getAllQueryParams()
this.httpOptions['params'] = this.getAppendParams( this.getAllQueryParams() )
return this.fetch(this.apiUrl, this.httpOptions).then(
success,
Expand Down Expand Up @@ -750,14 +753,16 @@ export default {
},
getAllQueryParams () {
let params = {}
if (typeof(this.queryParams) === 'function') {
params = this.queryParams(this.sortOrder, this.currentPage, this.perPage)
return typeof(params) !== 'object' ? {} : params
}
params[this.queryParams.sort] = this.getSortParam()
params[this.queryParams.page] = this.currentPage
params[this.queryParams.perPage] = this.perPage
for (let x in this.appendParams) {
params[x] = this.appendParams[x]
}
return params
},
getSortParam () {
Expand All @@ -784,6 +789,13 @@ export default {
return result;
},
getAppendParams (params) {
for (let x in this.appendParams) {
params[x] = this.appendParams[x]
}
return params
},
extractName (string) {
return string.split(':')[0].trim()
},
Expand Down Expand Up @@ -828,7 +840,7 @@ export default {
}
this.currentPage = 1 // reset page index
if (this.apiMode) {
if (this.apiMode || this.dataManager) {
this.loadData()
}
},
Expand Down Expand Up @@ -875,6 +887,16 @@ export default {
direction: 'asc'
});
},
sortClass (field) {
let cls = ''
let i = this.currentSortOrderPosition(field)
if (i !== false) {
cls = (this.sortOrder[i].direction == 'asc') ? this.css.ascendingClass : this.css.descendingClass
}
return cls
},
sortIcon (field) {
let cls = this.css.sortableIcon
let i = this.currentSortOrderPosition(field)
Expand Down
14 changes: 10 additions & 4 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ let vm = new Vue({
data: {
loading: '',
searchFor: '',
moreParams: {},
moreParams: { aa: 1111, bb: 222 },
fields: tableColumns,
tableHeight: '600px',
vuetableFields: false,
Expand Down Expand Up @@ -355,9 +355,7 @@ let vm = new Vue({
].join('')
},
setFilter () {
this.moreParams = {
'filter': this.searchFor
}
this.moreParams['filter'] = this.searchFor
this.$nextTick(function() {
this.$refs.vuetable.refresh()
})
Expand Down Expand Up @@ -390,6 +388,14 @@ let vm = new Vue({
rowClassCB (data, index) {
return (index % 2) === 0 ? 'odd' : 'even'
},
queryParams (sortOrder, currentPage, perPage) {
return {
'sort': sortOrder[0].field + '|' + sortOrder[0].direction,
'order': sortOrder[0].direction,
'page': currentPage,
'per_page': perPage
}
},
onCellClicked (data, field, event) {
console.log('cellClicked', field.name)
if (field.name !== '__actions') {
Expand Down

0 comments on commit d99d93c

Please sign in to comment.