2019-09-20 16:22:03 +00:00
|
|
|
import {EventJoinOptions} from "@/types/event.model";
|
2019-01-21 14:08:22 +00:00
|
|
|
<template>
|
2019-05-22 12:12:11 +00:00
|
|
|
<section class="container">
|
2019-09-12 09:34:01 +00:00
|
|
|
<h1 class="title" v-if="isUpdate === false">
|
|
|
|
{{ $t('Create a new event') }}
|
|
|
|
</h1>
|
|
|
|
<h1 class="title" v-else>
|
|
|
|
{{ $t('Update event {name}', { name: event.title }) }}
|
2019-01-21 14:08:22 +00:00
|
|
|
</h1>
|
2019-09-02 12:35:50 +00:00
|
|
|
|
2019-09-12 09:34:01 +00:00
|
|
|
<div v-if="$apollo.loading">{{ $t('Loading…') }}</div>
|
2019-09-02 12:35:50 +00:00
|
|
|
|
2019-05-28 16:55:02 +00:00
|
|
|
<div class="columns is-centered" v-else>
|
2019-09-02 12:35:50 +00:00
|
|
|
<form class="column is-two-thirds-desktop" @submit="createOrUpdate">
|
2019-07-30 14:40:59 +00:00
|
|
|
<h2 class="subtitle">
|
2019-09-12 09:34:01 +00:00
|
|
|
{{ $t('General information') }}
|
2019-07-30 14:40:59 +00:00
|
|
|
</h2>
|
2019-07-26 09:30:28 +00:00
|
|
|
<picture-upload v-model="pictureFile" />
|
|
|
|
|
2019-09-23 09:51:59 +00:00
|
|
|
<b-field :label="$t('Title')" :type="checkTitleLength[0]" :message="checkTitleLength[1]">
|
|
|
|
<b-input aria-required="true" required v-model="event.title" />
|
2019-01-21 14:08:22 +00:00
|
|
|
</b-field>
|
|
|
|
|
2019-07-26 09:30:28 +00:00
|
|
|
<tag-input v-model="event.tags" :data="tags" path="title" />
|
|
|
|
|
2019-09-12 09:34:01 +00:00
|
|
|
<date-time-picker v-model="event.beginsOn" :label="$t('Starts on…')" :step="15"/>
|
|
|
|
<date-time-picker v-model="event.endsOn" :label="$t('Ends on…')" :step="15" />
|
2019-01-21 14:08:22 +00:00
|
|
|
|
2019-09-11 07:59:01 +00:00
|
|
|
<address-auto-complete v-model="event.physicalAddress" />
|
|
|
|
|
2019-09-12 09:34:01 +00:00
|
|
|
<b-field :label="$t('Organizer')">
|
2019-09-11 07:59:01 +00:00
|
|
|
<identity-picker v-model="event.organizerActor"></identity-picker>
|
|
|
|
</b-field>
|
|
|
|
|
2019-05-28 16:55:02 +00:00
|
|
|
<div class="field">
|
2019-09-12 09:34:01 +00:00
|
|
|
<label class="label">{{ $t('Description') }}</label>
|
2019-05-28 16:55:02 +00:00
|
|
|
<editor v-model="event.description" />
|
|
|
|
</div>
|
|
|
|
|
2019-09-12 09:34:01 +00:00
|
|
|
<b-field :label="$t('Website / URL')">
|
2019-08-28 09:28:27 +00:00
|
|
|
<b-input v-model="event.onlineAddress" placeholder="URL" />
|
|
|
|
</b-field>
|
|
|
|
|
2019-09-12 09:34:01 +00:00
|
|
|
<!--<b-field :label="$t('Category')">
|
2019-01-21 14:08:22 +00:00
|
|
|
<b-select placeholder="Select a category" v-model="event.category">
|
|
|
|
<option
|
|
|
|
v-for="category in categories"
|
|
|
|
:value="category"
|
2019-02-22 15:54:01 +00:00
|
|
|
:key="category"
|
2019-09-12 09:34:01 +00:00
|
|
|
>{{ $t(category) }}</option>
|
2019-01-21 14:08:22 +00:00
|
|
|
</b-select>
|
2019-08-07 14:51:48 +00:00
|
|
|
</b-field>-->
|
2019-01-21 14:08:22 +00:00
|
|
|
|
2019-07-30 14:40:59 +00:00
|
|
|
<h2 class="subtitle">
|
2019-09-12 09:34:01 +00:00
|
|
|
{{ $t('Who can view this event and participate') }}
|
2019-07-30 14:40:59 +00:00
|
|
|
</h2>
|
|
|
|
<div class="field">
|
2019-09-20 17:43:29 +00:00
|
|
|
<b-radio v-model="event.visibility"
|
|
|
|
name="eventVisibility"
|
|
|
|
:native-value="EventVisibility.PUBLIC">
|
2019-09-12 09:34:01 +00:00
|
|
|
{{ $t('Visible everywhere on the web (public)') }}
|
2019-07-30 14:40:59 +00:00
|
|
|
</b-radio>
|
|
|
|
</div>
|
|
|
|
<div class="field">
|
2019-09-20 17:43:29 +00:00
|
|
|
<b-radio v-model="event.visibility"
|
|
|
|
name="eventVisibility"
|
|
|
|
:native-value="EventVisibility.UNLISTED">
|
2019-09-12 09:34:01 +00:00
|
|
|
{{ $t('Only accessible through link and search (private)') }}
|
2019-07-30 14:40:59 +00:00
|
|
|
</b-radio>
|
|
|
|
</div>
|
2019-08-28 09:28:27 +00:00
|
|
|
<div class="field">
|
2019-09-20 17:43:29 +00:00
|
|
|
<b-radio v-model="event.visibility"
|
|
|
|
name="eventVisibility"
|
|
|
|
:native-value="EventVisibility.PRIVATE">
|
2019-09-12 09:34:01 +00:00
|
|
|
{{ $t('Page limited to my group (asks for auth)') }}
|
2019-08-28 09:28:27 +00:00
|
|
|
</b-radio>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="field">
|
2019-09-12 09:34:01 +00:00
|
|
|
<label class="label">{{ $t('Participation approval') }}</label>
|
2019-08-28 09:28:27 +00:00
|
|
|
<b-switch v-model="needsApproval">
|
2019-09-12 09:34:01 +00:00
|
|
|
{{ $t('I want to approve every participation request') }}
|
2019-08-28 09:28:27 +00:00
|
|
|
</b-switch>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="field">
|
|
|
|
<b-switch v-model="limitedPlaces">
|
2019-09-12 09:34:01 +00:00
|
|
|
{{ $t('Limited places') }}
|
2019-08-28 09:28:27 +00:00
|
|
|
</b-switch>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="box" v-if="limitedPlaces">
|
2019-09-12 09:34:01 +00:00
|
|
|
<b-field :label="$t('Number of places')">
|
2019-08-28 09:28:27 +00:00
|
|
|
<b-numberinput v-model="event.options.maximumAttendeeCapacity"></b-numberinput>
|
|
|
|
</b-field>
|
|
|
|
|
|
|
|
<b-field>
|
|
|
|
<b-switch v-model="event.options.showRemainingAttendeeCapacity">
|
2019-09-12 09:34:01 +00:00
|
|
|
{{ $t('Show remaining number of places') }}
|
2019-08-28 09:28:27 +00:00
|
|
|
</b-switch>
|
|
|
|
</b-field>
|
|
|
|
|
|
|
|
<b-field>
|
|
|
|
<b-switch v-model="event.options.showParticipationPrice">
|
2019-09-12 09:34:01 +00:00
|
|
|
{{ $t('Display participation price') }}
|
2019-08-28 09:28:27 +00:00
|
|
|
</b-switch>
|
|
|
|
</b-field>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<h2 class="subtitle">
|
2019-09-12 09:34:01 +00:00
|
|
|
{{ $t('Public comment moderation') }}
|
2019-08-28 09:28:27 +00:00
|
|
|
</h2>
|
|
|
|
|
2019-09-12 09:34:01 +00:00
|
|
|
<label>{{ $t('Comments on the event page') }}</label>
|
2019-07-30 14:40:59 +00:00
|
|
|
|
2019-08-28 09:28:27 +00:00
|
|
|
<div class="field">
|
|
|
|
<b-radio v-model="event.options.commentModeration"
|
|
|
|
name="commentModeration"
|
|
|
|
:native-value="CommentModeration.ALLOW_ALL">
|
2019-09-12 09:34:01 +00:00
|
|
|
{{ $t('Allow all comments') }}
|
2019-08-28 09:28:27 +00:00
|
|
|
</b-radio>
|
|
|
|
</div>
|
2019-09-02 12:35:50 +00:00
|
|
|
|
2019-08-28 09:28:27 +00:00
|
|
|
<div class="field">
|
|
|
|
<b-radio v-model="event.options.commentModeration"
|
|
|
|
name="commentModeration"
|
|
|
|
:native-value="CommentModeration.MODERATED">
|
2019-09-12 09:34:01 +00:00
|
|
|
{{ $t('Moderated comments (shown after approval)') }}
|
2019-08-28 09:28:27 +00:00
|
|
|
</b-radio>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="field">
|
|
|
|
<b-radio v-model="event.options.commentModeration"
|
|
|
|
name="commentModeration"
|
|
|
|
:native-value="CommentModeration.CLOSED">
|
2019-09-12 09:34:01 +00:00
|
|
|
{{ $t('Close comments for all (except for admins)') }}
|
2019-08-28 09:28:27 +00:00
|
|
|
</b-radio>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<h2 class="subtitle">
|
2019-09-12 09:34:01 +00:00
|
|
|
{{ $t('Status') }}
|
2019-08-28 09:28:27 +00:00
|
|
|
</h2>
|
|
|
|
|
|
|
|
<div class="field">
|
|
|
|
<b-radio v-model="event.status"
|
|
|
|
name="status"
|
|
|
|
:native-value="EventStatus.TENTATIVE">
|
2019-09-12 09:34:01 +00:00
|
|
|
{{ $t('Tentative: Will be confirmed later') }}
|
2019-08-28 09:28:27 +00:00
|
|
|
</b-radio>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="field">
|
|
|
|
<b-radio v-model="event.status"
|
|
|
|
name="status"
|
|
|
|
:native-value="EventStatus.CONFIRMED">
|
2019-09-12 09:34:01 +00:00
|
|
|
{{ $t('Confirmed: Will happen') }}
|
2019-08-28 09:28:27 +00:00
|
|
|
</b-radio>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<button class="button is-primary">
|
2019-09-12 09:34:01 +00:00
|
|
|
<span v-if="isUpdate === false">{{ $t('Create my event') }}</span>
|
|
|
|
<span v-else> {{ $t('Update my event') }}</span>
|
2019-01-21 14:08:22 +00:00
|
|
|
</button>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
|
2019-09-09 09:21:42 +00:00
|
|
|
<style lang="scss">
|
|
|
|
@import "@/variables.scss";
|
|
|
|
|
|
|
|
h2.subtitle {
|
|
|
|
margin: 10px 0;
|
|
|
|
|
|
|
|
span {
|
|
|
|
padding: 5px 7px;
|
|
|
|
display: inline;
|
|
|
|
background: $secondary;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
|
2019-01-21 14:08:22 +00:00
|
|
|
<script lang="ts">
|
2019-09-20 16:22:03 +00:00
|
|
|
import { CREATE_EVENT, EDIT_EVENT, FETCH_EVENT } from '@/graphql/event';
|
2019-09-02 12:35:50 +00:00
|
|
|
import { Component, Prop, Vue, Watch } from 'vue-property-decorator';
|
2019-09-20 16:22:03 +00:00
|
|
|
import {
|
|
|
|
CommentModeration, EventJoinOptions,
|
|
|
|
EventModel,
|
|
|
|
EventStatus,
|
|
|
|
EventVisibility,
|
|
|
|
EventVisibilityJoinOptions,
|
|
|
|
} from '@/types/event.model';
|
2019-09-11 07:59:01 +00:00
|
|
|
import { CURRENT_ACTOR_CLIENT } from '@/graphql/actor';
|
2019-09-20 16:22:03 +00:00
|
|
|
import { Person } from '@/types/actor';
|
2019-05-22 12:12:11 +00:00
|
|
|
import PictureUpload from '@/components/PictureUpload.vue';
|
2019-05-28 16:55:02 +00:00
|
|
|
import Editor from '@/components/Editor.vue';
|
2019-06-07 15:19:30 +00:00
|
|
|
import DateTimePicker from '@/components/Event/DateTimePicker.vue';
|
2019-07-26 09:30:28 +00:00
|
|
|
import TagInput from '@/components/Event/TagInput.vue';
|
|
|
|
import { TAGS } from '@/graphql/tags';
|
|
|
|
import { ITag } from '@/types/tag.model';
|
2019-07-30 08:35:29 +00:00
|
|
|
import AddressAutoComplete from '@/components/Event/AddressAutoComplete.vue';
|
2019-09-02 12:35:50 +00:00
|
|
|
import { buildFileFromIPicture, buildFileVariable } from '@/utils/image';
|
2019-09-11 07:59:01 +00:00
|
|
|
import IdentityPicker from '@/views/Account/IdentityPicker.vue';
|
2019-01-21 14:08:22 +00:00
|
|
|
|
2019-03-05 11:07:58 +00:00
|
|
|
@Component({
|
2019-09-11 07:59:01 +00:00
|
|
|
components: { AddressAutoComplete, TagInput, DateTimePicker, PictureUpload, Editor, IdentityPicker },
|
2019-03-05 11:07:58 +00:00
|
|
|
apollo: {
|
2019-09-11 07:59:01 +00:00
|
|
|
currentActor: {
|
|
|
|
query: CURRENT_ACTOR_CLIENT,
|
2019-03-22 09:57:14 +00:00
|
|
|
},
|
2019-07-26 09:30:28 +00:00
|
|
|
tags: {
|
|
|
|
query: TAGS,
|
|
|
|
},
|
2019-03-22 09:57:14 +00:00
|
|
|
},
|
2019-03-05 11:07:58 +00:00
|
|
|
})
|
2019-09-02 12:35:50 +00:00
|
|
|
export default class EditEvent extends Vue {
|
|
|
|
@Prop({ type: Boolean, default: false }) isUpdate!: boolean;
|
2019-01-21 14:08:22 +00:00
|
|
|
@Prop({ required: false, type: String }) uuid!: string;
|
|
|
|
|
2019-09-02 12:35:50 +00:00
|
|
|
eventId!: string | undefined;
|
|
|
|
|
2019-09-11 07:59:01 +00:00
|
|
|
currentActor = new Person();
|
2019-09-04 16:24:31 +00:00
|
|
|
tags: ITag[] = [];
|
2019-09-02 12:35:50 +00:00
|
|
|
event = new EventModel();
|
2019-07-23 15:14:03 +00:00
|
|
|
pictureFile: File | null = null;
|
2019-09-02 12:35:50 +00:00
|
|
|
|
2019-08-28 09:28:27 +00:00
|
|
|
EventStatus = EventStatus;
|
2019-09-20 17:43:29 +00:00
|
|
|
EventVisibility = EventVisibility;
|
2019-08-28 09:28:27 +00:00
|
|
|
needsApproval: boolean = false;
|
|
|
|
canPromote: boolean = true;
|
|
|
|
limitedPlaces: boolean = false;
|
|
|
|
CommentModeration = CommentModeration;
|
2019-01-21 14:08:22 +00:00
|
|
|
|
2019-09-02 12:35:50 +00:00
|
|
|
// categories: string[] = Object.keys(Category);
|
|
|
|
|
|
|
|
@Watch('$route.params.eventId', { immediate: true })
|
|
|
|
async onEventIdParamChanged (val: string) {
|
2019-09-04 16:24:31 +00:00
|
|
|
if (!this.isUpdate) return;
|
2019-09-02 12:35:50 +00:00
|
|
|
|
|
|
|
this.eventId = val;
|
|
|
|
|
|
|
|
if (this.eventId) {
|
|
|
|
this.event = await this.getEvent();
|
|
|
|
|
|
|
|
this.pictureFile = await buildFileFromIPicture(this.event.picture);
|
2019-09-04 16:24:31 +00:00
|
|
|
this.limitedPlaces = this.event.options.maximumAttendeeCapacity != null;
|
2019-09-02 12:35:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-07 15:19:30 +00:00
|
|
|
created() {
|
|
|
|
const now = new Date();
|
|
|
|
const end = new Date();
|
|
|
|
end.setUTCHours(now.getUTCHours() + 3);
|
2019-09-02 12:35:50 +00:00
|
|
|
|
2019-06-07 15:19:30 +00:00
|
|
|
this.event.beginsOn = now;
|
|
|
|
this.event.endsOn = end;
|
2019-09-11 07:59:01 +00:00
|
|
|
this.event.organizerActor = this.event.organizerActor || this.currentActor;
|
2019-06-07 15:19:30 +00:00
|
|
|
}
|
|
|
|
|
2019-09-02 12:35:50 +00:00
|
|
|
createOrUpdate(e: Event) {
|
2019-01-21 14:08:22 +00:00
|
|
|
e.preventDefault();
|
2019-07-23 15:14:03 +00:00
|
|
|
|
2019-09-02 12:35:50 +00:00
|
|
|
if (this.eventId) return this.updateEvent();
|
|
|
|
|
|
|
|
return this.createEvent();
|
|
|
|
}
|
|
|
|
|
|
|
|
async createEvent() {
|
|
|
|
try {
|
2019-08-28 09:28:27 +00:00
|
|
|
const { data } = await this.$apollo.mutate({
|
2019-09-02 12:35:50 +00:00
|
|
|
mutation: CREATE_EVENT,
|
|
|
|
variables: this.buildVariables(),
|
|
|
|
});
|
|
|
|
|
|
|
|
console.log('Event created', data);
|
|
|
|
|
2019-09-04 16:24:31 +00:00
|
|
|
await this.$router.push({
|
2019-09-02 12:35:50 +00:00
|
|
|
name: 'Event',
|
|
|
|
params: { uuid: data.createEvent.uuid },
|
|
|
|
});
|
|
|
|
} catch (err) {
|
|
|
|
console.error(err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async updateEvent() {
|
|
|
|
try {
|
|
|
|
await this.$apollo.mutate({
|
|
|
|
mutation: EDIT_EVENT,
|
|
|
|
variables: this.buildVariables(),
|
|
|
|
});
|
|
|
|
|
2019-09-04 16:24:31 +00:00
|
|
|
await this.$router.push({
|
2019-09-02 12:35:50 +00:00
|
|
|
name: 'Event',
|
|
|
|
params: { uuid: this.eventId as string },
|
|
|
|
});
|
|
|
|
} catch (err) {
|
|
|
|
console.error(err);
|
2019-01-21 14:08:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-23 15:14:03 +00:00
|
|
|
/**
|
|
|
|
* Build variables for Event GraphQL creation query
|
|
|
|
*/
|
|
|
|
private buildVariables() {
|
2019-09-11 07:59:01 +00:00
|
|
|
let res = this.event.toEditJSON();
|
|
|
|
if (this.event.organizerActor) {
|
|
|
|
res = Object.assign(res, { organizerActorId: this.event.organizerActor.id });
|
|
|
|
}
|
2019-07-30 08:35:29 +00:00
|
|
|
|
2019-09-04 16:24:31 +00:00
|
|
|
delete this.event.options['__typename'];
|
|
|
|
|
2019-07-30 08:35:29 +00:00
|
|
|
if (this.event.physicalAddress) {
|
|
|
|
delete this.event.physicalAddress['__typename'];
|
|
|
|
}
|
2019-07-23 15:14:03 +00:00
|
|
|
|
2019-09-02 12:35:50 +00:00
|
|
|
const pictureObj = buildFileVariable(this.pictureFile, 'picture');
|
2019-07-23 15:14:03 +00:00
|
|
|
|
|
|
|
return Object.assign({}, res, pictureObj);
|
2019-05-22 12:12:11 +00:00
|
|
|
}
|
|
|
|
|
2019-09-02 12:35:50 +00:00
|
|
|
private async getEvent() {
|
|
|
|
const result = await this.$apollo.query({
|
|
|
|
query: FETCH_EVENT,
|
|
|
|
variables: {
|
|
|
|
uuid: this.eventId,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
return new EventModel(result.data.event);
|
|
|
|
}
|
|
|
|
|
2019-09-20 16:22:03 +00:00
|
|
|
@Watch('needsApproval')
|
|
|
|
updateEventJoinOptions(needsApproval) {
|
|
|
|
if (needsApproval === true) {
|
|
|
|
this.event.joinOptions = EventJoinOptions.RESTRICTED;
|
|
|
|
} else {
|
|
|
|
this.event.joinOptions = EventJoinOptions.FREE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-23 09:51:59 +00:00
|
|
|
get checkTitleLength() {
|
|
|
|
return this.event.title.length > 80 ? ['is-info', this.$t('The event title will be ellipsed.')] : [undefined, undefined];
|
|
|
|
}
|
|
|
|
|
2019-01-21 14:08:22 +00:00
|
|
|
// 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}`
|
|
|
|
// };
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
}
|
2019-09-02 12:35:50 +00:00
|
|
|
</script>
|
2019-08-28 09:28:27 +00:00
|
|
|
|