aboutsummaryrefslogtreecommitdiff
path: root/static
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2021-11-18 21:41:20 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2021-11-18 21:41:20 +0100
commite5219a712560fde7c843652f088de995a6de68ea (patch)
treed66b46cf4944eb2e3b6fbfe28a553bfd17a85bb1 /static
parentMinor fixes. (diff)
downloadcalp-e5219a712560fde7c843652f088de995a6de68ea.tar.gz
calp-e5219a712560fde7c843652f088de995a6de68ea.tar.xz
Restore remove event functionality.
Diffstat (limited to 'static')
-rw-r--r--static/components/popup-element.ts9
-rw-r--r--static/server_connect.ts11
2 files changed, 15 insertions, 5 deletions
diff --git a/static/components/popup-element.ts b/static/components/popup-element.ts
index 2f019f4d..cb67035f 100644
--- a/static/components/popup-element.ts
+++ b/static/components/popup-element.ts
@@ -9,6 +9,8 @@ import { vcal_objects } from '../globals'
import { ComponentVEvent } from './vevent'
import { TabElement } from './tab-element'
+import { remove_event } from '../server_connect'
+
/* <popup-element /> */
class PopupElement extends ComponentVEvent {
@@ -74,8 +76,11 @@ class PopupElement extends ComponentVEvent {
let nav = body.getElementsByClassName("popup-control")[0] as HTMLElement;
bind_popup_control(nav);
- let btn = body.querySelector('.popup-control .close-tooltip') as HTMLButtonElement
- btn.addEventListener('click', () => close_popup(this));
+ let close_btn = body.querySelector('.popup-control .close-button') as HTMLButtonElement
+ close_btn.addEventListener('click', () => close_popup(this));
+
+ let remove_btn = body.querySelector('.popup-control .remove-button') as HTMLButtonElement
+ remove_btn.addEventListener('click', () => remove_event(uid));
/* end nav bar */
this.replaceChildren(body);
diff --git a/static/server_connect.ts b/static/server_connect.ts
index 1d01e07e..66410324 100644
--- a/static/server_connect.ts
+++ b/static/server_connect.ts
@@ -21,16 +21,21 @@ async function remove_event(uid: uid) {
});
console.log(response);
- toggle_popup(popup_from_event(element));
+ // toggle_popup(popup_from_event(element));
if (response.status < 200 || response.status >= 300) {
let body = await response.text();
alert(`HTTP error ${response.status}\n${body}`)
} else {
- element.remove();
+ /* Remove all HTML components which belong to this vevent */
+ for (let component of element.registered) {
+ component.remove();
+ }
+ /* remove the vevent from our global store,
+ hopefully also freeing it for garbace collection */
+ vcal_objects.delete(uid);
}
}
-*/
// function event_to_jcal(event) {
// /* encapsulate event in a shim calendar, to ensure that