add duplicate event

This commit is contained in:
setop 2020-04-23 00:27:09 +02:00 committed by Thomas Citharel
parent a56ebe8dab
commit 09af783ee3
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773
9 changed files with 92 additions and 15 deletions

View file

@ -98,6 +98,20 @@
>{{ $t("Edit") }}</b-button >{{ $t("Edit") }}</b-button
> >
</li> </li>
<li>
<b-button
type="is-text"
@click="
gotToWithCheck(participation, {
name: RouteName.DUPLICATE_EVENT,
params: { eventId: participation.event.uuid },
})
"
icon-left="content-duplicate"
>
{{ $t("Duplicate") }}
</b-button>
</li>
<li <li
v-if=" v-if="
![ParticipantRole.PARTICIPANT, ParticipantRole.NOT_APPROVED].includes( ![ParticipantRole.PARTICIPANT, ParticipantRole.NOT_APPROVED].includes(

View file

@ -567,5 +567,22 @@
"List title": "List title", "List title": "List title",
"Create a new list": "Create a new list", "Create a new list": "Create a new list",
"Your timezone is currently set to {timezone}.": "Your timezone is currently set to {timezone}.", "Your timezone is currently set to {timezone}.": "Your timezone is currently set to {timezone}.",
"Timezone detected as {timezone}.": "Timezone detected as {timezone}." "Timezone detected as {timezone}.": "Timezone detected as {timezone}.",
"Bold": "Bold",
"Italic": "Italic",
"Duplicate": "Duplicate",
"Home": "Home",
"Important event updates": "Important event updates",
"Like title update, start or end date change, event being confirmed or cancelled.": "Like title update, start or end date change, event being confirmed or cancelled.",
"Notification on the day of the event": "Notification on the day of the event",
"We'll use your timezone settings to send a recap of the morning of the event.": "We'll use your timezone settings to send a recap of the morning of the event.",
"You can pick your timezone into your preferences.": "You can pick your timezone into your preferences.",
"Recap every week": "Recap every week",
"You'll get a weekly recap every Monday for upcoming events, if you have any.": "You'll get a weekly recap every Monday for upcoming events, if you have any.",
"Notification before the event": "Notification before the event",
"We'll send you an email one hour before the event begins, to be sure you won't forget about it.": "We'll send you an email one hour before the event begins, to be sure you won't forget about it.",
"Timezone": "Timezone",
"Select a timezone": "Select a timezone",
"Other": "Other",
"No moderation logs yet": "No moderation logs yet"
} }

View file

@ -570,5 +570,24 @@
"Task lists": "Listes de tâches", "Task lists": "Listes de tâches",
"Add a todo": "Ajouter un todo", "Add a todo": "Ajouter un todo",
"List title": "Titre de la liste", "List title": "Titre de la liste",
"Create a new list": "Créer une nouvelle liste" "Create a new list": "Créer une nouvelle liste",
"Timezone detected as {timezone}.": "Fuseau horaire détecté en tant que {timezone}.",
"Your timezone is currently set to {timezone}.": "Votre fuseau horaire est actuellement défini à {timezone}.",
"Bold": "Gras",
"Italic": "Italique",
"Duplicate": "Dupliquer",
"Home": "Accueil",
"Important event updates": "Mises à jour importantes des événements",
"Like title update, start or end date change, event being confirmed or cancelled.": "Comme le changement du titre de l'événement, de sa date de début ou de fin, ou bien qu'il soit confirmé ou bien annulé.",
"Notification on the day of the event": "Notification le jour de l'événement",
"We'll use your timezone settings to send a recap of the morning of the event.": "Nous prendrons en compte votre fuseau horaire pour vous envoyer un récapitulatif de vos événements le matin.",
"You can pick your timezone into your preferences.": "Vous pouvez choisir votre fuseau horaire dans vos préférences.",
"Recap every week": "Récapitulatif hebdomadaire",
"You'll get a weekly recap every Monday for upcoming events, if you have any.": "Vous recevrez un récapitulatif hebdomadaire chaque lundi pour les événements de la semaine, si vous en avez.",
"Notification before the event": "Notification avant l'événement",
"We'll send you an email one hour before the event begins, to be sure you won't forget about it.": "Nous vous enverrons un email une heure avant que l'événement débute, pour être sûr que vous ne l'oubliez pas.",
"Timezone": "Fuseau horaire",
"Select a timezone": "Selectionnez un fuseau horaire",
"Other": "Autre",
"No moderation logs yet": "Pas encore de journaux de modération"
} }

View file

@ -1,4 +1,4 @@
import { RouteConfig } from "vue-router"; import { RouteConfig, Route } from "vue-router";
import EventList from "../views/Event/EventList.vue"; import EventList from "../views/Event/EventList.vue";
import Location from "../views/Location.vue"; import Location from "../views/Location.vue";
@ -15,6 +15,7 @@ export enum EventRouteName {
MY_EVENTS = "MyEvents", MY_EVENTS = "MyEvents",
EXPLORE = "Explore", EXPLORE = "Explore",
EDIT_EVENT = "EditEvent", EDIT_EVENT = "EditEvent",
DUPLICATE_EVENT = "DuplicateEvent",
PARTICIPATIONS = "Participations", PARTICIPATIONS = "Participations",
EVENT = "Event", EVENT = "Event",
EVENT_PARTICIPATE_WITH_ACCOUNT = "EVENT_PARTICIPATE_WITH_ACCOUNT", EVENT_PARTICIPATE_WITH_ACCOUNT = "EVENT_PARTICIPATE_WITH_ACCOUNT",
@ -55,7 +56,14 @@ export const eventRoutes: RouteConfig[] = [
name: EventRouteName.EDIT_EVENT, name: EventRouteName.EDIT_EVENT,
component: editEvent, component: editEvent,
meta: { requiredAuth: true }, meta: { requiredAuth: true },
props: true, props: (route: Route) => ({ ...route.params, ...{ isUpdate: true } }),
},
{
path: "/events/duplicate/:eventId",
name: EventRouteName.DUPLICATE_EVENT,
component: editEvent,
meta: { requiredAuth: true },
props: (route: Route) => ({ ...route.params, ...{ isDuplicate: true } }),
}, },
{ {
path: "/events/:eventId/participations", path: "/events/:eventId/participations",

View file

@ -1,8 +1,12 @@
<template> <template>
<section> <section>
<div class="container"> <div class="container">
<h1 class="title" v-if="isUpdate === false">{{ $t("Create a new event") }}</h1> <h1 class="title" v-if="isUpdate === true">
<h1 class="title" v-else>{{ $t("Update event {name}", { name: event.title }) }}</h1> {{ $t("Update event {name}", { name: event.title }) }}
</h1>
<h1 class="title" v-else>
{{ $t("Create a new event") }}
</h1>
<form ref="form"> <form ref="form">
<subtitle>{{ $t("General information") }}</subtitle> <subtitle>{{ $t("General information") }}</subtitle>
@ -404,6 +408,10 @@ const DEFAULT_LIMIT_NUMBER_OF_PLACES = 10;
export default class EditEvent extends Vue { export default class EditEvent extends Vue {
@Prop({ required: false, type: String }) eventId: undefined | string; @Prop({ required: false, type: String }) eventId: undefined | string;
@Prop({ type: Boolean, default: false }) isUpdate!: boolean;
@Prop({ type: Boolean, default: false }) isDuplicate!: boolean;
currentActor = new Person(); currentActor = new Person();
tags: ITag[] = []; tags: ITag[] = [];
@ -441,10 +449,6 @@ export default class EditEvent extends Vue {
this.unmodifiedEvent = JSON.parse(JSON.stringify(this.event.toEditJSON())); this.unmodifiedEvent = JSON.parse(JSON.stringify(this.event.toEditJSON()));
} }
get isUpdate(): boolean {
return this.eventId !== undefined;
}
@Watch("eventId", { immediate: true }) @Watch("eventId", { immediate: true })
resetFormForCreation(eventId: string) { resetFormForCreation(eventId: string) {
if (eventId === undefined) { if (eventId === undefined) {
@ -491,7 +495,7 @@ export default class EditEvent extends Vue {
createOrUpdateDraft(e: Event) { createOrUpdateDraft(e: Event) {
e.preventDefault(); e.preventDefault();
if (this.validateForm()) { if (this.validateForm()) {
if (this.eventId) return this.updateEvent(); if (this.eventId && !this.isDuplicate) return this.updateEvent();
return this.createEvent(); return this.createEvent();
} }
@ -716,6 +720,11 @@ export default class EditEvent extends Vue {
if (result.data.event.endsOn === null) { if (result.data.event.endsOn === null) {
this.endsOnNull = true; this.endsOnNull = true;
} }
// as stated here : https://github.com/elixir-ecto/ecto/issues/1684
// "Ecto currently silently transforms empty strings into nil"
if (result.data.event.description === null) {
result.data.event.description = "";
}
return new EventModel(result.data.event); return new EventModel(result.data.event);
} }

View file

@ -230,6 +230,18 @@
<b-icon icon="pencil" /> <b-icon icon="pencil" />
</router-link> </router-link>
</b-dropdown-item> </b-dropdown-item>
<b-dropdown-item
aria-role="listitem"
has-link
v-if="actorIsOrganizer || event.draft"
>
<router-link
:to="{ name: RouteName.DUPLICATE_EVENT, params: { eventId: event.uuid } }"
>
{{ $t("Duplicate") }}
<b-icon icon="content-duplicate" />
</router-link>
</b-dropdown-item>
<b-dropdown-item <b-dropdown-item
aria-role="listitem" aria-role="listitem"
v-if="actorIsOrganizer || event.draft" v-if="actorIsOrganizer || event.draft"

View file

@ -42,7 +42,7 @@
</li> </li>
</ul> </ul>
<div v-else> <div v-else>
<b-message type="is-info">No moderation logs yet</b-message> <b-message type="is-info">{{ $t('No moderation logs yet') }}</b-message>
</div> </div>
</section> </section>
</template> </template>

View file

@ -1,6 +1,5 @@
<template> <template>
<div v-if="loggedUser"> <div v-if="loggedUser">
<h2 class="subtitle">{{ $t("No notification settings yet") }}</h2>
<div class="field"> <div class="field">
<b-checkbox disabled v-model="notificationEventUpdates"> <b-checkbox disabled v-model="notificationEventUpdates">
<strong>{{ $t("Important event updates") }}</strong> <strong>{{ $t("Important event updates") }}</strong>

View file

@ -1,6 +1,5 @@
<template> <template>
<div> <div>
<h2 class="subtitle">{{ $t("No preferences yet") }}</h2>
<b-field :label="$t('Timezone')"> <b-field :label="$t('Timezone')">
<b-select <b-select
:placeholder="$t('Select a timezone')" :placeholder="$t('Select a timezone')"