aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--module/calp/html/view/calendar.scm4
-rw-r--r--static/globals.ts23
-rw-r--r--static/style.scss13
3 files changed, 40 insertions, 0 deletions
diff --git a/module/calp/html/view/calendar.scm b/module/calp/html/view/calendar.scm
index e50bcfe5..3abf4959 100644
--- a/module/calp/html/view/calendar.scm
+++ b/module/calp/html/view/calendar.scm
@@ -137,6 +137,10 @@ window.default_calendar='~a';"
next-start: next-start
prev-start: prev-start
)
+
+ ,(btn onclick: "addNewEvent()"
+ "+")
+
;; Popups used to be here, but was moved into render-calendar so each
;; sub-view can itself decide where to put them. This is important
;; since they need to be placed as children to the scrolling
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) {
diff --git a/static/style.scss b/static/style.scss
index 4e9936a2..48de9bcc 100644
--- a/static/style.scss
+++ b/static/style.scss
@@ -45,6 +45,19 @@ html, body {
-1em 1em 0.5em gold;
z-index: 1;
}
+
+ /* For new event button */
+ position: relative;
+
+ /* add new event button */
+ > button {
+ position: absolute;
+ right: 2mm;
+ bottom: 5mm;
+
+ height: 1cm;
+ width: 1cm;
+ }
}