gancio-upstream/components/Event.vue

122 lines
3 KiB
Vue
Raw Normal View History

2019-04-03 00:25:12 +02:00
<template lang="pug">
2020-02-11 11:53:32 +01:00
.card.event.h-event.mt-1.text-white(body-style='padding: 0px;')
2020-02-09 18:15:44 +01:00
nuxt-link(:to='`/event/${event.id}`')
2020-02-21 18:10:21 +01:00
el-image(v-if='showImage && event.image_path'
lazy :src='`/media/thumb/${event.image_path}`')
2020-02-09 18:15:44 +01:00
.float-right
i.text-danger.el-icon-refresh(v-if='event.parentId')
.badge.text-info(v-if='settings.enable_resources && event.resources && event.resources.length') {{event.resources.length}}
2020-02-11 11:53:32 +01:00
.p-name.p-summary.title {{event.title}}
2020-02-09 18:15:44 +01:00
.card-body
2020-02-11 15:39:57 +01:00
//- when
2020-02-09 18:15:44 +01:00
div
i.el-icon-date
2020-02-11 11:53:32 +01:00
time.dt-start(:datetime='event.start_datetime|unixFormat("YYYY-MM-DD HH:mm")') {{event|when}}
2020-02-11 15:39:57 +01:00
//- place
2020-02-11 11:53:32 +01:00
el-button.p-location.mt-1.bg-dark.text-warning.float-right(plain size='mini' round type='text' icon='el-icon-location-outline' @click='addPlace') {{event.place.name}}
2020-02-11 15:39:57 +01:00
//- description
2020-02-11 11:53:32 +01:00
.description.p-description.mt-3(v-if='!event.image_path || !event.tags.length' v-html='description')
2020-02-09 18:15:44 +01:00
.card-footer(v-if='event.tags.length')
el-button.ml-1.bg-dark(type='text' plain round size='mini' v-for='tag in event.tags' :key='tag' @click='addTag(tag)') {{tag}}
2019-04-03 00:25:12 +02:00
</template>
<script>
2020-02-09 18:15:44 +01:00
import { mapState, mapActions } from 'vuex'
2019-04-03 00:25:12 +02:00
export default {
2019-05-30 12:04:14 +02:00
props: {
event: { type: Object, default: () => ({}) },
2019-05-30 12:04:14 +02:00
showTags: {
type: Boolean,
default: true
},
showImage: {
type: Boolean,
default: true
2019-09-11 19:12:24 +02:00
}
2019-04-03 00:25:12 +02:00
},
2019-05-30 12:04:14 +02:00
computed: {
2020-02-09 18:15:44 +01:00
...mapState(['settings', 'filters']),
description () {
return this.event.description.slice(0, 500)
},
show_footer () {
return (this.event.tags.length || this.event.resources.length)
}
},
methods: {
...mapActions(['setSearchTags', 'setSearchPlaces']),
addTag (tag) {
if (this.filters.tags.includes(tag)) {
this.setSearchTags(this.filters.tags.filter(t => t !== tag))
} else {
this.setSearchTags(this.filters.tags.concat([tag]))
}
},
addPlace () {
const place = this.event.place.id
if (this.filters.places.includes(place)) {
this.setSearchPlaces(this.filters.places.filter(p => p !== place))
} else {
this.setSearchPlaces(this.filters.places.concat(place))
}
}
2019-04-03 00:25:12 +02:00
}
}
</script>
2019-05-30 12:04:14 +02:00
<style lang='less'>
.event {
2020-02-09 18:15:44 +01:00
width: 320px;
max-width: 450px;
flex-grow: 1;
margin: .2em;
background-color: #202020;
2019-04-03 00:25:12 +02:00
2020-02-09 18:15:44 +01:00
a:hover {
2019-05-30 12:04:14 +02:00
text-decoration: none;
2020-02-09 18:15:44 +01:00
.title {
border-bottom: 1px solid #888;
color: white;
}
2019-05-30 12:04:14 +02:00
}
2019-04-03 00:25:12 +02:00
2020-02-09 18:15:44 +01:00
.title {
margin-left: 1rem;
margin-top: 1rem;
margin-right: 1rem;
border-bottom: 1px solid #333;
transition: border-color .5s;
font-size: 1.2em;
max-height: 3em;
overflow: hidden;
color: #fea;
2019-05-30 12:04:14 +02:00
}
2019-04-03 00:25:12 +02:00
2020-02-09 18:15:44 +01:00
.card-footer {
max-height: 4.5em;
overflow: hidden;
padding: .25rem 0.5rem;
line-height: 1.8rem;
2020-02-10 00:41:18 +01:00
min-height: 2.2rem;
2019-05-30 12:04:14 +02:00
}
2020-02-09 18:15:44 +01:00
.description {
color: #999;
font-size: 0.8em;
2019-05-30 12:04:14 +02:00
p {
margin: 0px;
}
}
2020-02-21 18:10:21 +01:00
.el-image { width: 100% }
2020-02-09 18:15:44 +01:00
img {
width: 100%;
max-height: 250px;
object-fit: cover;
object-position: top;
2019-05-30 12:04:14 +02:00
}
2019-04-03 00:25:12 +02:00
}
</style>