aboutsummaryrefslogtreecommitdiff
path: root/static/components
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2021-11-19 16:45:06 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2021-11-19 16:45:06 +0100
commit3bd26b63adf49ec1b3f52897008738f13b864451 (patch)
treeb8b0d7a6eca1c209558a5f350bd281c2c2a01028 /static/components
parentAdd input-list custom element. (diff)
downloadcalp-3bd26b63adf49ec1b3f52897008738f13b864451.tar.gz
calp-3bd26b63adf49ec1b3f52897008738f13b864451.tar.xz
Add basic rrule tab.
Diffstat (limited to 'static/components')
-rw-r--r--static/components/edit-rrule.ts51
-rw-r--r--static/components/vevent-block.ts4
2 files changed, 55 insertions, 0 deletions
diff --git a/static/components/edit-rrule.ts b/static/components/edit-rrule.ts
new file mode 100644
index 00000000..a4d09083
--- /dev/null
+++ b/static/components/edit-rrule.ts
@@ -0,0 +1,51 @@
+export { EditRRule }
+
+import { ComponentVEvent } from './vevent'
+import { VEvent } from '../vevent'
+import { vcal_objects } from '../globals'
+
+import { RecurrenceRule } from '../vevent'
+
+/* <vevent-edit-rrule/> */
+class EditRRule extends ComponentVEvent {
+
+ constructor() {
+ super();
+
+ let frag = this.template.content.cloneNode(true) as DocumentFragment
+ let body = frag.firstElementChild!
+ this.replaceChildren(body);
+ }
+
+ connectedCallback() {
+ this.redraw(vcal_objects.get(this.uid)!)
+ }
+
+ redraw(data: VEvent) {
+
+ let rrule = data.getProperty('rrule')
+ if (!rrule) return;
+ rrule = rrule as RecurrenceRule
+
+ for (let el of this.querySelectorAll('[name]')) {
+
+ /*
+ el ought to be one of the tag types:
+ <input/>, <input-list/>, <select/>, and <date-time-input/>
+ Which all have `name` and `value` fields, allowing the code
+ below to work.
+ */
+
+ let name = el.getAttribute('name')
+ if (!name) {
+ console.warn(`Input without name, ${el}`)
+ continue
+ }
+
+ let value: any = rrule[name];
+ if (value)
+ (el as any).value = value;
+ }
+ }
+
+}
diff --git a/static/components/vevent-block.ts b/static/components/vevent-block.ts
index 8c6d11cf..a4aaba24 100644
--- a/static/components/vevent-block.ts
+++ b/static/components/vevent-block.ts
@@ -59,5 +59,9 @@ class ComponentBlock extends ComponentVEvent {
if (data.calendar) {
this.dataset.calendar = data.calendar;
}
+
+ if (data.getProperty('rrule') !== undefined) {
+ (this.getElementsByClassName('repeating')![0] as HTMLElement).innerText = '↺'
+ }
}
}