2019-04-03 00:25:12 +02:00
|
|
|
<template lang="pug">
|
2019-06-26 15:44:26 +02:00
|
|
|
el-card#eventDetail
|
2019-05-30 12:04:14 +02:00
|
|
|
//- close button
|
|
|
|
nuxt-link.float-right(to='/')
|
2019-07-05 01:38:31 +02:00
|
|
|
el-button(circle icon='el-icon-close' type='danger' size='small' plain)
|
2019-05-30 12:04:14 +02:00
|
|
|
|
2019-06-09 00:45:50 +02:00
|
|
|
div(v-if='!event')
|
|
|
|
h5 {{$t('event.not_found')}}
|
2019-05-30 12:04:14 +02:00
|
|
|
|
2019-06-09 00:45:50 +02:00
|
|
|
div(v-else)
|
2019-07-23 01:31:43 +02:00
|
|
|
//- title
|
2019-06-09 00:45:50 +02:00
|
|
|
h5.text-center {{event.title}}
|
|
|
|
div.nextprev
|
2019-07-23 01:31:43 +02:00
|
|
|
nuxt-link(v-if='prev' :to='`/event/${prev}`')
|
2019-06-25 01:05:38 +02:00
|
|
|
el-button( type='success' size='mini')
|
2019-06-12 23:41:19 +02:00
|
|
|
v-icon(name='chevron-left')
|
2019-07-23 01:31:43 +02:00
|
|
|
nuxt-link.float-right(v-if='next' :to='`/event/${next}`')
|
2019-06-25 01:05:38 +02:00
|
|
|
el-button(type='success' size='mini')
|
2019-06-12 23:41:19 +02:00
|
|
|
v-icon(name='chevron-right')
|
2019-07-23 01:31:43 +02:00
|
|
|
|
2019-06-09 00:45:50 +02:00
|
|
|
//- image
|
2019-06-26 18:37:02 +02:00
|
|
|
img.main(:src='imgPath' v-if='event.image_path')
|
2019-05-30 12:04:14 +02:00
|
|
|
|
2019-06-09 00:45:50 +02:00
|
|
|
.info
|
2019-07-23 01:31:43 +02:00
|
|
|
div {{event|when}}
|
2019-06-09 00:45:50 +02:00
|
|
|
div {{event.place.name}} - {{event.place.address}}
|
2019-05-30 12:04:14 +02:00
|
|
|
|
2019-06-09 00:45:50 +02:00
|
|
|
//- description and tags
|
|
|
|
div(v-if='event.description || event.tags')
|
2019-06-26 14:44:21 +02:00
|
|
|
pre(v-html='$options.filters.linkify(event.description)')
|
2019-06-09 00:45:50 +02:00
|
|
|
el-tag.mr-1(v-for='tag in event.tags'
|
|
|
|
size='mini' :key='tag.tag') {{tag.tag}}
|
2019-05-30 12:04:14 +02:00
|
|
|
|
2019-06-09 00:45:50 +02:00
|
|
|
//- show hide, confirm, delete, edit buttons when allowed
|
|
|
|
div(v-if='mine')
|
|
|
|
hr
|
2019-06-12 23:41:19 +02:00
|
|
|
el-button(v-if='event.is_visible' size='mini' plain type='warning' @click.prevents='toggle') {{$t('common.hide')}}
|
|
|
|
el-button(v-else plain type='success' size='mini' @click.prevents='toggle') {{$t('common.confirm')}}
|
|
|
|
el-button(plain type='danger' size='mini' @click.prevent='remove') {{$t('common.remove')}}
|
|
|
|
el-button(plain type='primary' size='mini' @click='$router.replace(`/add/${event.id}`)') {{$t('common.edit')}}
|
2019-06-09 00:45:50 +02:00
|
|
|
|
2019-08-02 13:43:28 +02:00
|
|
|
//- comments from fediverse
|
|
|
|
#comments.card-body(v-if='settings.enable_federation')
|
2019-08-07 19:15:15 +02:00
|
|
|
small.float-right 🔖 {{event.likes.length}}
|
|
|
|
small.float-right.mr-3 ✊ {{event.boost.length}}<br/>
|
2019-08-02 13:43:28 +02:00
|
|
|
strong {{$t('common.comments')}} -
|
|
|
|
<small>{{$t('event.interact_with_me_at')}} <u>{{event.user.username}}@{{settings.baseurl|url2host}}</u></small>
|
2019-06-26 18:37:02 +02:00
|
|
|
|
|
|
|
.card-header(v-for='comment in event.comments' :key='comment.id')
|
2019-08-01 15:18:45 +02:00
|
|
|
a.float-right(:href='comment.data.url')
|
|
|
|
small {{comment.data.published|datetime}}
|
2019-06-26 18:37:02 +02:00
|
|
|
div.mt-1(v-html='comment_filter(comment.data.content)')
|
|
|
|
img(v-for='img in comment.data.media_attachments' :src='img.url')
|
2019-05-30 12:04:14 +02:00
|
|
|
|
2019-04-03 00:25:12 +02:00
|
|
|
</template>
|
|
|
|
<script>
|
2019-05-30 12:04:14 +02:00
|
|
|
import { mapState, mapActions, mapGetters } from 'vuex'
|
2019-06-25 01:05:38 +02:00
|
|
|
import { MessageBox } from 'element-ui'
|
2019-04-03 00:25:12 +02:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'Event',
|
2019-05-30 12:04:14 +02:00
|
|
|
// transition: null,
|
2019-07-23 01:31:43 +02:00
|
|
|
// Watch for $route.query.page to call
|
|
|
|
// Component methods (asyncData, fetch, validate, layout, etc.)
|
2019-05-30 12:04:14 +02:00
|
|
|
// watchQuery: ['id'],
|
|
|
|
// Key for <NuxtChild> (transitions)
|
|
|
|
// key: to => to.fullPath,
|
|
|
|
// Called to know which transition to apply
|
|
|
|
// transition(to, from) {
|
|
|
|
// if (!from) return 'slide-left'
|
|
|
|
// return +to.params.id < +from.params.id ? 'slide-right' : 'slide-left'
|
|
|
|
// },
|
|
|
|
|
2019-04-29 00:27:29 +02:00
|
|
|
head () {
|
2019-06-09 00:45:50 +02:00
|
|
|
if (!this.event) return {}
|
2019-04-29 00:27:29 +02:00
|
|
|
return {
|
2019-08-07 19:15:15 +02:00
|
|
|
title: `${this.settings.title} - ${this.event.title}`,
|
2019-04-29 00:27:29 +02:00
|
|
|
meta: [
|
|
|
|
// hid is used as unique identifier. Do not use `vmid` for it as it will not work
|
2019-07-23 01:31:43 +02:00
|
|
|
{ hid: 'description', name: 'description',
|
|
|
|
content: this.event.description.slice(0, 1000) },
|
|
|
|
{ hid: 'og-description', name: 'og:description',
|
|
|
|
content: this.event.description.slice(0, 100) },
|
|
|
|
{ hid: 'og-title', property: 'og:title', content: this.event.title },
|
|
|
|
{ hid: 'og-url', property: 'og:url', content: `event/${this.event.id}` },
|
2019-04-29 00:27:29 +02:00
|
|
|
{ property: 'og:type', content: 'event'},
|
|
|
|
{ property: 'og:image', content: this.imgPath }
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
2019-06-14 23:26:13 +02:00
|
|
|
async fetch ({ $axios, store }) {
|
|
|
|
try {
|
|
|
|
const now = new Date()
|
|
|
|
const events = await $axios.$get(`/event/${now.getMonth()}/${now.getFullYear()}`)
|
|
|
|
return store.commit('setEvents', events)
|
|
|
|
} catch(e) {
|
|
|
|
console.error(e)
|
|
|
|
}
|
|
|
|
},
|
2019-07-04 01:09:35 +02:00
|
|
|
async asyncData ( { $axios, params, error }) {
|
|
|
|
try {
|
2019-07-23 01:31:43 +02:00
|
|
|
const [ id, start_datetime ] = params.id.split('_')
|
|
|
|
const event = await $axios.$get(`/event/${id}`)
|
2019-08-07 19:15:15 +02:00
|
|
|
event.start_datetime = start_datetime ? Number(start_datetime) : event.start_datetime
|
2019-07-27 13:05:02 +02:00
|
|
|
event.end_datetime = event.end_datetime
|
2019-08-07 19:15:15 +02:00
|
|
|
return { event, id: Number(id) }
|
2019-07-04 01:09:35 +02:00
|
|
|
} catch(e) {
|
|
|
|
error({ statusCode: 404, message: 'Event not found'})
|
|
|
|
}
|
2019-06-09 00:45:50 +02:00
|
|
|
},
|
2019-04-03 00:25:12 +02:00
|
|
|
computed: {
|
2019-05-30 12:04:14 +02:00
|
|
|
...mapGetters(['filteredEvents']),
|
2019-06-12 23:41:19 +02:00
|
|
|
...mapState(['settings']),
|
2019-05-30 12:04:14 +02:00
|
|
|
next () {
|
|
|
|
let found = false
|
2019-07-23 01:31:43 +02:00
|
|
|
const event = this.filteredEvents.find(e => {
|
2019-05-30 12:04:14 +02:00
|
|
|
if (found) return e
|
2019-08-07 19:15:15 +02:00
|
|
|
found = (e.start_datetime === this.event.start_datetime && e.id === this.event.id)
|
2019-05-30 12:04:14 +02:00
|
|
|
})
|
2019-07-23 01:31:43 +02:00
|
|
|
if (!event) return false
|
|
|
|
if (event.recurrent) {
|
2019-07-27 13:05:02 +02:00
|
|
|
return `${event.id}_${event.start_datetime}`
|
2019-07-23 01:31:43 +02:00
|
|
|
}
|
|
|
|
return event.id
|
2019-05-30 12:04:14 +02:00
|
|
|
},
|
|
|
|
prev () {
|
2019-07-23 01:31:43 +02:00
|
|
|
let event = false
|
2019-05-30 12:04:14 +02:00
|
|
|
this.filteredEvents.find(e => {
|
2019-07-23 01:31:43 +02:00
|
|
|
if (e.start_datetime === this.event.start_datetime && e.id === this.event.id) return true
|
|
|
|
event = e
|
2019-05-30 12:04:14 +02:00
|
|
|
})
|
2019-07-23 01:31:43 +02:00
|
|
|
if (!event) return false
|
|
|
|
if (event.recurrent) {
|
2019-07-27 13:05:02 +02:00
|
|
|
return `${event.id}_${event.start_datetime}`
|
2019-07-23 01:31:43 +02:00
|
|
|
}
|
|
|
|
return event.id
|
2019-05-30 12:04:14 +02:00
|
|
|
},
|
2019-04-03 00:25:12 +02:00
|
|
|
imgPath () {
|
2019-04-29 00:27:29 +02:00
|
|
|
return this.event.image_path && '/media/' + this.event.image_path
|
2019-04-03 00:25:12 +02:00
|
|
|
},
|
|
|
|
mine () {
|
2019-05-30 12:04:14 +02:00
|
|
|
if (!this.$auth.user) return false
|
2019-04-29 00:27:29 +02:00
|
|
|
return this.event.userId === this.$auth.user.id || this.$auth.user.is_admin
|
2019-04-30 01:04:24 +02:00
|
|
|
},
|
2019-04-03 00:25:12 +02:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
...mapActions(['delEvent']),
|
2019-04-30 01:04:24 +02:00
|
|
|
comment_filter (value) {
|
|
|
|
return value.replace(/<a.*href="([^">]+).*>(?:.(?!\<\/a\>))*.<\/a>/, (orig, url) => {
|
|
|
|
// get extension
|
|
|
|
const ext = url.slice(-4)
|
|
|
|
if (['.mp3', '.ogg'].indexOf(ext)>-1) {
|
|
|
|
return `<audio controls><source src='${url}'></audio>`
|
|
|
|
} else {
|
|
|
|
return orig
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
2019-04-03 00:25:12 +02:00
|
|
|
async remove () {
|
2019-05-30 12:04:14 +02:00
|
|
|
try {
|
2019-06-25 01:05:38 +02:00
|
|
|
await MessageBox.confirm(this.$t('event.remove_confirmation'), this.$t('common.confirm'), {
|
|
|
|
confirmButtonText: this.$t('common.ok'),
|
|
|
|
cancelButtonText: this.$t('common.cancel'),
|
|
|
|
type: 'error'})
|
2019-05-30 12:04:14 +02:00
|
|
|
await this.$axios.delete(`/user/event/${this.id}`)
|
|
|
|
this.delEvent(Number(this.id))
|
2019-06-25 01:05:38 +02:00
|
|
|
this.$router.replace("/")
|
2019-05-30 12:04:14 +02:00
|
|
|
} catch (e) {
|
|
|
|
console.error(e)
|
|
|
|
}
|
2019-04-03 00:25:12 +02:00
|
|
|
},
|
|
|
|
async toggle () {
|
|
|
|
try {
|
|
|
|
if (this.event.is_visible) {
|
2019-04-23 15:45:52 +02:00
|
|
|
await this.$axios.$get(`/event/unconfirm/${this.id}`)
|
2019-04-03 00:25:12 +02:00
|
|
|
this.event.is_visible = false
|
|
|
|
} else {
|
2019-04-23 15:45:52 +02:00
|
|
|
await this.$axios.$get(`/event/confirm/${this.id}`)
|
2019-04-03 00:25:12 +02:00
|
|
|
this.event.is_visible = true
|
|
|
|
}
|
|
|
|
} catch (e) {
|
2019-05-30 12:04:14 +02:00
|
|
|
console.error(e)
|
2019-04-03 00:25:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
2019-05-30 12:04:14 +02:00
|
|
|
<style lang='less'>
|
2019-04-23 15:45:52 +02:00
|
|
|
|
2019-05-30 12:04:14 +02:00
|
|
|
#eventDetail {
|
|
|
|
max-width: 1000px;
|
|
|
|
border-radius: 0px;
|
|
|
|
margin: 0 auto;
|
2019-04-30 01:04:24 +02:00
|
|
|
|
2019-05-30 12:04:14 +02:00
|
|
|
pre {
|
|
|
|
color: #404246;
|
|
|
|
font-size: 1em;
|
|
|
|
font-family: BlinkMacSystemFont,-apple-system,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,Helvetica,Arial,sans-serif !important;
|
|
|
|
}
|
2019-04-30 01:04:24 +02:00
|
|
|
|
2019-05-30 12:04:14 +02:00
|
|
|
h5 {
|
2019-06-25 01:05:38 +02:00
|
|
|
font-size: 2em;
|
|
|
|
font-weight: 600;
|
2019-05-30 12:04:14 +02:00
|
|
|
min-height: 40px;
|
|
|
|
}
|
2019-04-23 15:45:52 +02:00
|
|
|
|
2019-05-30 12:04:14 +02:00
|
|
|
.info {
|
|
|
|
margin: 10px;
|
|
|
|
font-size: 1.3em;
|
|
|
|
font-weight: 600;
|
|
|
|
text-align: center;
|
|
|
|
}
|
2019-04-03 00:25:12 +02:00
|
|
|
|
2019-05-30 12:04:14 +02:00
|
|
|
img {
|
|
|
|
max-height: 89vh;
|
|
|
|
object-fit: contain;
|
2019-06-26 18:37:02 +02:00
|
|
|
&.main {
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#comments {
|
|
|
|
img {
|
|
|
|
max-width: 100%;
|
|
|
|
}
|
2019-07-05 23:58:47 +02:00
|
|
|
.invisible {
|
|
|
|
visibility: visible !important;
|
|
|
|
}
|
2019-05-30 12:04:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
.avatar {
|
|
|
|
width: auto;
|
|
|
|
height: 40px;
|
|
|
|
border-radius: 5px;
|
|
|
|
}
|
2019-04-03 00:25:12 +02:00
|
|
|
|
2019-05-30 12:04:14 +02:00
|
|
|
.nextprev {
|
|
|
|
font-size: 10px;
|
|
|
|
margin-bottom: 5px;
|
|
|
|
}
|
2019-04-03 00:25:12 +02:00
|
|
|
}
|
|
|
|
|
2019-05-30 12:04:14 +02:00
|
|
|
@media only screen and (max-width: 768px) {
|
|
|
|
#eventDetail {
|
|
|
|
font-size: 12px;
|
|
|
|
}
|
2019-04-03 00:25:12 +02:00
|
|
|
}
|
2019-05-30 12:04:14 +02:00
|
|
|
|
2019-04-03 00:25:12 +02:00
|
|
|
</style>
|
|
|
|
|