This commit is contained in:
lesion 2019-06-14 23:26:13 +02:00
parent c8895e77ff
commit f04012d1ce
3 changed files with 17 additions and 8 deletions

View file

@ -4,7 +4,6 @@
el-button
v-icon(name='times' color='red')
h5 {{edit?$t('common.edit_event'):$t('common.add_event')}}
el-form
no-ssr
el-tabs.mb-2(v-model='activeTab')

View file

@ -2,7 +2,7 @@
el-card#eventDetail(v-loading='!loaded')
//- close button
nuxt-link.float-right(to='/')
el-button(type='danger' plain circle)
el-button(type='danger' plain)
v-icon(name='times')
div(v-if='!event')
@ -13,7 +13,7 @@
h5.text-center {{event.title}}
div.nextprev
nuxt-link(v-if='prev' :to='`/event/${prev.id}`')
el-button( round type='success')
el-button(round type='success')
v-icon(name='chevron-left')
nuxt-link.float-right(v-if='next' :to='`/event/${next.id}`')
el-button(round type='success')
@ -89,6 +89,15 @@ export default {
]
}
},
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)
}
},
async asyncData ( { $axios, params }) {
const event = await $axios.$get(`/event/${params.id}`)
const loaded = !event.image_path

View file

@ -82,15 +82,18 @@ const eventController = {
res.json(place)
},
// TODO retrieve next/prev event also
// select id, start_datetime, title from events where start_datetime > (select start_datetime from events where id=89) order by start_datetime limit 20;
// weigth is not updated
async get(req, res) {
const id = req.params.event_id
const event = await Event.findByPk(id, { include:
[
const event = await Event.findByPk(id, {
include: [
Tag,
Comment,
{ model: Place, attributes: ['name', 'address'] }
],
order: [ [Comment, 'id', 'DESC'], [Tag, 'weigth', 'DESC'] ]
order: [ [Comment, 'id', 'DESC'], [Tag, 'weigth', 'DESC'] ]
})
if (event) {
res.json(event)
@ -184,8 +187,6 @@ const eventController = {
[Tag, 'weigth', 'DESC']
],
include: [
// { model: User, required: false },
// { type: Comment, required: false, attributes: ['']
{ model: Tag, required: false, attributes: ['tag', 'weigth', 'color'] },
{ model: Place, required: false, attributes: ['id', 'name', 'address'] }
]