aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.scm1
-rw-r--r--module/html/view/calendar.scm20
-rw-r--r--module/vcomponent.scm4
-rw-r--r--static/script.js19
4 files changed, 32 insertions, 12 deletions
diff --git a/config.scm b/config.scm
index c2d395a4..b6f22941 100644
--- a/config.scm
+++ b/config.scm
@@ -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