diff options
Diffstat (limited to '')
-rw-r--r-- | static/components/popup-element.ts | 21 |
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; +} |