Event edit and participant fixes
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -486,6 +486,7 @@ import "intersection-observer";
|
||||
import { CONFIG } from "../../graphql/config";
|
||||
import { IConfig } from "../../types/config.model";
|
||||
import { ApolloCache, FetchResult, InMemoryCache } from "@apollo/client/core";
|
||||
import { cloneDeep } from "@apollo/client/utilities";
|
||||
|
||||
const DEFAULT_LIMIT_NUMBER_OF_PLACES = 10;
|
||||
|
||||
@@ -512,7 +513,7 @@ const DEFAULT_LIMIT_NUMBER_OF_PLACES = 10;
|
||||
};
|
||||
},
|
||||
update(data) {
|
||||
return new EventModel(data.event);
|
||||
return new EventModel(cloneDeep(data.event));
|
||||
},
|
||||
skip() {
|
||||
return !this.eventId;
|
||||
@@ -547,8 +548,6 @@ export default class EditEvent extends Vue {
|
||||
|
||||
config!: IConfig;
|
||||
|
||||
unmodifiedEvent!: IEvent;
|
||||
|
||||
pictureFile: File | null = null;
|
||||
|
||||
EventStatus = EventStatus;
|
||||
@@ -646,7 +645,11 @@ export default class EditEvent extends Vue {
|
||||
if (!(this.isUpdate || this.isDuplicate)) {
|
||||
this.initializeEvent();
|
||||
} else {
|
||||
this.event.description = this.event.description || "";
|
||||
this.event = {
|
||||
...this.event,
|
||||
options: this.event.options,
|
||||
description: this.event.description || "",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -669,27 +672,6 @@ export default class EditEvent extends Vue {
|
||||
}
|
||||
}
|
||||
|
||||
@Watch("event")
|
||||
setInitialData(): void {
|
||||
if (
|
||||
this.isUpdate &&
|
||||
this.unmodifiedEvent === undefined &&
|
||||
this.event &&
|
||||
this.event.uuid
|
||||
) {
|
||||
this.unmodifiedEvent = JSON.parse(
|
||||
JSON.stringify(this.event.toEditJSON())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// @Watch('event.attributedTo', { deep: true })
|
||||
// updateHideOrganizerWhenGroupEventOption(attributedTo) {
|
||||
// if (!attributedTo.preferredUsername) {
|
||||
// this.event.options.hideOrganizerWhenGroupEvent = false;
|
||||
// }
|
||||
// }
|
||||
|
||||
private validateForm() {
|
||||
const form = this.$refs.form as HTMLFormElement;
|
||||
if (form.checkValidity()) {
|
||||
@@ -777,8 +759,8 @@ export default class EditEvent extends Vue {
|
||||
}
|
||||
|
||||
get updateEventMessage(): string {
|
||||
if (this.unmodifiedEvent.draft && !this.event.draft)
|
||||
return this.$i18n.t("The event has been updated and published") as string;
|
||||
// if (this.unmodifiedEvent.draft && !this.event.draft)
|
||||
// return this.$i18n.t("The event has been updated and published") as string;
|
||||
return (
|
||||
this.event.draft
|
||||
? this.$i18n.t("The draft event has been updated")
|
||||
@@ -884,24 +866,12 @@ export default class EditEvent extends Vue {
|
||||
? this.event.organizerActor
|
||||
: this.organizerActor;
|
||||
if (organizerActor) {
|
||||
res = Object.assign(res, {
|
||||
organizerActorId: organizerActor.id,
|
||||
});
|
||||
res = { ...res, organizerActorId: organizerActor?.id };
|
||||
}
|
||||
const attributedToId = this.event.attributedTo?.id
|
||||
? this.event.attributedTo.id
|
||||
: null;
|
||||
res = Object.assign(res, { attributedToId });
|
||||
|
||||
// eslint-disable-next-line
|
||||
// @ts-ignore
|
||||
delete this.event.options.__typename;
|
||||
|
||||
if (this.event.physicalAddress) {
|
||||
// eslint-disable-next-line
|
||||
// @ts-ignore
|
||||
delete this.event.physicalAddress.__typename;
|
||||
}
|
||||
res = { ...res, attributedToId };
|
||||
|
||||
if (this.endsOnNull) {
|
||||
res.endsOn = null;
|
||||
@@ -931,25 +901,6 @@ export default class EditEvent extends Vue {
|
||||
return res;
|
||||
}
|
||||
|
||||
private async getEvent() {
|
||||
const result = await this.$apollo.query({
|
||||
query: FETCH_EVENT,
|
||||
variables: {
|
||||
uuid: this.eventId,
|
||||
},
|
||||
});
|
||||
|
||||
if (result.data.event.endsOn === null) {
|
||||
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);
|
||||
}
|
||||
|
||||
@Watch("limitedPlaces")
|
||||
updatedEventCapacityOptions(limitedPlaces: boolean): void {
|
||||
if (!limitedPlaces) {
|
||||
@@ -1023,10 +974,11 @@ export default class EditEvent extends Vue {
|
||||
}
|
||||
|
||||
get isEventModified(): boolean {
|
||||
return (
|
||||
JSON.stringify(this.event.toEditJSON()) !==
|
||||
JSON.stringify(this.unmodifiedEvent)
|
||||
);
|
||||
// return (
|
||||
// JSON.stringify(this.event.toEditJSON()) !==
|
||||
// JSON.stringify(this.unmodifiedEvent)
|
||||
// );
|
||||
return false;
|
||||
}
|
||||
|
||||
get beginsOn(): Date {
|
||||
|
||||
Reference in New Issue
Block a user