2020-02-18 08:57:00 +01:00
|
|
|
import { Address, IAddress } from "@/types/address.model";
|
|
|
|
import { ITag } from "@/types/tag.model";
|
|
|
|
import { IPicture } from "@/types/picture.model";
|
|
|
|
import { IComment } from "@/types/comment.model";
|
|
|
|
import { Paginate } from "@/types/paginate";
|
|
|
|
import { Actor, Group, IActor, IPerson } from "./actor";
|
2019-01-21 15:08:22 +01:00
|
|
|
|
|
|
|
export enum EventStatus {
|
2020-02-18 08:57:00 +01:00
|
|
|
TENTATIVE = "TENTATIVE",
|
|
|
|
CONFIRMED = "CONFIRMED",
|
|
|
|
CANCELLED = "CANCELLED",
|
2019-01-21 15:08:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export enum EventVisibility {
|
2020-02-18 08:57:00 +01:00
|
|
|
PUBLIC = "PUBLIC",
|
|
|
|
UNLISTED = "UNLISTED",
|
|
|
|
RESTRICTED = "RESTRICTED",
|
|
|
|
PRIVATE = "PRIVATE",
|
2019-02-01 12:33:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export enum EventJoinOptions {
|
2020-02-18 08:57:00 +01:00
|
|
|
FREE = "FREE",
|
|
|
|
RESTRICTED = "RESTRICTED",
|
|
|
|
INVITE = "INVITE",
|
2019-01-21 15:08:22 +01:00
|
|
|
}
|
|
|
|
|
2019-08-28 11:28:27 +02:00
|
|
|
export enum EventVisibilityJoinOptions {
|
2020-02-18 08:57:00 +01:00
|
|
|
PUBLIC = "PUBLIC",
|
|
|
|
LINK = "LINK",
|
|
|
|
LIMITED = "LIMITED",
|
2019-08-28 11:28:27 +02:00
|
|
|
}
|
|
|
|
|
2019-01-21 15:08:22 +01:00
|
|
|
export enum ParticipantRole {
|
2020-02-18 08:57:00 +01:00
|
|
|
NOT_APPROVED = "NOT_APPROVED",
|
|
|
|
NOT_CONFIRMED = "NOT_CONFIRMED",
|
|
|
|
REJECTED = "REJECTED",
|
|
|
|
PARTICIPANT = "PARTICIPANT",
|
|
|
|
MODERATOR = "MODERATOR",
|
|
|
|
ADMINISTRATOR = "ADMINISTRATOR",
|
|
|
|
CREATOR = "CREATOR",
|
2019-01-21 15:08:22 +01:00
|
|
|
}
|
|
|
|
|
2019-02-22 16:54:01 +01:00
|
|
|
export enum Category {
|
2020-02-18 08:57:00 +01:00
|
|
|
BUSINESS = "business",
|
|
|
|
CONFERENCE = "conference",
|
|
|
|
BIRTHDAY = "birthday",
|
|
|
|
DEMONSTRATION = "demonstration",
|
|
|
|
MEETING = "meeting",
|
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;
|
|
|
|
}
|
|
|
|
|
2019-01-21 15:08:22 +01:00
|
|
|
export interface IParticipant {
|
2019-09-20 18:22:03 +02:00
|
|
|
id?: string;
|
2019-02-22 11:24:41 +01:00
|
|
|
role: ParticipantRole;
|
|
|
|
actor: IActor;
|
|
|
|
event: IEvent;
|
2020-02-18 08:57:00 +01:00
|
|
|
metadata: { cancellationToken?: string; message?: string };
|
2020-03-05 19:32:34 +01:00
|
|
|
insertedAt?: Date;
|
2019-01-21 15:08:22 +01:00
|
|
|
}
|
|
|
|
|
2019-09-18 17:32:37 +02:00
|
|
|
export class Participant implements IParticipant {
|
2019-09-20 18:22:03 +02:00
|
|
|
id?: string;
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2019-09-18 17:32:37 +02:00
|
|
|
event!: IEvent;
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2019-09-18 17:32:37 +02:00
|
|
|
actor!: IActor;
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2019-09-18 17:32:37 +02:00
|
|
|
role: ParticipantRole = ParticipantRole.NOT_APPROVED;
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2019-12-20 13:04:34 +01:00
|
|
|
metadata = {};
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2020-03-05 19:32:34 +01:00
|
|
|
insertedAt?: Date;
|
2019-09-18 17:32:37 +02:00
|
|
|
|
|
|
|
constructor(hash?: IParticipant) {
|
|
|
|
if (!hash) return;
|
|
|
|
|
2019-09-20 18:22:03 +02:00
|
|
|
this.id = hash.id;
|
2019-09-18 17:32:37 +02:00
|
|
|
this.event = new EventModel(hash.event);
|
|
|
|
this.actor = new Actor(hash.actor);
|
|
|
|
this.role = hash.role;
|
2019-12-20 13:04:34 +01:00
|
|
|
this.metadata = hash.metadata;
|
2020-03-05 19:32:34 +01:00
|
|
|
this.insertedAt = hash.insertedAt;
|
2019-09-18 17:32:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-28 11:28:27 +02:00
|
|
|
export interface IOffer {
|
|
|
|
price: number;
|
|
|
|
priceCurrency: string;
|
|
|
|
url: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface IParticipationCondition {
|
|
|
|
title: string;
|
|
|
|
content: string;
|
|
|
|
url: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export enum CommentModeration {
|
2020-02-18 08:57:00 +01:00
|
|
|
ALLOW_ALL = "ALLOW_ALL",
|
|
|
|
MODERATED = "MODERATED",
|
|
|
|
CLOSED = "CLOSED",
|
2019-08-28 11:28:27 +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
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2019-09-02 14:35:50 +02:00
|
|
|
picture: IPicture | null;
|
2019-02-22 11:24:41 +01:00
|
|
|
|
2019-09-11 09:59:01 +02:00
|
|
|
organizerActor?: IActor;
|
2020-02-18 08:57:00 +01:00
|
|
|
attributedTo?: IActor;
|
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;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
export interface IEventOptions {
|
|
|
|
maximumAttendeeCapacity: number;
|
|
|
|
remainingAttendeeCapacity: number;
|
|
|
|
showRemainingAttendeeCapacity: boolean;
|
2019-12-20 13:04:34 +01:00
|
|
|
anonymousParticipation: boolean;
|
2020-02-18 08:57:00 +01:00
|
|
|
hideOrganizerWhenGroupEvent: boolean;
|
2019-08-28 11:28:27 +02:00
|
|
|
offers: IOffer[];
|
|
|
|
participationConditions: IParticipationCondition[];
|
|
|
|
attendees: string[];
|
|
|
|
program: string;
|
|
|
|
commentModeration: CommentModeration;
|
|
|
|
showParticipationPrice: boolean;
|
2019-10-14 19:29:18 +02:00
|
|
|
showStartTime: boolean;
|
|
|
|
showEndTime: boolean;
|
2019-08-28 11:28:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export class EventOptions implements IEventOptions {
|
2019-09-09 11:21:42 +02:00
|
|
|
maximumAttendeeCapacity = 0;
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2019-09-09 11:21:42 +02:00
|
|
|
remainingAttendeeCapacity = 0;
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2019-09-09 11:21:42 +02:00
|
|
|
showRemainingAttendeeCapacity = false;
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2019-12-20 13:04:34 +01:00
|
|
|
anonymousParticipation = false;
|
2020-02-18 08:57:00 +01:00
|
|
|
|
|
|
|
hideOrganizerWhenGroupEvent = false;
|
|
|
|
|
2019-08-28 11:28:27 +02:00
|
|
|
offers: IOffer[] = [];
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2019-08-28 11:28:27 +02:00
|
|
|
participationConditions: IParticipationCondition[] = [];
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2019-08-28 11:28:27 +02:00
|
|
|
attendees: string[] = [];
|
2020-02-18 08:57:00 +01:00
|
|
|
|
|
|
|
program = "";
|
|
|
|
|
2019-09-09 11:21:42 +02:00
|
|
|
commentModeration = CommentModeration.ALLOW_ALL;
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2019-09-09 11:21:42 +02:00
|
|
|
showParticipationPrice = false;
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2019-10-14 19:29:18 +02:00
|
|
|
showStartTime = true;
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2019-10-14 19:29:18 +02:00
|
|
|
showEndTime = true;
|
2019-02-22 11:24:41 +01: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;
|
|
|
|
|
|
|
|
picture: IPicture | null = null;
|
|
|
|
|
|
|
|
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-02-18 08:57:00 +01:00
|
|
|
attributedTo?: IActor = new Actor();
|
|
|
|
|
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
|
|
|
|
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;
|
|
|
|
this.description = hash.description;
|
|
|
|
|
|
|
|
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;
|
2019-12-03 11:29:51 +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
|
|
|
|
|
|
|
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
|
|
|
picture: this.picture,
|
|
|
|
onlineAddress: this.onlineAddress,
|
|
|
|
phoneAddress: this.phoneAddress,
|
|
|
|
physicalAddress: this.physicalAddress,
|
|
|
|
options: this.options,
|
2020-02-18 08:57:00 +01:00
|
|
|
// organizerActorId: this.organizerActor && this.organizerActor.id ? this.organizerActor.id : null,
|
|
|
|
attributedToId: this.attributedTo && this.attributedTo.id ? this.attributedTo.id : null,
|
2019-09-09 11:21:42 +02:00
|
|
|
};
|
2019-09-02 14:35:50 +02:00
|
|
|
}
|
2019-03-22 10:57:14 +01:00
|
|
|
}
|
2020-02-18 08:57:00 +01:00
|
|
|
|
|
|
|
interface IEventEditJSON {
|
|
|
|
id?: string;
|
|
|
|
title: string;
|
|
|
|
description: string;
|
|
|
|
beginsOn: string;
|
|
|
|
endsOn: string | null;
|
|
|
|
status: EventStatus;
|
|
|
|
visibility: EventVisibility;
|
|
|
|
joinOptions: EventJoinOptions;
|
|
|
|
draft: boolean;
|
|
|
|
picture: IPicture | { pictureId: string } | null;
|
|
|
|
attributedToId: string | null;
|
|
|
|
onlineAddress?: string;
|
|
|
|
phoneAddress?: string;
|
|
|
|
physicalAddress?: IAddress;
|
|
|
|
tags: string[];
|
|
|
|
options: IEventOptions;
|
|
|
|
}
|