diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-08-12 15:57:55 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-08-12 15:57:55 +0200 |
commit | fd72079c5163f9881872d70b64aafde03b8b2385 (patch) | |
tree | 6840d4c4bf511f0e4a2c53fd0fe74240e076775c | |
parent | Calendar names now encoded with modified base64 (diff) | |
download | calp-fd72079c5163f9881872d70b64aafde03b8b2385.tar.gz calp-fd72079c5163f9881872d70b64aafde03b8b2385.tar.xz |
Add option for default calendar.
Diffstat (limited to '')
-rw-r--r-- | config.scm | 1 | ||||
-rw-r--r-- | module/html/view/calendar.scm | 20 | ||||
-rw-r--r-- | module/vcomponent.scm | 4 | ||||
-rw-r--r-- | static/script.js | 19 |
4 files changed, 32 insertions, 12 deletions
@@ -76,3 +76,4 @@ [else (parse-links str)]))) (set-config! 'week-start mon) +(set-config! 'default-calendar "Calendar") diff --git a/module/html/view/calendar.scm b/module/html/view/calendar.scm index ed6ea066..76d1e79f 100644 --- a/module/html/view/calendar.scm +++ b/module/html/view/calendar.scm @@ -16,10 +16,14 @@ )) :use-module (html config) :use-module (html util) + + :use-module (util config) + :use-module (srfi srfi-1) :use-module (srfi srfi-26) :use-module (srfi srfi-41) :use-module (srfi srfi-41 util) + :use-module ((vcomponent group) :select (group-stream get-groups-between)) :use-module ((git) @@ -288,13 +292,17 @@ ,(html-attr (prop calendar 'NAME)))) ,(prop calendar 'NAME))) calendars)) - (div (@ (id "calendar-dropdown-template") (class "template")) - (select + (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))) - calendars)) + ,@(let ((dflt (get-config 'default-calendar))) + (map (lambda (calendar) + (define name (prop calendar 'NAME)) + `(option (@ (value ,(html-attr name)) + ,@(when (string=? name dflt) + '((selected)))) + ,name)) + calendars))) ))) ;; List of events diff --git a/module/vcomponent.scm b/module/vcomponent.scm index 66b72162..b4a30c83 100644 --- a/module/vcomponent.scm +++ b/module/vcomponent.scm @@ -17,3 +17,7 @@ [(string? v) ((@ (glob) glob) v)] [else #f]))) +(define-config default-calendar "" + description: "Default calendar to use for operations. Set to empty string to unset" + pre: (ensure string?)) + diff --git a/static/script.js b/static/script.js index 40d8a6d1..ab882d6a 100644 --- a/static/script.js +++ b/static/script.js @@ -522,12 +522,19 @@ function place_in_edit_mode (event) { 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; - } - } + label: { + for (let [i, option] of calendar_dropdown.childNodes.entries()) { + if (option.value === calclass.substr(4)) { + calendar_dropdown.selectedIndex = i; + break label; + } + } + /* no match, try find default calendar */ + let t; + if ((t = calendar_dropdown.querySelector("[selected]"))) { + event.properties.calendar = t.value; + } + } /* Instant change while user is stepping through would be |