From 410404cfdd54c083b6609fd52334e02d320145d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Wed, 10 Nov 2021 01:40:22 +0100 Subject: Re-modularize javascript. This moves almost everything out of globals.ts, into sepparate files. Things are still slightly to tightly coupled. But that is worked on. --- static/components/vevent-description.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 static/components/vevent-description.ts (limited to 'static/components/vevent-description.ts') diff --git a/static/components/vevent-description.ts b/static/components/vevent-description.ts new file mode 100644 index 00000000..f97b60e1 --- /dev/null +++ b/static/components/vevent-description.ts @@ -0,0 +1,12 @@ +export { ComponentDescription } + +import { ComponentVEvent } from './vevent' + +/* + +*/ +class ComponentDescription extends ComponentVEvent { + constructor() { + super(); + } +} -- cgit v1.2.3 From 0cfa00fc43eaf98db8b2461a2d07687b6591cd6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Fri, 26 Nov 2021 17:14:30 +0100 Subject: Remove default ComponentVEvent redraw. --- static/components/vevent-description.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'static/components/vevent-description.ts') diff --git a/static/components/vevent-description.ts b/static/components/vevent-description.ts index f97b60e1..03c5355d 100644 --- a/static/components/vevent-description.ts +++ b/static/components/vevent-description.ts @@ -1,5 +1,6 @@ export { ComponentDescription } +import { VEvent } from '../vevent' import { ComponentVEvent } from './vevent' /* @@ -9,4 +10,25 @@ class ComponentDescription extends ComponentVEvent { constructor() { super(); } + + redraw(data: VEvent) { + // update ourselves from template + + let body = (this.template.content.cloneNode(true) as DocumentFragment).firstElementChild!; + + for (let el of body.querySelectorAll('[data-property]')) { + if (!(el instanceof HTMLElement)) continue; + let p = el.dataset.property!; + let d, fmt; + if ((d = data.getProperty(p))) { + if ((fmt = el.dataset.fmt)) { + el.textContent = d.format(fmt); + } else { + el.textContent = d; + } + } + } + + this.replaceChildren(body); + } } -- cgit v1.2.3 From 4b9fa491fa44c6a4df803b49e4987a03bdc71a0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Fri, 26 Nov 2021 17:53:32 +0100 Subject: Display categories in event description. --- static/components/vevent-description.ts | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'static/components/vevent-description.ts') diff --git a/static/components/vevent-description.ts b/static/components/vevent-description.ts index 03c5355d..b1605d50 100644 --- a/static/components/vevent-description.ts +++ b/static/components/vevent-description.ts @@ -2,6 +2,7 @@ export { ComponentDescription } import { VEvent } from '../vevent' import { ComponentVEvent } from './vevent' +import { makeElement } from '../lib' /* @@ -21,10 +22,23 @@ class ComponentDescription extends ComponentVEvent { let p = el.dataset.property!; let d, fmt; if ((d = data.getProperty(p))) { - if ((fmt = el.dataset.fmt)) { - el.textContent = d.format(fmt); - } else { - el.textContent = d; + switch (p.toLowerCase()) { + case 'categories': + for (let item of d) { + let q = encodeURIComponent( + `(member "${item}" (or (prop event (quote CATEGORIES)) (quote ())))`) + el.appendChild(makeElement('a', { + textContent: item, + href: `/search/?q=${q}`, + })) + } + break; + default: + if ((fmt = el.dataset.fmt)) { + el.textContent = d.format(fmt); + } else { + el.textContent = d; + } } } } -- cgit v1.2.3 From 457ab3301782e4e91334961208c5e4bbde95987d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Fri, 10 Dec 2021 03:04:34 +0100 Subject: Add various type specifiers. --- static/components/vevent-description.ts | 4 ---- 1 file changed, 4 deletions(-) (limited to 'static/components/vevent-description.ts') diff --git a/static/components/vevent-description.ts b/static/components/vevent-description.ts index b1605d50..09c836b0 100644 --- a/static/components/vevent-description.ts +++ b/static/components/vevent-description.ts @@ -8,10 +8,6 @@ import { makeElement } from '../lib' */ class ComponentDescription extends ComponentVEvent { - constructor() { - super(); - } - redraw(data: VEvent) { // update ourselves from template -- cgit v1.2.3 From 2e4b349b723531a3a2a42db11527ee3fc90b4b59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sun, 12 Dec 2021 20:36:43 +0100 Subject: Correctly show recur indicator. --- static/components/vevent-description.ts | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'static/components/vevent-description.ts') diff --git a/static/components/vevent-description.ts b/static/components/vevent-description.ts index 09c836b0..98c9007e 100644 --- a/static/components/vevent-description.ts +++ b/static/components/vevent-description.ts @@ -39,6 +39,13 @@ class ComponentDescription extends ComponentVEvent { } } + let repeating = body.getElementsByClassName('repeating')[0] as HTMLElement + if (data.getProperty('rrule')) { + repeating.classList.remove('hidden'); + } else { + repeating.classList.add('hidden'); + } + this.replaceChildren(body); } } -- cgit v1.2.3 From 3ddbd37ade2e03e4fc3a6f5ba52234bc286fded3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 13 Dec 2021 02:26:36 +0100 Subject: Made VEventComponent template optional. --- static/components/vevent-description.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'static/components/vevent-description.ts') diff --git a/static/components/vevent-description.ts b/static/components/vevent-description.ts index 98c9007e..4d81d6b3 100644 --- a/static/components/vevent-description.ts +++ b/static/components/vevent-description.ts @@ -8,10 +8,18 @@ import { makeElement } from '../lib' */ class ComponentDescription extends ComponentVEvent { + + constructor(uid?: string) { + super(uid); + if (!this.template) { + throw 'vevent-description template required'; + } + } + redraw(data: VEvent) { // update ourselves from template - let body = (this.template.content.cloneNode(true) as DocumentFragment).firstElementChild!; + let body = (this.template!.content.cloneNode(true) as DocumentFragment).firstElementChild!; for (let el of body.querySelectorAll('[data-property]')) { if (!(el instanceof HTMLElement)) continue; -- cgit v1.2.3