start with import event feature

This commit is contained in:
les
2020-10-10 00:40:47 +02:00
parent cdfe81e36e
commit a9c81c575b
5 changed files with 115 additions and 11 deletions

View File

@@ -0,0 +1,57 @@
<template lang="pug">
v-card(color='secondary')
v-card-title {{$t('event.importURL')}}
v-card-text
v-form(v-model='valid' ref='form' lazy-validation)
v-text-field(v-model='URL' :loading='loading' :error='error' :error-messages='errorMessage')
p {{event}}
v-card-actions
v-spacer
v-btn(@click='$emit("close")' color='warning') {{$t('common.cancel')}}
v-btn(@click='importURL' :loading='loading' :disabled='loading'
color='primary') {{$t('common.import')}}
</template>
<script>
export default {
name: 'ImportDialog',
data () {
return {
errorMessage: '',
error: false,
loading: false,
valid: false,
URL: '',
event: {}
}
},
methods: {
async importURL() {
if (!this.URL) {
this.errorMessage = this.$validators.required('common.URL')('')
this.error = true
return
}
this.error = false
this.errorMessage = ''
this.loading = true
try {
const ret = await this.$axios.$get('/event/import', { params: { URL: this.URL }})
this.event = ret
// check if contain an h-event
this.$emit('imported', ret)
console.error(ret)
} catch (e) {
console.error(e)
this.error = true
this.errorMessage = String(e)
}
this.loading = false
}
}
}
</script>

View File

@@ -1,9 +1,15 @@
<template lang="pug">
v-container.container
v-card
v-card-title {{edit?$t('common.edit_event'):$t('common.add_event')}}
v-card-title
h4 {{edit?$t('common.edit_event'):$t('common.add_event')}}
v-spacer
v-btn(link text color='primary' @click='openImportDialog=true') <v-icon>mdi-file-import</v-icon> {{$t('event.import_URL')}}
v-dialog(v-model='openImportDialog')
ImportDialog(@close='openImportDialog=false' @imported='eventImported')
v-card-text
v-form(v-model='valid')
v-form(v-model='valid' ref='form' lazy-validation)
//- Not logged event
div(v-if='!$auth.loggedIn')
@@ -151,7 +157,7 @@
v-card-actions
v-spacer
v-btn(@click='done' :loading='loading' :disabled='!valid || loading || !date'
v-btn(@click='done' :loading='loading' :disabled='!valid || loading'
color='primary') {{edit?$t('common.edit'):$t('common.send')}}
</template>
@@ -161,10 +167,11 @@ import _ from 'lodash'
import moment from 'dayjs'
import Editor from '@/components/Editor'
import List from '@/components/List'
import ImportDialog from './ImportDialog'
export default {
name: 'NewEvent',
components: { List, Editor },
components: { List, Editor, ImportDialog },
validate ({ store }) {
return (store.state.auth.loggedIn || store.state.settings.allow_anon_event)
},
@@ -211,6 +218,7 @@ export default {
valid: false,
dueDateMenu: false,
fromDateMenu: false,
openImportDialog: false,
event: {
type: 'normal',
place: { name: '', address: '' },
@@ -363,6 +371,10 @@ export default {
},
methods: {
...mapActions(['addEvent', 'updateEvent', 'updateMeta', 'updateEvents']),
eventImported (event) {
console.error('sono dentro event imported', event)
this.event = event
},
selectPlace (p) {
console.error('sono dentro selectePlace')
const place = p && this.places.find(place => place.id === p.id)
@@ -386,6 +398,7 @@ export default {
this.event.image = {}
},
async done () {
if (!this.$refs.form.validate()) return
this.loading = true
let start_datetime, end_datetime
const [start_hour, start_minute] = this.time.start.split(':')

View File

@@ -8,7 +8,7 @@
//- v-list-item(two-line)
//- v-list-item-content
.text-h5.text-sm-h4
b {{event.title}}
b.p-name {{event.title}}
v-row
v-col.col-12.col-lg-9
//- TOFIX: avoid reflow
@@ -34,10 +34,10 @@
b.ml-2 {{event|when}}
p.subtitle-1 {{event.start_datetime|from}}
.text-h5
.text-h5.p-location
v-icon mdi-map-marker
b.p-location.ml-2 {{event.place.name}}
p.subtitle-1 {{event.place.address}}
b.vcard.ml-2 {{event.place.name}}
p.adr {{event.place.address}}
//- info & actions
v-list
@@ -56,7 +56,7 @@
v-dialog(v-model='showEmbed')
EmbedEvent(:event='event' @close='showEmbed=false')
div.p-description(v-html='event.description')
p.p-description.text-h6(v-html='event.description')
v-chip.p-category.ml-1(small v-for='tag in event.tags' color='primary' outlined :key='tag') {{tag}}
//- //- info & actions