taskManager & recurrent events generation

This commit is contained in:
les
2020-01-30 12:37:19 +01:00
parent 0d83a48452
commit 6ad7fd1d79
21 changed files with 366 additions and 291 deletions

View File

@@ -52,10 +52,10 @@ export default {
async register () {
this.loading = true
try {
const { user } = await this.$axios.$post('/user/register', this.user)
await this.$axios.$post('/user/register', this.user)
Message({
showClose: true,
message: this.$t(`register.${user.is_admin ? 'admin_' : ''}complete`),
message: this.$t('register.complete'),
type: 'success'
})
this.close()

View File

@@ -135,7 +135,7 @@ export default {
data.event.type = 'multidate'
} else if (event.recurrent) {
data.event.type = 'recurrent'
data.event.recurrent = JSON.parse(event.recurrent)
data.event.recurrent = event.recurrent
} else {
data.event.type = 'normal'
data.date = moment.unix(event.start_datetime)
@@ -184,15 +184,15 @@ export default {
if (!dates || !dates.length) { return '' }
const freq = this.event.recurrent.frequency
const weekDays = _(dates).map(date => moment(date).format('dddd')).uniq()
const weekDays = _(dates).map(date => moment(date).format('dddd')).uniq().value()
if (freq === '1w' || freq === '2w') {
return this.$t(`event.recurrent_${freq}_days`, { days: weekDays.join(', ') })
} else if (freq === '1m' || freq === '2m') {
const days = _(dates).map(date => moment(date).date()).uniq()
const days = _(dates).map(date => moment(date).date()).uniq().value()
const n = Math.floor((days[0] - 1) / 7) + 1
return [
{ label: this.$tc(`event.recurrent_${freq}_days`, days.length, { days }), key: 'ordinal' },
{ label: this.$tc(`event.recurrent_${freq}_ordinal`, days.length, { n: this.$t(`ordinal.${n}`), days: weekDays.join(', ') }), key: 'weekday' }
{ label: this.$tc(`event.recurrent_${freq}_ordinal`, days.length, { n, days: weekDays.join(', ') }), key: 'weekday' }
]
} else if (freq === '1d') {
return this.$t('event.recurrent_each_day')
@@ -231,7 +231,6 @@ export default {
.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() })))
console.error(this.event.type)
if (this.event.type === 'recurrent' && this.date && this.date.length) {
attributes.push({
key: 'recurrent',

View File

@@ -1,20 +1,19 @@
<template lang="pug">
nuxt-link.embed_event(:to='`/event/${link}`' target='_blank' :class='{ withImg: event.image_path }')
nuxt-link.embed_event(:to='`/event/${id}`' target='_blank' :class='{ withImg: event.image_path }')
//- image
img.float-left(v-if='event.image_path' :src='`/media/thumb/${event.image_path}`')
.event-info
//- image
img.float-left(v-if='event.image_path' :src='`/media/thumb/${event.image_path}`')
.event-info
//- title
.date {{event|when('home')}}<br/>
h4 {{event.title}}
//- title
.date {{event|when('home')}}<br/>
h4 {{event.title}}
//- date / place
.date {{event.place.name}}<br/> {{event.place.address}}
//- date / place
.date {{event.place.name}}<br/> {{event.place.address}}
</template>
<script>
import { mapState } from 'vuex'
import Event from '../../components/Event'
export default {
@@ -22,10 +21,8 @@ export default {
components: { Event },
async asyncData ({ $axios, params, error, store }) {
try {
const [id, start_datetime] = params.event_id.split('_')
const event = await $axios.$get(`/event/${id}`)
event.start_datetime = start_datetime ? Number(start_datetime) : event.start_datetime
return { event, id: Number(id) }
const event = await $axios.$get(`/event/${params.event_id}`)
return { event, id: Number(params.event_id) }
} catch (e) {
error({ statusCode: 404, message: 'Event not found' })
}
@@ -34,31 +31,10 @@ export default {
return {
loading: true
}
},
computed: {
...mapState(['settings']),
date () {
return new Date(this.event.start_datetime).getDate()
},
link () {
if (this.event.recurrent) {
return `${this.event.id}_${this.event.start_datetime}`
}
return this.event.id
}
}
}
/**
* <style>
.embedded_gancio {
border: none;
width: 450px;
height: 220px;
float: left;
}</style>
<iframe src='http://localhost:13120/embed/1' class='embedded_gancio'></iframe>
*/
// <iframe src='http://localhost:13120/embed/1' class='embedded_gancio'></iframe>
</script>
<style lang='less'>
.embed_event {

View File

@@ -29,8 +29,8 @@
//- info & actions for desktop
el-col.menu(:sm='6' :xs='24')
el-menu.menu.mt-2(router)
p <i class='el-icon-time'></i> <b>{{event|when}}</b> <br/><small>{{event|to}}</small>
p <i class='el-icon-map-location'></i> <b>{{event.place.name}}</b> - {{event.place.address}}
p <i class='el-icon-date'></i> <b>{{event|when}}</b> <br/><small>{{event|to}}</small>
p <i class='el-icon-location-outline'></i> <b>{{event.place.name}}</b> - {{event.place.address}}
el-divider {{$t('common.actions')}}
el-menu-item(
v-clipboard:success='copyLink'
@@ -80,7 +80,7 @@ import EmbedEvent from './embedEvent'
import FollowMe from './followMe'
import { Message, MessageBox } from 'element-ui'
import moment from 'dayjs'
import moment from 'moment-timezone'
export default {
name: 'Event',
@@ -88,17 +88,8 @@ export default {
components: { EventAdmin, EmbedEvent, FollowMe },
async asyncData ({ $axios, params, error, store }) {
try {
const [id, start_datetime] = params.id.split('_')
const event = await $axios.$get(`/event/${id}`)
event.start_datetime = start_datetime
? Number(start_datetime)
: event.start_datetime
// const now = new Date()
// const events = await $axios.$get(
// `/event/${now.getMonth()}/${now.getFullYear()}`
// )
// store.commit('setEvents', events)
return { event, id: Number(id) }
const event = await $axios.$get(`/event/${params.id}`)
return { event, id: Number(params.id) }
} catch (e) {
error({ statusCode: 404, message: 'Event not found' })
}
@@ -201,9 +192,6 @@ export default {
if (!event) {
return false
}
if (event.recurrent) {
return `${event.id}_${event.start_datetime}`
}
return event.id
},
prev () {
@@ -220,9 +208,6 @@ export default {
if (!event) {
return false
}
if (event.recurrent) {
return `${event.id}_${event.start_datetime}`
}
return event.id
},
imgPath () {

View File

@@ -1,11 +1,19 @@
<template lang='pug'>
el-menu.menu
div
el-divider {{$t('common.admin')}}
el-menu-item
div(@click.prevents='toggle') {{$t(event.is_visible?'common.hide':'common.confirm')}}
el-menu-item
div(@click.prevent='remove') {{$t('common.remove')}}
el-menu-item(@click='$router.replace(`/add/${event.id}`)') {{$t('common.edit')}}
el-menu.menu
el-menu-item
div(v-if='event.is_visible' @click='toggle(false)') <i class='el-icon-open'/> {{$t('common.hide')}}
div(v-else @click='toggle(false)') <i class='el-icon-turn-off'/> {{$t('common.confirm')}}
el-menu-item
div(@click='remove(false)') <i class='el-icon-delete'/> {{$t('common.remove')}}
el-menu-item(@click='$router.replace(`/add/${event.id}`)') <i class='el-icon-edit'/> {{$t('common.edit')}}
div(v-if='event.parentId')
el-divider {{$t('event.recurrent')}}
el-menu-item(v-if='event.parent.is_visible' @click='toggle(true)') <i class='el-icon-video-pause'/> {{$t('common.pause')}}
el-menu-item(v-else @click='toggle(true)') <i class='el-icon-video-play'/> {{$t('common.start')}}
el-menu-item(@click='remove(true)') <i class='el-icon-delete'/> {{$t('common.remove')}}
el-menu-item(@click='$router.replace(`/add/${event.parentId}`)') <i class='el-icon-edit'/> {{$t('common.edit')}}
</template>
<script>
import { MessageBox } from 'element-ui'
@@ -13,30 +21,39 @@ import { mapActions } from 'vuex'
export default {
name: 'EventAdmin',
props: ['event'],
props: {
event: {
type: Object,
default: () => ({})
}
},
methods: {
...mapActions(['delEvent']),
async remove () {
async remove (parent = false) {
try {
await MessageBox.confirm(this.$t('event.remove_confirmation'), this.$t('common.confirm'), {
confirmButtonText: this.$t('common.ok'),
cancelButtonText: this.$t('common.cancel'),
type: 'error' })
await this.$axios.delete(`/user/event/${this.event.id}`)
this.delEvent(Number(this.event.id))
type: 'error'
})
const id = parent ? this.event.parentId : this.event.id
await this.$axios.delete(`/user/event/${id}`)
this.delEvent(Number(id))
this.$router.replace('/')
} catch (e) {
console.error(e)
}
},
async toggle () {
async toggle (parent = false) {
const id = parent ? this.event.parentId : this.event.id
const is_visible = parent ? this.event.parent.is_visible : this.event.is_visible
const method = is_visible ? 'unconfirm' : 'confirm'
try {
if (this.event.is_visible) {
await this.$axios.$get(`/event/unconfirm/${this.event.id}`)
this.event.is_visible = false
await this.$axios.$get(`/event/${method}/${id}`)
if (parent) {
this.event.parent.is_visible = !is_visible
} else {
await this.$axios.$get(`/event/confirm/${this.event.id}`)
this.event.is_visible = true
this.event.is_visible = !is_visible
}
} catch (e) {
console.error(e)