Feat: list years
This commit is contained in:
parent
e22445646a
commit
acab0a9d68
@ -1,6 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<nav>
|
<nav>
|
||||||
<h1><router-link to="/"> Sous Margot </router-link></h1>
|
<h1><router-link to="/"> Sous Margot </router-link></h1>
|
||||||
|
<h2>
|
||||||
|
<ul id="years">
|
||||||
|
<li v-for="year in years" :key="year">
|
||||||
|
<span @click="select_year(year)" :class="{selected_year:year==current_year}">{{ year }}</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</h2>
|
||||||
<div class="nav-link">
|
<div class="nav-link">
|
||||||
<router-link to="/edit">
|
<router-link to="/edit">
|
||||||
<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="user-edit" class="svg-inline--fa fa-user-edit fa-w-20" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512" width='25px' height="25px">
|
<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="user-edit" class="svg-inline--fa fa-user-edit fa-w-20" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512" width='25px' height="25px">
|
||||||
@ -18,13 +25,35 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { mapGetters } from 'vuex'
|
||||||
|
import { getYear } from 'date-fns'
|
||||||
|
const today = new Date()
|
||||||
export default {
|
export default {
|
||||||
name: 'Nav',
|
name: 'Nav',
|
||||||
props: {
|
data () {
|
||||||
|
return {
|
||||||
|
current_year: getYear(today),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters({
|
||||||
|
years: "travail/years",
|
||||||
|
})
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
select_year: function (year) {
|
||||||
|
this.current_year=year
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|
||||||
|
.selected_year {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
@ -55,12 +55,17 @@ const travail = {
|
|||||||
return state.months
|
return state.months
|
||||||
},
|
},
|
||||||
getMonth: (state) => (date) => {
|
getMonth: (state) => (date) => {
|
||||||
|
// Get a month by its date
|
||||||
return state.months[date]
|
return state.months[date]
|
||||||
},
|
},
|
||||||
count: (state, getters) => {
|
count: (state, getters) => {
|
||||||
// Amount of mounts
|
// Amount of mounts
|
||||||
return Object.keys(getters.months).length
|
return Object.keys(getters.months).length
|
||||||
},
|
},
|
||||||
|
years: (state) => {
|
||||||
|
// list of years with data
|
||||||
|
return Object.keys(state.months).map(k => k.slice(0,4)).filter((v, i, a) => a.indexOf(v) === i)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
cleanMonths (state) {
|
cleanMonths (state) {
|
||||||
|
Loading…
Reference in New Issue
Block a user