aboutsummaryrefslogtreecommitdiff
path: root/static/globals.ts
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2021-12-10 16:18:47 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2021-12-10 16:20:03 +0100
commit12d9658e95ec981239a8391e75af784efe78f47f (patch)
tree99db273a24f02fc1cc91cc2efeff98239e9be748 /static/globals.ts
parentBroke out setup of popup on event creation. (diff)
downloadcalp-12d9658e95ec981239a8391e75af784efe78f47f.tar.gz
calp-12d9658e95ec981239a8391e75af784efe78f47f.tar.xz
Add create event button!
Diffstat (limited to 'static/globals.ts')
-rw-r--r--static/globals.ts23
1 files changed, 23 insertions, 0 deletions
diff --git a/static/globals.ts b/static/globals.ts
index cb65d953..eb7488c0 100644
--- a/static/globals.ts
+++ b/static/globals.ts
@@ -7,6 +7,9 @@ import { VEvent } from './vevent'
import { uid } from './types'
import { ComponentBlock } from './components/vevent-block'
+import { v4 as uuid } from 'uuid'
+import { setup_popup_element } from './components/popup-element'
+
const vcal_objects: Map<uid, VEvent> = new Map;
const event_calendar_mapping: Map<uid, string> = new Map;
@@ -16,10 +19,30 @@ declare global {
VIEW: 'month' | 'week';
EDIT_MODE: boolean;
default_calendar: string;
+
+ addNewEvent: ((e: any) => void);
}
}
window.vcal_objects = vcal_objects;
+
+window.addNewEvent = () => {
+ let ev = new VEvent();
+ let uid = uuid()
+ let now = new Date()
+ ev.setProperties([
+ ['uid', uid],
+ ['dtstart', now, 'date-time'],
+ ['dtend', new Date(now.getTime() + 3600 * 1000), 'date-time'],
+ ])
+ ev.calendar = window.default_calendar;
+
+ vcal_objects.set(uid, ev);
+
+ let popup = setup_popup_element(ev);
+ popup.maximize();
+}
+
function find_block(uid: uid): ComponentBlock | null {
let obj = vcal_objects.get(uid)
if (obj === undefined) {