2020-11-27 19:27:44 +01:00
|
|
|
import { Address } from "@/types/address.model";
|
|
|
|
import type { IAddress } from "@/types/address.model";
|
|
|
|
import type { ITag } from "@/types/tag.model";
|
|
|
|
import type { IMedia } from "@/types/media.model";
|
|
|
|
import type { IComment } from "@/types/comment.model";
|
|
|
|
import type { Paginate } from "@/types/paginate";
|
|
|
|
import { Actor, Group } from "./actor";
|
|
|
|
import type { IActor, IGroup, IPerson } from "./actor";
|
|
|
|
import type { IParticipant } from "./participant.model";
|
|
|
|
import { EventOptions } from "./event-options.model";
|
|
|
|
import type { IEventOptions } from "./event-options.model";
|
|
|
|
import { EventJoinOptions, EventStatus, EventVisibility } from "./enums";
|
2019-01-21 15:08:22 +01:00
|
|
|
|
2019-10-13 16:24:43 +02:00
|
|
|
export interface IEventCardOptions {
|
|
|
|
hideDate: boolean;
|
|
|
|
loggedPerson: IPerson | boolean;
|
|
|
|
hideDetails: boolean;
|
|
|
|
organizerActor: IActor | null;
|
2020-10-01 15:57:07 +02:00
|
|
|
memberofGroup: boolean;
|
2019-10-13 16:24:43 +02:00
|
|
|
}
|
|
|
|
|
2019-10-13 13:56:24 +02:00
|
|
|
export interface IEventParticipantStats {
|
2019-10-25 17:43:37 +02:00
|
|
|
notApproved: number;
|
2019-12-20 13:04:34 +01:00
|
|
|
notConfirmed: number;
|
2019-10-13 13:56:24 +02:00
|
|
|
rejected: number;
|
2019-10-25 17:43:37 +02:00
|
|
|
participant: number;
|
|
|
|
creator: number;
|
|
|
|
moderator: number;
|
|
|
|
administrator: number;
|
|
|
|
going: number;
|
2019-10-13 13:56:24 +02:00
|
|
|
}
|
|
|
|
|
2020-11-06 11:34:32 +01:00
|
|
|
interface IEventEditJSON {
|
|
|
|
id?: string;
|
|
|
|
title: string;
|
|
|
|
description: string;
|
|
|
|
beginsOn: string;
|
|
|
|
endsOn: string | null;
|
|
|
|
status: EventStatus;
|
|
|
|
visibility: EventVisibility;
|
|
|
|
joinOptions: EventJoinOptions;
|
|
|
|
draft: boolean;
|
2020-11-26 11:41:13 +01:00
|
|
|
picture?: IMedia | { mediaId: string } | null;
|
2020-11-06 11:34:32 +01:00
|
|
|
attributedToId: string | null;
|
|
|
|
onlineAddress?: string;
|
|
|
|
phoneAddress?: string;
|
|
|
|
physicalAddress?: IAddress;
|
|
|
|
tags: string[];
|
|
|
|
options: IEventOptions;
|
|
|
|
contacts: { id?: string }[];
|
|
|
|
}
|
|
|
|
|
2019-01-21 15:08:22 +01:00
|
|
|
export interface IEvent {
|
2019-09-20 18:22:03 +02:00
|
|
|
id?: string;
|
2019-02-22 11:24:41 +01:00
|
|
|
uuid: string;
|
|
|
|
url: string;
|
|
|
|
local: boolean;
|
|
|
|
|
|
|
|
title: string;
|
2019-04-11 14:57:13 +02:00
|
|
|
slug: string;
|
2019-02-22 11:24:41 +01:00
|
|
|
description: string;
|
2019-03-22 10:57:14 +01:00
|
|
|
beginsOn: Date;
|
2019-09-02 14:35:50 +02:00
|
|
|
endsOn: Date | null;
|
2019-03-22 10:57:14 +01:00
|
|
|
publishAt: Date;
|
2019-02-22 11:24:41 +01:00
|
|
|
status: EventStatus;
|
|
|
|
visibility: EventVisibility;
|
2019-03-22 10:57:14 +01:00
|
|
|
joinOptions: EventJoinOptions;
|
2019-10-02 17:59:07 +02:00
|
|
|
draft: boolean;
|
2019-02-22 11:24:41 +01:00
|
|
|
|
2020-11-26 11:41:13 +01:00
|
|
|
picture: IMedia | null;
|
2019-02-22 11:24:41 +01:00
|
|
|
|
2019-09-11 09:59:01 +02:00
|
|
|
organizerActor?: IActor;
|
2020-11-06 11:34:32 +01:00
|
|
|
attributedTo?: IGroup;
|
2019-10-13 13:56:24 +02:00
|
|
|
participantStats: IEventParticipantStats;
|
2020-03-05 19:32:34 +01:00
|
|
|
participants: Paginate<IParticipant>;
|
2019-02-22 11:24:41 +01:00
|
|
|
|
2019-04-12 17:00:55 +02:00
|
|
|
relatedEvents: IEvent[];
|
2019-11-15 18:36:47 +01:00
|
|
|
comments: IComment[];
|
2019-04-12 17:00:55 +02:00
|
|
|
|
2019-03-22 15:51:23 +01:00
|
|
|
onlineAddress?: string;
|
|
|
|
phoneAddress?: string;
|
|
|
|
physicalAddress?: IAddress;
|
2019-07-26 11:30:28 +02:00
|
|
|
|
|
|
|
tags: ITag[];
|
2019-08-28 11:28:27 +02:00
|
|
|
options: IEventOptions;
|
2020-09-29 09:53:48 +02:00
|
|
|
contacts: IActor[];
|
2019-10-01 20:10:53 +02:00
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
toEditJSON(): IEventEditJSON;
|
2019-08-28 11:28:27 +02:00
|
|
|
}
|
|
|
|
|
2019-03-05 12:07:58 +01:00
|
|
|
export class EventModel implements IEvent {
|
2019-09-20 18:22:03 +02:00
|
|
|
id?: string;
|
2019-09-02 14:35:50 +02:00
|
|
|
|
|
|
|
beginsOn = new Date();
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2019-09-02 14:35:50 +02:00
|
|
|
endsOn: Date | null = new Date();
|
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
title = "";
|
|
|
|
|
|
|
|
url = "";
|
|
|
|
|
|
|
|
uuid = "";
|
|
|
|
|
|
|
|
slug = "";
|
|
|
|
|
|
|
|
description = "";
|
|
|
|
|
2019-09-02 14:35:50 +02:00
|
|
|
local = true;
|
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
onlineAddress: string | undefined = "";
|
|
|
|
|
|
|
|
phoneAddress: string | undefined = "";
|
|
|
|
|
2019-09-02 14:35:50 +02:00
|
|
|
physicalAddress?: IAddress;
|
|
|
|
|
2020-11-26 11:41:13 +01:00
|
|
|
picture: IMedia | null = null;
|
2019-09-02 14:35:50 +02:00
|
|
|
|
|
|
|
visibility = EventVisibility.PUBLIC;
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2019-09-02 14:35:50 +02:00
|
|
|
joinOptions = EventJoinOptions.FREE;
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2019-09-02 14:35:50 +02:00
|
|
|
status = EventStatus.CONFIRMED;
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2019-10-02 17:59:07 +02:00
|
|
|
draft = true;
|
2019-09-02 14:35:50 +02:00
|
|
|
|
|
|
|
publishAt = new Date();
|
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
participantStats = {
|
|
|
|
notApproved: 0,
|
|
|
|
notConfirmed: 0,
|
|
|
|
rejected: 0,
|
|
|
|
participant: 0,
|
|
|
|
moderator: 0,
|
|
|
|
administrator: 0,
|
|
|
|
creator: 0,
|
|
|
|
going: 0,
|
|
|
|
};
|
|
|
|
|
2020-03-05 19:32:34 +01:00
|
|
|
participants!: Paginate<IParticipant>;
|
2019-09-02 14:35:50 +02:00
|
|
|
|
2019-04-12 17:00:55 +02:00
|
|
|
relatedEvents: IEvent[] = [];
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2019-11-15 18:36:47 +01:00
|
|
|
comments: IComment[] = [];
|
2019-09-02 14:35:50 +02:00
|
|
|
|
2020-11-06 11:34:32 +01:00
|
|
|
attributedTo?: IGroup = new Group();
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2019-11-15 18:36:47 +01:00
|
|
|
organizerActor?: IActor = new Actor();
|
2019-09-02 14:35:50 +02:00
|
|
|
|
2019-07-26 11:30:28 +02:00
|
|
|
tags: ITag[] = [];
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2020-09-29 09:53:48 +02:00
|
|
|
contacts: IActor[] = [];
|
|
|
|
|
2019-08-28 11:28:27 +02:00
|
|
|
options: IEventOptions = new EventOptions();
|
2019-09-02 14:35:50 +02:00
|
|
|
|
|
|
|
constructor(hash?: IEvent) {
|
|
|
|
if (!hash) return;
|
|
|
|
|
|
|
|
this.id = hash.id;
|
|
|
|
this.uuid = hash.uuid;
|
|
|
|
this.url = hash.url;
|
|
|
|
this.local = hash.local;
|
|
|
|
|
|
|
|
this.title = hash.title;
|
|
|
|
this.slug = hash.slug;
|
2020-10-09 18:12:35 +02:00
|
|
|
this.description = hash.description || "";
|
2019-09-02 14:35:50 +02:00
|
|
|
|
|
|
|
this.beginsOn = new Date(hash.beginsOn);
|
|
|
|
if (hash.endsOn) this.endsOn = new Date(hash.endsOn);
|
|
|
|
|
|
|
|
this.publishAt = new Date(hash.publishAt);
|
|
|
|
|
|
|
|
this.status = hash.status;
|
|
|
|
this.visibility = hash.visibility;
|
|
|
|
this.joinOptions = hash.joinOptions;
|
2019-10-02 17:59:07 +02:00
|
|
|
this.draft = hash.draft;
|
2019-09-02 14:35:50 +02:00
|
|
|
|
|
|
|
this.picture = hash.picture;
|
|
|
|
|
|
|
|
this.organizerActor = new Actor(hash.organizerActor);
|
2020-02-18 08:57:00 +01:00
|
|
|
this.attributedTo = new Group(hash.attributedTo);
|
2019-09-02 14:35:50 +02:00
|
|
|
this.participants = hash.participants;
|
|
|
|
|
|
|
|
this.relatedEvents = hash.relatedEvents;
|
|
|
|
|
|
|
|
this.onlineAddress = hash.onlineAddress;
|
|
|
|
this.phoneAddress = hash.phoneAddress;
|
2020-11-30 10:24:11 +01:00
|
|
|
this.physicalAddress = hash.physicalAddress
|
|
|
|
? new Address(hash.physicalAddress)
|
|
|
|
: undefined;
|
2019-09-18 17:32:37 +02:00
|
|
|
this.participantStats = hash.participantStats;
|
2019-09-02 14:35:50 +02:00
|
|
|
|
2020-09-29 09:53:48 +02:00
|
|
|
this.contacts = hash.contacts;
|
|
|
|
|
2019-09-02 14:35:50 +02:00
|
|
|
this.tags = hash.tags;
|
2019-09-09 11:21:42 +02:00
|
|
|
if (hash.options) this.options = hash.options;
|
|
|
|
}
|
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
toEditJSON(): IEventEditJSON {
|
2019-09-09 11:21:42 +02:00
|
|
|
return {
|
|
|
|
id: this.id,
|
|
|
|
title: this.title,
|
|
|
|
description: this.description,
|
|
|
|
beginsOn: this.beginsOn.toISOString(),
|
|
|
|
endsOn: this.endsOn ? this.endsOn.toISOString() : null,
|
|
|
|
status: this.status,
|
|
|
|
visibility: this.visibility,
|
2019-09-20 18:22:03 +02:00
|
|
|
joinOptions: this.joinOptions,
|
2019-10-02 17:59:07 +02:00
|
|
|
draft: this.draft,
|
2020-02-18 08:57:00 +01:00
|
|
|
tags: this.tags.map((t) => t.title),
|
2019-09-09 11:21:42 +02:00
|
|
|
onlineAddress: this.onlineAddress,
|
|
|
|
phoneAddress: this.phoneAddress,
|
|
|
|
physicalAddress: this.physicalAddress,
|
|
|
|
options: this.options,
|
2020-11-30 10:24:11 +01:00
|
|
|
attributedToId:
|
|
|
|
this.attributedTo && this.attributedTo.id ? this.attributedTo.id : null,
|
2020-09-29 09:53:48 +02:00
|
|
|
contacts: this.contacts.map(({ id }) => ({
|
|
|
|
id,
|
|
|
|
})),
|
2019-09-09 11:21:42 +02:00
|
|
|
};
|
2019-09-02 14:35:50 +02:00
|
|
|
}
|
2019-03-22 10:57:14 +01:00
|
|
|
}
|