Allow to add metadata to an event
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -251,3 +251,27 @@ export enum SortDirection {
|
||||
ASC = "ASC",
|
||||
DESC = "DESC",
|
||||
}
|
||||
|
||||
export enum EventMetadataType {
|
||||
STRING = "STRING",
|
||||
INTEGER = "INTEGER",
|
||||
FLOAT = "FLOAT",
|
||||
BOOLEAN = "BOOLEAN",
|
||||
}
|
||||
|
||||
export enum EventMetadataKeyType {
|
||||
PLAIN = "PLAIN",
|
||||
URL = "URL",
|
||||
CHOICE = "CHOICE",
|
||||
HANDLE = "HANDLE",
|
||||
}
|
||||
|
||||
export enum EventMetadataCategories {
|
||||
ACCESSIBILITY = "ACCESSIBILITY",
|
||||
LIVE = "LIVE",
|
||||
REPLAY = "REPLAY",
|
||||
SOCIAL = "SOCIAL",
|
||||
TOOLS = "TOOLS",
|
||||
DETAILS = "DETAILS",
|
||||
BOOKING = "BOOKING",
|
||||
}
|
||||
|
||||
23
js/src/types/event-metadata.ts
Normal file
23
js/src/types/event-metadata.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import {
|
||||
EventMetadataCategories,
|
||||
EventMetadataKeyType,
|
||||
EventMetadataType,
|
||||
} from "./enums";
|
||||
|
||||
export interface IEventMetadata {
|
||||
key: string;
|
||||
title?: string;
|
||||
value: string;
|
||||
type: EventMetadataType;
|
||||
}
|
||||
|
||||
export interface IEventMetadataDescription extends IEventMetadata {
|
||||
icon?: string;
|
||||
placeholder?: string;
|
||||
description: string;
|
||||
choices?: Record<string, string>;
|
||||
keyType: EventMetadataKeyType;
|
||||
pattern?: RegExp;
|
||||
label: string;
|
||||
category: EventMetadataCategories;
|
||||
}
|
||||
@@ -10,6 +10,7 @@ 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";
|
||||
import { IEventMetadata } from "./event-metadata";
|
||||
|
||||
export interface IEventCardOptions {
|
||||
hideDate: boolean;
|
||||
@@ -49,6 +50,7 @@ interface IEventEditJSON {
|
||||
tags: string[];
|
||||
options: IEventOptions;
|
||||
contacts: { id?: string }[];
|
||||
metadata: IEventMetadata[];
|
||||
}
|
||||
|
||||
export interface IEvent {
|
||||
@@ -84,6 +86,7 @@ export interface IEvent {
|
||||
|
||||
tags: ITag[];
|
||||
options: IEventOptions;
|
||||
metadata: IEventMetadata[];
|
||||
contacts: IActor[];
|
||||
|
||||
toEditJSON(): IEventEditJSON;
|
||||
@@ -153,6 +156,8 @@ export class EventModel implements IEvent {
|
||||
|
||||
options: IEventOptions = new EventOptions();
|
||||
|
||||
metadata: IEventMetadata[] = [];
|
||||
|
||||
constructor(hash?: IEvent) {
|
||||
if (!hash) return;
|
||||
|
||||
@@ -193,6 +198,7 @@ export class EventModel implements IEvent {
|
||||
this.contacts = hash.contacts;
|
||||
|
||||
this.tags = hash.tags;
|
||||
this.metadata = hash.metadata;
|
||||
if (hash.options) this.options = hash.options;
|
||||
}
|
||||
|
||||
@@ -212,6 +218,12 @@ export class EventModel implements IEvent {
|
||||
phoneAddress: this.phoneAddress,
|
||||
physicalAddress: this.removeTypeName(this.physicalAddress),
|
||||
options: this.removeTypeName(this.options),
|
||||
metadata: this.metadata.map(({ key, value, type, title }) => ({
|
||||
key,
|
||||
value,
|
||||
type,
|
||||
title,
|
||||
})),
|
||||
attributedToId:
|
||||
this.attributedTo && this.attributedTo.id ? this.attributedTo.id : null,
|
||||
contacts: this.contacts.map(({ id }) => ({
|
||||
|
||||
Reference in New Issue
Block a user