2019-01-21 15:08:22 +01:00
|
|
|
<template>
|
2019-10-01 20:10:53 +02:00
|
|
|
<section>
|
2020-10-09 18:12:35 +02:00
|
|
|
<div class="container" v-if="isCurrentActorOrganizer">
|
2020-04-23 00:27:09 +02:00
|
|
|
<h1 class="title" v-if="isUpdate === true">
|
|
|
|
{{ $t("Update event {name}", { name: event.title }) }}
|
|
|
|
</h1>
|
|
|
|
<h1 class="title" v-else>
|
|
|
|
{{ $t("Create a new event") }}
|
|
|
|
</h1>
|
2019-10-01 20:10:53 +02:00
|
|
|
|
2019-12-20 13:04:34 +01:00
|
|
|
<form ref="form">
|
2020-02-18 08:57:00 +01:00
|
|
|
<subtitle>{{ $t("General information") }}</subtitle>
|
2020-11-20 18:34:13 +01:00
|
|
|
<picture-upload
|
|
|
|
v-model="pictureFile"
|
|
|
|
:textFallback="$t('Headline picture')"
|
|
|
|
:defaultImage="event.picture"
|
|
|
|
/>
|
2019-12-20 13:04:34 +01:00
|
|
|
|
2020-11-30 10:24:11 +01:00
|
|
|
<b-field
|
|
|
|
:label="$t('Title')"
|
|
|
|
:type="checkTitleLength[0]"
|
|
|
|
:message="checkTitleLength[1]"
|
|
|
|
>
|
|
|
|
<b-input
|
|
|
|
size="is-large"
|
|
|
|
aria-required="true"
|
|
|
|
required
|
|
|
|
v-model="event.title"
|
|
|
|
/>
|
2019-12-20 13:04:34 +01:00
|
|
|
</b-field>
|
2019-07-26 11:30:28 +02:00
|
|
|
|
2019-12-20 13:04:34 +01:00
|
|
|
<tag-input v-model="event.tags" :data="tags" path="title" />
|
2019-01-21 15:08:22 +01:00
|
|
|
|
2020-12-10 12:16:35 +01:00
|
|
|
<b-field horizontal :label="$t('Starts on…')" class="begins-on-field">
|
|
|
|
<b-datetimepicker
|
2021-01-25 15:59:57 +01:00
|
|
|
class="datepicker starts-on"
|
2020-12-10 12:16:35 +01:00
|
|
|
:placeholder="$t('Type or select a date…')"
|
|
|
|
icon="calendar-today"
|
|
|
|
:locale="$i18n.locale"
|
|
|
|
v-model="event.beginsOn"
|
|
|
|
horizontal-time-picker
|
|
|
|
editable
|
|
|
|
>
|
|
|
|
</b-datetimepicker>
|
|
|
|
</b-field>
|
|
|
|
|
|
|
|
<b-field horizontal :label="$t('Ends on…')">
|
|
|
|
<b-datetimepicker
|
2021-01-25 15:59:57 +01:00
|
|
|
class="datepicker ends-on"
|
2020-12-10 12:16:35 +01:00
|
|
|
:placeholder="$t('Type or select a date…')"
|
|
|
|
icon="calendar-today"
|
|
|
|
:locale="$i18n.locale"
|
|
|
|
v-model="event.endsOn"
|
|
|
|
horizontal-time-picker
|
|
|
|
:min-datetime="event.beginsOn"
|
|
|
|
editable
|
|
|
|
>
|
|
|
|
</b-datetimepicker>
|
|
|
|
</b-field>
|
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
<!-- <b-switch v-model="endsOnNull">{{ $t('No end date') }}</b-switch>-->
|
|
|
|
<b-button type="is-text" @click="dateSettingsIsOpen = true">
|
|
|
|
{{ $t("Date parameters") }}
|
|
|
|
</b-button>
|
2019-09-11 09:59:01 +02:00
|
|
|
|
2020-07-31 17:52:26 +02:00
|
|
|
<full-address-auto-complete v-model="event.physicalAddress" />
|
2019-09-11 09:59:01 +02:00
|
|
|
|
2019-12-20 13:04:34 +01:00
|
|
|
<div class="field">
|
2020-02-18 08:57:00 +01:00
|
|
|
<label class="label">{{ $t("Description") }}</label>
|
2019-12-20 13:04:34 +01:00
|
|
|
<editor v-model="event.description" />
|
|
|
|
</div>
|
2019-10-01 20:10:53 +02:00
|
|
|
|
2019-12-20 13:04:34 +01:00
|
|
|
<b-field :label="$t('Website / URL')">
|
2020-11-30 10:24:11 +01:00
|
|
|
<b-input
|
|
|
|
icon="link"
|
|
|
|
type="url"
|
|
|
|
v-model="event.onlineAddress"
|
|
|
|
placeholder="URL"
|
|
|
|
/>
|
2019-12-20 13:04:34 +01:00
|
|
|
</b-field>
|
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
<subtitle>{{ $t("Organizers") }}</subtitle>
|
2020-09-29 09:53:48 +02:00
|
|
|
|
2021-03-29 10:33:19 +02:00
|
|
|
<div v-if="config && config.features.groups && organizerActor.id">
|
2020-09-29 09:53:48 +02:00
|
|
|
<b-field>
|
|
|
|
<organizer-picker-wrapper
|
2021-03-29 10:33:19 +02:00
|
|
|
v-model="organizerActor"
|
2020-09-29 09:53:48 +02:00
|
|
|
:contacts.sync="event.contacts"
|
|
|
|
/>
|
|
|
|
</b-field>
|
2021-03-29 10:33:19 +02:00
|
|
|
<p v-if="!attributedToAGroup && organizerActorEqualToCurrentActor">
|
2020-11-30 10:24:11 +01:00
|
|
|
{{
|
|
|
|
$t("The event will show as attributed to your personal profile.")
|
|
|
|
}}
|
2020-09-29 09:53:48 +02:00
|
|
|
</p>
|
2021-03-29 10:33:19 +02:00
|
|
|
<p v-else-if="!attributedToAGroup">
|
|
|
|
{{ $t("The event will show as attributed to this profile.") }}
|
|
|
|
</p>
|
2020-09-29 09:53:48 +02:00
|
|
|
<p v-else>
|
2020-11-30 10:24:11 +01:00
|
|
|
<span>{{
|
|
|
|
$t("The event will show as attributed to this group.")
|
|
|
|
}}</span>
|
2020-09-29 09:53:48 +02:00
|
|
|
<span
|
|
|
|
v-if="event.contacts && event.contacts.length"
|
|
|
|
v-html="
|
2021-03-29 10:33:19 +02:00
|
|
|
' ' +
|
2020-11-30 10:24:11 +01:00
|
|
|
$tc(
|
|
|
|
'<b>{contact}</b> will be displayed as contact.',
|
|
|
|
event.contacts.length,
|
|
|
|
{
|
|
|
|
contact: formatList(
|
|
|
|
event.contacts.map((contact) =>
|
|
|
|
displayNameAndUsername(contact)
|
|
|
|
)
|
|
|
|
),
|
|
|
|
}
|
|
|
|
)
|
2020-09-29 09:53:48 +02:00
|
|
|
"
|
|
|
|
/>
|
2021-03-29 10:33:19 +02:00
|
|
|
<span v-else>
|
|
|
|
{{ $t("You may show some members as contacts.") }}
|
|
|
|
</span>
|
2020-09-29 09:53:48 +02:00
|
|
|
</p>
|
2020-02-18 08:57:00 +01:00
|
|
|
</div>
|
|
|
|
<subtitle>{{ $t("Who can view this event and participate") }}</subtitle>
|
|
|
|
<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"
|
2020-06-15 19:41:11 +02:00
|
|
|
>{{ $t("Only accessible through link (private)") }}</b-radio
|
2020-02-18 08:57:00 +01:00
|
|
|
>
|
|
|
|
</div>
|
2019-12-20 13:04:34 +01:00
|
|
|
<!-- <div class="field">
|
|
|
|
<b-radio v-model="event.visibility"
|
|
|
|
name="eventVisibility"
|
|
|
|
:native-value="EventVisibility.PRIVATE">
|
|
|
|
{{ $t('Page limited to my group (asks for auth)') }}
|
|
|
|
</b-radio>
|
2020-02-18 08:57:00 +01:00
|
|
|
</div>-->
|
2019-12-20 13:04:34 +01:00
|
|
|
|
2020-11-30 10:24:11 +01:00
|
|
|
<div
|
|
|
|
class="field"
|
|
|
|
v-if="config && config.anonymous.participation.allowed"
|
|
|
|
>
|
2020-02-18 08:57:00 +01:00
|
|
|
<label class="label">{{ $t("Anonymous participations") }}</label>
|
2019-12-20 13:04:34 +01:00
|
|
|
<b-switch v-model="event.options.anonymousParticipation">
|
2020-11-30 10:24:11 +01:00
|
|
|
{{
|
|
|
|
$t("I want to allow people to participate without an account.")
|
|
|
|
}}
|
|
|
|
<small
|
|
|
|
v-if="
|
|
|
|
config.anonymous.participation.validation.email
|
|
|
|
.confirmationRequired
|
|
|
|
"
|
|
|
|
>
|
2020-02-18 08:57:00 +01:00
|
|
|
<br />
|
|
|
|
{{
|
|
|
|
$t(
|
|
|
|
"Anonymous participants will be asked to confirm their participation through e-mail."
|
|
|
|
)
|
|
|
|
}}
|
2019-12-20 13:04:34 +01:00
|
|
|
</small>
|
|
|
|
</b-switch>
|
|
|
|
</div>
|
2019-08-28 11:28:27 +02:00
|
|
|
|
2019-12-20 13:04:34 +01:00
|
|
|
<div class="field">
|
2020-02-18 08:57:00 +01:00
|
|
|
<label class="label">{{ $t("Participation approval") }}</label>
|
|
|
|
<b-switch v-model="needsApproval">{{
|
|
|
|
$t("I want to approve every participation request")
|
|
|
|
}}</b-switch>
|
2019-12-20 13:04:34 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="field">
|
2020-02-18 08:57:00 +01:00
|
|
|
<label class="label">{{ $t("Number of places") }}</label>
|
2020-11-30 10:24:11 +01:00
|
|
|
<b-switch v-model="limitedPlaces">{{
|
|
|
|
$t("Limited number of places")
|
|
|
|
}}</b-switch>
|
2019-12-20 13:04:34 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="box" v-if="limitedPlaces">
|
|
|
|
<b-field :label="$t('Number of places')">
|
2020-02-18 08:57:00 +01:00
|
|
|
<b-numberinput
|
|
|
|
controls-position="compact"
|
|
|
|
min="1"
|
|
|
|
v-model="event.options.maximumAttendeeCapacity"
|
|
|
|
/>
|
2019-12-20 13:04:34 +01:00
|
|
|
</b-field>
|
2020-02-18 08:57:00 +01:00
|
|
|
<!--
|
2019-12-20 13:04:34 +01:00
|
|
|
<b-field>
|
|
|
|
<b-switch v-model="event.options.showRemainingAttendeeCapacity">
|
|
|
|
{{ $t('Show remaining number of places') }}
|
|
|
|
</b-switch>
|
|
|
|
</b-field>
|
2019-10-01 20:10:53 +02:00
|
|
|
|
2019-12-20 13:04:34 +01:00
|
|
|
<b-field>
|
|
|
|
<b-switch v-model="event.options.showParticipationPrice">
|
|
|
|
{{ $t('Display participation price') }}
|
|
|
|
</b-switch>
|
2020-02-18 08:57:00 +01:00
|
|
|
</b-field>-->
|
2019-12-20 13:04:34 +01:00
|
|
|
</div>
|
2019-08-28 11:28:27 +02:00
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
<subtitle>{{ $t("Public comment moderation") }}</subtitle>
|
2019-07-30 16:40:59 +02:00
|
|
|
|
2019-12-20 13:04:34 +01:00
|
|
|
<div class="field">
|
2020-02-18 08:57:00 +01:00
|
|
|
<b-radio
|
|
|
|
v-model="event.options.commentModeration"
|
|
|
|
name="commentModeration"
|
|
|
|
:native-value="CommentModeration.ALLOW_ALL"
|
2020-10-05 16:42:31 +02:00
|
|
|
>{{ $t("Allow all comments from users with accounts") }}</b-radio
|
2020-02-18 08:57:00 +01:00
|
|
|
>
|
2019-12-20 13:04:34 +01:00
|
|
|
</div>
|
2019-08-28 11:28:27 +02:00
|
|
|
|
2020-02-18 08:57:00 +01: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-12-20 13:04:34 +01:00
|
|
|
<div class="field">
|
2020-02-18 08:57:00 +01:00
|
|
|
<b-radio
|
|
|
|
v-model="event.options.commentModeration"
|
|
|
|
name="commentModeration"
|
|
|
|
:native-value="CommentModeration.CLOSED"
|
|
|
|
>{{ $t("Close comments for all (except for admins)") }}</b-radio
|
|
|
|
>
|
2019-12-20 13:04:34 +01:00
|
|
|
</div>
|
2019-08-28 11:28:27 +02:00
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
<subtitle>{{ $t("Status") }}</subtitle>
|
2019-12-20 13:04:34 +01:00
|
|
|
|
2020-10-13 16:57:36 +02:00
|
|
|
<b-field class="event__status__field">
|
2020-02-18 08:57:00 +01:00
|
|
|
<b-radio-button
|
|
|
|
v-model="event.status"
|
|
|
|
name="status"
|
|
|
|
type="is-warning"
|
|
|
|
:native-value="EventStatus.TENTATIVE"
|
|
|
|
>
|
2019-12-20 13:04:34 +01:00
|
|
|
<b-icon icon="calendar-question" />
|
2020-02-18 08:57:00 +01:00
|
|
|
{{ $t("Tentative: Will be confirmed later") }}
|
2019-12-20 13:04:34 +01:00
|
|
|
</b-radio-button>
|
2020-02-18 08:57:00 +01:00
|
|
|
<b-radio-button
|
|
|
|
v-model="event.status"
|
|
|
|
name="status"
|
|
|
|
type="is-success"
|
|
|
|
:native-value="EventStatus.CONFIRMED"
|
|
|
|
>
|
2019-12-20 13:04:34 +01:00
|
|
|
<b-icon icon="calendar-check" />
|
2020-02-18 08:57:00 +01:00
|
|
|
{{ $t("Confirmed: Will happen") }}
|
2019-12-20 13:04:34 +01:00
|
|
|
</b-radio-button>
|
2020-02-18 08:57:00 +01:00
|
|
|
<b-radio-button
|
|
|
|
v-model="event.status"
|
|
|
|
name="status"
|
|
|
|
type="is-danger"
|
|
|
|
:native-value="EventStatus.CANCELLED"
|
|
|
|
>
|
2019-12-20 13:04:34 +01:00
|
|
|
<b-icon icon="calendar-remove" />
|
|
|
|
{{ $t("Cancelled: Won't happen") }}
|
|
|
|
</b-radio-button>
|
|
|
|
</b-field>
|
|
|
|
</form>
|
2019-01-21 15:08:22 +01:00
|
|
|
</div>
|
2020-08-31 12:40:30 +02:00
|
|
|
<b-modal v-model="dateSettingsIsOpen" has-modal-card trap-focus>
|
2020-02-18 08:57:00 +01:00
|
|
|
<form action>
|
2020-08-27 15:41:48 +02:00
|
|
|
<div class="modal-card" style="width: auto">
|
2019-10-14 19:29:18 +02:00
|
|
|
<header class="modal-card-head">
|
2020-02-18 08:57:00 +01:00
|
|
|
<p class="modal-card-title">{{ $t("Date and time settings") }}</p>
|
2019-10-14 19:29:18 +02:00
|
|
|
</header>
|
|
|
|
<section class="modal-card-body">
|
|
|
|
<b-field :label="$t('Event page settings')">
|
2020-02-18 08:57:00 +01:00
|
|
|
<b-switch v-model="event.options.showStartTime">{{
|
|
|
|
$t("Show the time when the event begins")
|
|
|
|
}}</b-switch>
|
2019-10-14 19:29:18 +02:00
|
|
|
</b-field>
|
|
|
|
<b-field>
|
2020-02-18 08:57:00 +01:00
|
|
|
<b-switch v-model="event.options.showEndTime">{{
|
|
|
|
$t("Show the time when the event ends")
|
|
|
|
}}</b-switch>
|
2019-10-14 19:29:18 +02:00
|
|
|
</b-field>
|
|
|
|
</section>
|
|
|
|
<footer class="modal-card-foot">
|
2020-11-30 10:24:11 +01:00
|
|
|
<button
|
|
|
|
class="button"
|
|
|
|
type="button"
|
|
|
|
@click="dateSettingsIsOpen = false"
|
|
|
|
>
|
2020-02-18 08:57:00 +01:00
|
|
|
{{ $t("OK") }}
|
|
|
|
</button>
|
2019-10-14 19:29:18 +02:00
|
|
|
</footer>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</b-modal>
|
2019-12-03 11:29:51 +01:00
|
|
|
<span ref="bottomObserver" />
|
2020-02-18 08:57:00 +01:00
|
|
|
<nav
|
|
|
|
role="navigation"
|
|
|
|
aria-label="main navigation"
|
2020-10-13 16:57:36 +02:00
|
|
|
class="navbar save__navbar"
|
2020-02-18 08:57:00 +01:00
|
|
|
:class="{ 'is-fixed-bottom': showFixedNavbar }"
|
2020-10-09 18:12:35 +02:00
|
|
|
v-if="isCurrentActorOrganizer"
|
2020-02-18 08:57:00 +01:00
|
|
|
>
|
2019-10-01 20:10:53 +02:00
|
|
|
<div class="container">
|
|
|
|
<div class="navbar-menu">
|
|
|
|
<div class="navbar-start">
|
2020-11-30 10:24:11 +01: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">
|
2020-11-30 10:24:11 +01:00
|
|
|
<b-button type="is-text" @click="confirmGoBack">{{
|
|
|
|
$t("Cancel")
|
|
|
|
}}</b-button>
|
2019-10-01 20:10:53 +02:00
|
|
|
</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">
|
2020-10-01 18:25:57 +02:00
|
|
|
<b-button
|
|
|
|
type="is-primary"
|
|
|
|
outlined
|
|
|
|
@click="createOrUpdateDraft"
|
|
|
|
:disabled="saving"
|
|
|
|
>{{ $t("Save draft") }}</b-button
|
|
|
|
>
|
2019-10-01 20:10:53 +02:00
|
|
|
</span>
|
|
|
|
<span class="navbar-item">
|
2020-02-18 08:57:00 +01:00
|
|
|
<b-button
|
|
|
|
type="is-primary"
|
2020-10-01 18:25:57 +02:00
|
|
|
:disabled="saving"
|
2020-02-18 08:57:00 +01:00
|
|
|
@click="createOrUpdatePublish"
|
|
|
|
@keyup.enter="createOrUpdatePublish"
|
|
|
|
>
|
2020-11-30 10:24:11 +01:00
|
|
|
<span v-if="isUpdate === false">{{
|
|
|
|
$t("Create my event")
|
|
|
|
}}</span>
|
|
|
|
<span v-else-if="event.draft === true">{{
|
|
|
|
$t("Publish")
|
|
|
|
}}</span>
|
2020-02-18 08:57:00 +01:00
|
|
|
<span v-else>{{ $t("Update my event") }}</span>
|
2019-10-01 20:10:53 +02:00
|
|
|
</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>
|
2020-02-18 08:57:00 +01:00
|
|
|
main section > .container {
|
|
|
|
background: $white;
|
|
|
|
}
|
2019-12-20 13:04:34 +01:00
|
|
|
|
2020-10-13 16:57:36 +02:00
|
|
|
.save__navbar {
|
2020-11-16 10:04:47 +01:00
|
|
|
::v-deep .navbar-menu,
|
2020-10-13 16:57:36 +02:00
|
|
|
.navbar-end {
|
|
|
|
flex-wrap: wrap;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@media screen and (max-width: 768px) {
|
|
|
|
.navbar.is-fixed-bottom {
|
|
|
|
position: initial;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
h2.subtitle {
|
|
|
|
margin: 10px 0;
|
2019-09-09 11:21:42 +02:00
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
span {
|
|
|
|
padding: 5px 7px;
|
|
|
|
display: inline;
|
|
|
|
background: $secondary;
|
2019-09-09 11:21:42 +02:00
|
|
|
}
|
2020-02-18 08:57:00 +01:00
|
|
|
}
|
2019-10-01 20:10:53 +02:00
|
|
|
|
2020-10-13 16:57:36 +02:00
|
|
|
.event__status__field {
|
2020-11-16 10:04:47 +01:00
|
|
|
::v-deep .field.has-addons {
|
2020-10-13 16:57:36 +02:00
|
|
|
display: flex;
|
|
|
|
flex-wrap: wrap;
|
|
|
|
justify-content: flex-start;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-25 15:59:57 +01:00
|
|
|
.datepicker {
|
|
|
|
::v-deep .dropdown-menu {
|
|
|
|
z-index: 200;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
section {
|
|
|
|
& > .container {
|
|
|
|
padding: 2rem 1.5rem;
|
|
|
|
}
|
2019-10-01 20:10:53 +02:00
|
|
|
|
2020-12-10 12:16:35 +01:00
|
|
|
.begins-on-field {
|
|
|
|
margin-top: 22px;
|
|
|
|
}
|
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
nav.navbar {
|
|
|
|
min-height: 2rem !important;
|
|
|
|
background: lighten($secondary, 10%);
|
2019-10-01 20:10:53 +02:00
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
.container {
|
|
|
|
min-height: 2rem;
|
2019-10-01 20:10:53 +02:00
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
.navbar-menu,
|
|
|
|
.navbar-end {
|
|
|
|
display: flex !important;
|
|
|
|
background: lighten($secondary, 10%);
|
|
|
|
}
|
2019-10-01 20:10:53 +02:00
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
.navbar-end {
|
|
|
|
justify-content: flex-end;
|
|
|
|
margin-left: auto;
|
2019-10-01 20:10:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-02-18 08:57:00 +01:00
|
|
|
}
|
2019-09-09 11:21:42 +02:00
|
|
|
</style>
|
2021-04-19 12:04:52 +02:00
|
|
|
<style lang="scss">
|
|
|
|
.dialog .modal-card {
|
|
|
|
max-width: 500px;
|
|
|
|
|
|
|
|
.modal-card-foot {
|
|
|
|
justify-content: center;
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
|
|
|
& > button {
|
|
|
|
margin-bottom: 5px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|
2019-09-09 11:21:42 +02:00
|
|
|
|
2019-01-21 15:08:22 +01:00
|
|
|
<script lang="ts">
|
2020-02-18 08:57:00 +01:00
|
|
|
import { Component, Prop, Vue, Watch } from "vue-property-decorator";
|
2021-05-12 18:10:07 +02:00
|
|
|
import { RefetchQueryDescription } from "@apollo/client/core/watchQueryOptions";
|
2020-02-18 08:57:00 +01:00
|
|
|
import PictureUpload from "@/components/PictureUpload.vue";
|
|
|
|
import EditorComponent from "@/components/Editor.vue";
|
|
|
|
import TagInput from "@/components/Event/TagInput.vue";
|
2020-07-31 17:52:26 +02:00
|
|
|
import FullAddressAutoComplete from "@/components/Event/FullAddressAutoComplete.vue";
|
2020-02-18 08:57:00 +01:00
|
|
|
import IdentityPickerWrapper from "@/views/Account/IdentityPickerWrapper.vue";
|
|
|
|
import Subtitle from "@/components/Utils/Subtitle.vue";
|
|
|
|
import { Route } from "vue-router";
|
2020-09-29 09:53:48 +02:00
|
|
|
import { formatList } from "@/utils/i18n";
|
2020-11-27 19:27:44 +01:00
|
|
|
import {
|
2021-03-29 10:33:19 +02:00
|
|
|
ActorType,
|
2020-11-27 19:27:44 +01:00
|
|
|
CommentModeration,
|
|
|
|
EventJoinOptions,
|
|
|
|
EventStatus,
|
|
|
|
EventVisibility,
|
|
|
|
ParticipantRole,
|
|
|
|
} from "@/types/enums";
|
2020-09-29 09:53:48 +02:00
|
|
|
import OrganizerPickerWrapper from "../../components/Event/OrganizerPickerWrapper.vue";
|
2020-02-18 08:57:00 +01:00
|
|
|
import {
|
|
|
|
CREATE_EVENT,
|
|
|
|
EDIT_EVENT,
|
|
|
|
EVENT_PERSON_PARTICIPATION,
|
|
|
|
FETCH_EVENT,
|
|
|
|
} from "../../graphql/event";
|
2020-11-27 19:27:44 +01:00
|
|
|
import { EventModel, IEvent } from "../../types/event.model";
|
2019-09-20 18:22:03 +02:00
|
|
|
import {
|
2020-02-18 08:57:00 +01:00
|
|
|
CURRENT_ACTOR_CLIENT,
|
2021-03-29 10:33:19 +02:00
|
|
|
IDENTITIES,
|
2020-02-18 08:57:00 +01:00
|
|
|
LOGGED_USER_DRAFTS,
|
|
|
|
LOGGED_USER_PARTICIPATIONS,
|
|
|
|
} from "../../graphql/actor";
|
2021-03-29 10:33:19 +02:00
|
|
|
import { displayNameAndUsername, IActor, IGroup } from "../../types/actor";
|
2020-02-18 08:57:00 +01:00
|
|
|
import { TAGS } from "../../graphql/tags";
|
|
|
|
import { ITag } from "../../types/tag.model";
|
2020-11-30 10:24:11 +01:00
|
|
|
import {
|
|
|
|
buildFileFromIMedia,
|
|
|
|
buildFileVariable,
|
|
|
|
readFileAsync,
|
|
|
|
} from "../../utils/image";
|
2020-02-18 08:57:00 +01:00
|
|
|
import RouteName from "../../router/name";
|
|
|
|
import "intersection-observer";
|
|
|
|
import { CONFIG } from "../../graphql/config";
|
|
|
|
import { IConfig } from "../../types/config.model";
|
2021-06-11 14:21:27 +02:00
|
|
|
import { ApolloCache, FetchResult } from "@apollo/client/core";
|
2021-06-27 18:17:24 +02:00
|
|
|
import cloneDeep from "lodash/cloneDeep";
|
2019-01-21 15:08:22 +01:00
|
|
|
|
2019-12-15 22:42:38 +01:00
|
|
|
const DEFAULT_LIMIT_NUMBER_OF_PLACES = 10;
|
|
|
|
|
2019-03-05 12:07:58 +01:00
|
|
|
@Component({
|
2020-02-18 08:57:00 +01:00
|
|
|
components: {
|
2020-09-29 09:53:48 +02:00
|
|
|
OrganizerPickerWrapper,
|
2020-02-18 08:57:00 +01:00
|
|
|
Subtitle,
|
|
|
|
IdentityPickerWrapper,
|
2020-07-31 17:52:26 +02:00
|
|
|
FullAddressAutoComplete,
|
2020-02-18 08:57:00 +01:00
|
|
|
TagInput,
|
|
|
|
PictureUpload,
|
|
|
|
Editor: EditorComponent,
|
|
|
|
},
|
2019-03-05 12:07:58 +01:00
|
|
|
apollo: {
|
2019-12-20 13:04:34 +01:00
|
|
|
currentActor: CURRENT_ACTOR_CLIENT,
|
|
|
|
tags: TAGS,
|
|
|
|
config: CONFIG,
|
2021-03-29 10:33:19 +02:00
|
|
|
identities: IDENTITIES,
|
2020-02-18 08:57:00 +01:00
|
|
|
event: {
|
|
|
|
query: FETCH_EVENT,
|
|
|
|
variables() {
|
|
|
|
return {
|
|
|
|
uuid: this.eventId,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
update(data) {
|
2021-05-17 18:20:53 +02:00
|
|
|
return new EventModel(data.event);
|
2020-02-18 08:57:00 +01:00
|
|
|
},
|
|
|
|
skip() {
|
|
|
|
return !this.eventId;
|
|
|
|
},
|
|
|
|
},
|
2019-03-22 10:57:14 +01:00
|
|
|
},
|
2019-10-10 16:47:38 +02:00
|
|
|
metaInfo() {
|
|
|
|
return {
|
2020-09-29 09:53:48 +02:00
|
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
2020-02-18 08:57:00 +01:00
|
|
|
// @ts-ignore
|
2020-11-30 10:24:11 +01:00
|
|
|
title: (this.isUpdate
|
|
|
|
? this.$t("Event edition")
|
|
|
|
: this.$t("Event creation")) as string,
|
2019-10-10 16:47:38 +02:00
|
|
|
};
|
|
|
|
},
|
2019-03-05 12:07:58 +01:00
|
|
|
})
|
2019-09-02 14:35:50 +02:00
|
|
|
export default class EditEvent extends Vue {
|
2020-02-18 08:57:00 +01:00
|
|
|
@Prop({ required: false, type: String }) eventId: undefined | string;
|
2019-09-02 14:35:50 +02:00
|
|
|
|
2020-04-23 00:27:09 +02:00
|
|
|
@Prop({ type: Boolean, default: false }) isUpdate!: boolean;
|
|
|
|
|
|
|
|
@Prop({ type: Boolean, default: false }) isDuplicate!: boolean;
|
|
|
|
|
2021-03-29 10:33:19 +02:00
|
|
|
currentActor!: IActor;
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2019-09-04 18:24:31 +02:00
|
|
|
tags: ITag[] = [];
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2019-10-01 20:10:53 +02:00
|
|
|
event: IEvent = new EventModel();
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2021-03-29 10:33:19 +02:00
|
|
|
identities: IActor[] = [];
|
|
|
|
|
2019-12-20 13:04:34 +01:00
|
|
|
config!: IConfig;
|
2020-02-18 08:57:00 +01:00
|
|
|
|
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;
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2019-09-20 19:43:29 +02:00
|
|
|
EventVisibility = EventVisibility;
|
2019-01-21 15:08:22 +01:00
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
needsApproval = false;
|
2019-09-02 14:35:50 +02:00
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
canPromote = true;
|
2019-09-02 14:35:50 +02:00
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
limitedPlaces = false;
|
2019-09-02 14:35:50 +02:00
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
CommentModeration = CommentModeration;
|
2019-09-02 14:35:50 +02:00
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
showFixedNavbar = true;
|
|
|
|
|
|
|
|
observer!: IntersectionObserver;
|
|
|
|
|
|
|
|
dateSettingsIsOpen = false;
|
|
|
|
|
|
|
|
endsOnNull = false;
|
2019-09-02 14:35:50 +02:00
|
|
|
|
2020-10-01 18:25:57 +02:00
|
|
|
saving = false;
|
|
|
|
|
2020-09-29 09:53:48 +02:00
|
|
|
displayNameAndUsername = displayNameAndUsername;
|
|
|
|
|
|
|
|
formatList = formatList;
|
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
@Watch("eventId", { immediate: true })
|
2020-09-29 09:53:48 +02:00
|
|
|
resetFormForCreation(eventId: string): void {
|
2020-02-18 08:57:00 +01:00
|
|
|
if (eventId === undefined) {
|
|
|
|
this.event = new EventModel();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private initializeEvent() {
|
2020-12-10 12:16:35 +01:00
|
|
|
const roundUpTo15Minutes = (time: Date) => {
|
|
|
|
time.setMilliseconds(Math.round(time.getMilliseconds() / 1000) * 1000);
|
|
|
|
time.setSeconds(Math.round(time.getSeconds() / 60) * 60);
|
|
|
|
time.setMinutes(Math.round(time.getMinutes() / 15) * 15);
|
|
|
|
return time;
|
|
|
|
};
|
|
|
|
|
|
|
|
const now = roundUpTo15Minutes(new Date());
|
|
|
|
const end = new Date(now.valueOf());
|
|
|
|
|
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;
|
2020-10-13 16:57:36 +02:00
|
|
|
}
|
|
|
|
|
2021-03-29 10:33:19 +02:00
|
|
|
get organizerActor(): IActor {
|
|
|
|
if (this.event?.attributedTo?.id) {
|
|
|
|
return this.event.attributedTo;
|
|
|
|
}
|
|
|
|
if (this.event?.organizerActor?.id) {
|
2020-10-13 16:57:36 +02:00
|
|
|
return this.event.organizerActor;
|
|
|
|
}
|
|
|
|
return this.currentActor;
|
2019-06-07 17:19:30 +02:00
|
|
|
}
|
|
|
|
|
2021-03-29 10:33:19 +02:00
|
|
|
set organizerActor(actor: IActor) {
|
|
|
|
if (actor?.type === ActorType.GROUP) {
|
|
|
|
this.event.attributedTo = actor as IGroup;
|
|
|
|
this.event.organizerActor = this.currentActor;
|
|
|
|
} else {
|
|
|
|
this.event.attributedTo = undefined;
|
|
|
|
this.event.organizerActor = actor;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
get attributedToAGroup(): boolean {
|
|
|
|
return this.event.attributedTo?.id !== undefined;
|
|
|
|
}
|
|
|
|
|
2020-09-29 09:53:48 +02:00
|
|
|
async mounted(): Promise<void> {
|
2020-02-18 08:57:00 +01:00
|
|
|
this.observer = new IntersectionObserver(
|
|
|
|
(entries) => {
|
2020-09-29 09:53:48 +02:00
|
|
|
// eslint-disable-next-line no-restricted-syntax
|
2020-02-18 08:57:00 +01:00
|
|
|
for (const entry of entries) {
|
|
|
|
if (entry) {
|
|
|
|
this.showFixedNavbar = !entry.isIntersecting;
|
|
|
|
}
|
2019-10-01 20:10:53 +02:00
|
|
|
}
|
2020-02-18 08:57:00 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
rootMargin: "-50px 0px -50px",
|
2019-10-01 20:10:53 +02:00
|
|
|
}
|
2020-02-18 08:57:00 +01:00
|
|
|
);
|
2019-10-01 20:10:53 +02:00
|
|
|
this.observer.observe(this.$refs.bottomObserver as Element);
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2020-11-26 11:41:13 +01:00
|
|
|
this.pictureFile = await buildFileFromIMedia(this.event.picture);
|
2020-02-18 08:57:00 +01:00
|
|
|
this.limitedPlaces = this.event.options.maximumAttendeeCapacity > 0;
|
2020-06-15 18:12:49 +02:00
|
|
|
if (!(this.isUpdate || this.isDuplicate)) {
|
|
|
|
this.initializeEvent();
|
2020-10-09 18:12:35 +02:00
|
|
|
} else {
|
2021-05-17 09:38:04 +02:00
|
|
|
this.event = {
|
|
|
|
...this.event,
|
2021-06-27 18:17:24 +02:00
|
|
|
options: cloneDeep(this.event.options),
|
2021-05-17 09:38:04 +02:00
|
|
|
description: this.event.description || "",
|
|
|
|
};
|
2020-06-15 18:12:49 +02:00
|
|
|
}
|
2019-10-01 20:10:53 +02:00
|
|
|
}
|
|
|
|
|
2020-09-29 09:53:48 +02:00
|
|
|
createOrUpdateDraft(e: Event): void {
|
2019-01-21 15:08:22 +01:00
|
|
|
e.preventDefault();
|
2019-10-02 17:59:07 +02:00
|
|
|
if (this.validateForm()) {
|
2020-10-08 16:16:42 +02:00
|
|
|
if (this.eventId && !this.isDuplicate) {
|
|
|
|
this.updateEvent();
|
|
|
|
} else {
|
|
|
|
this.createEvent();
|
|
|
|
}
|
2019-10-02 17:59:07 +02:00
|
|
|
}
|
|
|
|
}
|
2019-09-02 14:35:50 +02:00
|
|
|
|
2020-09-29 09:53:48 +02:00
|
|
|
createOrUpdatePublish(e: Event): void {
|
2020-10-01 18:25:57 +02:00
|
|
|
e.preventDefault();
|
2019-10-02 17:59:07 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2020-09-29 09:53:48 +02:00
|
|
|
async createEvent(): Promise<void> {
|
2020-10-01 18:25:57 +02:00
|
|
|
this.saving = true;
|
2019-10-14 11:41:57 +02:00
|
|
|
const variables = await this.buildVariables();
|
|
|
|
|
2019-10-09 14:55:45 +02:00
|
|
|
try {
|
2021-06-11 14:21:27 +02:00
|
|
|
const { data } = await this.$apollo.mutate<{ createEvent: IEvent }>({
|
2019-10-09 14:55:45 +02:00
|
|
|
mutation: CREATE_EVENT,
|
2019-10-14 11:41:57 +02:00
|
|
|
variables,
|
2021-05-12 18:10:07 +02:00
|
|
|
update: (
|
2021-06-11 14:21:27 +02:00
|
|
|
store: ApolloCache<{ createEvent: IEvent }>,
|
2021-05-12 18:10:07 +02:00
|
|
|
{ data: updatedData }: FetchResult
|
|
|
|
) => this.postCreateOrUpdate(store, updatedData?.createEvent),
|
|
|
|
refetchQueries: ({ data: updatedData }: FetchResult) =>
|
|
|
|
this.postRefetchQueries(updatedData?.createEvent),
|
2019-10-09 14:55:45 +02:00
|
|
|
});
|
|
|
|
|
2019-10-13 13:56:24 +02:00
|
|
|
this.$buefy.notification.open({
|
2020-02-18 08:57:00 +01:00
|
|
|
message: (this.event.draft
|
|
|
|
? this.$i18n.t("The event has been created as a draft")
|
|
|
|
: this.$i18n.t("The event has been published")) as string,
|
|
|
|
type: "is-success",
|
|
|
|
position: "is-bottom-right",
|
2019-10-13 13:56:24 +02:00
|
|
|
duration: 5000,
|
|
|
|
});
|
2021-06-11 15:08:53 +02:00
|
|
|
if (data?.createEvent) {
|
|
|
|
await this.$router.push({
|
|
|
|
name: "Event",
|
|
|
|
params: { uuid: data.createEvent.uuid },
|
|
|
|
});
|
|
|
|
}
|
2019-10-09 14:55:45 +02:00
|
|
|
} catch (err) {
|
2020-10-01 18:25:57 +02:00
|
|
|
this.saving = false;
|
2019-10-09 14:55:45 +02:00
|
|
|
console.error(err);
|
2020-10-09 16:07:13 +02:00
|
|
|
this.handleError(err);
|
2019-10-09 14:55:45 +02:00
|
|
|
}
|
2019-09-02 14:35:50 +02:00
|
|
|
}
|
|
|
|
|
2020-09-29 09:53:48 +02:00
|
|
|
async updateEvent(): Promise<void> {
|
2020-10-01 18:25:57 +02:00
|
|
|
this.saving = true;
|
2019-10-14 11:41:57 +02:00
|
|
|
const variables = await this.buildVariables();
|
|
|
|
|
2019-09-02 14:35:50 +02:00
|
|
|
try {
|
2021-06-11 14:21:27 +02:00
|
|
|
await this.$apollo.mutate<{ updateEvent: IEvent }>({
|
2019-09-02 14:35:50 +02:00
|
|
|
mutation: EDIT_EVENT,
|
2019-10-14 11:41:57 +02:00
|
|
|
variables,
|
2021-05-12 18:10:07 +02:00
|
|
|
update: (
|
2021-06-11 14:21:27 +02:00
|
|
|
store: ApolloCache<{ updateEvent: IEvent }>,
|
2021-05-12 18:10:07 +02:00
|
|
|
{ data: updatedData }: FetchResult
|
|
|
|
) => this.postCreateOrUpdate(store, updatedData?.updateEvent),
|
|
|
|
refetchQueries: ({ data }: FetchResult) =>
|
|
|
|
this.postRefetchQueries(data?.updateEvent),
|
2019-09-02 14:35:50 +02:00
|
|
|
});
|
|
|
|
|
2019-10-13 13:56:24 +02:00
|
|
|
this.$buefy.notification.open({
|
|
|
|
message: this.updateEventMessage,
|
2020-02-18 08:57:00 +01:00
|
|
|
type: "is-success",
|
|
|
|
position: "is-bottom-right",
|
2019-10-13 13:56:24 +02:00
|
|
|
duration: 5000,
|
|
|
|
});
|
2019-09-04 18:24:31 +02:00
|
|
|
await this.$router.push({
|
2020-02-18 08:57:00 +01:00
|
|
|
name: "Event",
|
2019-09-02 14:35:50 +02:00
|
|
|
params: { uuid: this.eventId as string },
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-10-01 18:25:57 +02:00
|
|
|
this.saving = false;
|
2020-10-09 16:07:13 +02:00
|
|
|
this.handleError(err);
|
2019-01-21 15:08:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-09 18:12:35 +02:00
|
|
|
get isCurrentActorOrganizer(): boolean {
|
|
|
|
return !(
|
|
|
|
this.eventId &&
|
2021-02-05 14:45:39 +01:00
|
|
|
this.event.organizerActor?.id !== undefined &&
|
2021-03-29 10:33:19 +02:00
|
|
|
!this.identities
|
|
|
|
.map(({ id }) => id)
|
|
|
|
.includes(this.event.organizerActor?.id)
|
|
|
|
);
|
2020-10-09 18:12:35 +02:00
|
|
|
}
|
|
|
|
|
2019-10-13 13:56:24 +02:00
|
|
|
get updateEventMessage(): string {
|
2021-05-17 09:38:04 +02:00
|
|
|
// if (this.unmodifiedEvent.draft && !this.event.draft)
|
|
|
|
// return this.$i18n.t("The event has been updated and published") as string;
|
2021-05-17 19:01:08 +02:00
|
|
|
return (
|
|
|
|
this.event.draft
|
|
|
|
? this.$i18n.t("The draft event has been updated")
|
|
|
|
: this.$i18n.t("The event has been updated")
|
|
|
|
) as string;
|
2019-10-13 13:56:24 +02:00
|
|
|
}
|
|
|
|
|
2020-10-09 16:07:13 +02:00
|
|
|
private handleError(err: any) {
|
|
|
|
console.error(err);
|
|
|
|
|
|
|
|
if (err.graphQLErrors !== undefined) {
|
|
|
|
err.graphQLErrors.forEach(({ message }: { message: string }) => {
|
|
|
|
this.$notifier.error(message);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
*/
|
2020-02-18 08:57:00 +01:00
|
|
|
private postCreateOrUpdate(store: any, updateEvent: IEvent) {
|
|
|
|
const resultEvent: IEvent = { ...updateEvent };
|
2021-06-10 10:31:59 +02:00
|
|
|
console.log(resultEvent);
|
2019-10-04 18:28:25 +02:00
|
|
|
if (!updateEvent.draft) {
|
|
|
|
store.writeQuery({
|
|
|
|
query: EVENT_PERSON_PARTICIPATION,
|
2020-02-18 08:57:00 +01:00
|
|
|
variables: {
|
2021-06-10 10:31:59 +02:00
|
|
|
eventId: resultEvent.id,
|
|
|
|
name: resultEvent.organizerActor?.preferredUsername,
|
2020-02-18 08:57:00 +01:00
|
|
|
},
|
2019-10-04 18:28:25 +02:00
|
|
|
data: {
|
|
|
|
person: {
|
2020-02-18 08:57:00 +01:00
|
|
|
__typename: "Person",
|
2021-06-10 10:31:59 +02:00
|
|
|
id: resultEvent?.organizerActor?.id,
|
2020-06-15 18:12:49 +02:00
|
|
|
participations: {
|
2020-11-20 18:34:13 +01:00
|
|
|
__typename: "PaginatedParticipantList",
|
2020-06-15 18:12:49 +02:00
|
|
|
total: 1,
|
|
|
|
elements: [
|
|
|
|
{
|
|
|
|
__typename: "Participant",
|
|
|
|
id: "unknown",
|
|
|
|
role: ParticipantRole.CREATOR,
|
|
|
|
actor: {
|
|
|
|
__typename: "Actor",
|
2021-06-10 10:31:59 +02:00
|
|
|
id: resultEvent?.organizerActor?.id,
|
2020-06-15 18:12:49 +02:00
|
|
|
},
|
|
|
|
event: {
|
|
|
|
__typename: "Event",
|
2021-06-10 10:31:59 +02:00
|
|
|
id: resultEvent.id,
|
2020-06-15 18:12:49 +02:00
|
|
|
},
|
2020-02-18 08:57:00 +01:00
|
|
|
},
|
2020-06-15 18:12:49 +02:00
|
|
|
],
|
|
|
|
},
|
2019-10-04 18:28:25 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
/**
|
|
|
|
* Refresh drafts or participation cache depending if the event is still draft or not
|
|
|
|
*/
|
2020-09-29 09:53:48 +02:00
|
|
|
// eslint-disable-next-line class-methods-use-this
|
|
|
|
private postRefetchQueries(updateEvent: IEvent): RefetchQueryDescription {
|
2019-10-04 18:28:25 +02:00
|
|
|
if (updateEvent.draft) {
|
2020-02-18 08:57:00 +01:00
|
|
|
return [
|
|
|
|
{
|
|
|
|
query: LOGGED_USER_DRAFTS,
|
|
|
|
},
|
|
|
|
];
|
2019-10-04 18:28:25 +02:00
|
|
|
}
|
2020-02-18 08:57:00 +01:00
|
|
|
return [
|
|
|
|
{
|
|
|
|
query: LOGGED_USER_PARTICIPATIONS,
|
|
|
|
variables: {
|
|
|
|
afterDateTime: new Date(),
|
|
|
|
},
|
2019-10-04 18:28:25 +02:00
|
|
|
},
|
2020-02-18 08:57:00 +01:00
|
|
|
];
|
2019-10-04 18:28:25 +02:00
|
|
|
}
|
|
|
|
|
2021-03-29 10:33:19 +02:00
|
|
|
get organizerActorEqualToCurrentActor(): boolean {
|
|
|
|
return (
|
|
|
|
this.currentActor?.id !== undefined &&
|
|
|
|
this.organizerActor?.id === this.currentActor?.id
|
|
|
|
);
|
2020-09-29 09:53:48 +02:00
|
|
|
}
|
|
|
|
|
2019-07-23 17:14:03 +02:00
|
|
|
/**
|
|
|
|
* Build variables for Event GraphQL creation query
|
|
|
|
*/
|
2019-10-14 11:41:57 +02:00
|
|
|
private async buildVariables() {
|
2021-06-10 10:31:59 +02:00
|
|
|
let res = new EventModel(this.event).toEditJSON();
|
2021-03-29 19:26:33 +02:00
|
|
|
const organizerActor = this.event.organizerActor?.id
|
|
|
|
? this.event.organizerActor
|
|
|
|
: this.organizerActor;
|
|
|
|
if (organizerActor) {
|
2021-05-17 09:38:04 +02:00
|
|
|
res = { ...res, organizerActorId: organizerActor?.id };
|
2020-02-18 08:57:00 +01:00
|
|
|
}
|
2021-03-29 10:33:19 +02:00
|
|
|
const attributedToId = this.event.attributedTo?.id
|
|
|
|
? this.event.attributedTo.id
|
|
|
|
: null;
|
2021-05-17 09:38:04 +02:00
|
|
|
res = { ...res, attributedToId };
|
2019-07-23 17:14:03 +02:00
|
|
|
|
2019-10-14 19:29:18 +02:00
|
|
|
if (this.endsOnNull) {
|
|
|
|
res.endsOn = null;
|
|
|
|
}
|
|
|
|
|
2020-11-20 18:34:13 +01:00
|
|
|
if (this.pictureFile) {
|
|
|
|
const pictureObj = buildFileVariable(this.pictureFile, "picture");
|
|
|
|
res = { ...res, ...pictureObj };
|
|
|
|
}
|
2019-10-14 11:41:57 +02:00
|
|
|
|
2019-11-15 18:36:47 +01:00
|
|
|
try {
|
2020-11-20 18:34:13 +01:00
|
|
|
if (this.event.picture && this.pictureFile) {
|
2020-11-30 10:24:11 +01:00
|
|
|
const oldPictureFile = (await buildFileFromIMedia(
|
|
|
|
this.event.picture
|
|
|
|
)) as File;
|
2019-11-15 18:36:47 +01:00
|
|
|
const oldPictureFileContent = await readFileAsync(oldPictureFile);
|
2020-11-30 10:24:11 +01:00
|
|
|
const newPictureFileContent = await readFileAsync(
|
|
|
|
this.pictureFile as File
|
|
|
|
);
|
2019-11-15 18:36:47 +01:00
|
|
|
if (oldPictureFileContent === newPictureFileContent) {
|
2020-11-26 11:41:13 +01:00
|
|
|
res.picture = { mediaId: this.event.picture.id };
|
2019-11-15 18:36:47 +01:00
|
|
|
}
|
2019-10-14 11:41:57 +02:00
|
|
|
}
|
2019-11-15 18:36:47 +01:00
|
|
|
} catch (e) {
|
|
|
|
console.error(e);
|
2019-10-14 11:41:57 +02:00
|
|
|
}
|
|
|
|
return res;
|
2019-05-22 14:12:11 +02:00
|
|
|
}
|
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
@Watch("limitedPlaces")
|
2020-09-29 09:53:48 +02:00
|
|
|
updatedEventCapacityOptions(limitedPlaces: boolean): void {
|
2019-12-15 22:42:38 +01:00
|
|
|
if (!limitedPlaces) {
|
|
|
|
this.event.options.maximumAttendeeCapacity = 0;
|
|
|
|
this.event.options.remainingAttendeeCapacity = 0;
|
|
|
|
this.event.options.showRemainingAttendeeCapacity = false;
|
|
|
|
} else {
|
2020-02-18 08:57:00 +01:00
|
|
|
this.event.options.maximumAttendeeCapacity =
|
2020-11-30 10:24:11 +01:00
|
|
|
this.event.options.maximumAttendeeCapacity ||
|
|
|
|
DEFAULT_LIMIT_NUMBER_OF_PLACES;
|
2019-12-10 22:40:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
@Watch("needsApproval")
|
2020-09-29 09:53:48 +02:00
|
|
|
updateEventJoinOptions(needsApproval: boolean): void {
|
2019-09-20 18:22:03 +02:00
|
|
|
if (needsApproval === true) {
|
|
|
|
this.event.joinOptions = EventJoinOptions.RESTRICTED;
|
|
|
|
} else {
|
|
|
|
this.event.joinOptions = EventJoinOptions.FREE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-29 09:53:48 +02:00
|
|
|
get checkTitleLength(): Array<string | undefined> {
|
2020-02-18 08:57:00 +01:00
|
|
|
return this.event.title.length > 80
|
2020-09-29 09:53:48 +02:00
|
|
|
? ["is-info", this.$t("The event title will be ellipsed.") as string]
|
2020-02-18 08:57:00 +01:00
|
|
|
: [undefined, undefined];
|
2019-09-23 11:51:59 +02:00
|
|
|
}
|
|
|
|
|
2019-10-01 20:10:53 +02:00
|
|
|
/**
|
|
|
|
* Confirm cancel
|
|
|
|
*/
|
2020-12-14 09:23:29 +01:00
|
|
|
confirmGoElsewhere(callback: () => any): void {
|
2019-10-02 17:59:07 +02:00
|
|
|
if (!this.isEventModified) {
|
2020-11-27 19:27:44 +01:00
|
|
|
callback();
|
2019-10-02 17:59:07 +02:00
|
|
|
}
|
2020-02-18 08:57:00 +01:00
|
|
|
const title: string = this.isUpdate
|
|
|
|
? (this.$t("Cancel edition") as string)
|
|
|
|
: (this.$t("Cancel creation") as string);
|
|
|
|
const message: string = this.isUpdate
|
|
|
|
? (this.$t(
|
|
|
|
"Are you sure you want to cancel the event edition? You'll lose all modifications.",
|
|
|
|
{ title: this.event.title }
|
|
|
|
) as string)
|
|
|
|
: (this.$t(
|
|
|
|
"Are you sure you want to cancel the event creation? You'll lose all modifications.",
|
|
|
|
{ title: this.event.title }
|
|
|
|
) as string);
|
2019-10-01 20:10:53 +02:00
|
|
|
|
|
|
|
this.$buefy.dialog.confirm({
|
|
|
|
title,
|
|
|
|
message,
|
2020-11-13 13:39:52 +01:00
|
|
|
confirmText: this.$t("Abandon editing") as string,
|
2020-02-18 08:57:00 +01:00
|
|
|
cancelText: this.$t("Continue editing") as string,
|
|
|
|
type: "is-warning",
|
2019-10-01 20:10:53 +02:00
|
|
|
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
|
|
|
|
*/
|
2020-09-29 09:53:48 +02:00
|
|
|
confirmGoBack(): void {
|
2019-10-09 17:18:27 +02:00
|
|
|
this.confirmGoElsewhere(() => this.$router.go(-1));
|
|
|
|
}
|
|
|
|
|
2020-11-27 19:27:44 +01:00
|
|
|
// eslint-disable-next-line consistent-return
|
|
|
|
beforeRouteLeave(to: Route, from: Route, next: () => void): void {
|
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 {
|
2021-05-17 09:38:04 +02:00
|
|
|
// return (
|
|
|
|
// JSON.stringify(this.event.toEditJSON()) !==
|
|
|
|
// JSON.stringify(this.unmodifiedEvent)
|
|
|
|
// );
|
|
|
|
return false;
|
2019-10-01 20:10:53 +02:00
|
|
|
}
|
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
get beginsOn(): Date {
|
|
|
|
return this.event.beginsOn;
|
|
|
|
}
|
2019-10-09 12:54:09 +02:00
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
@Watch("beginsOn", { deep: true })
|
2020-09-29 09:53:48 +02:00
|
|
|
onBeginsOnChanged(beginsOn: string): void {
|
2019-10-09 12:54:09 +02:00
|
|
|
if (!this.event.endsOn) return;
|
|
|
|
const dateBeginsOn = new Date(beginsOn);
|
|
|
|
const dateEndsOn = new Date(this.event.endsOn);
|
|
|
|
if (dateEndsOn < dateBeginsOn) {
|
|
|
|
this.event.endsOn = dateBeginsOn;
|
2019-12-10 00:10:12 +01:00
|
|
|
this.event.endsOn.setHours(dateBeginsOn.getHours() + 1);
|
2019-10-09 12:54:09 +02:00
|
|
|
}
|
|
|
|
if (dateEndsOn === dateBeginsOn) {
|
2019-10-14 19:29:18 +02:00
|
|
|
this.event.endsOn.setHours(dateEndsOn.getHours() + 1);
|
2019-10-09 12:54:09 +02:00
|
|
|
}
|
|
|
|
}
|
2019-10-11 18:41:29 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* In event endsOn datepicker, we lock starting with the day before the beginsOn date
|
|
|
|
*/
|
|
|
|
get minDateForEndsOn(): Date {
|
|
|
|
const minDate = new Date(this.event.beginsOn);
|
|
|
|
minDate.setDate(minDate.getDate() - 1);
|
|
|
|
return minDate;
|
|
|
|
}
|
2019-01-21 15:08:22 +01:00
|
|
|
}
|
2019-09-02 14:35:50 +02:00
|
|
|
</script>
|