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". --- utils/src/main.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'utils/src') diff --git a/utils/src/main.rs b/utils/src/main.rs index 4428ac3..cafb4f9 100644 --- a/utils/src/main.rs +++ b/utils/src/main.rs @@ -34,12 +34,13 @@ struct Question { space: AnswerSpace, } -#[derive(Deserialize, Serialize, StaticType, Debug)] +#[derive(Deserialize, Serialize, StaticType, Debug, PartialEq)] enum AnswerSpace { Single(Vec), Multiple(Vec), YesOrNo, Freeform(String), + Date, } #[derive(StructOpt, Debug)] @@ -79,6 +80,11 @@ fn main () { std::process::exit(1); }, Ok(data) => { + if data.questions.iter().any(|q| q.space == AnswerSpace::Date) { + eprintln!(">> Warning: html input type date is not supported by Safari and Internet Explorer.\n See https://caniuse.com/input-datetime for details."); + } + + let json = json::to_string(&data).unwrap(); // if a public key is given to encrypt the survey, ad-hoc typecheck it -- cgit v1.2.3