2020-11-13 00:12:05 +01:00
|
|
|
<template lang="pug">
|
|
|
|
v-container#home(fluid)
|
|
|
|
|
|
|
|
//- Announcements
|
|
|
|
Announcement(v-for='announcement in announcements' :key='`a_${announcement.id}`' :announcement='announcement')
|
|
|
|
|
2020-12-04 17:28:54 +01:00
|
|
|
//- Calendar and search bar
|
2021-02-09 12:15:22 +01:00
|
|
|
v-row
|
2021-01-11 00:17:56 +01:00
|
|
|
.col-xl-5.col-lg-5.col-md-7.col-sm-12.col-xs-12
|
2020-12-04 17:28:54 +01:00
|
|
|
//- this is needed as v-calendar does not support SSR
|
|
|
|
//- https://github.com/nathanreyes/v-calendar/issues/336
|
|
|
|
client-only
|
|
|
|
Calendar(@dayclick='dayChange' @monthchange='monthChange' :events='events')
|
2020-11-13 00:12:05 +01:00
|
|
|
|
2021-02-09 12:15:22 +01:00
|
|
|
.col.pt-0.pt-md-2
|
2020-12-04 17:28:54 +01:00
|
|
|
Search(:filters='filters' @update='updateFilters')
|
2021-01-11 00:17:56 +01:00
|
|
|
v-chip(v-if='selectedDay' close @click:close='dayChange({ date: selectedDay})') {{selectedDay}}
|
2020-11-13 00:12:05 +01:00
|
|
|
|
2020-12-04 17:28:54 +01:00
|
|
|
//- Events
|
2021-01-22 21:16:22 +01:00
|
|
|
#events.mt-1
|
|
|
|
//- div.event(v-for='(event, idx) in events' :key='event.id' v-intersect="(entries, observer, isIntersecting) => intersecting[event.id] = isIntersecting")
|
|
|
|
Event(:event='event' v-for='(event, idx) in events' :key='event.id' @tagclick='tagClick' @placeclick='placeClick')
|
2020-11-13 00:12:05 +01:00
|
|
|
|
2019-04-03 00:25:12 +02:00
|
|
|
</template>
|
2020-11-13 00:12:05 +01:00
|
|
|
|
2019-05-30 12:04:14 +02:00
|
|
|
<script>
|
2020-11-13 00:12:05 +01:00
|
|
|
import { mapState, mapActions } from 'vuex'
|
|
|
|
import dayjs from 'dayjs'
|
|
|
|
import Event from '@/components/Event'
|
|
|
|
import Announcement from '@/components/Announcement'
|
|
|
|
import Search from '@/components/Search'
|
2020-12-04 17:28:54 +01:00
|
|
|
import Calendar from '@/components/Calendar'
|
2019-05-30 12:04:14 +02:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'Index',
|
2020-12-04 17:28:54 +01:00
|
|
|
components: { Event, Search, Announcement, Calendar },
|
2021-01-11 00:17:56 +01:00
|
|
|
async asyncData ({ params, $api, store }) {
|
2020-11-13 00:12:05 +01:00
|
|
|
const events = await $api.getEvents({
|
2021-01-11 00:17:56 +01:00
|
|
|
start: dayjs().unix(),
|
|
|
|
end: null,
|
|
|
|
filters: { show_recurrent: store.state.settings.allow_recurrent_event && store.state.settings.recurrent_event_visible }
|
2020-11-13 00:12:05 +01:00
|
|
|
})
|
2021-01-25 01:17:25 +01:00
|
|
|
return { events, first: true }
|
2020-11-13 00:12:05 +01:00
|
|
|
},
|
2021-01-11 00:17:56 +01:00
|
|
|
data ({ $store }) {
|
2020-11-13 00:12:05 +01:00
|
|
|
return {
|
2021-01-25 01:17:25 +01:00
|
|
|
first: true,
|
2020-11-13 00:12:05 +01:00
|
|
|
date: dayjs().format('YYYY-MM-DD'),
|
|
|
|
events: [],
|
|
|
|
start: dayjs().unix(),
|
|
|
|
end: null,
|
2021-01-11 00:17:56 +01:00
|
|
|
filters: { tags: [], places: [], show_recurrent: $store.state.settings.allow_recurrent_event && $store.state.settings.recurrent_event_visible },
|
2021-01-25 01:17:25 +01:00
|
|
|
selectedDay: null
|
2021-01-22 21:16:22 +01:00
|
|
|
// intersecting: {}
|
2020-11-13 00:12:05 +01:00
|
|
|
}
|
2019-06-06 23:54:32 +02:00
|
|
|
},
|
2020-11-13 00:12:05 +01:00
|
|
|
computed: {
|
2021-01-11 00:17:56 +01:00
|
|
|
...mapState(['settings', 'announcements'])
|
|
|
|
},
|
2020-11-13 00:12:05 +01:00
|
|
|
methods: {
|
2021-01-22 21:16:22 +01:00
|
|
|
// onIntersect (isIntersecting, eventId) {
|
|
|
|
// this.intersecting[eventId] = isIntersecting
|
|
|
|
// },
|
2020-11-13 00:12:05 +01:00
|
|
|
...mapActions(['setFilters']),
|
2021-01-22 23:08:38 +01:00
|
|
|
updateEvents () {
|
|
|
|
return this.$api.getEvents({
|
2020-11-13 00:12:05 +01:00
|
|
|
start: this.start,
|
|
|
|
end: this.end,
|
|
|
|
places: this.filters.places,
|
2021-01-11 00:17:56 +01:00
|
|
|
tags: this.filters.tags,
|
|
|
|
show_recurrent: this.filters.show_recurrent
|
2021-01-22 23:08:38 +01:00
|
|
|
}).then(events => {
|
|
|
|
this.events = events
|
|
|
|
this.setFilters(this.filters)
|
2020-11-13 00:12:05 +01:00
|
|
|
})
|
|
|
|
},
|
|
|
|
placeClick (place_id) {
|
|
|
|
if (this.filters.places.includes(place_id)) {
|
|
|
|
this.filters.places = this.filters.places.filter(p_id => p_id !== place_id)
|
|
|
|
} else {
|
|
|
|
this.filters.places.push(place_id)
|
|
|
|
}
|
|
|
|
this.updateEvents()
|
|
|
|
},
|
|
|
|
tagClick (tag) {
|
|
|
|
if (this.filters.tags.includes(tag)) {
|
|
|
|
this.filters.tags = this.filters.tags.filter(t => t !== tag)
|
|
|
|
} else {
|
|
|
|
this.filters.tags.push(tag)
|
|
|
|
}
|
|
|
|
this.updateEvents()
|
|
|
|
},
|
|
|
|
updateFilters (filters) {
|
|
|
|
this.filters = filters
|
|
|
|
this.updateEvents()
|
|
|
|
},
|
2020-12-04 17:28:54 +01:00
|
|
|
monthChange ({ year, month }) {
|
2021-01-25 01:17:25 +01:00
|
|
|
if (this.first) {
|
|
|
|
this.first = false
|
|
|
|
return
|
|
|
|
}
|
2020-11-13 00:12:05 +01:00
|
|
|
this.selectedDay = null
|
|
|
|
|
|
|
|
// check if current month is selected
|
2021-01-22 23:08:38 +01:00
|
|
|
if (month - 1 === dayjs().month() && year === dayjs().year()) {
|
2020-11-13 00:12:05 +01:00
|
|
|
this.start = dayjs().unix()
|
|
|
|
this.date = dayjs().format('YYYY-MM-DD')
|
|
|
|
} else {
|
|
|
|
this.date = ''
|
|
|
|
this.start = dayjs().year(year).month(month - 1).startOf('month').unix() // .startOf('week').unix()
|
|
|
|
}
|
|
|
|
// this.end = dayjs().year(year).month(month - 1).endOf('month').unix() // .endOf('week').unix()
|
|
|
|
this.end = null
|
|
|
|
this.updateEvents()
|
|
|
|
},
|
|
|
|
dayChange (day) {
|
2021-01-11 00:17:56 +01:00
|
|
|
const date = dayjs(day.date).format('YYYY-MM-DD')
|
|
|
|
if (this.selectedDay === date) {
|
2020-11-13 00:12:05 +01:00
|
|
|
this.selectedDay = null
|
|
|
|
this.start = dayjs().unix() // .startOf('week').unix()
|
|
|
|
this.end = null
|
|
|
|
this.updateEvents()
|
|
|
|
return
|
|
|
|
}
|
2021-01-11 00:17:56 +01:00
|
|
|
this.start = dayjs(date).startOf('day').unix()
|
2020-11-13 00:12:05 +01:00
|
|
|
this.end = dayjs(day).endOf('day').unix()
|
2021-01-11 00:17:56 +01:00
|
|
|
this.selectedDay = date
|
2020-11-13 00:12:05 +01:00
|
|
|
this.updateEvents()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
head () {
|
|
|
|
return {
|
|
|
|
title: this.settings.title,
|
|
|
|
meta: [
|
|
|
|
// hid is used as unique identifier. Do not use `vmid` for it as it will not work
|
|
|
|
{ hid: 'description', name: 'description', content: this.settings.description },
|
|
|
|
{ hid: 'og-description', name: 'og:description', content: this.settings.description },
|
|
|
|
{ hid: 'og-title', property: 'og:title', content: this.settings.title },
|
|
|
|
{ hid: 'og-url', property: 'og:url', content: this.settings.baseurl },
|
|
|
|
{ property: 'og:image', content: this.settings.baseurl + '/favicon.ico' }
|
|
|
|
],
|
|
|
|
link: [
|
|
|
|
{ rel: 'alternate', type: 'application/rss+xml', title: this.settings.title, href: this.settings.baseurl + '/feed/rss' }
|
|
|
|
]
|
|
|
|
}
|
2020-01-15 23:47:17 +01:00
|
|
|
}
|
2019-05-30 12:04:14 +02:00
|
|
|
}
|
|
|
|
</script>
|
2020-11-13 00:12:05 +01:00
|
|
|
<style lang='less'>
|
|
|
|
#home {
|
|
|
|
max-width: 1400px;
|
|
|
|
}
|
|
|
|
|
|
|
|
#events {
|
|
|
|
margin: 0 auto;
|
|
|
|
display: flex;
|
|
|
|
flex-wrap: wrap;
|
|
|
|
justify-content: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|