From 80d9b7fc4d0e4b3c8c7421b0615019b89ee3ad2c Mon Sep 17 00:00:00 2001 From: les Date: Wed, 11 Sep 2019 11:56:22 +0200 Subject: [PATCH] show recurrent events while creating a new one --- pages/add/_edit.vue | 31 +++---------------------------- plugins/filters.js | 2 +- server/api/controller/user.js | 2 +- 3 files changed, 5 insertions(+), 30 deletions(-) diff --git a/pages/add/_edit.vue b/pages/add/_edit.vue index eb74517d..519cd8bb 100644 --- a/pages/add/_edit.vue +++ b/pages/add/_edit.vue @@ -273,39 +273,14 @@ export default { attributes.push ({ key: 'today', dates: new Date(), highlight: { color: 'yellow' }}) attributes = attributes.concat(this.filteredEvents - .filter(e => !e.multidate && !e.recurrent) - .map(e => ({ key: e.id, dot: {}, dates: moment.unix(e.start_datetime).toDate()}))) + .filter(e => !e.multidate && (!e.recurrent || this.event.type === 'recurrent')) + .map(e => ({ key: e.id, dot: { color: this.event.type === 'recurrent' ? 'orange' : 'green' }, dates: moment.unix(e.start_datetime).toDate()}))) attributes = attributes.concat(this.filteredEvents .filter(e => e.multidate && !e.recurrent) .map( e => ({ key: e.id, highlight: {}, dates: { start: moment.unix(e.start_datetime).toDate(), end: moment.unix(e.end_datetime).toDate() }}))) - - if (this.event.type === 'recurrent' && this.event.recurrent.frequency) { - const recurrent = {} - const frequency = this.event.recurrent.frequency - if (Array.isArray(this.date) && (frequency === '1w' || frequency === '2w')) { - recurrent.weekdays = uniq(map(this.date, d => moment(d).day()+1 )) - recurrent.weeklyInterval = frequency[0]*1 - recurrent.start = new Date(this.date[0]) - } else if (Array.isArray(this.date) && (frequency === '1m' || frequency === '2m')) { - if (!this.date || !this.date.length) return attributes - if (this.event.recurrent.type === 'weekday') { - const days = uniq(map(this.date, d => moment(d).date())) - const n = Math.floor((days[0]-1)/7)+1 - recurrent.ordinalWeekdays = { [n]: this.date.map(d => moment(d).day()+1) } - } else if (this.event.recurrent.type === 'ordinal') { - recurrent.days = uniq(map(this.date, d => moment(d).date())) - } - recurrent.monthlyInterval = frequency[0]*1 - recurrent.start = new Date(this.date[0]) - } else if (this.event.recurrent.frequency === '1d') { - recurrent.dailyInterval = 1 - } else { - return attributes - } - attributes.push({name: 'recurrent', dates: recurrent, dot: { color: 'red'}}) - } + return attributes }, disableAddress () { diff --git a/plugins/filters.js b/plugins/filters.js index 9c9187cf..2d9e7694 100644 --- a/plugins/filters.js +++ b/plugins/filters.js @@ -14,7 +14,7 @@ export default ({ app, store }) => { // Vue.filter('hour', value => moment(value).locale(store.state.locale).format('HH:mm')) // shown in mobile homepage - Vue.filter('day', value => moment.unix(value).locale(store.state.locale).format('dddd, D MMMM')) + Vue.filter('day', value => moment.unix(value).locale(store.state.locale).format('dddd, D MMM')) // Vue.filter('month', value => moment(value).locale(store.state.locale).format('MMM')) // format event start/end datetime based on page diff --git a/server/api/controller/user.js b/server/api/controller/user.js index 72a875db..7b9e6703 100644 --- a/server/api/controller/user.js +++ b/server/api/controller/user.js @@ -91,7 +91,7 @@ const userController = { let event = await Event.create(eventDetails) - // create place if needs to + // create place if needed let place try { place = await Place.findOrCreate({ where: { name: body.place_name },