From a64c2a665af1abe0b91f1c5eb1f97df91ed8a4de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sun, 3 Oct 2021 17:48:13 +0200 Subject: Further work, rework popup. --- module/calp/html/vcomponent.scm | 18 ++++++++------ module/calp/html/view/calendar.scm | 1 + module/calp/html/view/calendar/week.scm | 42 ++++++++++++++++++++++++++++++--- 3 files changed, 51 insertions(+), 10 deletions(-) (limited to 'module') diff --git a/module/calp/html/vcomponent.scm b/module/calp/html/vcomponent.scm index 5600646a..c5ae452d 100644 --- a/module/calp/html/vcomponent.scm +++ b/module/calp/html/vcomponent.scm @@ -1,5 +1,6 @@ (define-module (calp html vcomponent) :use-module (calp util) + :use-module ((calp util exceptions) :select (warning)) :use-module (vcomponent) :use-module (srfi srfi-1) :use-module (srfi srfi-26) @@ -66,10 +67,9 @@ (@ ,@(assq-merge attributes `( - (class " vevent eventtext summary-tab " - ,(when (and (prop ev 'PARTSTAT) - (eq? 'TENTATIVE (prop ev 'PARTSTAT))) - " tentative ")) + (class ,(when (and (prop ev 'PARTSTAT) + (eq? 'TENTATIVE (prop ev 'PARTSTAT))) + " tentative ")) (data-uid ,(prop ev 'UID))))) (h3 ,(fmt-header (when (prop ev 'RRULE) @@ -368,7 +368,8 @@ " transparent") ) (data-uid ,(prop ev 'UID)) - (onclick "toggle_popup('popup' + this.id)") + ;; TODO figure out stable way to get popup for element + ;; (onclick "toggle_popup('popup' + this.id)") ))) ;; Inner div to prevent overflow. Previously "overflow: none" ;; was set on the surounding div, but the popup /needs/ to @@ -571,10 +572,13 @@ )))) + + (define-public (popup ev id) - `(div (@ (id ,id) (class "popup-container CAL_" + (warning "popup is deprecated") + `(div (@ (id ,id) (class "popup-container CAL_" ,(html-attr (or (prop (parent ev) 'NAME) - "unknown"))) + "unknown"))) (onclick "event.stopPropagation()")) ;; TODO all (?) code uses .popup-container as the popup, while .popup sits and does nothing. ;; Do something about this? diff --git a/module/calp/html/view/calendar.scm b/module/calp/html/view/calendar.scm index f8188352..f447773d 100644 --- a/module/calp/html/view/calendar.scm +++ b/module/calp/html/view/calendar.scm @@ -117,6 +117,7 @@ ;; (script (@ (defer) (src "/static/date_time.js"))) ;; (script (@ (defer) (src "/static/vcal.js"))) (script (@ (defer) (src "/static/script.js"))) + (script (@ (defer) (src "/static/vevent.js"))) (script (@ (defer) (src "/static/globals.js"))) ;; on load diff --git a/module/calp/html/view/calendar/week.scm b/module/calp/html/view/calendar/week.scm index c2165a8e..5361ab65 100644 --- a/module/calp/html/view/calendar/week.scm +++ b/module/calp/html/view/calendar/week.scm @@ -14,6 +14,9 @@ events-between)) :use-module ((calp html vcomponent) :select (make-block) ) + :use-module ((calp html components) + :select (btn tabset #; #; form with-label + )) :use-module ((vcomponent group) :select (group-stream get-groups-between)) ) @@ -52,10 +55,16 @@ ,@(for event in (stream->list (events-between start-date end-date events)) - ((@ (calp html vcomponent ) popup) - event (string-append "popup" (html-id event)))) + `(popup-element + (@ (class "vevent") + (data-uid ,(prop event 'UID))) + ) + #; + ((@ (calp html vcomponent ) popup) ; + event (string-append "popup" (html-id event)))) )) + ;; description in sidebar / tab of popup (template (@ (id "vevent-description")) ,(description-template) @@ -70,11 +79,38 @@ ,(block-template) ) + ;; Based on popup:s output + (template + (@ (id "popup-template")) + (div (@ ; (id ,id) + (class "popup-container CAL_" + #; + ,(html-attr (or (prop (parent ev) 'NAME) ; + "unknown"))) + (onclick "event.stopPropagation()")) + (div (@ (class "popup")) + (nav (@ (class "popup-control")) + ,(btn "×" + title: "Stäng" + onclick: "" + ;; onclick: "close_popup(document.getElementById(this.closest('.popup-container').id))" + class: '("close-tooltip"))) + + ,(tabset + `(("📅" title: "Översikt" + (vevent-description (@ (class "populate-with-uid"))) + ) + + ,@(when (edit-mode) + `(("📅" title: "Redigera" + (vevent-edit (@ (class "populate-with-uid")))))))))) + ) + ))) ;; based on the output of fmt-single-event (define (description-template) - '(div (@ (class " eventtext summary-tab " ())) + '(div (@ (class " vevent eventtext summary-tab " ())) (h3 ((span (@ (class "repeating")) ; "↺" ) (span (@ (class "bind summary") -- cgit v1.2.3