From 5a91457a5b8595969957cd6676afc2fff858251e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 11 Aug 2020 17:19:37 +0200 Subject: HTML Created events now have a description. Unfortunately they ALWAYS have a description. --- module/html/vcomponent.scm | 5 +++-- module/html/view/calendar.scm | 3 ++- static/script.js | 22 ++++++++++++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/module/html/vcomponent.scm b/module/html/vcomponent.scm index f9c24ecd..ca8a81c2 100644 --- a/module/html/vcomponent.scm +++ b/module/html/vcomponent.scm @@ -78,8 +78,9 @@ (div (@ (class "location")) ,(string-map (lambda (c) (if (char=? c #\,) #\newline c)) (prop ev 'LOCATION))))) - ,(and=> (prop ev 'DESCRIPTION) - (lambda (str) (format-description ev str))) + ,(awhen (prop ev 'DESCRIPTION) + `(span (@ (class "description")) + ,(format-description ev it))) ,(awhen (prop ev 'RRULE) `(span (@ (class "rrule")) ,@(format-recurrence-rule ev))) diff --git a/module/html/view/calendar.scm b/module/html/view/calendar.scm index 2371cfe0..4753e1e6 100644 --- a/module/html/view/calendar.scm +++ b/module/html/view/calendar.scm @@ -317,7 +317,8 @@ ;; cloned mulitple times. dtstart: (datetime) dtend: (datetime) - summary: "New Event")))) + summary: "New Event" + description: "None yet")))) (event (car (children cal)))) `((div (@ (class "template event-container") (id "event-template") ;; Only needed to create a duration. So actual dates diff --git a/static/script.js b/static/script.js index 32bc3b4b..c2ea07c1 100644 --- a/static/script.js +++ b/static/script.js @@ -471,6 +471,28 @@ function place_in_edit_mode (event) { summary.replaceWith(input); + /* ---------------------------------------- */ + + let descs = popup.getElementsByClassName("description"); + if (descs.length === 1) { + let description = descs[0]; + let textarea = makeElement('textarea', { + name: "description", + placeholder: description.innerText, + required: false, + }); + + textarea.oninput = function () { + event.properties["description"] = this.value; + } + + let slot = event.properties["_slot_description"] + let idx = slot.findIndex(e => e[0] === description); + slot.splice(idx, 1, [input, (s, v) => s.innerHTML = v]) + + description.replaceWith(textarea); + } + /* ---------------------------------------- */ let submit = makeElement( 'input', { -- cgit v1.2.3 From ad78b193271abb6df486d3acfd7ab94f51cd101c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 11 Aug 2020 19:39:37 +0200 Subject: Can create events without descriptions again. --- module/html/view/calendar.scm | 5 ++++- module/vcomponent/parse/xcal.scm | 30 ++++++++++++++++++------------ static/script.js | 3 ++- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/module/html/view/calendar.scm b/module/html/view/calendar.scm index 4753e1e6..f058d01e 100644 --- a/module/html/view/calendar.scm +++ b/module/html/view/calendar.scm @@ -318,7 +318,10 @@ dtstart: (datetime) dtend: (datetime) summary: "New Event" - description: "None yet")))) + ;; force a description field, + ;; but don't put anything in + ;; it. + description: "")))) (event (car (children cal)))) `((div (@ (class "template event-container") (id "event-template") ;; Only needed to create a duration. So actual dates diff --git a/module/vcomponent/parse/xcal.scm b/module/vcomponent/parse/xcal.scm index 76bdb251..06745864 100644 --- a/module/vcomponent/parse/xcal.scm +++ b/module/vcomponent/parse/xcal.scm @@ -126,21 +126,27 @@ (let ((params (handle-parameters parameters)) (tag* (symbol-upcase tag))) (for (type value) in (zip type value) - (set! (prop* component tag*) - (make-vline tag* - (handle-tag - tag (handle-value type params value)) - params))))] + ;; ignore empty fields + ;; mostly for + (unless (null? value) + (set! (prop* component tag*) + (make-vline tag* + (handle-tag + tag (handle-value type params value)) + params)))))] [(tag (type value ...) ...) (for (type value) in (zip type value) - (let ((params (make-hash-table)) - (tag* (symbol-upcase tag))) - (set! (prop* component tag*) - (make-vline tag* - (handle-tag - tag (handle-value type params value)) - params))))]))) + ;; ignore empty fields + ;; mostly for + (unless (null? value) + (let ((params (make-hash-table)) + (tag* (symbol-upcase tag))) + (set! (prop* component tag*) + (make-vline tag* + (handle-tag + tag (handle-value type params value)) + params)))))]))) ;; children (awhen (assoc-ref sxcal 'components) diff --git a/static/script.js b/static/script.js index c2ea07c1..be19dc13 100644 --- a/static/script.js +++ b/static/script.js @@ -478,7 +478,8 @@ function place_in_edit_mode (event) { let description = descs[0]; let textarea = makeElement('textarea', { name: "description", - placeholder: description.innerText, + placeholder: "Description (optional)", + innerHTML: description.innerText, required: false, }); -- cgit v1.2.3 From 995929362ea939adf7abf420adf02eb549392fae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 11 Aug 2020 19:40:24 +0200 Subject: Add TODO about trimming text. --- module/vcomponent/parse/xcal.scm | 1 + 1 file changed, 1 insertion(+) diff --git a/module/vcomponent/parse/xcal.scm b/module/vcomponent/parse/xcal.scm index 06745864..2c8b7fe8 100644 --- a/module/vcomponent/parse/xcal.scm +++ b/module/vcomponent/parse/xcal.scm @@ -22,6 +22,7 @@ [(boolean) (string=? "true" (car value))] + ;; TODO possibly trim whitespace on text fields [(cal-address uri text unknown) (car value)] [(date) (parse-iso-date (car value))] -- cgit v1.2.3 From 2e684fd427097965834bd5f1f22196be99b82757 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 11 Aug 2020 19:49:28 +0200 Subject: Allow events to enter edit mode after creation. --- module/html/vcomponent.scm | 3 +++ static/script.js | 1 + static/style.css | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/module/html/vcomponent.scm b/module/html/vcomponent.scm index ca8a81c2..308f779a 100644 --- a/module/html/vcomponent.scm +++ b/module/html/vcomponent.scm @@ -175,6 +175,9 @@ title: "Stäng" onclick: "close_popup(document.getElementById(this.closest('.popup-container').id))" class: '("close-tooltip")) + ,(btn "🖊️" + title: "Redigera" + onclick: "place_in_edit_mode(document.getElementById(this.closest('.popup-container').id.substr(5)))") ,(btn "🗑" title: "Ta bort" onclick: "remove_event(document.getElementById(this.closest('.popup-container').id.substr(5)))")) diff --git a/static/script.js b/static/script.js index be19dc13..37f86549 100644 --- a/static/script.js +++ b/static/script.js @@ -428,6 +428,7 @@ function place_in_edit_mode (event) { let input = makeElement ('input', { type: "time", required: true, + value: field.innerText, onchange: function (e) { /* Only update datetime when the input is filled out */ diff --git a/static/style.css b/static/style.css index 193cc1fb..3a2a8c5d 100644 --- a/static/style.css +++ b/static/style.css @@ -509,7 +509,7 @@ along with their colors. overflow: visible; } -.event input { +.popup input { white-space: initial; border: 1px solid gray; max-width: 100%; -- cgit v1.2.3 From 7c914d16b60fb72aa25aa469b60b85f06fb3a518 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 11 Aug 2020 20:05:40 +0200 Subject: Keep summary when editing existing elements. --- module/html/view/calendar.scm | 2 +- static/script.js | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/module/html/view/calendar.scm b/module/html/view/calendar.scm index f058d01e..7d38140f 100644 --- a/module/html/view/calendar.scm +++ b/module/html/view/calendar.scm @@ -317,7 +317,7 @@ ;; cloned mulitple times. dtstart: (datetime) dtend: (datetime) - summary: "New Event" + summary: "" ;; force a description field, ;; but don't put anything in ;; it. diff --git a/static/script.js b/static/script.js index 37f86549..7f9291d7 100644 --- a/static/script.js +++ b/static/script.js @@ -457,8 +457,9 @@ function place_in_edit_mode (event) { let summary = popup.getElementsByClassName("summary")[0]; let input = makeElement('input', { - name: "dtstart", - placeholder: summary.innerText, + name: "summary", + value: summary.innerText, + placeholder: "Sammanfattning", required: true, }); @@ -539,7 +540,7 @@ window.onload = function () { let popupElement = document.getElementById("popup" + event.id); open_popup(popupElement); - popupElement.querySelector("input[name='dtstart']").focus(); + popupElement.querySelector("input[name='summary']").focus(); }); } @@ -557,7 +558,7 @@ window.onload = function () { let popupElement = document.getElementById("popup" + event.id); open_popup(popupElement); - popupElement.querySelector("input[name='dtstart']").focus(); + popupElement.querySelector("input[name='summary']").focus(); }); } -- cgit v1.2.3 From aa18e57dfdf2bd0f626d7101ab712e6a0ff6dbf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 11 Aug 2020 20:05:56 +0200 Subject: Focus summary when editing existing. --- module/entry-points/server.scm | 3 +++ static/script.js | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/module/entry-points/server.scm b/module/entry-points/server.scm index 466860cd..dc675813 100644 --- a/module/entry-points/server.scm +++ b/module/entry-points/server.scm @@ -163,6 +163,9 @@ (format #f "No event with UID '~a'" uid)))) ;; TODO this fails when dtstart is . + ;; TODO If data has an explicit UID and that UID already exists we + ;; overwrite it in the database. We however don't remove the old + ;; event from the in-memory set, but rather just adds the new. (POST "/insert" (cal data) (unless (and cal data) diff --git a/static/script.js b/static/script.js index 7f9291d7..5b6f561a 100644 --- a/static/script.js +++ b/static/script.js @@ -475,6 +475,10 @@ function place_in_edit_mode (event) { /* ---------------------------------------- */ + /* TODO add elements if the arent't already there + * Almost all should be direct children of '.event-body'. + * Biggest problem is generated fields relative order. + */ let descs = popup.getElementsByClassName("description"); if (descs.length === 1) { let description = descs[0]; @@ -515,6 +519,11 @@ function place_in_edit_mode (event) { article.replaceWith(wrappingForm); wrappingForm.appendChild(article); + /* this is for existing events. + * Newly created events aren't in the DOM tree yet, and can + * therefore not yet be focused */ + input.focus(); + } window.onload = function () { @@ -558,7 +567,7 @@ window.onload = function () { let popupElement = document.getElementById("popup" + event.id); open_popup(popupElement); - popupElement.querySelector("input[name='summary']").focus(); + popupElement.querySelector("input[name='summary']").focus(); }); } -- cgit v1.2.3 From e65184faa90ccc7760c90659e92080984afc0b3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 11 Aug 2020 20:16:02 +0200 Subject: Expand whitespace. --- static/script.js | 52 +++++++++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/static/script.js b/static/script.js index 5b6f561a..cc647b77 100644 --- a/static/script.js +++ b/static/script.js @@ -459,7 +459,7 @@ function place_in_edit_mode (event) { let input = makeElement('input', { name: "summary", value: summary.innerText, - placeholder: "Sammanfattning", + placeholder: "Sammanfattning", required: true, }); @@ -475,30 +475,32 @@ function place_in_edit_mode (event) { /* ---------------------------------------- */ - /* TODO add elements if the arent't already there - * Almost all should be direct children of '.event-body'. - * Biggest problem is generated fields relative order. - */ - let descs = popup.getElementsByClassName("description"); - if (descs.length === 1) { - let description = descs[0]; - let textarea = makeElement('textarea', { - name: "description", - placeholder: "Description (optional)", - innerHTML: description.innerText, - required: false, - }); - - textarea.oninput = function () { - event.properties["description"] = this.value; - } - - let slot = event.properties["_slot_description"] - let idx = slot.findIndex(e => e[0] === description); - slot.splice(idx, 1, [input, (s, v) => s.innerHTML = v]) - - description.replaceWith(textarea); - } + /* TODO add elements if the arent't already there + * Almost all should be direct children of '.event-body' (or + * '.eventtext'?). + * Biggest problem is generated fields relative order. + */ + let descs = popup.getElementsByClassName("description"); + if (descs.length === 1) { + let description = descs[0]; + let textarea = makeElement('textarea', { + name: "description", + placeholder: "Description (optional)", + innerHTML: description.innerText, + required: false, + }); + + textarea.oninput = function () { + event.properties["description"] = this.value; + } + + let slot = event.properties["_slot_description"] + let idx = slot.findIndex(e => e[0] === description); + slot.splice(idx, 1, [input, (s, v) => s.innerHTML = v]) + + description.replaceWith(textarea); + } + /* ---------------------------------------- */ -- cgit v1.2.3 From 70dd50111a339fd9fcf54cc2f9670c1313a154a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 11 Aug 2020 20:25:56 +0200 Subject: Mercge CAL and CAL_bg css classes. --- module/html/vcomponent.scm | 20 +++++++++----------- module/html/view/calendar.scm | 2 +- static/style.css | 7 +++++++ 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/module/html/vcomponent.scm b/module/html/vcomponent.scm index 308f779a..1b17f039 100644 --- a/module/html/vcomponent.scm +++ b/module/html/vcomponent.scm @@ -50,7 +50,7 @@ ;; (format (current-error-port) "fmt-single-event: ~a~%" (prop ev 'X-HNH-FILENAME)) `(article (@ ,@(assq-merge attributes - `((class "eventtext CAL_bg_" + `((class "eventtext CAL_" ,(html-attr (or (prop (parent ev) 'NAME) "unknown")) ,(when (and (prop ev 'PARTSTAT) (eq? 'TENTATIVE (prop ev 'PARTSTAT))) @@ -119,16 +119,14 @@ (define-public (calendar-styles calendars) `(style - ,(format - #f "~:{.CAL_~a { background-color: ~a; color: ~a }~%.CAL_bg_~a { border-color: ~a }~%~}" - (map (lambda (c) - (let* ((name (html-attr (prop c 'NAME))) - (bg-color (prop c 'COLOR)) - (fg-color (and=> (prop c 'COLOR) - calculate-fg-color))) - (list name (or bg-color 'white) (or fg-color 'black) - name (or bg-color 'black)))) - calendars)))) + ,(format #f "~:{.CAL_~a { --color: ~a; --complement: ~a }~%~}" + (map (lambda (c) + (let* ((name (html-attr (prop c 'NAME))) + (bg-color (prop c 'COLOR)) + (fg-color (and=> (prop c 'COLOR) + calculate-fg-color))) + (list name (or bg-color 'white) (or fg-color 'black)))) + calendars)))) ;; "Physical" block in calendar view (define*-public (make-block ev optional: (extra-attributes '())) diff --git a/module/html/view/calendar.scm b/module/html/view/calendar.scm index 7d38140f..4fad41c8 100644 --- a/module/html/view/calendar.scm +++ b/module/html/view/calendar.scm @@ -284,7 +284,7 @@ (summary "Calendar list") (ul ,@(map (lambda (calendar) - `(li (@ (class "CAL_bg_" + `(li (@ (class "CAL_" ,(html-attr (prop calendar 'NAME)))) ,(prop calendar 'NAME))) calendars)))) diff --git a/static/style.css b/static/style.css index 3a2a8c5d..28901c8d 100644 --- a/static/style.css +++ b/static/style.css @@ -300,6 +300,7 @@ along with their colors. list-style-type: none; border-left-width: 1em; border-left-style: solid; + border-color: var(--color); padding-left: 1ex; /* force to single line */ @@ -507,6 +508,8 @@ along with their colors. transition: 0.3s; font-size: var(--event-font-size); overflow: visible; + background-color: var(--color); + color: var(--complement); } .popup input { @@ -607,6 +610,10 @@ along with their colors. padding-right: 1em; } +.eventlist .eventtext { + border-color: var(--color); +} + .eventlist .eventtext.tentative { border-left-style: dashed; } -- cgit v1.2.3 From 54c613f48caa01f05fac2774dc2d2253568b552e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 11 Aug 2020 20:17:25 +0200 Subject: Add dropdown editing event. --- module/html/view/calendar.scm | 9 ++++++++- static/script.js | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/module/html/view/calendar.scm b/module/html/view/calendar.scm index 4fad41c8..39f1092d 100644 --- a/module/html/view/calendar.scm +++ b/module/html/view/calendar.scm @@ -287,7 +287,14 @@ `(li (@ (class "CAL_" ,(html-attr (prop calendar 'NAME)))) ,(prop calendar 'NAME))) - calendars)))) + calendars)) + (div (@ (id "calendar-dropdown-template") (class "template")) + (select + ,@(map (lambda (calendar) + `(option (@ (value ,(prop calendar 'NAME))) + ,(prop calendar 'NAME))) + calendars)) + ))) ;; List of events (div (@ (class "eventlist") diff --git a/static/script.js b/static/script.js index cc647b77..0385ac5a 100644 --- a/static/script.js +++ b/static/script.js @@ -501,6 +501,11 @@ function place_in_edit_mode (event) { description.replaceWith(textarea); } + /* ---------------------------------------- */ + + let evtext = popup.getElementsByClassName('eventtext')[0] + let calendar_dropdown = document.getElementById('calendar-dropdown-template').firstChild.cloneNode(true); + evtext.prepend(calendar_dropdown); /* ---------------------------------------- */ -- cgit v1.2.3 From 7deb6aac6d5af730f564a9f238c8feaf77f0e167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 11 Aug 2020 20:35:12 +0200 Subject: Fix color in popups. --- static/style.css | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/static/style.css b/static/style.css index 28901c8d..1a7b2f14 100644 --- a/static/style.css +++ b/static/style.css @@ -300,7 +300,7 @@ along with their colors. list-style-type: none; border-left-width: 1em; border-left-style: solid; - border-color: var(--color); + border-color: var(--color); padding-left: 1ex; /* force to single line */ @@ -508,8 +508,8 @@ along with their colors. transition: 0.3s; font-size: var(--event-font-size); overflow: visible; - background-color: var(--color); - color: var(--complement); + background-color: var(--color); + color: var(--complement); } .popup input { @@ -611,7 +611,7 @@ along with their colors. } .eventlist .eventtext { - border-color: var(--color); + border-color: var(--color); } .eventlist .eventtext.tentative { @@ -741,6 +741,7 @@ along with their colors. user-select: none; cursor: grab; + background-color: var(--color); } .popup-control .btn { -- cgit v1.2.3 From 263e64dfe8549e6c726fb06dd5cdc03fa6a90298 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 11 Aug 2020 20:41:28 +0200 Subject: Limit CAL_ class to once per 'thing'. --- module/html/vcomponent.scm | 52 +++++++++++++++++++++++-------------------- module/html/view/calendar.scm | 2 +- static/style.css | 2 +- 3 files changed, 30 insertions(+), 26 deletions(-) diff --git a/module/html/vcomponent.scm b/module/html/vcomponent.scm index 1b17f039..5123af09 100644 --- a/module/html/vcomponent.scm +++ b/module/html/vcomponent.scm @@ -43,18 +43,21 @@ ;; TODO better format, add show in calendar button ,(fmt-single-event event))))) -;; For sidebar, just text +;; Format event as text. +;; Used in +;; - sidebar +;; - popup overwiew tab +;; - search result (event details) (define*-public (fmt-single-event ev optional: (attributes '()) key: (fmt-header list)) ;; (format (current-error-port) "fmt-single-event: ~a~%" (prop ev 'X-HNH-FILENAME)) `(article (@ ,@(assq-merge attributes - `((class "eventtext CAL_" - ,(html-attr (or (prop (parent ev) 'NAME) "unknown")) + `((class " eventtext " ,(when (and (prop ev 'PARTSTAT) (eq? 'TENTATIVE (prop ev 'PARTSTAT))) - " tentative"))))) + " tentative "))))) (h3 ,(fmt-header (when (prop ev 'RRULE) `(span (@ (class "repeating")) "↺")) @@ -100,13 +103,15 @@ (class "hidelink")) ,s)))) ,@(stream->list (stream-map - (lambda (ev) (fmt-single-event - ev `((id ,(html-id ev))) - fmt-header: - (lambda body - `(a (@ (href "#" ,(date-link (as-date (prop ev 'DTSTART)))) - (class "hidelink")) - ,@body)))) + (lambda (ev) + (fmt-single-event + ev `((id ,(html-id ev)) + (class "CAL_" ,(html-attr (or (prop (parent ev) 'NAME) "unknown")))) + fmt-header: + (lambda body + `(a (@ (href "#" ,(date-link (as-date (prop ev 'DTSTART)))) + (class "hidelink")) + ,@body)))) (stream-filter (lambda (ev) ;; If start was an earlier day @@ -165,10 +170,9 @@ (define-public (popup ev id) `(div (@ (class "popup-container") (id ,id) (onclick "event.stopPropagation()")) - (div (@ (class "popup")) - (nav (@ (class "popup-control CAL_" - ,(html-attr (or (prop (parent ev) 'NAME) - "unknown")))) + (div (@ (class "popup CAL_" ,(html-attr (or (prop (parent ev) 'NAME) + "unknown"))) ) + (nav (@ (class "popup-control")) ,(btn "×" title: "Stäng" onclick: "close_popup(document.getElementById(this.closest('.popup-container').id))" @@ -181,12 +185,12 @@ onclick: "remove_event(document.getElementById(this.closest('.popup-container').id.substr(5)))")) ,(tabset - `(("📅" title: "Översikt" - ,(fmt-single-event ev)) - ("⤓" title: "Nedladdning" - (div (@ (style "font-family:sans")) - (p "Ladda ner") - (ul (li (a (@ (href "/calendar/" ,(prop ev 'UID) ".ics")) - "som iCal")) - (li (a (@ (href "/calendar/" ,(prop ev 'UID) ".xcs")) - "som xCal")))))))))) + `(("📅" title: "Översikt" + ,(fmt-single-event ev)) + ("⤓" title: "Nedladdning" + (div (@ (style "font-family:sans")) + (p "Ladda ner") + (ul (li (a (@ (href "/calendar/" ,(prop ev 'UID) ".ics")) + "som iCal")) + (li (a (@ (href "/calendar/" ,(prop ev 'UID) ".xcs")) + "som xCal")))))))))) diff --git a/module/html/view/calendar.scm b/module/html/view/calendar.scm index 39f1092d..3c239bc6 100644 --- a/module/html/view/calendar.scm +++ b/module/html/view/calendar.scm @@ -291,7 +291,7 @@ (div (@ (id "calendar-dropdown-template") (class "template")) (select ,@(map (lambda (calendar) - `(option (@ (value ,(prop calendar 'NAME))) + `(option (@ (value ,(html-attr (prop calendar 'NAME)))) ,(prop calendar 'NAME))) calendars)) ))) diff --git a/static/style.css b/static/style.css index 1a7b2f14..719cca1c 100644 --- a/static/style.css +++ b/static/style.css @@ -818,7 +818,7 @@ along with their colors. } .tab [type=radio]:checked ~ label ~ .content { - z-index: 1; + z-index: 1; } /* Other -- cgit v1.2.3 From e360d3566eb878a944dada510a0c7e8437a5554b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 11 Aug 2020 21:31:52 +0200 Subject: Fix frontend for calendar choosing. --- module/html/vcomponent.scm | 9 ++++++--- module/html/view/calendar.scm | 1 + static/script.js | 38 ++++++++++++++++++++++++++++++++++++++ static/style.css | 4 ++++ 4 files changed, 49 insertions(+), 3 deletions(-) diff --git a/module/html/vcomponent.scm b/module/html/vcomponent.scm index 5123af09..3fac17bb 100644 --- a/module/html/vcomponent.scm +++ b/module/html/vcomponent.scm @@ -168,10 +168,13 @@ (define-public (popup ev id) - `(div (@ (class "popup-container") (id ,id) + `(div (@ (id ,id) (class "popup-container CAL_" + ,(html-attr (or (prop (parent ev) 'NAME) + "unknown"))) (onclick "event.stopPropagation()")) - (div (@ (class "popup CAL_" ,(html-attr (or (prop (parent ev) 'NAME) - "unknown"))) ) + ;; TODO all (?) code uses .popup-container as the popup, while .popup sits and does nothing. + ;; Do something about this? + (div (@ (class "popup")) (nav (@ (class "popup-control")) ,(btn "×" title: "Stäng" diff --git a/module/html/view/calendar.scm b/module/html/view/calendar.scm index 3c239bc6..72fcccbd 100644 --- a/module/html/view/calendar.scm +++ b/module/html/view/calendar.scm @@ -290,6 +290,7 @@ calendars)) (div (@ (id "calendar-dropdown-template") (class "template")) (select + (option "- Choose a Calendar -") ,@(map (lambda (calendar) `(option (@ (value ,(html-attr (prop calendar 'NAME)))) ,(prop calendar 'NAME))) diff --git a/static/script.js b/static/script.js index 0385ac5a..ed133a2d 100644 --- a/static/script.js +++ b/static/script.js @@ -122,6 +122,21 @@ function bind_popup_control (nav) { }); } +/* + * Finds the first element of the DOMTokenList whichs value matches + * the supplied regexp. Returns a pair of the index and the value. + */ +DOMTokenList.prototype.find = function (regexp) { + console.log(this); + let entries = this.entries(); + let entry; + while (! (entry = entries.next()).done) { + if (entry.value[1].match(regexp)) { + return entry.value; + } + } +} + class EventCreator { /* dynamicly created event when dragging */ @@ -505,6 +520,29 @@ function place_in_edit_mode (event) { let evtext = popup.getElementsByClassName('eventtext')[0] let calendar_dropdown = document.getElementById('calendar-dropdown-template').firstChild.cloneNode(true); + + let [_, calclass] = popup.classList.find(/^CAL_/); + for (let [i, option] of calendar_dropdown.childNodes.entries()) { + if (option.value === calclass.substr(4)) { + calendar_dropdown.selectedIndex = i; + break; + } + } + + /* Instant change while user is stepping through would be + * preferable. But I believe that