aboutsummaryrefslogtreecommitdiff
path: root/static/components
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2021-12-02 01:51:28 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2021-12-02 01:51:28 +0100
commit6c537f3f60aaac8ae850f8ecaefc2a0d04a8431e (patch)
tree48babe2596284dc2fb58b026428496581bee9d4b /static/components
parentRemove jcal-tests.js (diff)
downloadcalp-6c537f3f60aaac8ae850f8ecaefc2a0d04a8431e.tar.gz
calp-6c537f3f60aaac8ae850f8ecaefc2a0d04a8431e.tar.xz
Add basic changelog view
Diffstat (limited to 'static/components')
-rw-r--r--static/components/changelog.ts49
-rw-r--r--static/components/vevent-edit.ts2
2 files changed, 50 insertions, 1 deletions
diff --git a/static/components/changelog.ts b/static/components/changelog.ts
new file mode 100644
index 00000000..8f45794d
--- /dev/null
+++ b/static/components/changelog.ts
@@ -0,0 +1,49 @@
+import { makeElement } from '../lib'
+import { ComponentVEvent } from './vevent'
+import { VEvent } from '../vevent'
+
+export { VEventChangelog }
+
+class VEventChangelog extends ComponentVEvent {
+
+ ul: HTMLElement
+
+ constructor(uid?: string) {
+ super(uid);
+
+ this.ul = makeElement('ul');
+ }
+
+ connectedCallback() {
+ this.replaceChildren(this.ul);
+ }
+
+ redraw(data: VEvent) {
+ /* TODO only redraw what is needed */
+ let children = []
+ for (let el of data._changelog) {
+ let msg = '';
+ switch (el.type) {
+ case 'property':
+ msg += `change ${el.name}: `
+ msg += `from "${el.from}" to "${el.to}"`
+ break;
+ case 'calendar':
+ if (el.from === null && el.to === null) {
+ msg += '???'
+ } else if (el.from === null) {
+ msg += `set calendar to "${atob(el.to!)}"`
+ } else if (el.to === null) {
+ msg += `Remove calendar "${atob(el.from)}"`
+ } else {
+ msg += `Change calendar from "${atob(el.from)}" to "${atob(el.to)}"`
+ }
+ break;
+ }
+
+ children.push(makeElement('li', { textContent: msg }));
+ }
+
+ this.ul.replaceChildren(...children)
+ }
+}
diff --git a/static/components/vevent-edit.ts b/static/components/vevent-edit.ts
index 58cee870..d48c7967 100644
--- a/static/components/vevent-edit.ts
+++ b/static/components/vevent-edit.ts
@@ -58,7 +58,7 @@ class ComponentEdit extends ComponentVEvent {
// console.log(el);
el.addEventListener('input', (e) => {
let obj = vcal_objects.get(this.uid)
- console.log(el, e);
+ // console.log(el, e);
if (obj === undefined) {
throw 'No object with uid ' + this.uid
}