Complete Vue.js 2 Web Development_ Practical guide to building end-to-end web development solutions with Vue.js 2

(singke) #1

Displaying, Looping, Searching, and Filtering Data Chapter 2


filterField: '',
filterQuery: '',
filterUserState: ''
},
methods: {
activeStatus(person) {
return (person.isActive)? 'Active' : 'Inactive';
},

activeClass(person) {
return person.isActive? 'active' : 'inactive';
},
balanceClass(person) {
let balanceLevel = 'success';

if(person.balance < 2000) {
balanceLevel = 'error';
} else if (person.balance < 3000) {
balanceLevel = 'warning';
}

let increasing = false,
balance = person.balance / 1000;

if(Math.round(balance) == Math.ceil(balance)) {
increasing = 'increasing';
}

return [balanceLevel, increasing];
},

formatBalance(balance) {
return this.currency + balance.toFixed(2);
},
formatDate(date) {
let registered = new Date(date);
return registered.toLocaleString('en-US');
},

filterRow(person) {
let result = true;
if(this.filterField) {

if(this.filterField === 'isActive') {

result = (typeof this.filterUserState === 'boolean')?
(this.filterUserState === person.isActive) : true;
} else {
Free download pdf