aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2021-11-05 21:50:18 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2021-11-05 21:50:18 +0100
commit3afc7d26dcca96925be2e4230b4194a9b335af2b (patch)
treefdf8613f256d3b7a396e4b9deb8c29edf3b7cc0b
parentStart depending on npm. (diff)
downloadcalp-3afc7d26dcca96925be2e4230b4194a9b335af2b.tar.gz
calp-3afc7d26dcca96925be2e4230b4194a9b335af2b.tar.xz
doc updates.
-rw-r--r--static/globals.ts21
-rw-r--r--static/vevent.ts14
2 files changed, 32 insertions, 3 deletions
diff --git a/static/globals.ts b/static/globals.ts
index c18808e7..5e97bf39 100644
--- a/static/globals.ts
+++ b/static/globals.ts
@@ -19,6 +19,11 @@ function hasValue(obj: any): obj is HasValue {
return 'value' in obj;
}
+/* Root component for all events which content is closely linked to a
+@code{VEvent} object
+
+Lacks an accompaning tag, and shouldn't be directly instanciated.
+*/
class ComponentVEvent extends HTMLElement {
template: HTMLTemplateElement
@@ -73,11 +78,14 @@ class ComponentVEvent extends HTMLElement {
}
+
+/*
+ <vevent-description />
+*/
class ComponentDescription extends ComponentVEvent {
constructor() {
super();
}
-
}
function popuplateTab(tab: HTMLElement, tabgroup: string, index: number) {
@@ -96,6 +104,7 @@ function popuplateTab(tab: HTMLElement, tabgroup: string, index: number) {
}
}
+/* <vevent-edit /> */
class ComponentEdit extends ComponentVEvent {
firstTime: boolean
@@ -213,6 +222,10 @@ function find_block(uid: uid): HTMLElement | null {
return null;
}
+/* <vevent-block />
+
+ A grahpical block in the week view.
+*/
class ComponentBlock extends ComponentVEvent {
constructor() {
super();
@@ -229,7 +242,6 @@ class ComponentBlock extends ComponentVEvent {
redraw(data: VEvent) {
super.redraw(data);
-
let p;
if ((p = data.getProperty('dtstart'))) {
let c = this.closest('.event-container') as HTMLElement
@@ -300,6 +312,7 @@ window.addEventListener('load', function() {
+/* '<date-time-input />' */
class DateTimeInput extends /* HTMLInputElement */ HTMLElement {
constructor() {
super();
@@ -372,6 +385,7 @@ class DateTimeInput extends /* HTMLInputElement */ HTMLElement {
customElements.define('date-time-input', DateTimeInput /*, { extends: 'input' } */)
+
function verifySlot(el: Node | null): el is HTMLElement {
if (el === null) {
console.error("Element is null");
@@ -384,6 +398,8 @@ function verifySlot(el: Node | null): el is HTMLElement {
return true
}
+
+/* <tab-element /> */
class TabElement extends HTMLElement {
constructor() {
super();
@@ -419,6 +435,7 @@ function buildDescriptionList(data: [string, any][]): HTMLElement {
return dl;
}
+/* <popup-element /> */
class PopupElement extends HTMLElement {
tabgroup_id: string
diff --git a/static/vevent.ts b/static/vevent.ts
index 0fef9685..377cb6ae 100644
--- a/static/vevent.ts
+++ b/static/vevent.ts
@@ -1,9 +1,11 @@
import { ical_type, valid_input_types, JCal } from './types'
import { uid, parseDate } from './lib'
+
export { VEvent, xml_to_vcal }
"use strict";
+/* Something which can be redrawn */
interface Redrawable extends HTMLElement {
redraw: ((data: VEvent) => void)
}
@@ -63,10 +65,21 @@ class VEventValue {
class VEventDuration extends VEventValue {
}
+/*
+ Abstract representation of a calendar event (or similar).
+All "live" calendar data in the frontend should live in an object of this type.
+ */
class VEvent {
+ /* Calendar properties */
properties: Map<uid, VEventValue>
+
+ /* Children (such as alarms for events) */
components: VEvent[]
+
+ /* HTMLElements which wants to be redrawn when this object changes.
+ Elements can be registered with the @code{register} method.
+ */
registered: Redrawable[]
constructor(properties: Map<uid, VEventValue> = new Map(), components: VEvent[] = []) {
@@ -197,7 +210,6 @@ function make_vevent_value_(value_tag: Element) {
}
}
-/* xml dom object -> class VEvent */
function xml_to_vcal(xml: Element): VEvent {
/* xml MUST have a VEVENT (or equivalent) as its root */
let properties = xml.getElementsByTagName('properties')[0];