2019-01-21 15:08:22 +01:00
|
|
|
<template>
|
2019-10-01 20:10:53 +02:00
|
|
|
<section>
|
|
|
|
<div class="container">
|
|
|
|
<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 }) }}
|
|
|
|
</h1>
|
|
|
|
|
|
|
|
<div class="columns is-centered">
|
2019-10-02 17:59:07 +02:00
|
|
|
<form class="column is-two-thirds-desktop" ref="form">
|
2019-10-01 20:10:53 +02:00
|
|
|
<h2 class="subtitle">
|
|
|
|
{{ $t('General information') }}
|
|
|
|
</h2>
|
|
|
|
<picture-upload v-model="pictureFile" />
|
|
|
|
|
|
|
|
<b-field :label="$t('Title')" :type="checkTitleLength[0]" :message="checkTitleLength[1]">
|
2019-10-10 11:05:53 +02:00
|
|
|
<b-input size="is-large" aria-required="true" required v-model="event.title" />
|
2019-10-01 20:10:53 +02:00
|
|
|
</b-field>
|
2019-07-26 11:30:28 +02:00
|
|
|
|
2019-10-01 20:10:53 +02:00
|
|
|
<tag-input v-model="event.tags" :data="tags" path="title" />
|
2019-01-21 15:08:22 +01:00
|
|
|
|
2019-10-01 20:10:53 +02: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-09-11 09:59:01 +02:00
|
|
|
|
2019-10-01 20:10:53 +02:00
|
|
|
<address-auto-complete v-model="event.physicalAddress" />
|
2019-09-11 09:59:01 +02:00
|
|
|
|
2019-10-01 20:10:53 +02:00
|
|
|
<b-field :label="$t('Organizer')">
|
|
|
|
<identity-picker-wrapper v-model="event.organizerActor"></identity-picker-wrapper>
|
|
|
|
</b-field>
|
2019-05-28 18:55:02 +02:00
|
|
|
|
2019-07-30 16:40:59 +02:00
|
|
|
<div class="field">
|
2019-10-01 20:10:53 +02:00
|
|
|
<label class="label">{{ $t('Description') }}</label>
|
|
|
|
<editor v-model="event.description" />
|
2019-07-30 16:40:59 +02:00
|
|
|
</div>
|
2019-10-01 20:10:53 +02:00
|
|
|
|
|
|
|
<b-field :label="$t('Website / URL')">
|
|
|
|
<b-input v-model="event.onlineAddress" placeholder="URL" />
|
|
|
|
</b-field>
|
|
|
|
|
|
|
|
<!--<b-field :label="$t('Category')">
|
|
|
|
<b-select placeholder="Select a category" v-model="event.category">
|
|
|
|
<option
|
|
|
|
v-for="category in categories"
|
|
|
|
:value="category"
|
|
|
|
:key="category"
|
|
|
|
>{{ $t(category) }}</option>
|
|
|
|
</b-select>
|
|
|
|
</b-field>-->
|
|
|
|
|
|
|
|
<h2 class="subtitle">
|
|
|
|
{{ $t('Who can view this event and participate') }}
|
|
|
|
</h2>
|
|
|
|
<div class="field">
|
|
|
|
<b-radio v-model="event.visibility"
|
|
|
|
name="eventVisibility"
|
|
|
|
:native-value="EventVisibility.PUBLIC">
|
|
|
|
{{ $t('Visible everywhere on the web (public)') }}
|
|
|
|
</b-radio>
|
|
|
|
</div>
|
|
|
|
<div class="field">
|
|
|
|
<b-radio v-model="event.visibility"
|
|
|
|
name="eventVisibility"
|
|
|
|
:native-value="EventVisibility.UNLISTED">
|
|
|
|
{{ $t('Only accessible through link and search (private)') }}
|
|
|
|
</b-radio>
|
|
|
|
</div>
|
2019-10-09 12:54:09 +02:00
|
|
|
<!-- <div class="field">
|
2019-09-20 19:43:29 +02:00
|
|
|
<b-radio v-model="event.visibility"
|
|
|
|
name="eventVisibility"
|
2019-10-01 20:10:53 +02:00
|
|
|
:native-value="EventVisibility.PRIVATE">
|
|
|
|
{{ $t('Page limited to my group (asks for auth)') }}
|
2019-07-30 16:40:59 +02:00
|
|
|
</b-radio>
|
2019-10-09 12:54:09 +02:00
|
|
|
</div> -->
|
2019-08-28 11:28:27 +02:00
|
|
|
|
2019-10-01 20:10:53 +02:00
|
|
|
<div class="field">
|
|
|
|
<label class="label">{{ $t('Participation approval') }}</label>
|
|
|
|
<b-switch v-model="needsApproval">
|
|
|
|
{{ $t('I want to approve every participation request') }}
|
2019-08-28 11:28:27 +02:00
|
|
|
</b-switch>
|
2019-10-01 20:10:53 +02:00
|
|
|
</div>
|
2019-08-28 11:28:27 +02:00
|
|
|
|
2019-10-01 20:10:53 +02:00
|
|
|
<div class="field">
|
2019-10-09 12:54:09 +02:00
|
|
|
<label class="label">{{ $t('Number of places') }}</label>
|
2019-10-01 20:10:53 +02:00
|
|
|
<b-switch v-model="limitedPlaces">
|
2019-10-09 12:54:09 +02:00
|
|
|
{{ $t('Limited number of places') }}
|
2019-08-28 11:28:27 +02:00
|
|
|
</b-switch>
|
2019-10-01 20:10:53 +02:00
|
|
|
</div>
|
2019-08-28 11:28:27 +02:00
|
|
|
|
2019-10-01 20:10:53 +02:00
|
|
|
<div class="box" v-if="limitedPlaces">
|
|
|
|
<b-field :label="$t('Number of places')">
|
2019-10-09 12:54:09 +02:00
|
|
|
<b-numberinput controls-position="compact" min="0" v-model="event.options.maximumAttendeeCapacity"></b-numberinput>
|
2019-10-01 20:10:53 +02:00
|
|
|
</b-field>
|
2019-10-09 12:54:09 +02:00
|
|
|
<!--
|
2019-10-01 20:10:53 +02:00
|
|
|
<b-field>
|
|
|
|
<b-switch v-model="event.options.showRemainingAttendeeCapacity">
|
|
|
|
{{ $t('Show remaining number of places') }}
|
|
|
|
</b-switch>
|
|
|
|
</b-field>
|
|
|
|
|
|
|
|
<b-field>
|
|
|
|
<b-switch v-model="event.options.showParticipationPrice">
|
|
|
|
{{ $t('Display participation price') }}
|
|
|
|
</b-switch>
|
2019-10-09 12:54:09 +02:00
|
|
|
</b-field> -->
|
2019-10-01 20:10:53 +02:00
|
|
|
</div>
|
2019-08-28 11:28:27 +02:00
|
|
|
|
2019-10-09 12:54:09 +02:00
|
|
|
<!-- <h2 class="subtitle">
|
2019-10-01 20:10:53 +02:00
|
|
|
{{ $t('Public comment moderation') }}
|
|
|
|
</h2>
|
2019-07-30 16:40:59 +02:00
|
|
|
|
2019-10-01 20:10:53 +02:00
|
|
|
<label>{{ $t('Comments on the event page') }}</label>
|
2019-09-02 14:35:50 +02:00
|
|
|
|
2019-10-01 20:10:53 +02:00
|
|
|
<div class="field">
|
|
|
|
<b-radio v-model="event.options.commentModeration"
|
|
|
|
name="commentModeration"
|
|
|
|
:native-value="CommentModeration.ALLOW_ALL">
|
|
|
|
{{ $t('Allow all comments') }}
|
|
|
|
</b-radio>
|
|
|
|
</div>
|
2019-08-28 11:28:27 +02:00
|
|
|
|
2019-10-01 20:10:53 +02:00
|
|
|
<div class="field">
|
|
|
|
<b-radio v-model="event.options.commentModeration"
|
|
|
|
name="commentModeration"
|
|
|
|
:native-value="CommentModeration.MODERATED">
|
|
|
|
{{ $t('Moderated comments (shown after approval)') }}
|
|
|
|
</b-radio>
|
|
|
|
</div>
|
2019-08-28 11:28:27 +02:00
|
|
|
|
2019-10-01 20:10:53 +02:00
|
|
|
<div class="field">
|
|
|
|
<b-radio v-model="event.options.commentModeration"
|
|
|
|
name="commentModeration"
|
|
|
|
:native-value="CommentModeration.CLOSED">
|
|
|
|
{{ $t('Close comments for all (except for admins)') }}
|
|
|
|
</b-radio>
|
2019-10-09 12:54:09 +02:00
|
|
|
</div> -->
|
2019-08-28 11:28:27 +02:00
|
|
|
|
2019-10-01 20:10:53 +02:00
|
|
|
<h2 class="subtitle">
|
|
|
|
{{ $t('Status') }}
|
|
|
|
</h2>
|
2019-08-28 11:28:27 +02:00
|
|
|
|
2019-10-01 20:10:53 +02:00
|
|
|
<div class="field">
|
|
|
|
<b-radio v-model="event.status"
|
|
|
|
name="status"
|
|
|
|
:native-value="EventStatus.TENTATIVE">
|
|
|
|
{{ $t('Tentative: Will be confirmed later') }}
|
|
|
|
</b-radio>
|
|
|
|
</div>
|
2019-08-28 11:28:27 +02:00
|
|
|
|
2019-10-01 20:10:53 +02:00
|
|
|
<div class="field">
|
|
|
|
<b-radio v-model="event.status"
|
|
|
|
name="status"
|
|
|
|
:native-value="EventStatus.CONFIRMED">
|
|
|
|
{{ $t('Confirmed: Will happen') }}
|
|
|
|
</b-radio>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
2019-01-21 15:08:22 +01:00
|
|
|
</div>
|
2019-10-01 20:10:53 +02:00
|
|
|
<span ref="bottomObserver"></span>
|
|
|
|
<nav role="navigation" aria-label="main navigation" class="navbar" :class="{'is-fixed-bottom': showFixedNavbar }">
|
|
|
|
<div class="container">
|
|
|
|
<div class="navbar-menu">
|
|
|
|
<div class="navbar-start">
|
2019-10-03 11:37:34 +02:00
|
|
|
<span class="navbar-item" v-if="isEventModified">{{ $t('Unsaved changes') }}</span>
|
2019-10-01 20:10:53 +02:00
|
|
|
</div>
|
|
|
|
<div class="navbar-end">
|
|
|
|
<span class="navbar-item">
|
|
|
|
<b-button type="is-text" @click="confirmGoBack">
|
|
|
|
{{ $t('Cancel') }}
|
|
|
|
</b-button>
|
|
|
|
</span>
|
2019-10-02 17:59:07 +02:00
|
|
|
<!-- If an event has been published we can't make it draft anymore -->
|
|
|
|
<span class="navbar-item" v-if="event.draft === true">
|
|
|
|
<b-button type="is-primary" outlined @click="createOrUpdateDraft">
|
2019-10-01 20:10:53 +02:00
|
|
|
{{ $t('Save draft') }}
|
|
|
|
</b-button>
|
|
|
|
</span>
|
|
|
|
<span class="navbar-item">
|
2019-10-02 17:59:07 +02:00
|
|
|
<b-button type="is-primary" @click="createOrUpdatePublish" @keyup.enter="createOrUpdatePublish">
|
2019-10-01 20:10:53 +02:00
|
|
|
<span v-if="isUpdate === false">{{ $t('Create my event') }}</span>
|
2019-10-02 17:59:07 +02:00
|
|
|
<span v-else-if="event.draft === true"> {{ $t('Publish') }}</span>
|
2019-10-01 20:10:53 +02:00
|
|
|
<span v-else> {{ $t('Update my event') }}</span>
|
|
|
|
</b-button>
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</nav>
|
2019-01-21 15:08:22 +01:00
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
|
2019-10-01 20:10:53 +02:00
|
|
|
<style lang="scss" scoped>
|
2019-09-09 11:21:42 +02:00
|
|
|
@import "@/variables.scss";
|
|
|
|
|
|
|
|
h2.subtitle {
|
|
|
|
margin: 10px 0;
|
|
|
|
|
|
|
|
span {
|
|
|
|
padding: 5px 7px;
|
|
|
|
display: inline;
|
|
|
|
background: $secondary;
|
|
|
|
}
|
|
|
|
}
|
2019-10-01 20:10:53 +02:00
|
|
|
|
|
|
|
section {
|
|
|
|
& > .container {
|
|
|
|
margin-bottom: 2rem;
|
|
|
|
padding: 1rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
nav.navbar {
|
|
|
|
min-height: 2rem !important;
|
|
|
|
background: lighten($secondary, 10%);
|
|
|
|
|
|
|
|
.container {
|
|
|
|
min-height: 2rem;
|
|
|
|
|
|
|
|
.navbar-menu, .navbar-end {
|
|
|
|
display: flex !important;
|
|
|
|
background: lighten($secondary, 10%);
|
|
|
|
}
|
|
|
|
|
|
|
|
.navbar-end {
|
|
|
|
justify-content: flex-end;
|
|
|
|
margin-left: auto;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-09-09 11:21:42 +02:00
|
|
|
</style>
|
|
|
|
|
2019-01-21 15:08:22 +01:00
|
|
|
<script lang="ts">
|
2019-10-04 18:28:25 +02:00
|
|
|
import { CREATE_EVENT, EDIT_EVENT, EVENT_PERSON_PARTICIPATION, FETCH_EVENT } from '@/graphql/event';
|
2019-09-02 14:35:50 +02:00
|
|
|
import { Component, Prop, Vue, Watch } from 'vue-property-decorator';
|
2019-09-20 18:22:03 +02:00
|
|
|
import {
|
2019-10-03 16:54:56 +02:00
|
|
|
CommentModeration,
|
|
|
|
EventJoinOptions,
|
|
|
|
EventModel,
|
|
|
|
EventStatus,
|
|
|
|
EventVisibility,
|
|
|
|
IEvent, ParticipantRole,
|
|
|
|
} from '@/types/event.model';
|
|
|
|
import { CURRENT_ACTOR_CLIENT, IDENTITIES, LOGGED_USER_DRAFTS, LOGGED_USER_PARTICIPATIONS } from '@/graphql/actor';
|
2019-10-04 18:28:25 +02:00
|
|
|
import { IPerson, Person } from '@/types/actor';
|
2019-05-22 14:12:11 +02:00
|
|
|
import PictureUpload from '@/components/PictureUpload.vue';
|
2019-10-10 10:25:33 +02:00
|
|
|
import EditorComponent from '@/components/Editor.vue';
|
2019-06-07 17:19:30 +02:00
|
|
|
import DateTimePicker from '@/components/Event/DateTimePicker.vue';
|
2019-07-26 11:30:28 +02:00
|
|
|
import TagInput from '@/components/Event/TagInput.vue';
|
|
|
|
import { TAGS } from '@/graphql/tags';
|
|
|
|
import { ITag } from '@/types/tag.model';
|
2019-07-30 10:35:29 +02:00
|
|
|
import AddressAutoComplete from '@/components/Event/AddressAutoComplete.vue';
|
2019-09-02 14:35:50 +02:00
|
|
|
import { buildFileFromIPicture, buildFileVariable } from '@/utils/image';
|
2019-09-26 16:38:58 +02:00
|
|
|
import IdentityPickerWrapper from '@/views/Account/IdentityPickerWrapper.vue';
|
2019-10-09 19:41:17 +02:00
|
|
|
import { RouteName } from '@/router';
|
2019-01-21 15:08:22 +01:00
|
|
|
|
2019-03-05 12:07:58 +01:00
|
|
|
@Component({
|
2019-10-10 10:25:33 +02:00
|
|
|
components: { IdentityPickerWrapper, AddressAutoComplete, TagInput, DateTimePicker, PictureUpload, Editor: EditorComponent },
|
2019-03-05 12:07:58 +01:00
|
|
|
apollo: {
|
2019-09-11 09:59:01 +02:00
|
|
|
currentActor: {
|
|
|
|
query: CURRENT_ACTOR_CLIENT,
|
2019-03-22 10:57:14 +01:00
|
|
|
},
|
2019-07-26 11:30:28 +02:00
|
|
|
tags: {
|
|
|
|
query: TAGS,
|
|
|
|
},
|
2019-03-22 10:57:14 +01:00
|
|
|
},
|
2019-03-05 12:07:58 +01:00
|
|
|
})
|
2019-09-02 14:35:50 +02:00
|
|
|
export default class EditEvent extends Vue {
|
|
|
|
@Prop({ type: Boolean, default: false }) isUpdate!: boolean;
|
2019-01-21 15:08:22 +01:00
|
|
|
@Prop({ required: false, type: String }) uuid!: string;
|
|
|
|
|
2019-09-02 14:35:50 +02:00
|
|
|
eventId!: string | undefined;
|
|
|
|
|
2019-09-11 09:59:01 +02:00
|
|
|
currentActor = new Person();
|
2019-09-04 18:24:31 +02:00
|
|
|
tags: ITag[] = [];
|
2019-10-01 20:10:53 +02:00
|
|
|
event: IEvent = new EventModel();
|
|
|
|
unmodifiedEvent!: IEvent;
|
2019-07-23 17:14:03 +02:00
|
|
|
pictureFile: File | null = null;
|
2019-09-02 14:35:50 +02:00
|
|
|
|
2019-08-28 11:28:27 +02:00
|
|
|
EventStatus = EventStatus;
|
2019-09-20 19:43:29 +02:00
|
|
|
EventVisibility = EventVisibility;
|
2019-08-28 11:28:27 +02:00
|
|
|
needsApproval: boolean = false;
|
|
|
|
canPromote: boolean = true;
|
|
|
|
limitedPlaces: boolean = false;
|
|
|
|
CommentModeration = CommentModeration;
|
2019-10-01 20:10:53 +02:00
|
|
|
showFixedNavbar: boolean = true;
|
|
|
|
observer!: IntersectionObserver;
|
2019-01-21 15:08:22 +01:00
|
|
|
|
2019-09-02 14:35:50 +02:00
|
|
|
// categories: string[] = Object.keys(Category);
|
|
|
|
|
|
|
|
@Watch('$route.params.eventId', { immediate: true })
|
|
|
|
async onEventIdParamChanged (val: string) {
|
2019-09-04 18:24:31 +02:00
|
|
|
if (!this.isUpdate) return;
|
2019-09-02 14:35:50 +02:00
|
|
|
|
|
|
|
this.eventId = val;
|
|
|
|
|
|
|
|
if (this.eventId) {
|
|
|
|
this.event = await this.getEvent();
|
2019-10-03 11:37:34 +02:00
|
|
|
this.unmodifiedEvent = JSON.parse(JSON.stringify(this.event.toEditJSON()));
|
2019-09-02 14:35:50 +02:00
|
|
|
|
|
|
|
this.pictureFile = await buildFileFromIPicture(this.event.picture);
|
2019-09-04 18:24:31 +02:00
|
|
|
this.limitedPlaces = this.event.options.maximumAttendeeCapacity != null;
|
2019-09-02 14:35:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-07 17:19:30 +02:00
|
|
|
created() {
|
2019-10-03 11:37:34 +02:00
|
|
|
this.initializeEvent();
|
|
|
|
this.unmodifiedEvent = JSON.parse(JSON.stringify(this.event.toEditJSON()));
|
|
|
|
}
|
|
|
|
|
|
|
|
private initializeEvent() {
|
|
|
|
const roundUpTo = roundTo => x => new Date(Math.ceil(x / roundTo) * roundTo);
|
|
|
|
const roundUpTo15Minutes = roundUpTo(1000 * 60 * 15);
|
|
|
|
|
|
|
|
const now = roundUpTo15Minutes(new Date());
|
|
|
|
const end = roundUpTo15Minutes(new Date());
|
2019-06-07 17:19:30 +02:00
|
|
|
end.setUTCHours(now.getUTCHours() + 3);
|
2019-09-02 14:35:50 +02:00
|
|
|
|
2019-06-07 17:19:30 +02:00
|
|
|
this.event.beginsOn = now;
|
|
|
|
this.event.endsOn = end;
|
2019-09-11 09:59:01 +02:00
|
|
|
this.event.organizerActor = this.event.organizerActor || this.currentActor;
|
2019-06-07 17:19:30 +02:00
|
|
|
}
|
|
|
|
|
2019-10-01 20:10:53 +02:00
|
|
|
mounted() {
|
2019-10-03 11:37:34 +02:00
|
|
|
this.observer = new IntersectionObserver((entries) => {
|
2019-10-01 20:10:53 +02:00
|
|
|
for (const entry of entries) {
|
|
|
|
if (entry) {
|
|
|
|
this.showFixedNavbar = !entry.isIntersecting;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
rootMargin: '-50px 0px -50px',
|
|
|
|
});
|
|
|
|
this.observer.observe(this.$refs.bottomObserver as Element);
|
|
|
|
}
|
|
|
|
|
2019-10-02 17:59:07 +02:00
|
|
|
createOrUpdateDraft(e: Event) {
|
2019-01-21 15:08:22 +01:00
|
|
|
e.preventDefault();
|
2019-10-02 17:59:07 +02:00
|
|
|
if (this.validateForm()) {
|
|
|
|
if (this.eventId) return this.updateEvent();
|
2019-07-23 17:14:03 +02:00
|
|
|
|
2019-10-02 17:59:07 +02:00
|
|
|
return this.createEvent();
|
|
|
|
}
|
|
|
|
}
|
2019-09-02 14:35:50 +02:00
|
|
|
|
2019-10-02 17:59:07 +02:00
|
|
|
createOrUpdatePublish(e: Event) {
|
|
|
|
if (this.validateForm()) {
|
|
|
|
this.event.draft = false;
|
|
|
|
this.createOrUpdateDraft(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private validateForm() {
|
|
|
|
const form = this.$refs.form as HTMLFormElement;
|
|
|
|
if (form.checkValidity()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
form.reportValidity();
|
|
|
|
return false;
|
2019-09-02 14:35:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
async createEvent() {
|
2019-10-09 14:55:45 +02:00
|
|
|
try {
|
|
|
|
const { data } = await this.$apollo.mutate({
|
|
|
|
mutation: CREATE_EVENT,
|
|
|
|
variables: this.buildVariables(),
|
|
|
|
update: (store, { data: { createEvent } }) => this.postCreateOrUpdate(store, createEvent),
|
|
|
|
refetchQueries: ({ data: { createEvent } }) => this.postRefetchQueries(createEvent),
|
|
|
|
});
|
|
|
|
|
|
|
|
await this.$router.push({
|
|
|
|
name: 'Event',
|
|
|
|
params: { uuid: data.createEvent.uuid },
|
|
|
|
});
|
|
|
|
} catch (err) {
|
|
|
|
console.error(err);
|
|
|
|
}
|
2019-09-02 14:35:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
async updateEvent() {
|
|
|
|
try {
|
|
|
|
await this.$apollo.mutate({
|
|
|
|
mutation: EDIT_EVENT,
|
|
|
|
variables: this.buildVariables(),
|
2019-10-04 18:28:25 +02:00
|
|
|
update: (store, { data: { updateEvent } }) => this.postCreateOrUpdate(store, updateEvent),
|
|
|
|
refetchQueries: ({ data: { updateEvent } }) => this.postRefetchQueries(updateEvent),
|
2019-09-02 14:35:50 +02:00
|
|
|
});
|
|
|
|
|
2019-09-04 18:24:31 +02:00
|
|
|
await this.$router.push({
|
2019-09-02 14:35:50 +02:00
|
|
|
name: 'Event',
|
|
|
|
params: { uuid: this.eventId as string },
|
|
|
|
});
|
|
|
|
} catch (err) {
|
|
|
|
console.error(err);
|
2019-01-21 15:08:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-04 18:28:25 +02:00
|
|
|
/**
|
|
|
|
* Put in cache the updated or created event.
|
|
|
|
* If the event is not a draft anymore, also put in cache the participation
|
|
|
|
*/
|
|
|
|
private postCreateOrUpdate(store, updateEvent) {
|
|
|
|
const resultEvent: IEvent = Object.assign({}, updateEvent);
|
|
|
|
const organizerActor: IPerson = this.event.organizerActor as Person;
|
|
|
|
resultEvent.organizerActor = organizerActor;
|
|
|
|
resultEvent.relatedEvents = [];
|
|
|
|
|
|
|
|
store.writeQuery({ query: FETCH_EVENT, variables: { uuid: updateEvent.uuid }, data: { event: resultEvent } });
|
|
|
|
if (!updateEvent.draft) {
|
|
|
|
store.writeQuery({
|
|
|
|
query: EVENT_PERSON_PARTICIPATION,
|
|
|
|
variables: { eventId: updateEvent.id, name: organizerActor.preferredUsername },
|
|
|
|
data: {
|
|
|
|
person: {
|
|
|
|
__typename: 'Person',
|
|
|
|
id: organizerActor.id,
|
|
|
|
participations: [{
|
|
|
|
__typename: 'Participant',
|
|
|
|
id: 'unknown',
|
|
|
|
role: ParticipantRole.CREATOR,
|
|
|
|
actor: {
|
|
|
|
__typename: 'Actor',
|
|
|
|
id: organizerActor.id,
|
|
|
|
},
|
|
|
|
event: {
|
|
|
|
__typename: 'Event',
|
|
|
|
id: updateEvent.id,
|
|
|
|
},
|
|
|
|
}],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Refresh drafts or participation cache depending if the event is still draft or not
|
|
|
|
*/
|
|
|
|
private postRefetchQueries(updateEvent) {
|
|
|
|
if (updateEvent.draft) {
|
|
|
|
return [{
|
|
|
|
query: LOGGED_USER_DRAFTS,
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
return [{
|
|
|
|
query: LOGGED_USER_PARTICIPATIONS,
|
|
|
|
variables: {
|
|
|
|
afterDateTime: new Date(),
|
|
|
|
},
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
2019-07-23 17:14:03 +02:00
|
|
|
/**
|
|
|
|
* Build variables for Event GraphQL creation query
|
|
|
|
*/
|
|
|
|
private buildVariables() {
|
2019-09-11 09:59:01 +02:00
|
|
|
let res = this.event.toEditJSON();
|
|
|
|
if (this.event.organizerActor) {
|
|
|
|
res = Object.assign(res, { organizerActorId: this.event.organizerActor.id });
|
|
|
|
}
|
2019-07-30 10:35:29 +02:00
|
|
|
|
2019-09-04 18:24:31 +02:00
|
|
|
delete this.event.options['__typename'];
|
|
|
|
|
2019-07-30 10:35:29 +02:00
|
|
|
if (this.event.physicalAddress) {
|
|
|
|
delete this.event.physicalAddress['__typename'];
|
|
|
|
}
|
2019-07-23 17:14:03 +02:00
|
|
|
|
2019-09-02 14:35:50 +02:00
|
|
|
const pictureObj = buildFileVariable(this.pictureFile, 'picture');
|
2019-07-23 17:14:03 +02:00
|
|
|
|
|
|
|
return Object.assign({}, res, pictureObj);
|
2019-05-22 14:12:11 +02:00
|
|
|
}
|
|
|
|
|
2019-09-02 14:35:50 +02: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 18:22:03 +02:00
|
|
|
@Watch('needsApproval')
|
|
|
|
updateEventJoinOptions(needsApproval) {
|
|
|
|
if (needsApproval === true) {
|
|
|
|
this.event.joinOptions = EventJoinOptions.RESTRICTED;
|
|
|
|
} else {
|
|
|
|
this.event.joinOptions = EventJoinOptions.FREE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-23 11:51:59 +02:00
|
|
|
get checkTitleLength() {
|
|
|
|
return this.event.title.length > 80 ? ['is-info', this.$t('The event title will be ellipsed.')] : [undefined, undefined];
|
|
|
|
}
|
|
|
|
|
2019-10-01 20:10:53 +02:00
|
|
|
/**
|
|
|
|
* Confirm cancel
|
|
|
|
*/
|
2019-10-09 17:18:27 +02:00
|
|
|
confirmGoElsewhere(callback) {
|
2019-10-02 17:59:07 +02:00
|
|
|
if (!this.isEventModified) {
|
2019-10-09 17:18:27 +02:00
|
|
|
return callback();
|
2019-10-02 17:59:07 +02:00
|
|
|
}
|
2019-10-01 20:10:53 +02:00
|
|
|
const title: string = this.isUpdate ?
|
|
|
|
this.$t('Cancel edition') as string :
|
|
|
|
this.$t('Cancel creation') as string;
|
|
|
|
const message: string = this.isUpdate ?
|
2019-10-02 17:59:07 +02:00
|
|
|
this.$t("Are you sure you want to cancel the event edition? You'll lose all modifications.",
|
2019-10-01 20:10:53 +02:00
|
|
|
{ title: this.event.title }) as string :
|
2019-10-02 17:59:07 +02:00
|
|
|
this.$t("Are you sure you want to cancel the event creation? You'll lose all modifications.",
|
2019-10-01 20:10:53 +02:00
|
|
|
{ title: this.event.title }) as string;
|
|
|
|
|
|
|
|
this.$buefy.dialog.confirm({
|
|
|
|
title,
|
|
|
|
message,
|
2019-10-09 19:41:17 +02:00
|
|
|
confirmText: this.$t('Abandon edition') as string,
|
2019-10-01 20:10:53 +02:00
|
|
|
cancelText: this.$t('Continue editing') as string,
|
|
|
|
type: 'is-warning',
|
|
|
|
hasIcon: true,
|
2019-10-09 17:18:27 +02:00
|
|
|
onConfirm: callback,
|
2019-10-01 20:10:53 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-10-09 17:18:27 +02:00
|
|
|
/**
|
|
|
|
* Confirm cancel
|
|
|
|
*/
|
|
|
|
confirmGoBack() {
|
|
|
|
this.confirmGoElsewhere(() => this.$router.go(-1));
|
|
|
|
}
|
|
|
|
|
2019-10-09 17:54:35 +02:00
|
|
|
beforeRouteLeave(to, from, next) {
|
2019-10-09 19:41:17 +02:00
|
|
|
if (to.name === RouteName.EVENT) return next();
|
2019-10-09 17:54:35 +02:00
|
|
|
this.confirmGoElsewhere(() => next());
|
|
|
|
}
|
|
|
|
|
2019-10-01 20:10:53 +02:00
|
|
|
get isEventModified(): boolean {
|
2019-10-03 11:37:34 +02:00
|
|
|
return JSON.stringify(this.event.toEditJSON()) !== JSON.stringify(this.unmodifiedEvent);
|
2019-10-01 20:10:53 +02:00
|
|
|
}
|
|
|
|
|
2019-10-09 12:54:09 +02:00
|
|
|
get beginsOn() { return this.event.beginsOn; }
|
|
|
|
|
|
|
|
@Watch('beginsOn')
|
|
|
|
onBeginsOnChanged(beginsOn) {
|
|
|
|
if (!this.event.endsOn) return;
|
|
|
|
const dateBeginsOn = new Date(beginsOn);
|
|
|
|
const dateEndsOn = new Date(this.event.endsOn);
|
|
|
|
if (dateEndsOn < dateBeginsOn) {
|
|
|
|
this.event.endsOn = dateBeginsOn;
|
|
|
|
this.event.endsOn.setUTCHours(dateEndsOn.getUTCHours());
|
|
|
|
}
|
|
|
|
if (dateEndsOn === dateBeginsOn) {
|
|
|
|
this.event.endsOn.setUTCHours(dateEndsOn.getUTCHours() + 1);
|
|
|
|
}
|
|
|
|
}
|
2019-01-21 15:08:22 +01:00
|
|
|
}
|
2019-09-02 14:35:50 +02:00
|
|
|
</script>
|
2019-08-28 11:28:27 +02:00
|
|
|
|