From 5596ebcbad7721f767972c3143f8e5be1ba8fc09 Mon Sep 17 00:00:00 2001 From: stuebinm Date: Mon, 12 Apr 2021 18:07:41 +0200 Subject: add date answer space for now, this is just a simple date picker done via the html input type "date". Unfortunately, that's not supported by Safari, so the rust util now prints out a warning if it's used. I'm not sure if there's any other reasonable option which would go around this that's not "using a web framework" or "hacking a fallback date picker which just consists of a couple of combo boxes". --- site/index.html | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'site/index.html') diff --git a/site/index.html b/site/index.html index 6141163..1555a21 100644 --- a/site/index.html +++ b/site/index.html @@ -125,6 +125,32 @@ ]; } + function mkDatePicker (name) { + let [input, label] = mkOption("date", name); + let errormsg = setErrormsg( + mkElement("div","","error"), + null + ); + let div = appendChildren ( + mkElement("div"), + [label, + mkElement("span", " "), + input, + errormsg] + ); + return [ + div, + () => { + let date = input.valueAsDate; + let [ret, error] = date !== null && !isNaN(date.valueOf()) + ? [date.toISOString(), null] + : [null, _("Please pick a date")] + setErrormsg (errormsg, error); + return ret; + } + ] + } + // essentially a case - of statement over the answerspace type. // since there is no validation of the config json, it may turn // out to be a partial function in practice. @@ -132,6 +158,8 @@ let space = question.space; if (space === "YesOrNo") { return mkListSpace("radio", ["yes", "no"], question.name, question.question); + } if (space === "Date") { + return mkDatePicker(question.name); } if ("Single" in space) { return mkListSpace("radio", space.Single, question.name, question.question); } if ("Multiple" in space) { -- cgit v1.2.3