From 5211cea181bbdf9c5296f09806c3735197bc2042 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Fri, 10 Dec 2021 00:13:15 +0100 Subject: Close popup on event creation. --- static/components/vevent-block.ts | 5 +++++ static/event-creator.ts | 1 - static/script.ts | 12 ++++++------ static/server_connect.ts | 22 ++++++++++++++-------- 4 files changed, 25 insertions(+), 15 deletions(-) diff --git a/static/components/vevent-block.ts b/static/components/vevent-block.ts index de9cf748..0aad19b2 100644 --- a/static/components/vevent-block.ts +++ b/static/components/vevent-block.ts @@ -35,6 +35,11 @@ class ComponentBlock extends ComponentVEvent { } else { el.textContent = d; } + } else switch (p.toLowerCase()) { + /* We lack that property, but might want to set a default here */ + case 'summary': + el.textContent = 'Ny händelse' + break; } } diff --git a/static/event-creator.ts b/static/event-creator.ts index 6be94a9d..3459dba1 100644 --- a/static/event-creator.ts +++ b/static/event-creator.ts @@ -65,7 +65,6 @@ class EventCreator { // let [popup, event] = that.create_empty_event(); // that.event = event; that.ev = new VEvent(); - that.ev.setProperty('summary', 'Created Event'); that.ev.setProperty('uid', uuid()) that.ev.calendar = window.default_calendar; diff --git a/static/script.ts b/static/script.ts index df5e2c97..f378ced1 100644 --- a/static/script.ts +++ b/static/script.ts @@ -91,14 +91,14 @@ window.addEventListener('load', function() { let popup = new PopupElement(uid); ev.register(popup); - console.log(popup); + // console.log(popup); (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 open_popup(popup); - // (popup.querySelector("input[name='summary']") as HTMLInputElement).focus(); - // let popupElement = document.getElementById("popup" + event.id); - // open_popup(popup_from_event(event)); - - // popupElement.querySelector("input[name='summary']").focus(); + input.select(); })); } diff --git a/static/server_connect.ts b/static/server_connect.ts index 66410324..61eb4f30 100644 --- a/static/server_connect.ts +++ b/static/server_connect.ts @@ -94,7 +94,9 @@ async function create_event(event: VEvent) { return; } - let body = await response.text(); + /* response from here on is good */ + + // let body = await response.text(); /* server is assumed to return an XML document on the form @@ -103,10 +105,10 @@ async function create_event(event: VEvent) { parse that, and update our own vevent with the data. */ - let parser = new DOMParser(); - let return_properties = parser - .parseFromString(body, 'text/xml') - .children[0]; + // let parser = new DOMParser(); + // let return_properties = parser + // .parseFromString(body, 'text/xml') + // .children[0]; // let child; // while ((child = return_properties.firstChild)) { @@ -120,7 +122,11 @@ async function create_event(event: VEvent) { // } // } - // event.classList.remove("generated"); - // toggle_popup(popup_from); - + for (let r of event.registered) { + r.classList.remove('generated'); + if (r.tagName.toLowerCase() === 'popup-element') { + console.log(r); + r.removeAttribute('visible'); + } + } } -- cgit v1.2.3