2019-01-21 15:08:22 +01:00
|
|
|
<template>
|
|
|
|
<section>
|
|
|
|
<h1 class="title">
|
|
|
|
<translate>Create a new event</translate>
|
|
|
|
</h1>
|
|
|
|
<div v-if="$apollo.loading">Loading...</div>
|
|
|
|
<div class="columns" v-else>
|
|
|
|
<form class="column" @submit="createEvent">
|
|
|
|
<b-field :label="$gettext('Title')">
|
|
|
|
<b-input aria-required="true" required v-model="event.title"/>
|
|
|
|
</b-field>
|
|
|
|
|
|
|
|
<b-datepicker v-model="event.begins_on" inline></b-datepicker>
|
|
|
|
|
|
|
|
<b-field :label="$gettext('Category')">
|
|
|
|
<b-select placeholder="Select a category" v-model="event.category">
|
|
|
|
<option
|
|
|
|
v-for="category in categories"
|
|
|
|
:value="category"
|
2019-02-22 16:54:01 +01:00
|
|
|
:key="category"
|
|
|
|
>{{ $gettext(category) }}</option>
|
2019-01-21 15:08:22 +01:00
|
|
|
</b-select>
|
|
|
|
</b-field>
|
|
|
|
|
|
|
|
<button class="button is-primary">
|
|
|
|
<translate>Create my event</translate>
|
|
|
|
</button>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2019-02-22 16:54:01 +01:00
|
|
|
// import Location from '@/components/Location';
|
|
|
|
import {CREATE_EVENT, EDIT_EVENT} from "@/graphql/event";
|
|
|
|
import {Component, Prop, Vue} from "vue-property-decorator";
|
2019-03-05 12:07:58 +01:00
|
|
|
import {
|
|
|
|
Category,
|
|
|
|
IEvent,
|
|
|
|
EventModel,
|
|
|
|
} from "@/types/event.model";
|
2019-02-22 16:54:01 +01:00
|
|
|
import {LOGGED_PERSON} from "@/graphql/actor";
|
2019-03-05 12:07:58 +01:00
|
|
|
import {IPerson, Person} from "@/types/actor.model";
|
2019-01-21 15:08:22 +01:00
|
|
|
|
2019-03-05 12:07:58 +01:00
|
|
|
@Component({
|
|
|
|
apollo: {
|
|
|
|
loggedPerson: {
|
|
|
|
query: LOGGED_PERSON,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2019-01-21 15:08:22 +01:00
|
|
|
export default class CreateEvent extends Vue {
|
|
|
|
@Prop({ required: false, type: String }) uuid!: string;
|
|
|
|
|
2019-03-05 12:07:58 +01:00
|
|
|
loggedPerson: IPerson = new Person();
|
2019-02-22 16:54:01 +01:00
|
|
|
categories: string[] = Object.keys(Category);
|
2019-03-05 12:07:58 +01:00
|
|
|
event: IEvent = new EventModel();
|
2019-01-21 15:08:22 +01:00
|
|
|
|
|
|
|
createEvent(e: Event) {
|
|
|
|
e.preventDefault();
|
2019-03-05 12:07:58 +01:00
|
|
|
this.event.organizerActor = this.loggedPerson;
|
|
|
|
this.event.attributedTo = this.loggedPerson;
|
2019-01-21 15:08:22 +01:00
|
|
|
|
2019-03-05 12:07:58 +01:00
|
|
|
if (this.event.uuid === "") {
|
2019-01-21 15:08:22 +01:00
|
|
|
this.$apollo
|
|
|
|
.mutate({
|
|
|
|
mutation: CREATE_EVENT,
|
|
|
|
variables: {
|
|
|
|
title: this.event.title,
|
|
|
|
description: this.event.description,
|
|
|
|
beginsOn: this.event.begins_on,
|
2019-02-22 16:54:01 +01:00
|
|
|
category: this.event.category,
|
2019-01-21 15:08:22 +01:00
|
|
|
organizerActorId: this.event.organizerActor.id
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.then(data => {
|
|
|
|
console.log("event created", data);
|
|
|
|
this.$router.push({
|
|
|
|
name: "Event",
|
|
|
|
params: { uuid: data.data.createEvent.uuid }
|
|
|
|
});
|
|
|
|
})
|
|
|
|
.catch(error => {
|
2019-03-05 12:07:58 +01:00
|
|
|
console.error(error);
|
2019-01-21 15:08:22 +01:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
this.$apollo
|
|
|
|
.mutate({
|
|
|
|
mutation: EDIT_EVENT
|
|
|
|
})
|
|
|
|
.then(data => {
|
|
|
|
this.$router.push({
|
|
|
|
name: "Event",
|
|
|
|
params: { uuid: data.data.uuid }
|
|
|
|
});
|
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
console.log(error);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// getAddressData(addressData) {
|
|
|
|
// if (addressData !== null) {
|
|
|
|
// this.event.address = {
|
|
|
|
// geom: {
|
|
|
|
// data: {
|
|
|
|
// latitude: addressData.latitude,
|
|
|
|
// longitude: addressData.longitude
|
|
|
|
// },
|
|
|
|
// type: "point"
|
|
|
|
// },
|
|
|
|
// addressCountry: addressData.country,
|
|
|
|
// addressLocality: addressData.locality,
|
|
|
|
// addressRegion: addressData.administrative_area_level_1,
|
|
|
|
// postalCode: addressData.postal_code,
|
|
|
|
// streetAddress: `${addressData.street_number} ${addressData.route}`
|
|
|
|
// };
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.markdown-render h1 {
|
|
|
|
font-size: 2em;
|
|
|
|
}
|
|
|
|
</style>
|