From 5d96868dc6c0d92c120f78f059d8be25108b8e5e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Sun, 25 Jul 2021 20:26:04 +0200 Subject: [PATCH] submit mode for calendar widget --- widgets.css | 9 +++++++-- widgets.sh | 7 ++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/widgets.css b/widgets.css index bb48f52..594e115 100644 --- a/widgets.css +++ b/widgets.css @@ -37,15 +37,20 @@ table.calendar input[type=radio], table.calendar input[type=checkbox] { display: none; } -table.calendar td label { +table.calendar td label, +table.calendar td button { display: inline-block; width: 2em; margin: 0; padding: .25em; text-align: right; line-height: 1em; + box-shadow: none; + border-radius: 0; + border: none; } table.calendar td input:checked + label, -table.calendar td label[checked] { +table.calendar td label[checked], +table.calendar td button[name$=_remove] { font-weight: bold; line-height: .75em; border: .125em solid; diff --git a/widgets.sh b/widgets.sh index 4d3df23..ab88b3e 100755 --- a/widgets.sh +++ b/widgets.sh @@ -21,7 +21,7 @@ selected(){ w_month() { # Arguments: - # 1. (optional) select, multiple, none - default: select + # 1. (optional) select, multiple, submit, none - default: select # 2. (optional) Name of form field - default: "date" # 3. (optional) Month to display in format: YYYY-MM - default: current month # 4. (optional, multiple) Days to preselect in format: DD - default: none @@ -77,6 +77,11 @@ w_month() { printf '[td [input type=checkbox id="%s_%s" name="%s" value="%s" %s][label for="%s_%s" . %i]]' \ "$input" "$date" "$input" "$date" "$(checked $dom $selected)" "$input" "$date" "$dom" ;; + submit) + [ "$(checked $dom $selected)" ] \ + && printf '[td [submit "%s_remove" "%s" . %i][hidden "%s" "%s"]]' "$input" "$date" "$dom" "$input" "$date" \ + || printf '[td [submit "%s_add" "%s" . %i]]' "$input" "$date" "$dom" + ;; select|*) printf '[td [input type=radio id="%s_%s" name="%s" value="%s" %s][label for="%s_%s" . %i]]' \ "$input" "$date" "$input" "$date" "$(checked $dom $selected)" "$input" "$date" "$dom" -- 2.39.2