2019-01-21 14:08:22 +00:00
|
|
|
<template>
|
2019-10-01 18:10:53 +00:00
|
|
|
<section>
|
2021-07-23 13:56:35 +00:00
|
|
|
<div class="container" v-if="hasCurrentActorPermissionsToEdit">
|
2020-04-22 22:27:09 +00: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 18:10:53 +00:00
|
|
|
|
2019-12-20 12:04:34 +00:00
|
|
|
<form ref="form">
|
2020-02-18 07:57:00 +00:00
|
|
|
<subtitle>{{ $t("General information") }}</subtitle>
|
2020-11-20 17:34:13 +00:00
|
|
|
<picture-upload
|
|
|
|
v-model="pictureFile"
|
|
|
|
:textFallback="$t('Headline picture')"
|
|
|
|
:defaultImage="event.picture"
|
|
|
|
/>
|
2019-12-20 12:04:34 +00:00
|
|
|
|
2020-11-30 09:24:11 +00:00
|
|
|
<b-field
|
|
|
|
:label="$t('Title')"
|
2021-09-07 15:52:34 +00:00
|
|
|
label-for="title"
|
2020-11-30 09:24:11 +00:00
|
|
|
:type="checkTitleLength[0]"
|
|
|
|
:message="checkTitleLength[1]"
|
|
|
|
>
|
|
|
|
<b-input
|
|
|
|
size="is-large"
|
|
|
|
aria-required="true"
|
|
|
|
required
|
|
|
|
v-model="event.title"
|
2021-09-07 15:52:34 +00:00
|
|
|
id="title"
|
2020-11-30 09:24:11 +00:00
|
|
|
/>
|
2019-12-20 12:04:34 +00:00
|
|
|
</b-field>
|
2019-07-26 09:30:28 +00:00
|
|
|
|
2021-09-10 09:29:28 +00:00
|
|
|
<tag-input v-model="event.tags" />
|
2019-01-21 14:08:22 +00:00
|
|
|
|
2021-09-07 15:52:34 +00:00
|
|
|
<b-field
|
|
|
|
horizontal
|
|
|
|
:label="$t('Starts on…')"
|
|
|
|
class="begins-on-field"
|
|
|
|
label-for="begins-on-field"
|
|
|
|
>
|
2020-12-10 11:16:35 +00:00
|
|
|
<b-datetimepicker
|
2021-01-25 14:59:57 +00:00
|
|
|
class="datepicker starts-on"
|
2020-12-10 11:16:35 +00:00
|
|
|
:placeholder="$t('Type or select a date…')"
|
|
|
|
icon="calendar-today"
|
|
|
|
:locale="$i18n.locale"
|
2021-10-10 14:25:50 +00:00
|
|
|
v-model="beginsOn"
|
2020-12-10 11:16:35 +00:00
|
|
|
horizontal-time-picker
|
|
|
|
editable
|
2021-10-10 14:25:50 +00:00
|
|
|
:tz-offset="tzOffset(beginsOn)"
|
2021-09-07 15:52:34 +00:00
|
|
|
:datepicker="{
|
|
|
|
id: 'begins-on-field',
|
|
|
|
'aria-next-label': $t('Next month'),
|
|
|
|
'aria-previous-label': $t('Previous month'),
|
|
|
|
}"
|
2020-12-10 11:16:35 +00:00
|
|
|
>
|
|
|
|
</b-datetimepicker>
|
|
|
|
</b-field>
|
|
|
|
|
2021-09-07 15:52:34 +00:00
|
|
|
<b-field horizontal :label="$t('Ends on…')" label-for="ends-on-field">
|
2020-12-10 11:16:35 +00:00
|
|
|
<b-datetimepicker
|
2021-01-25 14:59:57 +00:00
|
|
|
class="datepicker ends-on"
|
2020-12-10 11:16:35 +00:00
|
|
|
:placeholder="$t('Type or select a date…')"
|
|
|
|
icon="calendar-today"
|
|
|
|
:locale="$i18n.locale"
|
2021-10-10 14:25:50 +00:00
|
|
|
v-model="endsOn"
|
2020-12-10 11:16:35 +00:00
|
|
|
horizontal-time-picker
|
2021-10-10 14:25:50 +00:00
|
|
|
:min-datetime="beginsOn"
|
|
|
|
:tz-offset="tzOffset(endsOn)"
|
2020-12-10 11:16:35 +00:00
|
|
|
editable
|
2021-09-07 15:52:34 +00:00
|
|
|
:datepicker="{
|
|
|
|
id: 'ends-on-field',
|
|
|
|
'aria-next-label': $t('Next month'),
|
|
|
|
'aria-previous-label': $t('Previous month'),
|
|
|
|
}"
|
2020-12-10 11:16:35 +00:00
|
|
|
>
|
|
|
|
</b-datetimepicker>
|
|
|
|
</b-field>
|
|
|
|
|
2020-02-18 07:57:00 +00:00
|
|
|
<b-button type="is-text" @click="dateSettingsIsOpen = true">
|
|
|
|
{{ $t("Date parameters") }}
|
|
|
|
</b-button>
|
2019-09-11 07:59:01 +00:00
|
|
|
|
2021-10-15 13:59:49 +00:00
|
|
|
<div class="address">
|
|
|
|
<full-address-auto-complete
|
|
|
|
v-model="eventPhysicalAddress"
|
|
|
|
:user-timezone="userActualTimezone"
|
|
|
|
:disabled="isOnline"
|
|
|
|
/>
|
|
|
|
<b-switch class="is-online" v-model="isOnline">{{
|
|
|
|
$t("The event is fully online")
|
|
|
|
}}</b-switch>
|
|
|
|
</div>
|
2019-09-11 07:59:01 +00:00
|
|
|
|
2019-12-20 12:04:34 +00:00
|
|
|
<div class="field">
|
2020-02-18 07:57:00 +00:00
|
|
|
<label class="label">{{ $t("Description") }}</label>
|
2021-10-10 14:24:12 +00:00
|
|
|
<editor
|
|
|
|
v-model="event.description"
|
|
|
|
:aria-label="$t('Event description body')"
|
|
|
|
/>
|
2019-12-20 12:04:34 +00:00
|
|
|
</div>
|
2019-10-01 18:10:53 +00:00
|
|
|
|
2021-09-07 15:52:34 +00:00
|
|
|
<b-field :label="$t('Website / URL')" label-for="website-url">
|
2020-11-30 09:24:11 +00:00
|
|
|
<b-input
|
|
|
|
icon="link"
|
|
|
|
type="url"
|
|
|
|
v-model="event.onlineAddress"
|
|
|
|
placeholder="URL"
|
2021-09-07 15:52:34 +00:00
|
|
|
id="website-url"
|
2020-11-30 09:24:11 +00:00
|
|
|
/>
|
2019-12-20 12:04:34 +00:00
|
|
|
</b-field>
|
|
|
|
|
2020-02-18 07:57:00 +00:00
|
|
|
<subtitle>{{ $t("Organizers") }}</subtitle>
|
2020-09-29 07:53:48 +00:00
|
|
|
|
2021-03-29 08:33:19 +00:00
|
|
|
<div v-if="config && config.features.groups && organizerActor.id">
|
2020-09-29 07:53:48 +00:00
|
|
|
<b-field>
|
|
|
|
<organizer-picker-wrapper
|
2021-03-29 08:33:19 +00:00
|
|
|
v-model="organizerActor"
|
2020-09-29 07:53:48 +00:00
|
|
|
:contacts.sync="event.contacts"
|
|
|
|
/>
|
|
|
|
</b-field>
|
2021-03-29 08:33:19 +00:00
|
|
|
<p v-if="!attributedToAGroup && organizerActorEqualToCurrentActor">
|
2020-11-30 09:24:11 +00:00
|
|
|
{{
|
|
|
|
$t("The event will show as attributed to your personal profile.")
|
|
|
|
}}
|
2020-09-29 07:53:48 +00:00
|
|
|
</p>
|
2021-03-29 08:33:19 +00:00
|
|
|
<p v-else-if="!attributedToAGroup">
|
|
|
|
{{ $t("The event will show as attributed to this profile.") }}
|
|
|
|
</p>
|
2020-09-29 07:53:48 +00:00
|
|
|
<p v-else>
|
2020-11-30 09:24:11 +00:00
|
|
|
<span>{{
|
|
|
|
$t("The event will show as attributed to this group.")
|
|
|
|
}}</span>
|
2020-09-29 07:53:48 +00:00
|
|
|
<span
|
|
|
|
v-if="event.contacts && event.contacts.length"
|
|
|
|
v-html="
|
2021-03-29 08:33:19 +00:00
|
|
|
' ' +
|
2020-11-30 09:24:11 +00:00
|
|
|
$tc(
|
|
|
|
'<b>{contact}</b> will be displayed as contact.',
|
|
|
|
event.contacts.length,
|
|
|
|
{
|
|
|
|
contact: formatList(
|
|
|
|
event.contacts.map((contact) =>
|
|
|
|
displayNameAndUsername(contact)
|
|
|
|
)
|
|
|
|
),
|
|
|
|
}
|
|
|
|
)
|
2020-09-29 07:53:48 +00:00
|
|
|
"
|
|
|
|
/>
|
2021-03-29 08:33:19 +00:00
|
|
|
<span v-else>
|
|
|
|
{{ $t("You may show some members as contacts.") }}
|
|
|
|
</span>
|
2020-09-29 07:53:48 +00:00
|
|
|
</p>
|
2020-02-18 07:57:00 +00:00
|
|
|
</div>
|
2021-08-09 12:26:11 +00:00
|
|
|
<subtitle>{{ $t("Event metadata") }}</subtitle>
|
|
|
|
<p>
|
|
|
|
{{
|
|
|
|
$t(
|
|
|
|
"Integrate this event with 3rd-party tools and show metadata for the event."
|
|
|
|
)
|
|
|
|
}}
|
|
|
|
</p>
|
|
|
|
<event-metadata-list v-model="event.metadata" />
|
2020-02-18 07:57:00 +00:00
|
|
|
<subtitle>{{ $t("Who can view this event and participate") }}</subtitle>
|
2021-09-07 15:52:34 +00:00
|
|
|
<fieldset>
|
|
|
|
<legend>
|
|
|
|
{{
|
|
|
|
$t(
|
|
|
|
"When the event is private, you'll need to share the link around."
|
|
|
|
)
|
|
|
|
}}
|
|
|
|
</legend>
|
|
|
|
<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 (private)") }}</b-radio
|
|
|
|
>
|
|
|
|
</div>
|
|
|
|
</fieldset>
|
2019-12-20 12:04:34 +00: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 07:57:00 +00:00
|
|
|
</div>-->
|
2019-12-20 12:04:34 +00:00
|
|
|
|
2020-11-30 09:24:11 +00:00
|
|
|
<div
|
|
|
|
class="field"
|
|
|
|
v-if="config && config.anonymous.participation.allowed"
|
|
|
|
>
|
2020-02-18 07:57:00 +00:00
|
|
|
<label class="label">{{ $t("Anonymous participations") }}</label>
|
2021-08-13 10:24:12 +00:00
|
|
|
<b-switch v-model="eventOptions.anonymousParticipation">
|
2020-11-30 09:24:11 +00:00
|
|
|
{{
|
|
|
|
$t("I want to allow people to participate without an account.")
|
|
|
|
}}
|
|
|
|
<small
|
|
|
|
v-if="
|
|
|
|
config.anonymous.participation.validation.email
|
|
|
|
.confirmationRequired
|
|
|
|
"
|
|
|
|
>
|
2020-02-18 07:57:00 +00:00
|
|
|
<br />
|
|
|
|
{{
|
|
|
|
$t(
|
|
|
|
"Anonymous participants will be asked to confirm their participation through e-mail."
|
|
|
|
)
|
|
|
|
}}
|
2019-12-20 12:04:34 +00:00
|
|
|
</small>
|
|
|
|
</b-switch>
|
|
|
|
</div>
|
2019-08-28 09:28:27 +00:00
|
|
|
|
2019-12-20 12:04:34 +00:00
|
|
|
<div class="field">
|
2020-02-18 07:57:00 +00: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 12:04:34 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="field">
|
2020-02-18 07:57:00 +00:00
|
|
|
<label class="label">{{ $t("Number of places") }}</label>
|
2020-11-30 09:24:11 +00:00
|
|
|
<b-switch v-model="limitedPlaces">{{
|
|
|
|
$t("Limited number of places")
|
|
|
|
}}</b-switch>
|
2019-12-20 12:04:34 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="box" v-if="limitedPlaces">
|
2021-09-07 15:52:34 +00:00
|
|
|
<b-field :label="$t('Number of places')" label-for="number-of-places">
|
2020-02-18 07:57:00 +00:00
|
|
|
<b-numberinput
|
|
|
|
controls-position="compact"
|
2021-09-07 15:52:34 +00:00
|
|
|
:aria-minus-label="$t('Decrease')"
|
|
|
|
:aria-plus-label="$t('Increase')"
|
2020-02-18 07:57:00 +00:00
|
|
|
min="1"
|
2021-08-13 10:24:12 +00:00
|
|
|
v-model="eventOptions.maximumAttendeeCapacity"
|
2021-09-07 15:52:34 +00:00
|
|
|
id="number-of-places"
|
2020-02-18 07:57:00 +00:00
|
|
|
/>
|
2019-12-20 12:04:34 +00:00
|
|
|
</b-field>
|
2020-02-18 07:57:00 +00:00
|
|
|
<!--
|
2019-12-20 12:04:34 +00:00
|
|
|
<b-field>
|
2021-08-13 10:24:12 +00:00
|
|
|
<b-switch v-model="eventOptions.showRemainingAttendeeCapacity">
|
2019-12-20 12:04:34 +00:00
|
|
|
{{ $t('Show remaining number of places') }}
|
|
|
|
</b-switch>
|
|
|
|
</b-field>
|
2019-10-01 18:10:53 +00:00
|
|
|
|
2019-12-20 12:04:34 +00:00
|
|
|
<b-field>
|
2021-08-13 10:24:12 +00:00
|
|
|
<b-switch v-model="eventOptions.showParticipationPrice">
|
2019-12-20 12:04:34 +00:00
|
|
|
{{ $t('Display participation price') }}
|
|
|
|
</b-switch>
|
2020-02-18 07:57:00 +00:00
|
|
|
</b-field>-->
|
2019-12-20 12:04:34 +00:00
|
|
|
</div>
|
2019-08-28 09:28:27 +00:00
|
|
|
|
2020-02-18 07:57:00 +00:00
|
|
|
<subtitle>{{ $t("Public comment moderation") }}</subtitle>
|
2019-07-30 14:40:59 +00:00
|
|
|
|
2021-09-07 15:52:34 +00:00
|
|
|
<fieldset>
|
|
|
|
<legend>{{ $t("Who can post a comment?") }}</legend>
|
|
|
|
<div class="field">
|
|
|
|
<b-radio
|
|
|
|
v-model="eventOptions.commentModeration"
|
|
|
|
name="commentModeration"
|
|
|
|
:native-value="CommentModeration.ALLOW_ALL"
|
|
|
|
>{{ $t("Allow all comments from users with accounts") }}</b-radio
|
|
|
|
>
|
|
|
|
</div>
|
2019-08-28 09:28:27 +00:00
|
|
|
|
2021-09-07 15:52:34 +00:00
|
|
|
<!-- <div class="field">-->
|
|
|
|
<!-- <b-radio v-model="eventOptions.commentModeration"-->
|
|
|
|
<!-- name="commentModeration"-->
|
|
|
|
<!-- :native-value="CommentModeration.MODERATED">-->
|
|
|
|
<!-- {{ $t('Moderated comments (shown after approval)') }}-->
|
|
|
|
<!-- </b-radio>-->
|
|
|
|
<!-- </div>-->
|
|
|
|
|
|
|
|
<div class="field">
|
|
|
|
<b-radio
|
|
|
|
v-model="eventOptions.commentModeration"
|
|
|
|
name="commentModeration"
|
|
|
|
:native-value="CommentModeration.CLOSED"
|
|
|
|
>{{ $t("Close comments for all (except for admins)") }}</b-radio
|
|
|
|
>
|
|
|
|
</div>
|
|
|
|
</fieldset>
|
2019-08-28 09:28:27 +00:00
|
|
|
|
2020-02-18 07:57:00 +00:00
|
|
|
<subtitle>{{ $t("Status") }}</subtitle>
|
2019-12-20 12:04:34 +00:00
|
|
|
|
2021-09-07 15:52:34 +00:00
|
|
|
<fieldset>
|
|
|
|
<legend>
|
|
|
|
{{
|
|
|
|
$t(
|
|
|
|
"Does the event needs to be confirmed later or is it cancelled?"
|
|
|
|
)
|
|
|
|
}}
|
|
|
|
</legend>
|
|
|
|
<b-field class="event__status__field">
|
|
|
|
<b-radio-button
|
|
|
|
v-model="event.status"
|
|
|
|
name="status"
|
|
|
|
type="is-warning"
|
|
|
|
:native-value="EventStatus.TENTATIVE"
|
|
|
|
>
|
|
|
|
<b-icon icon="calendar-question" />
|
|
|
|
{{ $t("Tentative: Will be confirmed later") }}
|
|
|
|
</b-radio-button>
|
|
|
|
<b-radio-button
|
|
|
|
v-model="event.status"
|
|
|
|
name="status"
|
|
|
|
type="is-success"
|
|
|
|
:native-value="EventStatus.CONFIRMED"
|
|
|
|
>
|
|
|
|
<b-icon icon="calendar-check" />
|
|
|
|
{{ $t("Confirmed: Will happen") }}
|
|
|
|
</b-radio-button>
|
|
|
|
<b-radio-button
|
|
|
|
v-model="event.status"
|
|
|
|
name="status"
|
|
|
|
type="is-danger"
|
|
|
|
:native-value="EventStatus.CANCELLED"
|
|
|
|
>
|
|
|
|
<b-icon icon="calendar-remove" />
|
|
|
|
{{ $t("Cancelled: Won't happen") }}
|
|
|
|
</b-radio-button>
|
|
|
|
</b-field>
|
|
|
|
</fieldset>
|
2019-12-20 12:04:34 +00:00
|
|
|
</form>
|
2019-01-21 14:08:22 +00:00
|
|
|
</div>
|
2021-07-23 13:56:35 +00:00
|
|
|
<div class="container section" v-else>
|
|
|
|
<b-message type="is-danger">
|
|
|
|
{{ $t("Only group moderators can create, edit and delete events.") }}
|
|
|
|
</b-message>
|
|
|
|
</div>
|
2020-08-31 10:40:30 +00:00
|
|
|
<b-modal v-model="dateSettingsIsOpen" has-modal-card trap-focus>
|
2020-02-18 07:57:00 +00:00
|
|
|
<form action>
|
2020-08-27 13:41:48 +00:00
|
|
|
<div class="modal-card" style="width: auto">
|
2019-10-14 17:29:18 +00:00
|
|
|
<header class="modal-card-head">
|
2021-10-10 14:25:50 +00:00
|
|
|
<h3 class="modal-card-title">{{ $t("Date and time settings") }}</h3>
|
2019-10-14 17:29:18 +00:00
|
|
|
</header>
|
|
|
|
<section class="modal-card-body">
|
2021-10-10 14:25:50 +00:00
|
|
|
<p>
|
|
|
|
{{
|
|
|
|
$t(
|
|
|
|
"Event timezone will default to the timezone of the event's address if there is one, or to your own timezone setting."
|
|
|
|
)
|
|
|
|
}}
|
|
|
|
</p>
|
|
|
|
<b-field :label="$t('Timezone')" label-for="timezone" expanded>
|
|
|
|
<b-select
|
|
|
|
:placeholder="$t('Select a timezone')"
|
|
|
|
:loading="!config"
|
|
|
|
v-model="timezone"
|
|
|
|
id="timezone"
|
|
|
|
>
|
|
|
|
<optgroup
|
|
|
|
:label="group"
|
|
|
|
v-for="(groupTimezones, group) in timezones"
|
|
|
|
:key="group"
|
|
|
|
>
|
|
|
|
<option
|
|
|
|
v-for="timezone in groupTimezones"
|
|
|
|
:value="`${group}/${timezone}`"
|
|
|
|
:key="timezone"
|
|
|
|
>
|
|
|
|
{{ sanitizeTimezone(timezone) }}
|
|
|
|
</option>
|
|
|
|
</optgroup>
|
|
|
|
</b-select>
|
|
|
|
<b-button
|
|
|
|
:disabled="!timezone"
|
|
|
|
@click="timezone = null"
|
|
|
|
class="reset-area"
|
|
|
|
icon-left="close"
|
|
|
|
:title="$t('Clear timezone field')"
|
|
|
|
/>
|
|
|
|
</b-field>
|
2019-10-14 17:29:18 +00:00
|
|
|
<b-field :label="$t('Event page settings')">
|
2021-08-13 10:24:12 +00:00
|
|
|
<b-switch v-model="eventOptions.showStartTime">{{
|
2020-02-18 07:57:00 +00:00
|
|
|
$t("Show the time when the event begins")
|
|
|
|
}}</b-switch>
|
2019-10-14 17:29:18 +00:00
|
|
|
</b-field>
|
|
|
|
<b-field>
|
2021-08-13 10:24:12 +00:00
|
|
|
<b-switch v-model="eventOptions.showEndTime">{{
|
2020-02-18 07:57:00 +00:00
|
|
|
$t("Show the time when the event ends")
|
|
|
|
}}</b-switch>
|
2019-10-14 17:29:18 +00:00
|
|
|
</b-field>
|
|
|
|
</section>
|
|
|
|
<footer class="modal-card-foot">
|
2020-11-30 09:24:11 +00:00
|
|
|
<button
|
|
|
|
class="button"
|
|
|
|
type="button"
|
|
|
|
@click="dateSettingsIsOpen = false"
|
|
|
|
>
|
2020-02-18 07:57:00 +00:00
|
|
|
{{ $t("OK") }}
|
|
|
|
</button>
|
2019-10-14 17:29:18 +00:00
|
|
|
</footer>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</b-modal>
|
2019-12-03 10:29:51 +00:00
|
|
|
<span ref="bottomObserver" />
|
2020-02-18 07:57:00 +00:00
|
|
|
<nav
|
|
|
|
role="navigation"
|
|
|
|
aria-label="main navigation"
|
2020-10-13 14:57:36 +00:00
|
|
|
class="navbar save__navbar"
|
2020-02-18 07:57:00 +00:00
|
|
|
:class="{ 'is-fixed-bottom': showFixedNavbar }"
|
2021-07-23 13:56:35 +00:00
|
|
|
v-if="hasCurrentActorPermissionsToEdit"
|
2020-02-18 07:57:00 +00:00
|
|
|
>
|
2019-10-01 18:10:53 +00:00
|
|
|
<div class="container">
|
|
|
|
<div class="navbar-menu">
|
|
|
|
<div class="navbar-start">
|
2020-11-30 09:24:11 +00:00
|
|
|
<span class="navbar-item" v-if="isEventModified">{{
|
|
|
|
$t("Unsaved changes")
|
|
|
|
}}</span>
|
2019-10-01 18:10:53 +00:00
|
|
|
</div>
|
|
|
|
<div class="navbar-end">
|
|
|
|
<span class="navbar-item">
|
2020-11-30 09:24:11 +00:00
|
|
|
<b-button type="is-text" @click="confirmGoBack">{{
|
|
|
|
$t("Cancel")
|
|
|
|
}}</b-button>
|
2019-10-01 18:10:53 +00:00
|
|
|
</span>
|
2019-10-02 15:59:07 +00: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 16:25:57 +00:00
|
|
|
<b-button
|
|
|
|
type="is-primary"
|
|
|
|
outlined
|
|
|
|
@click="createOrUpdateDraft"
|
|
|
|
:disabled="saving"
|
|
|
|
>{{ $t("Save draft") }}</b-button
|
|
|
|
>
|
2019-10-01 18:10:53 +00:00
|
|
|
</span>
|
|
|
|
<span class="navbar-item">
|
2020-02-18 07:57:00 +00:00
|
|
|
<b-button
|
|
|
|
type="is-primary"
|
2020-10-01 16:25:57 +00:00
|
|
|
:disabled="saving"
|
2020-02-18 07:57:00 +00:00
|
|
|
@click="createOrUpdatePublish"
|
|
|
|
@keyup.enter="createOrUpdatePublish"
|
|
|
|
>
|
2020-11-30 09:24:11 +00:00
|
|
|
<span v-if="isUpdate === false">{{
|
|
|
|
$t("Create my event")
|
|
|
|
}}</span>
|
|
|
|
<span v-else-if="event.draft === true">{{
|
|
|
|
$t("Publish")
|
|
|
|
}}</span>
|
2020-02-18 07:57:00 +00:00
|
|
|
<span v-else>{{ $t("Update my event") }}</span>
|
2019-10-01 18:10:53 +00:00
|
|
|
</b-button>
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</nav>
|
2019-01-21 14:08:22 +00:00
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
|
2019-10-01 18:10:53 +00:00
|
|
|
<style lang="scss" scoped>
|
2020-02-18 07:57:00 +00:00
|
|
|
main section > .container {
|
|
|
|
background: $white;
|
2021-09-07 15:52:34 +00:00
|
|
|
|
|
|
|
form {
|
|
|
|
h2 {
|
|
|
|
margin: 15px 0 7.5px;
|
|
|
|
}
|
|
|
|
|
|
|
|
legend {
|
|
|
|
margin-bottom: 0.75rem;
|
|
|
|
}
|
|
|
|
}
|
2020-02-18 07:57:00 +00:00
|
|
|
}
|
2019-12-20 12:04:34 +00:00
|
|
|
|
2020-10-13 14:57:36 +00:00
|
|
|
.save__navbar {
|
2020-11-16 09:04:47 +00:00
|
|
|
::v-deep .navbar-menu,
|
2020-10-13 14:57:36 +00:00
|
|
|
.navbar-end {
|
|
|
|
flex-wrap: wrap;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@media screen and (max-width: 768px) {
|
|
|
|
.navbar.is-fixed-bottom {
|
|
|
|
position: initial;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-18 07:57:00 +00:00
|
|
|
h2.subtitle {
|
|
|
|
margin: 10px 0;
|
2019-09-09 09:21:42 +00:00
|
|
|
|
2020-02-18 07:57:00 +00:00
|
|
|
span {
|
|
|
|
padding: 5px 7px;
|
|
|
|
display: inline;
|
|
|
|
background: $secondary;
|
2019-09-09 09:21:42 +00:00
|
|
|
}
|
2020-02-18 07:57:00 +00:00
|
|
|
}
|
2019-10-01 18:10:53 +00:00
|
|
|
|
2020-10-13 14:57:36 +00:00
|
|
|
.event__status__field {
|
2020-11-16 09:04:47 +00:00
|
|
|
::v-deep .field.has-addons {
|
2020-10-13 14:57:36 +00:00
|
|
|
display: flex;
|
|
|
|
flex-wrap: wrap;
|
|
|
|
justify-content: flex-start;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-25 14:59:57 +00:00
|
|
|
.datepicker {
|
|
|
|
::v-deep .dropdown-menu {
|
|
|
|
z-index: 200;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-18 07:57:00 +00:00
|
|
|
section {
|
|
|
|
& > .container {
|
|
|
|
padding: 2rem 1.5rem;
|
2021-09-07 15:52:34 +00:00
|
|
|
@media screen and (max-width: 768px) {
|
|
|
|
padding: 2rem 0.5rem;
|
|
|
|
}
|
2020-02-18 07:57:00 +00:00
|
|
|
}
|
2019-10-01 18:10:53 +00:00
|
|
|
|
2020-12-10 11:16:35 +00:00
|
|
|
.begins-on-field {
|
|
|
|
margin-top: 22px;
|
|
|
|
}
|
|
|
|
|
2020-02-18 07:57:00 +00:00
|
|
|
nav.navbar {
|
|
|
|
min-height: 2rem !important;
|
|
|
|
background: lighten($secondary, 10%);
|
2019-10-01 18:10:53 +00:00
|
|
|
|
2020-02-18 07:57:00 +00:00
|
|
|
.container {
|
|
|
|
min-height: 2rem;
|
2019-10-01 18:10:53 +00:00
|
|
|
|
2020-02-18 07:57:00 +00:00
|
|
|
.navbar-menu,
|
|
|
|
.navbar-end {
|
|
|
|
display: flex !important;
|
|
|
|
background: lighten($secondary, 10%);
|
|
|
|
}
|
2019-10-01 18:10:53 +00:00
|
|
|
|
2020-02-18 07:57:00 +00:00
|
|
|
.navbar-end {
|
|
|
|
justify-content: flex-end;
|
|
|
|
margin-left: auto;
|
2019-10-01 18:10:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-02-18 07:57:00 +00:00
|
|
|
}
|
2021-10-15 13:59:49 +00:00
|
|
|
|
|
|
|
.address {
|
|
|
|
::v-deep .address-autocomplete {
|
|
|
|
margin-bottom: 0 !important;
|
|
|
|
}
|
|
|
|
.is-online {
|
|
|
|
margin-bottom: 10px;
|
|
|
|
}
|
|
|
|
}
|
2019-09-09 09:21:42 +00:00
|
|
|
</style>
|
2021-04-19 10:04:52 +00: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 09:21:42 +00:00
|
|
|
|
2019-01-21 14:08:22 +00:00
|
|
|
<script lang="ts">
|
2020-02-18 07:57:00 +00:00
|
|
|
import { Component, Prop, Vue, Watch } from "vue-property-decorator";
|
2021-10-10 14:25:50 +00:00
|
|
|
import { getTimezoneOffset } from "date-fns-tz";
|
2020-02-18 07:57:00 +00:00
|
|
|
import PictureUpload from "@/components/PictureUpload.vue";
|
|
|
|
import EditorComponent from "@/components/Editor.vue";
|
|
|
|
import TagInput from "@/components/Event/TagInput.vue";
|
2020-07-31 15:52:26 +00:00
|
|
|
import FullAddressAutoComplete from "@/components/Event/FullAddressAutoComplete.vue";
|
2021-08-09 12:26:11 +00:00
|
|
|
import EventMetadataList from "@/components/Event/EventMetadataList.vue";
|
2020-02-18 07:57:00 +00:00
|
|
|
import IdentityPickerWrapper from "@/views/Account/IdentityPickerWrapper.vue";
|
|
|
|
import Subtitle from "@/components/Utils/Subtitle.vue";
|
2021-08-11 14:06:30 +00:00
|
|
|
import { RawLocation, Route } from "vue-router";
|
2020-09-29 07:53:48 +00:00
|
|
|
import { formatList } from "@/utils/i18n";
|
2020-11-27 18:27:44 +00:00
|
|
|
import {
|
2021-03-29 08:33:19 +00:00
|
|
|
ActorType,
|
2020-11-27 18:27:44 +00:00
|
|
|
CommentModeration,
|
|
|
|
EventJoinOptions,
|
|
|
|
EventStatus,
|
|
|
|
EventVisibility,
|
2021-07-23 13:56:35 +00:00
|
|
|
MemberRole,
|
2020-11-27 18:27:44 +00:00
|
|
|
ParticipantRole,
|
|
|
|
} from "@/types/enums";
|
2020-09-29 07:53:48 +00:00
|
|
|
import OrganizerPickerWrapper from "../../components/Event/OrganizerPickerWrapper.vue";
|
2020-02-18 07:57:00 +00:00
|
|
|
import {
|
|
|
|
CREATE_EVENT,
|
|
|
|
EDIT_EVENT,
|
|
|
|
EVENT_PERSON_PARTICIPATION,
|
|
|
|
FETCH_EVENT,
|
|
|
|
} from "../../graphql/event";
|
2021-08-13 10:24:12 +00:00
|
|
|
import {
|
|
|
|
EventModel,
|
2021-10-10 14:25:50 +00:00
|
|
|
IEditableEvent,
|
2021-08-13 10:24:12 +00:00
|
|
|
IEvent,
|
|
|
|
removeTypeName,
|
|
|
|
toEditJSON,
|
|
|
|
} from "../../types/event.model";
|
2019-09-20 16:22:03 +00:00
|
|
|
import {
|
2020-02-18 07:57:00 +00:00
|
|
|
CURRENT_ACTOR_CLIENT,
|
2021-03-29 08:33:19 +00:00
|
|
|
IDENTITIES,
|
2020-02-18 07:57:00 +00:00
|
|
|
LOGGED_USER_DRAFTS,
|
|
|
|
LOGGED_USER_PARTICIPATIONS,
|
2021-07-23 13:56:35 +00:00
|
|
|
PERSON_MEMBERSHIP_GROUP,
|
2020-02-18 07:57:00 +00:00
|
|
|
} from "../../graphql/actor";
|
2021-07-23 13:56:35 +00:00
|
|
|
import {
|
|
|
|
displayNameAndUsername,
|
|
|
|
IActor,
|
|
|
|
IGroup,
|
|
|
|
IPerson,
|
|
|
|
usernameWithDomain,
|
|
|
|
} from "../../types/actor";
|
2020-11-30 09:24:11 +00:00
|
|
|
import {
|
|
|
|
buildFileFromIMedia,
|
|
|
|
buildFileVariable,
|
|
|
|
readFileAsync,
|
|
|
|
} from "../../utils/image";
|
2020-02-18 07:57:00 +00:00
|
|
|
import RouteName from "../../router/name";
|
|
|
|
import "intersection-observer";
|
2021-10-10 14:25:50 +00:00
|
|
|
import { CONFIG_EDIT_EVENT } from "../../graphql/config";
|
2020-02-18 07:57:00 +00:00
|
|
|
import { IConfig } from "../../types/config.model";
|
2021-08-02 16:11:22 +00:00
|
|
|
import {
|
|
|
|
ApolloCache,
|
|
|
|
FetchResult,
|
|
|
|
InternalRefetchQueriesInclude,
|
|
|
|
} from "@apollo/client/core";
|
2021-06-27 16:17:24 +00:00
|
|
|
import cloneDeep from "lodash/cloneDeep";
|
2021-08-13 10:24:12 +00:00
|
|
|
import { IEventOptions } from "@/types/event-options.model";
|
2021-10-10 14:25:50 +00:00
|
|
|
import { USER_SETTINGS } from "@/graphql/user";
|
|
|
|
import { IUser } from "@/types/current-user.model";
|
|
|
|
import { IAddress } from "@/types/address.model";
|
2019-01-21 14:08:22 +00:00
|
|
|
|
2019-12-15 21:42:38 +00:00
|
|
|
const DEFAULT_LIMIT_NUMBER_OF_PLACES = 10;
|
|
|
|
|
2019-03-05 11:07:58 +00:00
|
|
|
@Component({
|
2020-02-18 07:57:00 +00:00
|
|
|
components: {
|
2020-09-29 07:53:48 +00:00
|
|
|
OrganizerPickerWrapper,
|
2020-02-18 07:57:00 +00:00
|
|
|
Subtitle,
|
|
|
|
IdentityPickerWrapper,
|
2020-07-31 15:52:26 +00:00
|
|
|
FullAddressAutoComplete,
|
2020-02-18 07:57:00 +00:00
|
|
|
TagInput,
|
|
|
|
PictureUpload,
|
|
|
|
Editor: EditorComponent,
|
2021-08-09 12:26:11 +00:00
|
|
|
EventMetadataList,
|
2020-02-18 07:57:00 +00:00
|
|
|
},
|
2019-03-05 11:07:58 +00:00
|
|
|
apollo: {
|
2019-12-20 12:04:34 +00:00
|
|
|
currentActor: CURRENT_ACTOR_CLIENT,
|
2021-10-10 14:25:50 +00:00
|
|
|
loggedUser: USER_SETTINGS,
|
|
|
|
config: CONFIG_EDIT_EVENT,
|
2021-03-29 08:33:19 +00:00
|
|
|
identities: IDENTITIES,
|
2020-02-18 07:57:00 +00:00
|
|
|
event: {
|
|
|
|
query: FETCH_EVENT,
|
|
|
|
variables() {
|
|
|
|
return {
|
|
|
|
uuid: this.eventId,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
update(data) {
|
2021-05-17 16:20:53 +00:00
|
|
|
return new EventModel(data.event);
|
2020-02-18 07:57:00 +00:00
|
|
|
},
|
|
|
|
skip() {
|
|
|
|
return !this.eventId;
|
|
|
|
},
|
|
|
|
},
|
2021-07-23 13:56:35 +00:00
|
|
|
person: {
|
|
|
|
query: PERSON_MEMBERSHIP_GROUP,
|
|
|
|
fetchPolicy: "cache-and-network",
|
|
|
|
variables() {
|
|
|
|
return {
|
|
|
|
id: this.currentActor.id,
|
|
|
|
group: usernameWithDomain(this.event?.attributedTo),
|
|
|
|
};
|
|
|
|
},
|
|
|
|
skip() {
|
|
|
|
return (
|
|
|
|
!this.event?.attributedTo ||
|
|
|
|
!this.event?.attributedTo?.preferredUsername
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
2019-03-22 09:57:14 +00:00
|
|
|
},
|
2019-10-10 14:47:38 +00:00
|
|
|
metaInfo() {
|
|
|
|
return {
|
2020-09-29 07:53:48 +00:00
|
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
2020-02-18 07:57:00 +00:00
|
|
|
// @ts-ignore
|
2020-11-30 09:24:11 +00:00
|
|
|
title: (this.isUpdate
|
|
|
|
? this.$t("Event edition")
|
|
|
|
: this.$t("Event creation")) as string,
|
2019-10-10 14:47:38 +00:00
|
|
|
};
|
|
|
|
},
|
2019-03-05 11:07:58 +00:00
|
|
|
})
|
2019-09-02 12:35:50 +00:00
|
|
|
export default class EditEvent extends Vue {
|
2020-02-18 07:57:00 +00:00
|
|
|
@Prop({ required: false, type: String }) eventId: undefined | string;
|
2019-09-02 12:35:50 +00:00
|
|
|
|
2020-04-22 22:27:09 +00:00
|
|
|
@Prop({ type: Boolean, default: false }) isUpdate!: boolean;
|
|
|
|
|
|
|
|
@Prop({ type: Boolean, default: false }) isDuplicate!: boolean;
|
|
|
|
|
2021-03-29 08:33:19 +00:00
|
|
|
currentActor!: IActor;
|
2020-02-18 07:57:00 +00:00
|
|
|
|
2021-10-10 14:25:50 +00:00
|
|
|
loggedUser!: IUser;
|
|
|
|
|
|
|
|
event: IEditableEvent = new EventModel();
|
2020-02-18 07:57:00 +00:00
|
|
|
|
2021-10-10 14:25:50 +00:00
|
|
|
unmodifiedEvent: IEditableEvent = new EventModel();
|
2021-08-11 14:06:30 +00:00
|
|
|
|
2021-03-29 08:33:19 +00:00
|
|
|
identities: IActor[] = [];
|
|
|
|
|
2021-07-23 13:56:35 +00:00
|
|
|
person!: IPerson;
|
|
|
|
|
2019-12-20 12:04:34 +00:00
|
|
|
config!: IConfig;
|
2020-02-18 07:57:00 +00:00
|
|
|
|
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;
|
2020-02-18 07:57:00 +00:00
|
|
|
|
2019-09-20 17:43:29 +00:00
|
|
|
EventVisibility = EventVisibility;
|
2019-01-21 14:08:22 +00:00
|
|
|
|
2020-02-18 07:57:00 +00:00
|
|
|
canPromote = true;
|
2019-09-02 12:35:50 +00:00
|
|
|
|
2020-02-18 07:57:00 +00:00
|
|
|
limitedPlaces = false;
|
2019-09-02 12:35:50 +00:00
|
|
|
|
2020-02-18 07:57:00 +00:00
|
|
|
CommentModeration = CommentModeration;
|
2019-09-02 12:35:50 +00:00
|
|
|
|
2020-02-18 07:57:00 +00:00
|
|
|
showFixedNavbar = true;
|
|
|
|
|
|
|
|
observer!: IntersectionObserver;
|
|
|
|
|
|
|
|
dateSettingsIsOpen = false;
|
|
|
|
|
2020-10-01 16:25:57 +00:00
|
|
|
saving = false;
|
|
|
|
|
2020-09-29 07:53:48 +00:00
|
|
|
displayNameAndUsername = displayNameAndUsername;
|
|
|
|
|
|
|
|
formatList = formatList;
|
|
|
|
|
2020-02-18 07:57:00 +00:00
|
|
|
@Watch("eventId", { immediate: true })
|
2020-09-29 07:53:48 +00:00
|
|
|
resetFormForCreation(eventId: string): void {
|
2020-02-18 07:57:00 +00:00
|
|
|
if (eventId === undefined) {
|
|
|
|
this.event = new EventModel();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private initializeEvent() {
|
2020-12-10 11:16:35 +00: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 15:19:30 +00:00
|
|
|
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;
|
2020-10-13 14:57:36 +00:00
|
|
|
}
|
|
|
|
|
2021-03-29 08:33:19 +00:00
|
|
|
get organizerActor(): IActor {
|
|
|
|
if (this.event?.attributedTo?.id) {
|
|
|
|
return this.event.attributedTo;
|
|
|
|
}
|
|
|
|
if (this.event?.organizerActor?.id) {
|
2020-10-13 14:57:36 +00:00
|
|
|
return this.event.organizerActor;
|
|
|
|
}
|
|
|
|
return this.currentActor;
|
2019-06-07 15:19:30 +00:00
|
|
|
}
|
|
|
|
|
2021-03-29 08:33:19 +00: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;
|
|
|
|
}
|
|
|
|
|
2021-08-13 10:24:12 +00:00
|
|
|
get eventOptions(): IEventOptions {
|
|
|
|
return removeTypeName(cloneDeep(this.event.options));
|
|
|
|
}
|
|
|
|
|
|
|
|
set eventOptions(options: IEventOptions) {
|
|
|
|
this.event.options = options;
|
|
|
|
}
|
|
|
|
|
2020-09-29 07:53:48 +00:00
|
|
|
async mounted(): Promise<void> {
|
2020-02-18 07:57:00 +00:00
|
|
|
this.observer = new IntersectionObserver(
|
|
|
|
(entries) => {
|
2020-09-29 07:53:48 +00:00
|
|
|
// eslint-disable-next-line no-restricted-syntax
|
2020-02-18 07:57:00 +00:00
|
|
|
for (const entry of entries) {
|
|
|
|
if (entry) {
|
|
|
|
this.showFixedNavbar = !entry.isIntersecting;
|
|
|
|
}
|
2019-10-01 18:10:53 +00:00
|
|
|
}
|
2020-02-18 07:57:00 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
rootMargin: "-50px 0px -50px",
|
2019-10-01 18:10:53 +00:00
|
|
|
}
|
2020-02-18 07:57:00 +00:00
|
|
|
);
|
2019-10-01 18:10:53 +00:00
|
|
|
this.observer.observe(this.$refs.bottomObserver as Element);
|
2020-02-18 07:57:00 +00:00
|
|
|
|
2020-11-26 10:41:13 +00:00
|
|
|
this.pictureFile = await buildFileFromIMedia(this.event.picture);
|
2021-08-13 10:24:12 +00:00
|
|
|
this.limitedPlaces = this.eventOptions.maximumAttendeeCapacity > 0;
|
2020-06-15 16:12:49 +00:00
|
|
|
if (!(this.isUpdate || this.isDuplicate)) {
|
|
|
|
this.initializeEvent();
|
2020-10-09 16:12:35 +00:00
|
|
|
} else {
|
2021-08-11 14:06:30 +00:00
|
|
|
this.event = new EventModel({
|
2021-05-17 07:38:04 +00:00
|
|
|
...this.event,
|
2021-06-27 16:17:24 +00:00
|
|
|
options: cloneDeep(this.event.options),
|
2021-05-17 07:38:04 +00:00
|
|
|
description: this.event.description || "",
|
2021-08-11 14:06:30 +00:00
|
|
|
});
|
2020-06-15 16:12:49 +00:00
|
|
|
}
|
2021-08-11 14:06:30 +00:00
|
|
|
this.unmodifiedEvent = cloneDeep(this.event);
|
2019-10-01 18:10:53 +00:00
|
|
|
}
|
|
|
|
|
2020-09-29 07:53:48 +00:00
|
|
|
createOrUpdateDraft(e: Event): void {
|
2019-01-21 14:08:22 +00:00
|
|
|
e.preventDefault();
|
2019-10-02 15:59:07 +00:00
|
|
|
if (this.validateForm()) {
|
2020-10-08 14:16:42 +00:00
|
|
|
if (this.eventId && !this.isDuplicate) {
|
|
|
|
this.updateEvent();
|
|
|
|
} else {
|
|
|
|
this.createEvent();
|
|
|
|
}
|
2019-10-02 15:59:07 +00:00
|
|
|
}
|
|
|
|
}
|
2019-09-02 12:35:50 +00:00
|
|
|
|
2020-09-29 07:53:48 +00:00
|
|
|
createOrUpdatePublish(e: Event): void {
|
2020-10-01 16:25:57 +00:00
|
|
|
e.preventDefault();
|
2019-10-02 15:59:07 +00: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 12:35:50 +00:00
|
|
|
}
|
|
|
|
|
2020-09-29 07:53:48 +00:00
|
|
|
async createEvent(): Promise<void> {
|
2020-10-01 16:25:57 +00:00
|
|
|
this.saving = true;
|
2019-10-14 09:41:57 +00:00
|
|
|
const variables = await this.buildVariables();
|
|
|
|
|
2019-10-09 12:55:45 +00:00
|
|
|
try {
|
2021-06-11 12:21:27 +00:00
|
|
|
const { data } = await this.$apollo.mutate<{ createEvent: IEvent }>({
|
2019-10-09 12:55:45 +00:00
|
|
|
mutation: CREATE_EVENT,
|
2019-10-14 09:41:57 +00:00
|
|
|
variables,
|
2021-05-12 16:10:07 +00:00
|
|
|
update: (
|
2021-06-11 12:21:27 +00:00
|
|
|
store: ApolloCache<{ createEvent: IEvent }>,
|
2021-05-12 16:10:07 +00:00
|
|
|
{ data: updatedData }: FetchResult
|
|
|
|
) => this.postCreateOrUpdate(store, updatedData?.createEvent),
|
|
|
|
refetchQueries: ({ data: updatedData }: FetchResult) =>
|
|
|
|
this.postRefetchQueries(updatedData?.createEvent),
|
2019-10-09 12:55:45 +00:00
|
|
|
});
|
|
|
|
|
2019-10-13 11:56:24 +00:00
|
|
|
this.$buefy.notification.open({
|
2020-02-18 07:57:00 +00: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 11:56:24 +00:00
|
|
|
duration: 5000,
|
|
|
|
});
|
2021-06-11 13:08:53 +00:00
|
|
|
if (data?.createEvent) {
|
|
|
|
await this.$router.push({
|
|
|
|
name: "Event",
|
|
|
|
params: { uuid: data.createEvent.uuid },
|
|
|
|
});
|
|
|
|
}
|
2019-10-09 12:55:45 +00:00
|
|
|
} catch (err) {
|
2020-10-01 16:25:57 +00:00
|
|
|
this.saving = false;
|
2019-10-09 12:55:45 +00:00
|
|
|
console.error(err);
|
2020-10-09 14:07:13 +00:00
|
|
|
this.handleError(err);
|
2019-10-09 12:55:45 +00:00
|
|
|
}
|
2019-09-02 12:35:50 +00:00
|
|
|
}
|
|
|
|
|
2020-09-29 07:53:48 +00:00
|
|
|
async updateEvent(): Promise<void> {
|
2020-10-01 16:25:57 +00:00
|
|
|
this.saving = true;
|
2019-10-14 09:41:57 +00:00
|
|
|
const variables = await this.buildVariables();
|
|
|
|
|
2019-09-02 12:35:50 +00:00
|
|
|
try {
|
2021-06-11 12:21:27 +00:00
|
|
|
await this.$apollo.mutate<{ updateEvent: IEvent }>({
|
2019-09-02 12:35:50 +00:00
|
|
|
mutation: EDIT_EVENT,
|
2019-10-14 09:41:57 +00:00
|
|
|
variables,
|
2021-05-12 16:10:07 +00:00
|
|
|
update: (
|
2021-06-11 12:21:27 +00:00
|
|
|
store: ApolloCache<{ updateEvent: IEvent }>,
|
2021-05-12 16:10:07 +00:00
|
|
|
{ data: updatedData }: FetchResult
|
|
|
|
) => this.postCreateOrUpdate(store, updatedData?.updateEvent),
|
|
|
|
refetchQueries: ({ data }: FetchResult) =>
|
|
|
|
this.postRefetchQueries(data?.updateEvent),
|
2019-09-02 12:35:50 +00:00
|
|
|
});
|
|
|
|
|
2019-10-13 11:56:24 +00:00
|
|
|
this.$buefy.notification.open({
|
|
|
|
message: this.updateEventMessage,
|
2020-02-18 07:57:00 +00:00
|
|
|
type: "is-success",
|
|
|
|
position: "is-bottom-right",
|
2019-10-13 11:56:24 +00:00
|
|
|
duration: 5000,
|
|
|
|
});
|
2019-09-04 16:24:31 +00:00
|
|
|
await this.$router.push({
|
2020-02-18 07:57:00 +00:00
|
|
|
name: "Event",
|
2019-09-02 12:35:50 +00:00
|
|
|
params: { uuid: this.eventId as string },
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-10-01 16:25:57 +00:00
|
|
|
this.saving = false;
|
2020-10-09 14:07:13 +00:00
|
|
|
this.handleError(err);
|
2019-01-21 14:08:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-23 13:56:35 +00:00
|
|
|
get hasCurrentActorPermissionsToEdit(): boolean {
|
2020-10-09 16:12:35 +00:00
|
|
|
return !(
|
|
|
|
this.eventId &&
|
2021-02-05 13:45:39 +00:00
|
|
|
this.event.organizerActor?.id !== undefined &&
|
2021-03-29 08:33:19 +00:00
|
|
|
!this.identities
|
|
|
|
.map(({ id }) => id)
|
2021-07-23 13:56:35 +00:00
|
|
|
.includes(this.event.organizerActor?.id) &&
|
|
|
|
!this.hasGroupPrivileges
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
get hasGroupPrivileges(): boolean {
|
|
|
|
return (
|
|
|
|
this.person?.memberships?.total > 0 &&
|
|
|
|
[MemberRole.MODERATOR, MemberRole.ADMINISTRATOR].includes(
|
|
|
|
this.person?.memberships?.elements[0].role
|
|
|
|
)
|
2021-03-29 08:33:19 +00:00
|
|
|
);
|
2020-10-09 16:12:35 +00:00
|
|
|
}
|
|
|
|
|
2019-10-13 11:56:24 +00:00
|
|
|
get updateEventMessage(): string {
|
2021-08-11 14:06:30 +00:00
|
|
|
if (this.unmodifiedEvent.draft && !this.event.draft)
|
|
|
|
return this.$i18n.t("The event has been updated and published") as string;
|
2021-05-17 17:01:08 +00: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 11:56:24 +00:00
|
|
|
}
|
|
|
|
|
2020-10-09 14:07:13 +00: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 16:28:25 +00: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 07:57:00 +00:00
|
|
|
private postCreateOrUpdate(store: any, updateEvent: IEvent) {
|
|
|
|
const resultEvent: IEvent = { ...updateEvent };
|
2021-10-10 14:25:50 +00:00
|
|
|
console.debug("resultEvent", resultEvent);
|
2019-10-04 16:28:25 +00:00
|
|
|
if (!updateEvent.draft) {
|
|
|
|
store.writeQuery({
|
|
|
|
query: EVENT_PERSON_PARTICIPATION,
|
2020-02-18 07:57:00 +00:00
|
|
|
variables: {
|
2021-06-10 08:31:59 +00:00
|
|
|
eventId: resultEvent.id,
|
|
|
|
name: resultEvent.organizerActor?.preferredUsername,
|
2020-02-18 07:57:00 +00:00
|
|
|
},
|
2019-10-04 16:28:25 +00:00
|
|
|
data: {
|
|
|
|
person: {
|
2020-02-18 07:57:00 +00:00
|
|
|
__typename: "Person",
|
2021-06-10 08:31:59 +00:00
|
|
|
id: resultEvent?.organizerActor?.id,
|
2020-06-15 16:12:49 +00:00
|
|
|
participations: {
|
2020-11-20 17:34:13 +00:00
|
|
|
__typename: "PaginatedParticipantList",
|
2020-06-15 16:12:49 +00:00
|
|
|
total: 1,
|
|
|
|
elements: [
|
|
|
|
{
|
|
|
|
__typename: "Participant",
|
|
|
|
id: "unknown",
|
|
|
|
role: ParticipantRole.CREATOR,
|
|
|
|
actor: {
|
|
|
|
__typename: "Actor",
|
2021-06-10 08:31:59 +00:00
|
|
|
id: resultEvent?.organizerActor?.id,
|
2020-06-15 16:12:49 +00:00
|
|
|
},
|
|
|
|
event: {
|
|
|
|
__typename: "Event",
|
2021-06-10 08:31:59 +00:00
|
|
|
id: resultEvent.id,
|
2020-06-15 16:12:49 +00:00
|
|
|
},
|
2020-02-18 07:57:00 +00:00
|
|
|
},
|
2020-06-15 16:12:49 +00:00
|
|
|
],
|
|
|
|
},
|
2019-10-04 16:28:25 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-18 07:57:00 +00:00
|
|
|
/**
|
|
|
|
* Refresh drafts or participation cache depending if the event is still draft or not
|
|
|
|
*/
|
2020-09-29 07:53:48 +00:00
|
|
|
// eslint-disable-next-line class-methods-use-this
|
2021-08-02 16:11:22 +00:00
|
|
|
private postRefetchQueries(
|
|
|
|
updateEvent: IEvent
|
|
|
|
): InternalRefetchQueriesInclude {
|
2019-10-04 16:28:25 +00:00
|
|
|
if (updateEvent.draft) {
|
2020-02-18 07:57:00 +00:00
|
|
|
return [
|
|
|
|
{
|
|
|
|
query: LOGGED_USER_DRAFTS,
|
|
|
|
},
|
|
|
|
];
|
2019-10-04 16:28:25 +00:00
|
|
|
}
|
2020-02-18 07:57:00 +00:00
|
|
|
return [
|
|
|
|
{
|
|
|
|
query: LOGGED_USER_PARTICIPATIONS,
|
|
|
|
variables: {
|
|
|
|
afterDateTime: new Date(),
|
|
|
|
},
|
2019-10-04 16:28:25 +00:00
|
|
|
},
|
2020-02-18 07:57:00 +00:00
|
|
|
];
|
2019-10-04 16:28:25 +00:00
|
|
|
}
|
|
|
|
|
2021-03-29 08:33:19 +00:00
|
|
|
get organizerActorEqualToCurrentActor(): boolean {
|
|
|
|
return (
|
|
|
|
this.currentActor?.id !== undefined &&
|
|
|
|
this.organizerActor?.id === this.currentActor?.id
|
|
|
|
);
|
2020-09-29 07:53:48 +00:00
|
|
|
}
|
|
|
|
|
2019-07-23 15:14:03 +00:00
|
|
|
/**
|
|
|
|
* Build variables for Event GraphQL creation query
|
|
|
|
*/
|
2019-10-14 09:41:57 +00:00
|
|
|
private async buildVariables() {
|
2021-08-13 10:24:12 +00:00
|
|
|
let res = {
|
|
|
|
...toEditJSON(new EventModel(this.event)),
|
|
|
|
options: this.eventOptions,
|
|
|
|
};
|
2021-10-10 14:25:50 +00:00
|
|
|
|
|
|
|
console.debug(this.event.beginsOn?.toISOString());
|
|
|
|
|
|
|
|
// if (this.event.beginsOn && this.timezone) {
|
|
|
|
// console.debug(
|
|
|
|
// "begins on should be",
|
|
|
|
// zonedTimeToUtc(this.event.beginsOn, this.timezone).toISOString()
|
|
|
|
// );
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (this.event.beginsOn && this.timezone) {
|
|
|
|
// res.beginsOn = zonedTimeToUtc(
|
|
|
|
// this.event.beginsOn,
|
|
|
|
// this.timezone
|
|
|
|
// ).toISOString();
|
|
|
|
// }
|
|
|
|
|
2021-03-29 17:26:33 +00:00
|
|
|
const organizerActor = this.event.organizerActor?.id
|
|
|
|
? this.event.organizerActor
|
|
|
|
: this.organizerActor;
|
|
|
|
if (organizerActor) {
|
2021-05-17 07:38:04 +00:00
|
|
|
res = { ...res, organizerActorId: organizerActor?.id };
|
2020-02-18 07:57:00 +00:00
|
|
|
}
|
2021-03-29 08:33:19 +00:00
|
|
|
const attributedToId = this.event.attributedTo?.id
|
|
|
|
? this.event.attributedTo.id
|
|
|
|
: null;
|
2021-05-17 07:38:04 +00:00
|
|
|
res = { ...res, attributedToId };
|
2019-07-23 15:14:03 +00:00
|
|
|
|
2020-11-20 17:34:13 +00:00
|
|
|
if (this.pictureFile) {
|
|
|
|
const pictureObj = buildFileVariable(this.pictureFile, "picture");
|
|
|
|
res = { ...res, ...pictureObj };
|
|
|
|
}
|
2019-10-14 09:41:57 +00:00
|
|
|
|
2019-11-15 17:36:47 +00:00
|
|
|
try {
|
2020-11-20 17:34:13 +00:00
|
|
|
if (this.event.picture && this.pictureFile) {
|
2020-11-30 09:24:11 +00:00
|
|
|
const oldPictureFile = (await buildFileFromIMedia(
|
|
|
|
this.event.picture
|
|
|
|
)) as File;
|
2019-11-15 17:36:47 +00:00
|
|
|
const oldPictureFileContent = await readFileAsync(oldPictureFile);
|
2020-11-30 09:24:11 +00:00
|
|
|
const newPictureFileContent = await readFileAsync(
|
|
|
|
this.pictureFile as File
|
|
|
|
);
|
2019-11-15 17:36:47 +00:00
|
|
|
if (oldPictureFileContent === newPictureFileContent) {
|
2020-11-26 10:41:13 +00:00
|
|
|
res.picture = { mediaId: this.event.picture.id };
|
2019-11-15 17:36:47 +00:00
|
|
|
}
|
2019-10-14 09:41:57 +00:00
|
|
|
}
|
2019-11-15 17:36:47 +00:00
|
|
|
} catch (e) {
|
|
|
|
console.error(e);
|
2019-10-14 09:41:57 +00:00
|
|
|
}
|
|
|
|
return res;
|
2019-05-22 12:12:11 +00:00
|
|
|
}
|
|
|
|
|
2020-02-18 07:57:00 +00:00
|
|
|
@Watch("limitedPlaces")
|
2020-09-29 07:53:48 +00:00
|
|
|
updatedEventCapacityOptions(limitedPlaces: boolean): void {
|
2019-12-15 21:42:38 +00:00
|
|
|
if (!limitedPlaces) {
|
2021-08-13 10:24:12 +00:00
|
|
|
this.eventOptions.maximumAttendeeCapacity = 0;
|
|
|
|
this.eventOptions.remainingAttendeeCapacity = 0;
|
|
|
|
this.eventOptions.showRemainingAttendeeCapacity = false;
|
2019-12-15 21:42:38 +00:00
|
|
|
} else {
|
2021-08-13 10:24:12 +00:00
|
|
|
this.eventOptions.maximumAttendeeCapacity =
|
|
|
|
this.eventOptions.maximumAttendeeCapacity ||
|
2020-11-30 09:24:11 +00:00
|
|
|
DEFAULT_LIMIT_NUMBER_OF_PLACES;
|
2019-12-10 21:40:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-30 15:40:41 +00:00
|
|
|
get needsApproval(): boolean {
|
|
|
|
return this.event?.joinOptions == EventJoinOptions.RESTRICTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
set needsApproval(value: boolean) {
|
|
|
|
if (value === true) {
|
2019-09-20 16:22:03 +00:00
|
|
|
this.event.joinOptions = EventJoinOptions.RESTRICTED;
|
|
|
|
} else {
|
|
|
|
this.event.joinOptions = EventJoinOptions.FREE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-29 07:53:48 +00:00
|
|
|
get checkTitleLength(): Array<string | undefined> {
|
2020-02-18 07:57:00 +00:00
|
|
|
return this.event.title.length > 80
|
2020-09-29 07:53:48 +00:00
|
|
|
? ["is-info", this.$t("The event title will be ellipsed.") as string]
|
2020-02-18 07:57:00 +00:00
|
|
|
: [undefined, undefined];
|
2019-09-23 09:51:59 +00:00
|
|
|
}
|
|
|
|
|
2019-10-01 18:10:53 +00:00
|
|
|
/**
|
|
|
|
* Confirm cancel
|
|
|
|
*/
|
2021-08-11 14:06:30 +00:00
|
|
|
confirmGoElsewhere(): Promise<boolean> {
|
|
|
|
// TODO: Make calculation of changes work again and bring this back
|
|
|
|
// If the event wasn't modified, no need to warn
|
|
|
|
// if (!this.isEventModified) {
|
|
|
|
// return Promise.resolve(true);
|
|
|
|
// }
|
2020-02-18 07:57:00 +00: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 18:10:53 +00:00
|
|
|
|
2021-08-11 14:06:30 +00:00
|
|
|
return new Promise((resolve) => {
|
|
|
|
this.$buefy.dialog.confirm({
|
|
|
|
title,
|
|
|
|
message,
|
|
|
|
confirmText: this.$t("Abandon editing") as string,
|
|
|
|
cancelText: this.$t("Continue editing") as string,
|
|
|
|
type: "is-warning",
|
|
|
|
hasIcon: true,
|
|
|
|
onConfirm: () => resolve(true),
|
|
|
|
onCancel: () => resolve(false),
|
|
|
|
});
|
2019-10-01 18:10:53 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-10-09 15:18:27 +00:00
|
|
|
/**
|
|
|
|
* Confirm cancel
|
|
|
|
*/
|
2020-09-29 07:53:48 +00:00
|
|
|
confirmGoBack(): void {
|
2021-08-11 14:06:30 +00:00
|
|
|
this.$router.go(-1);
|
2019-10-09 15:18:27 +00:00
|
|
|
}
|
|
|
|
|
2020-11-27 18:27:44 +00:00
|
|
|
// eslint-disable-next-line consistent-return
|
2021-08-11 14:06:30 +00:00
|
|
|
async beforeRouteLeave(
|
|
|
|
to: Route,
|
|
|
|
from: Route,
|
|
|
|
next: (to?: RawLocation | false | ((vm: any) => void)) => void
|
|
|
|
): Promise<void> {
|
2019-10-09 17:41:17 +00:00
|
|
|
if (to.name === RouteName.EVENT) return next();
|
2021-08-11 14:06:30 +00:00
|
|
|
if (await this.confirmGoElsewhere()) {
|
|
|
|
return next();
|
|
|
|
}
|
|
|
|
return next(false);
|
2019-10-09 15:54:35 +00:00
|
|
|
}
|
|
|
|
|
2019-10-01 18:10:53 +00:00
|
|
|
get isEventModified(): boolean {
|
2021-08-11 14:06:30 +00:00
|
|
|
return (
|
|
|
|
this.event &&
|
|
|
|
this.unmodifiedEvent &&
|
|
|
|
JSON.stringify(toEditJSON(this.event)) !==
|
|
|
|
JSON.stringify(this.unmodifiedEvent)
|
|
|
|
);
|
2019-10-01 18:10:53 +00:00
|
|
|
}
|
|
|
|
|
2021-10-10 14:25:50 +00:00
|
|
|
get beginsOn(): Date | null {
|
|
|
|
// if (this.timezone && this.event.beginsOn) {
|
|
|
|
// return utcToZonedTime(this.event.beginsOn, this.timezone);
|
|
|
|
// }
|
2020-02-18 07:57:00 +00:00
|
|
|
return this.event.beginsOn;
|
|
|
|
}
|
2019-10-09 10:54:09 +00:00
|
|
|
|
2021-10-10 14:25:50 +00:00
|
|
|
set beginsOn(beginsOn: Date | null) {
|
|
|
|
this.event.beginsOn = beginsOn;
|
|
|
|
if (!this.event.endsOn || !beginsOn) return;
|
2019-10-09 10:54:09 +00:00
|
|
|
const dateBeginsOn = new Date(beginsOn);
|
|
|
|
const dateEndsOn = new Date(this.event.endsOn);
|
|
|
|
if (dateEndsOn < dateBeginsOn) {
|
|
|
|
this.event.endsOn = dateBeginsOn;
|
2019-12-09 23:10:12 +00:00
|
|
|
this.event.endsOn.setHours(dateBeginsOn.getHours() + 1);
|
2019-10-09 10:54:09 +00:00
|
|
|
}
|
|
|
|
if (dateEndsOn === dateBeginsOn) {
|
2019-10-14 17:29:18 +00:00
|
|
|
this.event.endsOn.setHours(dateEndsOn.getHours() + 1);
|
2019-10-09 10:54:09 +00:00
|
|
|
}
|
|
|
|
}
|
2019-10-11 16:41:29 +00:00
|
|
|
|
2021-10-10 14:25:50 +00:00
|
|
|
get endsOn(): Date | null {
|
|
|
|
// if (this.event.endsOn && this.timezone) {
|
|
|
|
// return utcToZonedTime(this.event.endsOn, this.timezone);
|
|
|
|
// }
|
|
|
|
return this.event.endsOn;
|
|
|
|
}
|
|
|
|
|
|
|
|
set endsOn(endsOn: Date | null) {
|
|
|
|
this.event.endsOn = endsOn;
|
|
|
|
}
|
|
|
|
|
|
|
|
get timezones(): Record<string, string[]> {
|
|
|
|
if (!this.config || !this.config.timezones) return {};
|
|
|
|
return this.config.timezones.reduce(
|
|
|
|
(acc: { [key: string]: Array<string> }, val: string) => {
|
|
|
|
const components = val.split("/");
|
|
|
|
const [prefix, suffix] = [
|
|
|
|
components.shift() as string,
|
|
|
|
components.join("/"),
|
|
|
|
];
|
|
|
|
const pushOrCreate = (
|
|
|
|
acc2: { [key: string]: Array<string> },
|
|
|
|
prefix2: string,
|
|
|
|
suffix2: string
|
|
|
|
) => {
|
|
|
|
// eslint-disable-next-line no-param-reassign
|
|
|
|
(acc2[prefix2] = acc2[prefix2] || []).push(suffix2);
|
|
|
|
return acc2;
|
|
|
|
};
|
|
|
|
if (suffix) {
|
|
|
|
return pushOrCreate(acc, prefix, suffix);
|
|
|
|
}
|
|
|
|
return pushOrCreate(acc, this.$t("Other") as string, prefix);
|
|
|
|
},
|
|
|
|
{}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// eslint-disable-next-line class-methods-use-this
|
|
|
|
sanitizeTimezone(timezone: string): string {
|
|
|
|
return timezone
|
|
|
|
.split("_")
|
|
|
|
.join(" ")
|
|
|
|
.replace("St ", "St. ")
|
|
|
|
.split("/")
|
|
|
|
.join(" - ");
|
|
|
|
}
|
|
|
|
|
|
|
|
get timezone(): string | null {
|
|
|
|
return this.event.options.timezone;
|
|
|
|
}
|
|
|
|
|
|
|
|
set timezone(timezone: string | null) {
|
|
|
|
this.event.options = {
|
|
|
|
...this.event.options,
|
|
|
|
timezone,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
get userTimezone(): string | undefined {
|
|
|
|
return this.loggedUser?.settings?.timezone;
|
|
|
|
}
|
|
|
|
|
|
|
|
get userActualTimezone(): string {
|
|
|
|
if (this.userTimezone) {
|
|
|
|
return this.userTimezone;
|
|
|
|
}
|
|
|
|
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
|
|
}
|
|
|
|
|
|
|
|
tzOffset(date: Date): number {
|
|
|
|
if (this.timezone && date) {
|
|
|
|
const eventUTCOffset = getTimezoneOffset(this.timezone, date);
|
|
|
|
const localUTCOffset = getTimezoneOffset(this.userActualTimezone);
|
|
|
|
return (eventUTCOffset - localUTCOffset) / (60 * 1000);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
get eventPhysicalAddress(): IAddress | null {
|
|
|
|
return this.event.physicalAddress;
|
|
|
|
}
|
|
|
|
|
|
|
|
set eventPhysicalAddress(address: IAddress | null) {
|
|
|
|
if (address && address.timezone) {
|
|
|
|
this.timezone = address.timezone;
|
|
|
|
}
|
|
|
|
this.event.physicalAddress = address;
|
2019-10-11 16:41:29 +00:00
|
|
|
}
|
2021-10-15 13:59:49 +00:00
|
|
|
|
|
|
|
get isOnline(): boolean {
|
|
|
|
return this.event.options.isOnline;
|
|
|
|
}
|
|
|
|
|
|
|
|
set isOnline(isOnline: boolean) {
|
|
|
|
this.event.options = {
|
|
|
|
...this.event.options,
|
|
|
|
isOnline,
|
|
|
|
};
|
|
|
|
}
|
2019-01-21 14:08:22 +00:00
|
|
|
}
|
2019-09-02 12:35:50 +00:00
|
|
|
</script>
|