Change subTotal to a computed property.

This commit is contained in:
Praneet Loke 2017-02-27 17:16:04 -08:00 committed by Praneet Loke
parent 6148343d9c
commit ceeb1c37c2

View file

@ -46,7 +46,6 @@
},
data() {
return {
subTotal: 0,
totalItems: 0,
currentPage: 1,
currentSize: parseInt(this.mdSize, 10)
@ -72,14 +71,16 @@
},
shouldDisable() {
return this.currentSize * this.currentPage >= this.totalItems;
},
subTotal() {
const sub = this.currentPage * this.currentSize;
return sub > this.mdTotal ? this.mdTotal : sub;
}
},
methods: {
emitPaginationEvent() {
if (this.canFireEvents) {
const sub = this.currentPage * this.currentSize;
this.subTotal = sub > this.mdTotal ? this.mdTotal : sub;
this.$emit('pagination', {
size: this.currentSize,
page: this.currentPage
@ -109,7 +110,6 @@
},
mounted() {
this.$nextTick(() => {
this.subTotal = this.currentPage * this.currentSize;
this.mdPageOptions = this.mdPageOptions || [10, 25, 50, 100];
this.currentSize = this.mdPageOptions.includes(this.currentSize) ? this.currentSize : this.mdPageOptions[0];
this.canFireEvents = true;