From f04012d1ceeed2a77476185ba0c46e7790c618ec Mon Sep 17 00:00:00 2001 From: lesion Date: Fri, 14 Jun 2019 23:26:13 +0200 Subject: [PATCH] minor --- pages/add/_edit.vue | 1 - pages/event/_id.vue | 13 +++++++++++-- server/api/controller/event.js | 11 ++++++----- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/pages/add/_edit.vue b/pages/add/_edit.vue index 5d37bffd..176b551b 100644 --- a/pages/add/_edit.vue +++ b/pages/add/_edit.vue @@ -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') diff --git a/pages/event/_id.vue b/pages/event/_id.vue index 992bd46b..8165ff42 100644 --- a/pages/event/_id.vue +++ b/pages/event/_id.vue @@ -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 diff --git a/server/api/controller/event.js b/server/api/controller/event.js index 7d877153..3cfd540d 100644 --- a/server/api/controller/event.js +++ b/server/api/controller/event.js @@ -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'] } ]