aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2021-05-17 01:07:09 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2021-05-17 01:07:09 +0200
commit3d3963e53cb0646ded92c871a6ea7636b25714b3 (patch)
tree6cc6807ea74511258c542ac6615ecd126f7b47ed
parentRework date-time input to be cleaner + work again. (diff)
downloadcalp-3d3963e53cb0646ded92c871a6ea7636b25714b3.tar.gz
calp-3d3963e53cb0646ded92c871a6ea7636b25714b3.tar.xz
Cleanup + fix for wholeday checkbox.
-rw-r--r--module/calp/html/vcomponent.scm31
-rw-r--r--static/binders.js10
-rw-r--r--static/vcal.js4
3 files changed, 31 insertions, 14 deletions
diff --git a/module/calp/html/vcomponent.scm b/module/calp/html/vcomponent.scm
index 7530de91..787c4501 100644
--- a/module/calp/html/vcomponent.scm
+++ b/module/calp/html/vcomponent.scm
@@ -168,17 +168,23 @@
(input (@ (type "date")
(value ,(date->string (as-date start)))))
(input (@ (type "time")
- (value ,(time->string (as-time start)))))))
-
- ,@(with-label
- "Sluttid"
- `(div (@ (class "date-time bind")
- (data-bindby "bind_date_time")
- (name "dtend"))
- (input (@ (type "date")
- ,@(when end `((value ,(date->string (as-date end)))))))
- (input (@ (type "time")
- ,@(when end `((value ,(time->string (as-time end)))))))))
+ (value ,(time->string (as-time start) "~H:~M"))
+ ,@(when (date? start) '((disabled)))
+ ))))
+
+ ;; TODO some way to add an endtime if missing beforehand
+ ;; TODO, actually proper support for event without end times
+ ,@(when end
+ (with-label
+ "Sluttid"
+ `(div (@ (class "date-time bind")
+ (data-bindby "bind_date_time")
+ (name "dtend"))
+ (input (@ (type "date")
+ (value ,(date->string (as-date end)))))
+ (input (@ (type "time")
+ (value ,(time->string (as-time end) "~H:~M"))
+ ,@(when (date? end) '((disabled))))))))
(div
,@(with-label
@@ -186,7 +192,8 @@
`(input (@ (type "checkbox")
(class "bind")
(data-bindby "bind_wholeday")
- (name "wholeday")))))
+ (name "wholeday")
+ ,@(when (date? start) '((checked)))))))
))
diff --git a/static/binders.js b/static/binders.js
index 72550191..12d968e4 100644
--- a/static/binders.js
+++ b/static/binders.js
@@ -103,8 +103,14 @@ function bind_wholeday(el, e) {
}
for (let f of ['dtstart', 'dtend']) {
- let d = el.properties[f];
- if (! d) continue; /* dtend optional */
+ let param = el.properties[f];
+ if (! param) continue; /* dtend optional */
+ let d = param.value;
+ if (wholeday.checked) {
+ param.type = 'date';
+ } else {
+ param.type = 'date-time';
+ }
d.isWholeDay = wholeday.checked;
el.properties[f] = d;
}
diff --git a/static/vcal.js b/static/vcal.js
index 13c489b8..079b09f8 100644
--- a/static/vcal.js
+++ b/static/vcal.js
@@ -269,6 +269,10 @@ class VComponent {
Object.defineProperty(
this, property_name,
{
+ /* TODO there is an assymetry here with .value needing to be called for
+ get:ed stuff, but set MUST be an unwrapped item.
+ Fix this.
+ */
get: function() {
return this._values[property_name];
},