start with import event feature
This commit is contained in:
57
pages/add/ImportDialog.vue
Normal file
57
pages/add/ImportDialog.vue
Normal 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>
|
||||
@@ -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(':')
|
||||
|
||||
Reference in New Issue
Block a user