atst/js/components/tables/spend_table.js
2019-01-14 16:00:17 -05:00

46 lines
1.0 KiB
JavaScript

import { set } from 'vue/dist/vue'
import { formatDollars } from '../../lib/dollars'
export default {
name: 'spend-table',
props: {
applications: Object,
workspace: Object,
environments: Object,
currentMonthIndex: String,
prevMonthIndex: String,
twoMonthsAgoIndex: String
},
data: function () {
return {
applicationsState: this.applications
}
},
created: function () {
Object.keys(this.applications).forEach(application => {
set(this.applicationsState[application], 'isVisible', false)
})
},
methods: {
toggle: function (e, applicationName) {
this.applicationsState = Object.assign(this.applicationsState, {
[applicationName]: Object.assign(this.applicationsState[applicationName],{
isVisible: !this.applicationsState[applicationName].isVisible
})
})
},
formatDollars: function (value) {
return formatDollars(value, false)
},
round: function (value) {
return Math.round(value)
}
}
}