Skip to content

Commit

Permalink
v1.5.8
Browse files Browse the repository at this point in the history
  • Loading branch information
ratiw committed Dec 16, 2016
1 parent 0ec2903 commit 3df19c2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
37 changes: 27 additions & 10 deletions dist/vue-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -893,10 +893,12 @@ exports.default = {
console.warn('You did not provide reference id column with "__checkbox:<column_name>" field!');
return;
}

var key = dataItem[idColumn];
if (isChecked) {
this.selectedTo.push(dataItem[idColumn]);
this.selectId(key);
} else {
this.selectedTo.$remove(dataItem[idColumn]);
this.unselectId(key);
}
},
toggleAllCheckboxes: function toggleAllCheckboxes(isChecked, fieldName) {
Expand All @@ -905,26 +907,41 @@ exports.default = {

if (isChecked) {
this.tableData.forEach(function (dataItem) {
if (!self.isSelectedRow(dataItem, fieldName)) {
self.selectedTo.push(dataItem[idColumn]);
}
self.selectId(dataItem[idColumn]);
});
} else {
this.tableData.forEach(function (dataItem) {
self.selectedTo.$remove(dataItem[idColumn]);
self.unselectId(dataItem[idColumn]);
});
}
},
selectId: function selectId(key) {
if (!this.isSelectedRow(key)) {
this.selectedTo.push(key);
}
},
unselectId: function unselectId(key) {
this.selectedTo.$remove(key);
// this.selectedTo = this.selectedTo.filter(function(item) {
// return item !== key
// })
},
isSelectedRow: function isSelectedRow(dataItem, fieldName) {
return this.selectedTo.indexOf(dataItem[this.extractArgs(fieldName)]) >= 0;
return this.selectedTo.indexOf(key) >= 0;
},
rowSelected: function rowSelected(dataItem, fieldName) {
var idColumn = this.extractArgs(fieldName);
var key = dataItem[idColumn];

return this.isSelectedRow(key);
},
checkCheckboxesState: function checkCheckboxesState(fieldName) {
if (this.selectedTo.length === 0) return false;

var self = this;
var selector = 'th.checkbox_' + this.extractArgs(fieldName) + ' input[type=checkbox]';
var els = document.querySelectorAll(selector);
var idColumn = this.extractArgs(fieldName);
var selector = 'th.checkbox_' + idColumn + ' input[type=checkbox]';
var els = document.querySelectorAll(selector);

// count how many checkbox row in the current page has been checked
var selected = this.tableData.filter(function (item) {
Expand Down Expand Up @@ -1095,7 +1112,7 @@ exports.default = {
}
};
if (module.exports.__esModule) module.exports = module.exports.default
;(typeof module.exports === "function"? module.exports.options: module.exports).template = "\n<div class=\"{{wrapperClass}}\">\n <table class=\"vuetable {{tableClass}}\">\n <thead>\n <tr>\n <template v-for=\"field in fields\">\n <template v-if=\"field.visible\">\n <template v-if=\"isSpecialField(field.name)\">\n <th v-if=\"extractName(field.name) == '__checkbox'\" :class=\"[field.titleClass, 'checkbox_'+extractArgs(field.name)]\">\n <input type=\"checkbox\" @change=\"toggleAllCheckboxes($event.target.checked, field.name)\" :checked=\"checkCheckboxesState(field.name)\">\n </th>\n <th v-if=\"extractName(field.name) == '__component'\" @click=\"orderBy(field, $event)\" class=\"{{field.titleClass || ''}} {{isSortable(field) ? 'sortable' : ''}}\">\n {{field.title || ''}}\n <i v-if=\"isCurrentSortField(field) &amp;&amp; field.title\" class=\"{{ sortIcon(field) }}\" v-bind:style=\"{opacity: sortIconOpacity(field)}\"></i>\n </th>\n <th v-if=\"notIn(extractName(field.name), ['__checkbox', '__component'])\" id=\"{{field.name}}\" class=\"{{field.titleClass || ''}}\">\n {{field.title || ''}}\n </th>\n </template>\n <template v-else=\"\">\n <th @click=\"orderBy(field, $event)\" id=\"_{{field.name}}\" class=\"{{field.titleClass || ''}} {{isSortable(field) ? 'sortable' : ''}}\">\n {{getTitle(field) | capitalize}}&nbsp;\n <i v-if=\"isCurrentSortField(field)\" class=\"{{ sortIcon(field) }}\" v-bind:style=\"{opacity: sortIconOpacity(field)}\"></i>\n </th>\n </template>\n </template>\n </template>\n </tr>\n </thead>\n <tbody v-cloak=\"\">\n <template v-for=\"(itemNumber, item) in tableData\">\n <tr @dblclick=\"onRowDoubleClicked(item, $event)\" @click=\"onRowClicked(item, $event)\" :render=\"onRowChanged(item)\" :class=\"onRowClass(item, itemNumber)\">\n <template v-for=\"field in fields\">\n <template v-if=\"field.visible\">\n <template v-if=\"isSpecialField(field.name)\">\n <td v-if=\"extractName(field.name) == '__sequence'\" class=\"vuetable-sequence {{field.dataClass}}\" v-html=\"tablePagination.from + itemNumber\">\n </td>\n <td v-if=\"extractName(field.name) == '__checkbox'\" class=\"vuetable-checkboxes {{field.dataClass}}\">\n <input type=\"checkbox\" @change=\"toggleCheckbox($event.target.checked, item, field.name)\" :checked=\"isSelectedRow(item, field.name)\">\n </td>\n <td v-if=\"field.name == '__actions'\" class=\"vuetable-actions {{field.dataClass}}\">\n <template v-for=\"action in itemActions\">\n <button class=\"{{ action.class }}\" @click=\"callAction(action.name, item)\" v-attr=\"action.extra\">\n <i class=\"{{ action.icon }}\"></i> {{ action.label }}\n </button>\n </template>\n </td>\n <td v-if=\"extractName(field.name) == '__component'\" class=\"{{field.dataClass}}\">\n <component :is=\"extractArgs(field.name)\" :row-data=\"item\"></component>\n </td>\n </template>\n <template v-else=\"\">\n <td v-if=\"hasCallback(field)\" class=\"{{field.dataClass}}\" @click=\"onCellClicked(item, field, $event)\" @dblclick=\"onCellDoubleClicked(item, field, $event)\">\n {{{ callCallback(field, item) }}}\n </td>\n <td v-else=\"\" class=\"{{field.dataClass}}\" @click=\"onCellClicked(item, field, $event)\" @dblclick=\"onCellDoubleClicked(item, field, $event)\">\n {{{ getObjectValue(item, field.name, \"\") }}}\n </td>\n </template>\n </template>\n </template>\n </tr>\n <template v-if=\"useDetailRow\">\n <template v-if=\"useDetailRowComponent\">\n <tr v-if=\"isVisibleDetailRow(item[detailRowId])\" @click=\"onDetailRowClick(item, $event)\" :transition=\"detailRowTransition\" :class=\"[detailRowClass]\">\n <td :colspan=\"countVisibleFields\">\n <component :is=\"detailRowComponent\" :row-data=\"item\"></component>\n </td>\n </tr>\n </template>\n <template v-else=\"\">\n <tr v-if=\"isVisibleDetailRow(item[detailRowId])\" v-html=\"callDetailRowCallback(item)\" @click=\"onDetailRowClick(item, $event)\" :transition=\"detailRowTransition\" :class=\"[detailRowClass]\"></tr>\n </template>\n </template>\n </template>\n </tbody>\n </table>\n <div v-if=\"showPagination\" class=\"vuetable-pagination {{paginationClass}}\">\n <div class=\"vuetable-pagination-info {{paginationInfoClass}}\" v-html=\"paginationInfo\">\n </div>\n <div v-show=\"tablePagination &amp;&amp; tablePagination.last_page > 1\" class=\"vuetable-pagination-component {{paginationComponentClass}}\">\n <component v-ref:pagination=\"\" :is=\"paginationComponent\"></component>\n </div>\n </div>\n</div>\n"
;(typeof module.exports === "function"? module.exports.options: module.exports).template = "\n<div class=\"{{wrapperClass}}\">\n <table class=\"vuetable {{tableClass}}\">\n <thead>\n <tr>\n <template v-for=\"field in fields\">\n <template v-if=\"field.visible\">\n <template v-if=\"isSpecialField(field.name)\">\n <th v-if=\"extractName(field.name) == '__checkbox'\" :class=\"[field.titleClass, 'checkbox_'+extractArgs(field.name)]\">\n <input type=\"checkbox\" @change=\"toggleAllCheckboxes($event.target.checked, field.name)\" :checked=\"checkCheckboxesState(field.name)\">\n </th>\n <th v-if=\"extractName(field.name) == '__component'\" @click=\"orderBy(field, $event)\" class=\"{{field.titleClass || ''}} {{isSortable(field) ? 'sortable' : ''}}\">\n {{field.title || ''}}\n <i v-if=\"isCurrentSortField(field) &amp;&amp; field.title\" class=\"{{ sortIcon(field) }}\" :style=\"{opacity: sortIconOpacity(field)}\"></i>\n </th>\n <th v-if=\"notIn(extractName(field.name), ['__checkbox', '__component'])\" id=\"{{field.name}}\" class=\"{{field.titleClass || ''}}\">\n {{field.title || ''}}\n </th>\n </template>\n <template v-else=\"\">\n <th @click=\"orderBy(field, $event)\" id=\"_{{field.name}}\" class=\"{{field.titleClass || ''}} {{isSortable(field) ? 'sortable' : ''}}\">\n {{getTitle(field) | capitalize}}&nbsp;\n <i v-if=\"isCurrentSortField(field)\" class=\"{{ sortIcon(field) }}\" :style=\"{opacity: sortIconOpacity(field)}\"></i>\n </th>\n </template>\n </template>\n </template>\n </tr>\n </thead>\n <tbody v-cloak=\"\">\n <template v-for=\"(itemNumber, item) in tableData\">\n <tr @dblclick=\"onRowDoubleClicked(item, $event)\" @click=\"onRowClicked(item, $event)\" :render=\"onRowChanged(item)\" :class=\"onRowClass(item, itemNumber)\">\n <template v-for=\"field in fields\">\n <template v-if=\"field.visible\">\n <template v-if=\"isSpecialField(field.name)\">\n <td v-if=\"extractName(field.name) == '__sequence'\" class=\"vuetable-sequence {{field.dataClass}}\" v-html=\"tablePagination.from + itemNumber\">\n </td>\n <td v-if=\"extractName(field.name) == '__checkbox'\" class=\"vuetable-checkboxes {{field.dataClass}}\">\n <input type=\"checkbox\" @change=\"toggleCheckbox($event.target.checked, item, field.name)\" :checked=\"rowSelected(item, field.name)\">\n </td>\n <td v-if=\"field.name == '__actions'\" class=\"vuetable-actions {{field.dataClass}}\">\n <template v-for=\"action in itemActions\">\n <button class=\"{{ action.class }}\" @click=\"callAction(action.name, item)\" v-attr=\"action.extra\">\n <i class=\"{{ action.icon }}\"></i> {{ action.label }}\n </button>\n </template>\n </td>\n <td v-if=\"extractName(field.name) == '__component'\" class=\"{{field.dataClass}}\">\n <component :is=\"extractArgs(field.name)\" :row-data=\"item\" :row-index=\"itemNumber\"></component>\n </td>\n </template>\n <template v-else=\"\">\n <td v-if=\"hasCallback(field)\" class=\"{{field.dataClass}}\" @click=\"onCellClicked(item, field, $event)\" @dblclick=\"onCellDoubleClicked(item, field, $event)\">\n {{{ callCallback(field, item) }}}\n </td>\n <td v-else=\"\" class=\"{{field.dataClass}}\" @click=\"onCellClicked(item, field, $event)\" @dblclick=\"onCellDoubleClicked(item, field, $event)\">\n {{{ getObjectValue(item, field.name, \"\") }}}\n </td>\n </template>\n </template>\n </template>\n </tr>\n <template v-if=\"useDetailRow\">\n <template v-if=\"useDetailRowComponent\">\n <tr v-if=\"isVisibleDetailRow(item[detailRowId])\" @click=\"onDetailRowClick(item, $event)\" :transition=\"detailRowTransition\" :class=\"[detailRowClass]\">\n <td :colspan=\"countVisibleFields\">\n <component :is=\"detailRowComponent\" :row-data=\"item\" :row-index=\"itemNumber\"></component>\n </td>\n </tr>\n </template>\n <template v-else=\"\">\n <tr v-if=\"isVisibleDetailRow(item[detailRowId])\" v-html=\"callDetailRowCallback(item)\" @click=\"onDetailRowClick(item, $event)\" :transition=\"detailRowTransition\" :class=\"[detailRowClass]\"></tr>\n </template>\n </template>\n </template>\n </tbody>\n </table>\n <div v-if=\"showPagination\" class=\"vuetable-pagination {{paginationClass}}\">\n <div class=\"vuetable-pagination-info {{paginationInfoClass}}\" v-html=\"paginationInfo\">\n </div>\n <div v-show=\"tablePagination &amp;&amp; tablePagination.last_page > 1\" class=\"vuetable-pagination-component {{paginationComponentClass}}\">\n <component v-ref:pagination=\"\" :is=\"paginationComponent\"></component>\n </div>\n </div>\n</div>\n"
if (module.hot) {(function () { module.hot.accept()
var hotAPI = require("vue-hot-reload-api")
hotAPI.install(require("vue"), true)
Expand Down
Loading

0 comments on commit 3df19c2

Please sign in to comment.