aboutsummaryrefslogtreecommitdiff
path: root/static/components
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2021-12-10 16:18:26 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2021-12-10 16:20:03 +0100
commit3afbb8e871af4e37965850bb59df3fcf2337d2a8 (patch)
tree0f5050fd9d4685e988315355f14a4e93d7099ac5 /static/components
parent'.btn' no longer contains div. (diff)
downloadcalp-3afbb8e871af4e37965850bb59df3fcf2337d2a8.tar.gz
calp-3afbb8e871af4e37965850bb59df3fcf2337d2a8.tar.xz
Broke out setup of popup on event creation.
Diffstat (limited to 'static/components')
-rw-r--r--static/components/popup-element.ts21
1 files changed, 20 insertions, 1 deletions
diff --git a/static/components/popup-element.ts b/static/components/popup-element.ts
index 840faef8..4d5545fc 100644
--- a/static/components/popup-element.ts
+++ b/static/components/popup-element.ts
@@ -1,4 +1,4 @@
-export { PopupElement }
+export { PopupElement, setup_popup_element }
import { VEvent } from '../vevent'
import { bind_popup_control } from '../dragable'
@@ -141,3 +141,22 @@ class PopupElement extends ComponentVEvent {
el.style.height = `${parent.clientHeight - 20}px`
}
}
+
+/* Create a new popup element for the given VEvent, and ready it for editing the
+ event. Used when creating event (through the frontend).
+ The return value can safely be ignored.
+*/
+function setup_popup_element(ev: VEvent): PopupElement {
+ let uid = ev.getProperty('uid');
+ let popup = new PopupElement(uid);
+ ev.register(popup);
+ /* TODO propper way to find popup container */
+ (document.querySelector('.days') as Element).appendChild(popup);
+ let tabBtn = popup.querySelector('[role="tab"][title="Redigera"]') as HTMLButtonElement
+ tabBtn.click()
+ let tab = document.getElementById(tabBtn.getAttribute('aria-controls')!)!
+ let input = tab.querySelector('input[name="summary"]') as HTMLInputElement
+ popup.visible = true;
+ input.select();
+ return popup;
+}