Feat: add current year to nav

This commit is contained in:
Bertrand Benjamin 2022-02-13 18:14:54 +01:00
parent 8b92697870
commit da5f53c267

View File

@ -4,7 +4,7 @@
<h2>
<ul id="years">
<li v-for="year in years" :key="year">
<span @click="selectYear(year)" :class="{selected_year:year==current_year}">{{ year }}</span>
<span @click="selectYear(year)" :class="{selected_year:year==selected_year}">{{ year }}</span>
</li>
</ul>
</h2>
@ -34,20 +34,23 @@ export default {
data () {
return {
current_year: getYear(today),
current_date: today,
selected_year: getYear(today),
}
},
computed: {
...mapGetters({
years: "travail/years",
})
available_years: "travail/years",
}),
years: function () {
return [...this.available_years, this.current_year].filter((v, i, a) => a.indexOf(v) === i)
}
},
methods: {
...mapActions('travail', {
'setRange': 'setRange',
}),
selectYear: function (year) {
this.current_year=year
this.selected_year=year
this.setRange({
start: `${this.current_year}-01`,
end: `${this.current_year}-12`