2019-04-03 00:25:12 +02:00
|
|
|
<template lang="pug">
|
|
|
|
v-calendar#calendar.card(
|
2019-04-29 00:27:29 +02:00
|
|
|
title-position='left'
|
|
|
|
locale='it'
|
|
|
|
is-dark
|
2019-04-03 00:25:12 +02:00
|
|
|
show-caps
|
|
|
|
:attributes='attributes'
|
|
|
|
:from-page.sync='page'
|
|
|
|
is-expanded is-inline)
|
2019-04-29 00:27:29 +02:00
|
|
|
div(slot='popover', slot-scope='{ customData, attributes }')
|
|
|
|
p {{attributes}}
|
|
|
|
//- router-link(:to="`/event/${customData.id}`") {{customData.start_datetime|hour}} - {{customData.title}}
|
|
|
|
//- div(v-if='customData.days && customData.days[selectedEvent]')
|
|
|
|
p {{customData.days[customData.selectedEvent].title}}
|
|
|
|
p {{customData.days[customData.selectedEvent].tags}}
|
|
|
|
el-button(@click='customData.selectedEvent=customData.selectedEvent+1') {{customData.selectedEvent}}/{{customData.days.length}}
|
|
|
|
v-icon(name='clock' @click='customData.selectedEvent=customData.selectedEvent+1')
|
|
|
|
//- @{{customData.place.name}}
|
2019-04-03 00:25:12 +02:00
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
import { mapState, mapActions } from 'vuex'
|
|
|
|
import moment from 'dayjs'
|
|
|
|
import { intersection } from 'lodash'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'Calendar',
|
|
|
|
// filters,
|
|
|
|
data () {
|
|
|
|
const month = moment().month()+1
|
|
|
|
const year = moment().year()
|
|
|
|
return {
|
|
|
|
page: { month, year},
|
2019-04-29 00:27:29 +02:00
|
|
|
selectedEvent: {},
|
|
|
|
daysWithEvents: {}
|
2019-04-03 00:25:12 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
page () {
|
|
|
|
this.updateEvents(this.page)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
...mapActions(['updateEvents']),
|
2019-04-29 00:27:29 +02:00
|
|
|
nextEvent () {
|
|
|
|
|
|
|
|
},
|
2019-04-03 00:25:12 +02:00
|
|
|
eventToAttribute(event) {
|
|
|
|
let e = {
|
|
|
|
key: event.id,
|
|
|
|
customData: event,
|
|
|
|
order: event.start_datetime,
|
|
|
|
}
|
2019-04-29 00:27:29 +02:00
|
|
|
const day = moment(event.start_datetime).date()
|
|
|
|
if (!this.daysWithEvents[day]) {
|
|
|
|
this.daysWithEvents[day] = []
|
|
|
|
e.popover = {
|
|
|
|
slot: 'popover',
|
|
|
|
visibility: 'hover',
|
|
|
|
isInteractive: true,
|
|
|
|
hideIndicator: true,
|
|
|
|
}
|
|
|
|
e.customData.days = this.daysWithEvents[day]
|
|
|
|
}
|
|
|
|
this.daysWithEvents[day].push({title: event.title, when: event.start_datetime, tags: event.tags })
|
|
|
|
|
2019-04-03 00:25:12 +02:00
|
|
|
let color = event.tags && event.tags.length && event.tags[0].color ? event.tags[0].color : 'rgba(170,170,250,0.7)'
|
|
|
|
if (event.past) color = 'rgba(200,200,200,0.5)'
|
|
|
|
if (event.multidate) {
|
|
|
|
e.dates = {
|
|
|
|
start: event.start_datetime, end: event.end_datetime
|
|
|
|
}
|
|
|
|
e.highlight = { backgroundColor: color,
|
|
|
|
borderColor: 'transparent',
|
|
|
|
borderWidth: '4px' }
|
|
|
|
} else {
|
|
|
|
e.dates = event.start_datetime
|
|
|
|
e.dot = { backgroundColor: color, borderColor: color, borderWidth: '3px' }
|
|
|
|
}
|
|
|
|
return e
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
filteredEvents () {
|
|
|
|
return this.$store.getters.filteredEvents
|
|
|
|
},
|
2019-04-29 00:27:29 +02:00
|
|
|
...mapState(['events', 'filters']),
|
2019-04-03 00:25:12 +02:00
|
|
|
attributes () {
|
|
|
|
return [
|
2019-04-29 00:27:29 +02:00
|
|
|
{ key: 'today', dates: new Date(),
|
2019-04-03 00:25:12 +02:00
|
|
|
highlight: {
|
|
|
|
backgroundColor: '#aaffaa'
|
|
|
|
},
|
2019-04-29 00:27:29 +02:00
|
|
|
popover: {label: this.$t('common.today')}
|
2019-04-03 00:25:12 +02:00
|
|
|
},
|
|
|
|
...this.filteredEvents.map(this.eventToAttribute)
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
#calendar {
|
|
|
|
margin-bottom: 0em;
|
|
|
|
margin-top: 0.3em;
|
|
|
|
}
|
|
|
|
|
|
|
|
#calendar a {
|
|
|
|
color: blue;
|
|
|
|
}
|
|
|
|
</style>
|