diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2021-12-10 01:49:11 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2021-12-10 01:49:11 +0100 |
commit | 1ef01481fa9e70ef688b24ffd7957b97f020bb2e (patch) | |
tree | f5762e0914bae4696b89529f6d802d49baf6c40d /module/calp/html/vcomponent.scm | |
parent | Major cleanup in calp html. (diff) | |
download | calp-1ef01481fa9e70ef688b24ffd7957b97f020bb2e.tar.gz calp-1ef01481fa9e70ef688b24ffd7957b97f020bb2e.tar.xz |
Major move from week to calendar meta-view. Also repairs month view.
Diffstat (limited to 'module/calp/html/vcomponent.scm')
-rw-r--r-- | module/calp/html/vcomponent.scm | 350 |
1 files changed, 258 insertions, 92 deletions
diff --git a/module/calp/html/vcomponent.scm b/module/calp/html/vcomponent.scm index b5a4260e..43efe656 100644 --- a/module/calp/html/vcomponent.scm +++ b/module/calp/html/vcomponent.scm @@ -200,98 +200,6 @@ ))) -(define-public (edit-template calendars) - `(div (@ (class " eventtext edit-tab ")) - (form (@ (class "edit-form")) - (select (@ (class "calendar-selection")) - (option "- Choose a Calendar -") - ,@(let ((dflt (get-config 'default-calendar))) - (map (lambda (calendar) - (define name (prop calendar 'NAME)) - `(option (@ (value ,(base64encode name)) - ,@(when (string=? name dflt) - '((selected)))) - ,name)) - calendars))) - (h3 (input (@ (type "text") - (placeholder "Sammanfattning") - (name "summary") (required) - (data-property "summary") - ; (value ,(prop ev 'SUMMARY)) - ))) - - (div (@ (class "timeinput")) - - ,@(with-label - "Starttid" - '(date-time-input (@ (name "dtstart") - (data-property "dtstart") - ))) - - ,@(with-label - "Sluttid" - '(date-time-input (@ (name "dtend") - (data-property "dtend")))) - - (div (@ (class "checkboxes")) - ,@(with-label - "Heldag?" - `(input (@ (type "checkbox") - (name "wholeday") - ))) - ,@(with-label - "Upprepande?" - `(input (@ (type "checkbox") - (name "has_repeats") - )))) - - ) - - ,@(with-label - "Plats" - `(input (@ (placeholder "Plats") - (name "location") - (type "text") - (data-property "location") - ; (value ,(or (prop ev 'LOCATION) "")) - ))) - - ,@(with-label - "Beskrivning" - `(textarea (@ (placeholder "Beskrivning") - (data-property "description") - (name "description")) - ; ,(prop ev 'DESCRIPTION) - )) - - ,@(with-label - "Kategorier" - `(input-list - (@ (name "categories") - (data-property "categories")) - (input (@ (type "text") - (placeholder "Kattegori"))))) - - ;; TODO This should be a "list" where any field can be edited - ;; directly. Major thing holding us back currently is that - ;; <input-list /> doesn't supported advanced inputs - ;; (div (@ (class "input-list")) - ;; (div (@ (class "unit final newfield")) - ;; (input (@ (type "text") - ;; (list "known-fields") - ;; (placeholder "Nytt fält"))) - ;; (select (@ (name "TYPE")) - ;; (option (@ (value "TEXT")) "Text")) - ;; (span - ;; (input (@ (type "text") - ;; (placeholder "Värde")))))) - - ;; (hr) - - - (input (@ (type "submit"))) - ))) - ;; Single event in side bar (text objects) @@ -427,3 +335,261 @@ (prop event 'DTSTART))) "~Y-~m-~dT~H:~M:~S")))))) + +(define (week-day-select args) + `(select (@ ,@args) + (option "-") + ,@(map (lambda (x) `(option (@ (value ,(car x))) ,(cadr x))) + '((MO "Monday") + (TU "Tuesday") + (WE "Wednesday") + (TH "Thursday") + (FR "Friday") + (SA "Saturday") + (SU "Sunday"))))) + + +;;; Templates + + +;; edit tab of popup +(define-public (edit-template calendars) + `(template + (@ (id "vevent-edit")) + (div (@ (class " eventtext edit-tab ")) + (form (@ (class "edit-form")) + (select (@ (class "calendar-selection")) + (option "- Choose a Calendar -") + ,@(let ((dflt (get-config 'default-calendar))) + (map (lambda (calendar) + (define name (prop calendar 'NAME)) + `(option (@ (value ,(base64encode name)) + ,@(when (string=? name dflt) + '((selected)))) + ,name)) + calendars))) + (h3 (input (@ (type "text") + (placeholder "Sammanfattning") + (name "summary") (required) + (data-property "summary") + ; (value ,(prop ev 'SUMMARY)) + ))) + + (div (@ (class "timeinput")) + + ,@(with-label + "Starttid" + '(date-time-input (@ (name "dtstart") + (data-property "dtstart") + ))) + + ,@(with-label + "Sluttid" + '(date-time-input (@ (name "dtend") + (data-property "dtend")))) + + (div (@ (class "checkboxes")) + ,@(with-label + "Heldag?" + `(input (@ (type "checkbox") + (name "wholeday") + ))) + ,@(with-label + "Upprepande?" + `(input (@ (type "checkbox") + (name "has_repeats") + )))) + + ) + + ,@(with-label + "Plats" + `(input (@ (placeholder "Plats") + (name "location") + (type "text") + (data-property "location") + ; (value ,(or (prop ev 'LOCATION) "")) + ))) + + ,@(with-label + "Beskrivning" + `(textarea (@ (placeholder "Beskrivning") + (data-property "description") + (name "description")) + ; ,(prop ev 'DESCRIPTION) + )) + + ,@(with-label + "Kategorier" + `(input-list + (@ (name "categories") + (data-property "categories")) + (input (@ (type "text") + (placeholder "Kattegori"))))) + + ;; TODO This should be a "list" where any field can be edited + ;; directly. Major thing holding us back currently is that + ;; <input-list /> doesn't supported advanced inputs + ;; (div (@ (class "input-list")) + ;; (div (@ (class "unit final newfield")) + ;; (input (@ (type "text") + ;; (list "known-fields") + ;; (placeholder "Nytt fält"))) + ;; (select (@ (name "TYPE")) + ;; (option (@ (value "TEXT")) "Text")) + ;; (span + ;; (input (@ (type "text") + ;; (placeholder "Värde")))))) + + ;; (hr) + + + (input (@ (type "submit"))) + )))) + +;; description in sidebar / tab of popup +;; Template data for <vevent-description /> +(define-public (description-template) + '(template + (@ (id "vevent-description")) + (div (@ (class " vevent eventtext summary-tab " ())) + (h3 ((span (@ (class "repeating")) ; "↺" + ) + (span (@ (class "summary") + (data-property "summary"))))) + (div (div (time (@ (class "dtstart") + (data-property "dtstart") + (data-fmt "~L~H:~M") + (datetime ; "2021-09-29T19:56:46" + )) + ; "19:56" + ) + "\xa0—\xa0" + (time (@ (class "dtend") + (data-property "dtend") + (data-fmt "~L~H:~M") + (datetime ; "2021-09-29T19:56:46" + )) + ; "20:56" + )) + (div (@ (class "fields")) + (div (b "Plats: ") + (div (@ (class "location") + (data-property "location")) + ; "Alsättersgatan 13" + )) + (div (@ (class "description") + (data-property "description")) + ; "With a description" + ) + + (div (@ (class "categories") + (data-property "categories"))) + ;; (div (@ (class "categories")) + ;; (a (@ (class "category") + ;; (href "/search/?" + ;; "q=%28member%20%22test%22%20%28or%20%28prop%20event%20%28quote%20CATEGORIES%29%29%20%28quote%20%28%29%29%29%29")) + ;; test)) + ;; (div (@ (class "rrule")) + ;; "Upprepas " + ;; "varje vecka" + ;; ".") + (div (@ (class "last-modified")) + "Senast ändrad -" + ; "2021-09-29 19:56" + )))))) + +(define-public (vevent-edit-rrule-template) + `(template + (@ (id "vevent-edit-rrule")) + (div (@ (class "eventtext")) + (h2 "Upprepningar") + (dl + (dt "Frequency") + (dd (select (@ (name "freq")) + (option "-") + ,@(map (lambda (x) `(option (@ (value ,x)) ,(string-titlecase (symbol->string x)))) + '(SECONDLY MINUTELY HOURLY DAILY WEEKLY MONTHLY YEARLY)))) + + (dt "Until") + (dd (date-time-input (@ (name "until")))) + + (dt "Conut") + (dd (input (@ (type "number") (name "count") (min 0)))) + + (dt "Interval") + (dd (input (@ (type "number") (name "interval") ; min and max depend on FREQ + ))) + + ,@(concatenate + (map (lambda (pair) + (define name (list-ref pair 0)) + (define pretty-name (list-ref pair 1)) + (define min (list-ref pair 2)) + (define max (list-ref pair 3)) + `((dt ,pretty-name) + (dd (input-list (@ (name ,name)) + (input (@ (type "number") + (min ,min) (max ,max))))))) + '((bysecond "By Second" 0 60) + (byminute "By Minute" 0 59) + (byhour "By Hour" 0 23) + (bymonthday "By Month Day" -31 31) ; except 0 + (byyearday "By Year Day" -366 366) ; except 0 + (byweekno "By Week Number" -53 53) ; except 0 + (bymonth "By Month" 1 12) + (bysetpos "By Set Position" -366 366) ; except 0 + ))) + + ;; (dt "By Week Day") + ;; (dd (input-list (@ (name "byweekday")) + ;; (input (@ (type number) + ;; (min -53) (max 53) ; except 0 + ;; )) + ;; ,(week-day-select '()) + ;; )) + + (dt "Weekstart") + (dd ,(week-day-select '((name "wkst"))))))) + ) + + +;; Based on popup:s output +(define-public (popup-template) + `(template + (@ (id "popup-template")) + ;; becomes the direct child of <popup-element/> + (div (@ (class "popup-root window") + (onclick "event.stopPropagation()")) + + (nav (@ (class "popup-control")) + (button (@ (class "close-button") + (title "Stäng") + (aria-label "Close")) + "×") + (button (@ (class "maximize-button") + (title "Fullskärm") + ;; (aria-label "") + ) + "🗖") + (button (@ (class "remove-button") + (title "Ta Bort")) + "🗑")) + + (tab-group (@ (class "window-body")) + (vevent-description + (@ (data-label "📅") (data-title "Översikt") + (class "vevent"))) + + (vevent-edit + (@ (data-label "🖊") (data-title "Redigera"))) + + ;; (vevent-edit-rrule + ;; (@ (data-label "↺") (data-title "Upprepningar"))) + + (vevent-changelog + (@ (data-label "📒") (date-title "Changelog"))) + + ,@(when (debug) + '((vevent-dl + (@ (data-label "🐸") (data-title "Debug"))))))))) |