Feat: add current year to nav
This commit is contained in:
parent
8b92697870
commit
da5f53c267
@ -4,7 +4,7 @@
|
|||||||
<h2>
|
<h2>
|
||||||
<ul id="years">
|
<ul id="years">
|
||||||
<li v-for="year in years" :key="year">
|
<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>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</h2>
|
</h2>
|
||||||
@ -34,20 +34,23 @@ export default {
|
|||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
current_year: getYear(today),
|
current_year: getYear(today),
|
||||||
current_date: today,
|
selected_year: getYear(today),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters({
|
...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: {
|
methods: {
|
||||||
...mapActions('travail', {
|
...mapActions('travail', {
|
||||||
'setRange': 'setRange',
|
'setRange': 'setRange',
|
||||||
}),
|
}),
|
||||||
selectYear: function (year) {
|
selectYear: function (year) {
|
||||||
this.current_year=year
|
this.selected_year=year
|
||||||
this.setRange({
|
this.setRange({
|
||||||
start: `${this.current_year}-01`,
|
start: `${this.current_year}-01`,
|
||||||
end: `${this.current_year}-12`
|
end: `${this.current_year}-12`
|
||||||
|
Loading…
Reference in New Issue
Block a user