From 3afbb8e871af4e37965850bb59df3fcf2337d2a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Fri, 10 Dec 2021 16:18:26 +0100 Subject: Broke out setup of popup on event creation. --- static/components/popup-element.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'static/components/popup-element.ts') 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; +} -- cgit v1.2.3