Fix: linting
This commit is contained in:
parent
7fc1675052
commit
6a091efea6
@ -49,7 +49,6 @@ export default {
|
|||||||
var rows = []
|
var rows = []
|
||||||
if (t === 'sans tags') {
|
if (t === 'sans tags') {
|
||||||
rows = this.tag_filter_rows([], true, false)
|
rows = this.tag_filter_rows([], true, false)
|
||||||
console.log(rows)
|
|
||||||
} else {
|
} else {
|
||||||
rows = this.tag_filter_rows([t], false, false)
|
rows = this.tag_filter_rows([t], false, false)
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ export function total (rows, field = 'Montant') {
|
|||||||
return Math.round(sum)
|
return Math.round(sum)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function tag_filter (rows, tags, invert=false) {
|
export function tagFilter (rows, tags, invert = false) {
|
||||||
// filter rows by tags
|
// filter rows by tags
|
||||||
// invert inverts the selection
|
// invert inverts the selection
|
||||||
return rows.filter(row => {
|
return rows.filter(row => {
|
||||||
@ -55,7 +55,7 @@ export function tag_filter (rows, tags, invert=false) {
|
|||||||
|
|
||||||
function objectMap (object, mapFn) {
|
function objectMap (object, mapFn) {
|
||||||
// map a function on object value
|
// map a function on object value
|
||||||
return Object.keys(object).reduce(function(result, key) {
|
return Object.keys(object).reduce((result, key) => {
|
||||||
result[key] = mapFn(object[key])
|
result[key] = mapFn(object[key])
|
||||||
return result
|
return result
|
||||||
}, {})
|
}, {})
|
||||||
|
@ -3,26 +3,27 @@ import Vue from 'vue'
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
import Papa from 'papaparse'
|
import Papa from 'papaparse'
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
import { appendTag, formatDate, tag_filter } from '../../libs/data_processing'
|
import { appendTag, formatDate, tagFilter } from '../../libs/data_processing'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
namespaced: true,
|
namespaced: true,
|
||||||
state: {
|
state: {
|
||||||
csv: {},
|
csv: {},
|
||||||
month: moment(),
|
month: moment()
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
csvs: (state) => {
|
csvs: (state) => {
|
||||||
// return array of csv filename
|
// return array of csv filename
|
||||||
return Object.values(state.csv).sort((a, b) => {
|
return Object.values(state.csv).sort((a, b) => {
|
||||||
var filenameA=a.filename.toLowerCase(), filenameB=b.filename.toLowerCase()
|
var filenameA = a.filename.toLowerCase()
|
||||||
|
var filenameB = b.filename.toLowerCase()
|
||||||
if (filenameA < filenameB) {
|
if (filenameA < filenameB) {
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
if (filenameA > filenameB) {
|
if (filenameA > filenameB) {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
rows: (state) => {
|
rows: (state) => {
|
||||||
@ -68,11 +69,11 @@ export default {
|
|||||||
rows = getters.spending_rows
|
rows = getters.spending_rows
|
||||||
}
|
}
|
||||||
if (tags.length > 0) {
|
if (tags.length > 0) {
|
||||||
return tag_filter(rows, tags, invert)
|
return tagFilter(rows, tags, invert)
|
||||||
} else {
|
} else {
|
||||||
if (invert) {
|
if (invert) {
|
||||||
return rows.filter(r => {
|
return rows.filter(r => {
|
||||||
return r.tags.map(t => t.name.toLowerCase()).toString() === ["cb"].toString()
|
return r.tags.map(t => t.name.toLowerCase()).toString() === ['cb'].toString()
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
return rows
|
return rows
|
||||||
@ -100,7 +101,7 @@ export default {
|
|||||||
},
|
},
|
||||||
months: (state, getters) => {
|
months: (state, getters) => {
|
||||||
// Set of month
|
// Set of month
|
||||||
return [... new Set(getters.rows.map(x => moment(x.Date).format('MMMM YYYY')))]
|
return [...new Set(getters.rows.map(x => moment(x.Date).format('MMMM YYYY')))]
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -175,6 +176,6 @@ export default {
|
|||||||
prev_month (context) {
|
prev_month (context) {
|
||||||
var prev = moment(context.getters.month).subtract(1, 'months')
|
var prev = moment(context.getters.month).subtract(1, 'months')
|
||||||
context.commit('SET_MONTH', { month: prev })
|
context.commit('SET_MONTH', { month: prev })
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user