Feat: selecting a year is working
This commit is contained in:
parent
acab0a9d68
commit
4ddfa1654f
@ -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="select_year(year)" :class="{selected_year:year==current_year}">{{ year }}</span>
|
<span @click="selectYear(year)" :class="{selected_year:year==current_year}">{{ year }}</span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</h2>
|
</h2>
|
||||||
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapGetters } from 'vuex'
|
import { mapGetters } from 'vuex'
|
||||||
|
import { mapActions } from 'vuex'
|
||||||
import { getYear } from 'date-fns'
|
import { getYear } from 'date-fns'
|
||||||
const today = new Date()
|
const today = new Date()
|
||||||
export default {
|
export default {
|
||||||
@ -33,6 +34,7 @@ export default {
|
|||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
current_year: getYear(today),
|
current_year: getYear(today),
|
||||||
|
current_date: today,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -41,8 +43,15 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
select_year: function (year) {
|
...mapActions('travail', {
|
||||||
this.current_year=year
|
'setRange': 'setRange',
|
||||||
|
}),
|
||||||
|
selectYear: function (year) {
|
||||||
|
this.current_year=year
|
||||||
|
this.setRange({
|
||||||
|
start: `${this.current_year}-01`,
|
||||||
|
end: `${this.current_year}-12`
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user