diff options
Diffstat (limited to '')
-rw-r--r-- | static/components/vevent-description.ts | 22 |
1 files changed, 22 insertions, 0 deletions
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); + } } |